# Create a new invoice

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /meters/{meterIdentification}/invoices/received:
    post:
      summary: Create a new invoice
      deprecated: false
      description: >-
        This endpoint enables clients to add invoices for energy use to
        Enectiva. Each invoice is created in a separate HTTP request.


        The invoice can be added only to active meter. Attempt to add invoice to
        deactivated meter will end up in status 404.


        Each invoice must satisfy validation rules:


        - `from` and `to` are date strings in RFC3339 format, the dates are
        inclusive, invoice ranges for a given meter must not overlap, the whole
        range must be in the past


        - `cost` and `consumption` are non-negative floats, at least one of them
        must be provided


        - `note` is limited to 255 characters


        The required scope is `received_invoices`.
      operationId: Create a new invoice
      tags:
        - Received energy invoices
        - Received energy invoices
      parameters:
        - name: meterIdentification
          in: path
          description: >-
            See [meter
            identification](https://apidocs.enectiva.cz/introduction-1363538m0.md#meter-identification)
          required: true
          example: '{{meterIdentification}}'
          schema:
            type: string
        - name: Accept
          in: header
          description: e.g. application/vnd.api+json
          required: true
          example: application/vnd.api+json
          schema:
            type: string
        - name: Content-Type
          in: header
          description: ''
          required: true
          example: application/vnd.api+json
          schema:
            type: string
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              properties:
                data:
                  properties:
                    attributes:
                      properties:
                        consumption:
                          type: number
                        cost:
                          type: number
                        from:
                          type: string
                        note:
                          type: string
                        to:
                          type: string
                      type: object
                      x-apidog-orders:
                        - consumption
                        - cost
                        - from
                        - note
                        - to
                    type:
                      type: string
                  type: object
                  x-apidog-orders:
                    - attributes
                    - type
              type: object
              x-apidog-orders:
                - data
              examples:
                - data:
                    attributes:
                      consumption: 734.22
                      cost: 123.45
                      from: '2022-07-01'
                      note: Monthly electricity invoice
                      to: '2022-07-31'
                    type: received_invoices
            examples: {}
      responses:
        '201':
          description: Created
          content:
            application/vnd.api+json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      attributes:
                        type: object
                        properties:
                          consumption:
                            type: number
                          consumption_unit:
                            type: string
                          cost:
                            type: number
                          currency:
                            type: string
                          from:
                            type: string
                          note:
                            type: string
                          to:
                            type: string
                        required:
                          - consumption
                          - consumption_unit
                          - cost
                          - currency
                          - from
                          - note
                          - to
                        x-apidog-orders:
                          - consumption
                          - consumption_unit
                          - cost
                          - currency
                          - from
                          - note
                          - to
                      id:
                        type: string
                      type:
                        type: string
                    required:
                      - attributes
                      - id
                      - type
                    x-apidog-orders:
                      - attributes
                      - id
                      - type
                required:
                  - data
                x-apidog-orders:
                  - data
              examples:
                '1':
                  summary: response
                  value:
                    data:
                      attributes:
                        consumption: 734.22
                        consumption_unit: kWh
                        cost: 123.45
                        currency: EUR
                        from: '2022-07-01'
                        note: Monthly electricity invoice
                        to: '2022-07-31'
                      id: 022d3385-a109-4ccb-aeb5-b2e547b73e81
                      type: received_invoices
                '2':
                  summary: response
                  value:
                    errors:
                      - detail: Range ends in the future
                        status: '400'
                        title: Invalid data
                '3':
                  summary: response
                  value:
                    errors:
                      - detail: Access token is invalid.
                        status: '401'
                        title: Unauthorized
                '4':
                  summary: response
                  value:
                    errors:
                      - detail: >-
                          The access token does not have `received_invoices`
                          scope
                        status: '403'
                        title: Forbidden
                '5':
                  summary: response
                  value:
                    errors:
                      - status: '404'
                        title: Not Found
                '6':
                  summary: response
                  value:
                    errors:
                      - detail: Accept HTTP header must be "application/vnd.api+json".
                        status: '406'
                        title: Not acceptable
                '7':
                  summary: response
                  value:
                    errors:
                      - detail: >-
                          Multiple meters found with external_id 'METER_001'.
                          Use Enectiva ID instead.
                        meta:
                          conflicting_resources:
                            - href: >-
                                https://api.enectiva.cz/meters/123/invoices/received
                            - href: >-
                                https://api.enectiva.cz/meters/456/invoices/received
                        status: '409'
                        title: Conflict
                '8':
                  summary: response
                  value:
                    errors:
                      - detail: >-
                          Content-Type header must be
                          "application/vnd.api+json".
                        status: '415'
                        title: Unsupported Media Type
                '9':
                  summary: response
                  value:
                    errors:
                      - detail: You have exceeded the number of allowed requests.
                        status: '429'
                        title: Too Many Requests
                '10':
                  summary: response
                  value:
                    errors:
                      - detail: Something went wrong
                        status: '500'
                        title: Internal Server Error
          headers: {}
          x-apidog-name: Created
        '400':
          description: Bad Request
          content:
            application/vnd.api+json:
              schema:
                properties:
                  errors:
                    items:
                      properties:
                        detail:
                          type: string
                        status:
                          type: string
                        title:
                          type: string
                      type: object
                      x-apidog-orders:
                        - detail
                        - status
                        - title
                      required:
                        - detail
                        - status
                        - title
                    type: array
                type: object
                x-apidog-orders:
                  - errors
                examples:
                  - errors:
                      - detail: Range ends in the future
                        status: '400'
                        title: Invalid data
                required:
                  - errors
          headers: {}
          x-apidog-name: Bad Request
        '401':
          description: Unauthorized
          content:
            application/vnd.api+json:
              schema:
                properties:
                  errors:
                    items:
                      properties:
                        detail:
                          type: string
                        status:
                          type: string
                        title:
                          type: string
                      type: object
                      x-apidog-orders:
                        - detail
                        - status
                        - title
                      required:
                        - detail
                        - status
                        - title
                    type: array
                type: object
                x-apidog-orders:
                  - errors
                examples:
                  - errors:
                      - detail: Access token is invalid.
                        status: '401'
                        title: Unauthorized
                required:
                  - errors
          headers: {}
          x-apidog-name: Unauthorized
        '403':
          description: Forbidden
          content:
            application/vnd.api+json:
              schema:
                properties:
                  errors:
                    items:
                      properties:
                        detail:
                          type: string
                        status:
                          type: string
                        title:
                          type: string
                      type: object
                      x-apidog-orders:
                        - detail
                        - status
                        - title
                      required:
                        - status
                        - title
                        - detail
                    type: array
                type: object
                x-apidog-orders:
                  - errors
                examples:
                  - errors:
                      - detail: >-
                          The access token does not have `received_invoices`
                          scope
                        status: '403'
                        title: Forbidden
                required:
                  - errors
          headers: {}
          x-apidog-name: Forbidden
        '404':
          description: Not Found
          content:
            application/vnd.api+json:
              schema:
                properties:
                  errors:
                    items:
                      properties:
                        status:
                          type: string
                        title:
                          type: string
                      type: object
                      x-apidog-orders:
                        - status
                        - title
                      required:
                        - status
                        - title
                    type: array
                type: object
                x-apidog-orders:
                  - errors
                examples:
                  - errors:
                      - status: '404'
                        title: Not Found
                required:
                  - errors
          headers: {}
          x-apidog-name: Record Not Found
        '406':
          description: Not Acceptable
          content:
            application/vnd.api+json:
              schema:
                properties:
                  errors:
                    items:
                      properties:
                        detail:
                          type: string
                        status:
                          type: string
                        title:
                          type: string
                      type: object
                      x-apidog-orders:
                        - detail
                        - status
                        - title
                      required:
                        - detail
                        - status
                        - title
                    type: array
                type: object
                x-apidog-orders:
                  - errors
                examples:
                  - errors:
                      - detail: Accept HTTP header must be "application/vnd.api+json".
                        status: '406'
                        title: Not acceptable
                required:
                  - errors
          headers: {}
          x-apidog-name: Not Acceptable
        '409':
          description: Conflict
          content:
            application/vnd.api+json:
              schema:
                properties:
                  errors:
                    items:
                      properties:
                        detail:
                          type: string
                        meta:
                          properties:
                            conflicting_resources:
                              items:
                                properties:
                                  href:
                                    type: string
                                required:
                                  - href
                                type: object
                                x-apidog-orders:
                                  - href
                              type: array
                          type: object
                          x-apidog-orders:
                            - conflicting_resources
                        status:
                          type: string
                        title:
                          type: string
                      type: object
                      x-apidog-orders:
                        - detail
                        - meta
                        - status
                        - title
                      required:
                        - detail
                        - status
                        - title
                    type: array
                type: object
                x-apidog-orders:
                  - errors
                examples:
                  - errors:
                      - detail: >-
                          Multiple meters found with external_id 'METER_001'.
                          Use Enectiva ID instead.
                        meta:
                          conflicting_resources:
                            - href: >-
                                https://api.enectiva.cz/meters/123/invoices/received
                            - href: >-
                                https://api.enectiva.cz/meters/456/invoices/received
                        status: '409'
                        title: Conflict
                required:
                  - errors
          headers: {}
          x-apidog-name: Conflict
        '415':
          description: Unsupported Media Type
          content:
            application/vnd.api+json:
              schema:
                properties:
                  errors:
                    items:
                      properties:
                        detail:
                          type: string
                        status:
                          type: string
                        title:
                          type: string
                      type: object
                      x-apidog-orders:
                        - detail
                        - status
                        - title
                      required:
                        - detail
                        - status
                        - title
                    type: array
                type: object
                x-apidog-orders:
                  - errors
                examples:
                  - errors:
                      - detail: >-
                          Content-Type header must be
                          "application/vnd.api+json".
                        status: '415'
                        title: Unsupported Media Type
                required:
                  - errors
          headers: {}
          x-apidog-name: Unsupported Media Type
        '429':
          description: Too Many Requests
          content:
            application/vnd.api+json:
              schema:
                properties:
                  errors:
                    items:
                      properties:
                        detail:
                          type: string
                        status:
                          type: string
                        title:
                          type: string
                      type: object
                      x-apidog-orders:
                        - detail
                        - status
                        - title
                      required:
                        - detail
                        - status
                        - title
                    type: array
                type: object
                x-apidog-orders:
                  - errors
                examples:
                  - errors:
                      - detail: You have exceeded the number of allowed requests.
                        status: '429'
                        title: Too Many Requests
                required:
                  - errors
          headers: {}
          x-apidog-name: Too Many Requests
        '500':
          description: Internal Server Error
          content:
            application/vnd.api+json:
              schema:
                properties:
                  errors:
                    items:
                      properties:
                        detail:
                          type: string
                        status:
                          type: string
                        title:
                          type: string
                      type: object
                      x-apidog-orders:
                        - detail
                        - status
                        - title
                      required:
                        - detail
                        - status
                        - title
                    type: array
                type: object
                x-apidog-orders:
                  - errors
                examples:
                  - errors:
                      - detail: Something went wrong
                        status: '500'
                        title: Internal Server Error
                required:
                  - errors
          headers: {}
          x-apidog-name: Server Error
      security:
        - Access token: []
          x-apidog:
            schemeGroups:
              - id: eO1gIwoSseH50tAPce_Y9
                schemeIds:
                  - Access token
            required: true
            use:
              id: eO1gIwoSseH50tAPce_Y9
            scopes:
              eO1gIwoSseH50tAPce_Y9: {}
      x-apidog-folder: Received energy invoices
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/1003855/apis/api-19188105-run
components:
  schemas: {}
  securitySchemes:
    Access token:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
      x-apidog:
        addTokenTo: header
        headerPrefix: Bearer
    Import token:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
      x-apidog:
        addTokenTo: header
        headerPrefix: Bearer
    Login token:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
      x-apidog:
        addTokenTo: header
        headerPrefix: Bearer
    Access  or  Import token:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
      x-apidog:
        addTokenTo: header
        headerPrefix: Bearer
servers:
  - url: https://api.enectiva.cz
    description: https://api.enectiva.cz
security: []

```
