# Create a new reading

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /import/readings/{customerId}:
    post:
      summary: Create a new reading
      deprecated: false
      description: >
        This endpoint enables clients to add new readings to Enectiva. Each
        reading is sent in a separate HTTP request. The client can send the
        readings with any frequency but there really is no point in sending more
        than one reading per minute per meter. Sending readings from multiple
        servers might hit rate limiting limits.


        Readings should be sent in chronological order and at constant intervals
        if possible. Older readings will be accepted, but might not be used by
        Enectiva.


        Each reading is validated against these rules:


        - `time`, `state` and `import_id` are required fields and must be
        non-empty


        - `time` must conform to format defined in RFC3339, the time will be
        truncated to whole seconds


        - `import_id` is limited to 255 characters, it is case-sensitive, must
        not contain spaces


        - `state` has to be a floating point number; we recommend sending only
        reasonable number of digits after the decimal point


        - `unit` is an optional attribute limited to 50 case-sensitive
        characters; we recommend sending it when available because it is useful
        when debugging


        - `sender` is a case-sensitive string limited to 255 characters used for
        debugging and verification


        - `suit` is an optional string identifying the series of readings, if
        not provided `default` will be used, must not contain spaces


        - reading must be in the past


        Each reading might be flagged as suspicious by the API and not processed
        further to avoid problems further down the line. The typical cause for
        flagging is an unexpected unit or a sudden growth of the state (by
        orders of magnitude). If readings are flagged incorrectly, [please let
        us know](https://apidocs.enectiva.cz/introduction-1363538m0.md#contact).


        Readings can be sent for any meter without any prior setup. The client
        is responsible for keeping the meter IDs unique. The same meter IDs are
        then used in Enectiva to identify the source of readings. In case
        multiple series of values are associated with a single meter ID, they
        can be differentiated with `suit` field.


        For testing integration of a new client, we recommend using dummy meter
        IDs (e.g. `test`).


        Repeated attempts to insert an identical reading (the same `import_id`,
        `suit`, `time` and `state`) result in 409 status code. Client must stop
        sending the same reading over and over again (and move to the next one),
        not doing so would result in a stuck import series and potentially rate
        limiting.
      operationId: Create a new reading
      tags:
        - Readings to Enectiva
        - Readings to Enectiva
      parameters:
        - name: customerId
          in: path
          description: >-
            UUID of the customer, available in the token management section in
            Enectiva
          required: true
          example: '{{customerId}}'
          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: e.g. application/vnd.api+json
          required: true
          example: application/vnd.api+json
          schema:
            type: string
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  properties:
                    id:
                      type: integer
                    attributes:
                      type: object
                      properties:
                        time:
                          type: string
                        state:
                          type: number
                        import_id:
                          type: string
                        unit:
                          type: string
                        suspicious:
                          type: boolean
                        customer_uuid:
                          type: string
                        sender:
                          type: string
                        suit:
                          type: string
                      required:
                        - time
                        - state
                        - import_id
                        - unit
                        - suspicious
                        - customer_uuid
                        - sender
                        - suit
                      x-apidog-orders:
                        - time
                        - state
                        - import_id
                        - unit
                        - suspicious
                        - customer_uuid
                        - sender
                        - suit
                    type:
                      type: string
                  required:
                    - id
                    - attributes
                    - type
                  x-apidog-orders:
                    - id
                    - attributes
                    - type
              required:
                - data
              x-apidog-orders:
                - data
            example:
              data:
                id: 1
                attributes:
                  time: '2015-11-18T09:54:23+01:00'
                  state: 123456.78
                  import_id: 40AABB_007
                  unit: kW
                  suspicious: false
                  customer_uuid: 11e7e767-6f74-4994-b607-158ff7f7445e
                  sender: test_script_01
                  suit: default
                type: readings
      responses:
        '201':
          description: Created
          content:
            application/vnd.api+json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      attributes:
                        type: object
                        properties:
                          customer_uuid:
                            type: string
                          import_id:
                            type: string
                          sender:
                            type: string
                          state:
                            type: number
                          suit:
                            type: string
                          suspicious:
                            type: boolean
                          time:
                            type: string
                          unit:
                            type: string
                        required:
                          - customer_uuid
                          - import_id
                          - sender
                          - state
                          - suit
                          - suspicious
                          - time
                          - unit
                        x-apidog-orders:
                          - customer_uuid
                          - import_id
                          - sender
                          - state
                          - suit
                          - suspicious
                          - time
                          - unit
                      id:
                        type: integer
                      type:
                        type: string
                    required:
                      - attributes
                      - id
                      - type
                    x-apidog-orders:
                      - attributes
                      - id
                      - type
                required:
                  - data
                x-apidog-orders:
                  - data
              example:
                data:
                  attributes:
                    customer_uuid: 11e7e767-6f74-4994-b607-158ff7f7445e
                    import_id: 40AABB_007
                    sender: test_script_01
                    state: 123456.78
                    suit: default
                    suspicious: false
                    time: '2015-11-18T09:54:23+01:00'
                    unit: kW
                  id: 1
                  type: readings
          headers: {}
          x-apidog-name: Created
        '400':
          description: Bad Request
          content:
            application/vnd.api+json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        detail:
                          type: string
                        status:
                          type: string
                        title:
                          type: string
                      x-apidog-orders:
                        - detail
                        - status
                        - title
                      required:
                        - detail
                        - status
                        - title
                required:
                  - errors
                x-apidog-orders:
                  - errors
              example:
                errors:
                  - detail: Missing meter ID
                    status: '400'
                    title: Invalid data
          headers: {}
          x-apidog-name: Bad Request
        '401':
          description: Unauthorized
          content:
            application/vnd.api+json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        detail:
                          type: string
                        status:
                          type: string
                        title:
                          type: string
                      x-apidog-orders:
                        - detail
                        - status
                        - title
                      required:
                        - detail
                        - status
                        - title
                required:
                  - errors
                x-apidog-orders:
                  - errors
              example:
                errors:
                  - detail: Access token is invalid.
                    status: '401'
                    title: Unauthorized
          headers: {}
          x-apidog-name: Unauthorized
        '406':
          description: Not Acceptable
          content:
            application/vnd.api+json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        detail:
                          type: string
                        status:
                          type: string
                        title:
                          type: string
                      x-apidog-orders:
                        - detail
                        - status
                        - title
                      required:
                        - detail
                        - status
                        - title
                required:
                  - errors
                x-apidog-orders:
                  - errors
              example:
                errors:
                  - detail: Accept HTTP header must be "application/vnd.api+json".
                    status: '406'
                    title: Not acceptable
          headers: {}
          x-apidog-name: Not Acceptable
        '409':
          description: Conflict
          content:
            application/vnd.api+json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        detail:
                          type: string
                        status:
                          type: string
                        title:
                          type: string
                      x-apidog-orders:
                        - detail
                        - status
                        - title
                      required:
                        - detail
                        - status
                        - title
                required:
                  - errors
                x-apidog-orders:
                  - errors
              example:
                errors:
                  - detail: A record with the same ID already exists.
                    status: '409'
                    title: Conflict
          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
              example:
                errors:
                  - detail: Content-Type header must be "application/vnd.api+json".
                    status: '415'
                    title: Unsupported Media Type
          headers: {}
          x-apidog-name: Unsupported Media Type
        '429':
          description: Too Many Requests
          content:
            application/vnd.api+json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        detail:
                          type: string
                        status:
                          type: string
                        title:
                          type: string
                      x-apidog-orders:
                        - detail
                        - status
                        - title
                      required:
                        - detail
                        - status
                        - title
                required:
                  - errors
                x-apidog-orders:
                  - errors
              example:
                errors:
                  - detail: You have exceeded the number of allowed requests.
                    status: '429'
                    title: Too Many Requests
          headers: {}
          x-apidog-name: Too Many Requests
        '500':
          description: Internal Server Error
          content:
            application/vnd.api+json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        detail:
                          type: string
                        status:
                          type: string
                        title:
                          type: string
                      x-apidog-orders:
                        - detail
                        - status
                        - title
                      required:
                        - detail
                        - status
                        - title
                required:
                  - errors
                x-apidog-orders:
                  - errors
              example:
                errors:
                  - detail: Something went wrong
                    status: '500'
                    title: Internal Server Error
          headers: {}
          x-apidog-name: Server Error
      security:
        - Access  or  Import token: []
          x-apidog:
            schemeGroups:
              - id: '-RbIe6C-LdSrZFNDfJx4x'
                schemeIds:
                  - Access  or  Import token
            required: true
            use:
              id: '-RbIe6C-LdSrZFNDfJx4x'
            scopes:
              '-RbIe6C-LdSrZFNDfJx4x': {}
      x-apidog-folder: Readings to Enectiva
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/1003855/apis/api-19188101-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: []

```
