# Latest reading

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /import/readings/{customerId}/{importId}/{suit}/latest:
    get:
      summary: Latest reading
      deprecated: false
      description: >-
        Latest reading endpoint enables clients to get the latest imported
        reading for the given meter. It either returns the latest reading (even
        if marked as suspicious) with 200 or a 404 error when the given meter
        has no readings stored.


        Any token allowed to add readings is able to read the latest reading as
        well. The purpose is to minimize the number of requests to Librarian.
        Clients should keep track of readings sent to Librarian on their own.
        However, if they, for some reason, lose track, the preferred course of
        action is to use this endpoint rather than to send a series of readings
        that have been sent earlier. Duplicate requests result in 409 responses.
      operationId: Latest 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: importId
          in: path
          description: meter ID in question
          required: true
          example: '{{importId}}'
          schema:
            type: string
        - name: suit
          in: path
          description: >-
            identifier to distinguish multiple series of a single sensor (using
            the same `importId`), `default` by default
          required: true
          example: '{{suit}}'
          schema:
            type: string
        - name: Accept
          in: header
          description: e.g. application/vnd.api+json
          required: true
          example: application/vnd.api+json
          schema:
            type: string
      responses:
        '200':
          description: OK
          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: OK
        '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:
                        - title
                        - detail
                        - status
                required:
                  - errors
                x-apidog-orders:
                  - errors
              example:
                errors:
                  - detail: Access token is invalid.
                    status: '401'
                    title: Unauthorized
          headers: {}
          x-apidog-name: Unauthorized
        '404':
          description: Not Found
          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:
                        - title
                        - detail
                        - status
                required:
                  - errors
                x-apidog-orders:
                  - errors
              example:
                errors:
                  - detail: Requested resource has not been found
                    status: '404'
                    title: Not found
          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
              example:
                errors:
                  - detail: Accept HTTP header must be "application/vnd.api+json".
                    status: '406'
                    title: Not acceptable
          headers: {}
          x-apidog-name: Not Acceptable
        '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
              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: dds4etm4X9w1EiSDLldF5
                schemeIds:
                  - Access  or  Import token
            required: true
            use:
              id: dds4etm4X9w1EiSDLldF5
            scopes:
              dds4etm4X9w1EiSDLldF5: {}
      x-apidog-folder: Readings to Enectiva
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/1003855/apis/api-19188102-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: []

```
