# Create a new/update an existing profile

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /import/profiles/{customerId}:
    post:
      summary: Create a new/update an existing profile
      deprecated: false
      description: >
        This endpoint enables clients to add new profiles or update existing
        ones in Enectiva. Each profile is sent in a separate HTTP request.
        Sending profiles from multiple servers might hit rate limiting limits.


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


        Each profile is validated against these rules:


        - `from`, `to`, `value` and `import_id` are required fields and must be
        non-empty


        - `from` and `to` must conform to time 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


        - `value` 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


        - time range of a profile defined by `from` and `to` must not overlap
        with other profiles on the meter specified by `import_id` and `suit`.
        Time range excludes the upper bound `[from, to)`, so insertion of 2
        profiles with time ranges `[time_1, time_2)` and `[time_2, time_3)` do
        not fail on overlap conflict.


        - profiles must be in the past


        - when a time range exactly matches an existing profile's range (for the
        same `import_id`, `suit` and matching time range `from` and `to`), it
        will update the existing profile without creating a new one


        Each profile 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. If profiles are flagged incorrectly,
        [please let us
        know](https://apidocs.enectiva.cz/introduction-1363538m0.md#contact).


        Profiles 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`).


        The status code for a new profile is 201, while for an updated profile,
        it is 200.


        Repeated attempts to insert an identical or overlapping profile (the
        same `import_id`, `suit` and overlapping time range `from` and `to`)
        result in 409 status code. Client must stop sending the overlapping
        profile 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/update an existing profile
      tags:
        - Profiles to Enectiva
        - Profiles 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: ''
          required: true
          example: application/vnd.api+json
          schema:
            type: string
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  properties:
                    type:
                      type: string
                    attributes:
                      type: object
                      properties:
                        from:
                          type: string
                        to:
                          type: string
                        value:
                          type: number
                        import_id:
                          type: string
                        unit:
                          type: string
                        suit:
                          type: string
                      required:
                        - from
                        - to
                        - value
                        - import_id
                        - unit
                        - suit
                      x-apidog-orders:
                        - from
                        - to
                        - value
                        - import_id
                        - unit
                        - suit
                  required:
                    - type
                    - attributes
                  x-apidog-orders:
                    - type
                    - attributes
              required:
                - data
              x-apidog-orders:
                - data
            example:
              data:
                type: profiles
                attributes:
                  from: '2015-11-18T09:54:23+01:00'
                  to: '2015-11-18T09:59:23+01:00'
                  value: 123456.78
                  import_id: 40AABB_007
                  unit: kW
                  suit: default
      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
                          from:
                            type: string
                          import_id:
                            type: string
                          suit:
                            type: string
                          to:
                            type: string
                          unit:
                            type: string
                          value:
                            type: number
                        required:
                          - customer_uuid
                          - from
                          - import_id
                          - suit
                          - to
                          - unit
                          - value
                        x-apidog-orders:
                          - customer_uuid
                          - from
                          - import_id
                          - suit
                          - to
                          - unit
                          - value
                      id:
                        type: string
                      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
                    from: '2015-11-18T09:54:23+01:00'
                    import_id: 40AABB_007
                    suit: default
                    to: '2015-11-18T09:59:23+01:00'
                    unit: kW
                    value: 123456.78
                  id: '1'
                  type: profiles
          headers: {}
          x-apidog-name: OK
        '201':
          description: Created
          content:
            application/vnd.api+json:
              schema:
                properties:
                  data:
                    properties:
                      attributes:
                        properties:
                          customer_uuid:
                            type: string
                          from:
                            type: string
                          import_id:
                            type: string
                          suit:
                            type: string
                          to:
                            type: string
                          unit:
                            type: string
                          value:
                            type: number
                        type: object
                        x-apidog-orders:
                          - customer_uuid
                          - from
                          - import_id
                          - suit
                          - to
                          - unit
                          - value
                        required:
                          - customer_uuid
                          - from
                          - import_id
                          - suit
                          - to
                          - unit
                          - value
                      id:
                        type: string
                      type:
                        type: string
                    type: object
                    x-apidog-orders:
                      - attributes
                      - id
                      - type
                    required:
                      - attributes
                      - id
                      - type
                type: object
                x-apidog-orders:
                  - data
                examples:
                  - data:
                      attributes:
                        customer_uuid: 11e7e767-6f74-4994-b607-158ff7f7445e
                        from: '2015-11-18T09:54:23+01:00'
                        import_id: 40AABB_007
                        suit: default
                        to: '2015-11-18T09:59:23+01:00'
                        unit: kW
                        value: 123456.78
                      id: '1'
                      type: profiles
                required:
                  - data
              example:
                data:
                  attributes:
                    customer_uuid: 11e7e767-6f74-4994-b607-158ff7f7445e
                    from: '2015-11-18T09:54:23+01:00'
                    import_id: 40AABB_007
                    suit: default
                    to: '2015-11-18T09:59:23+01:00'
                    unit: kW
                    value: 123456.78
                  id: '1'
                  type: profiles
          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 is invalid
                        status: '400'
                        title: Bad Request
              example:
                errors:
                  - detail: Range is invalid
                    status: '400'
                    title: Bad Request
          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: >-
                          No access token provided, please use `Authorization:
                          Bearer access_token`
                        status: '401'
                        title: Unauthorized
                required:
                  - errors
              example:
                errors:
                  - detail: >-
                      No access token provided, please use `Authorization:
                      Bearer access_token`
                    status: '401'
                    title: Unauthorized
          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:
                        - detail
                        - status
                        - title
                    type: array
                type: object
                x-apidog-orders:
                  - errors
                examples:
                  - errors:
                      - detail: The access token does not have `la` scope
                        status: '403'
                        title: Forbidden
                required:
                  - errors
              example:
                errors:
                  - detail: The access token does not have `la` scope
                    status: '403'
                    title: Forbidden
          headers: {}
          x-apidog-name: Forbidden
        '404':
          description: Not Found
          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: Meter not found
                        status: '404'
                        title: Not Found
                required:
                  - errors
              example:
                errors:
                  - detail: Meter not 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: >-
                          Unsupported Accept header value in the request. The
                          endpoint expects the request to include header
                          `Accept: application/vnd.api+json`
                        status: '406'
                        title: Not Acceptable
                required:
                  - errors
              example:
                errors:
                  - detail: >-
                      Unsupported Accept header value in the request. The
                      endpoint expects the request to include header `Accept:
                      application/vnd.api+json`
                    status: '406'
                    title: Not Acceptable
          headers: {}
          x-apidog-name: Not Acceptable
        '409':
          description: Conflict
          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: >-
                          The given range overlaps with an existing record
                          (1/7/2023 00:00—31/7/2023 00:00). Change the period to
                          save the current profile.
                        status: '409'
                        title: Conflict
                required:
                  - errors
              example:
                errors:
                  - detail: >-
                      The given range overlaps with an existing record (1/7/2023
                      00:00—31/7/2023 00:00). Change the period to save the
                      current profile.
                    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: >-
                          Unsupported Content-Type header value in the request.
                          The endpoint expects the request to include header
                          `Content-Type: application/vnd.api+json`
                        status: '415'
                        title: Unsupported Media Type
                required:
                  - errors
              example:
                errors:
                  - detail: >-
                      Unsupported Content-Type header value in the request. The
                      endpoint expects the request to include header
                      `Content-Type: 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:
                properties:
                  errors:
                    items:
                      properties:
                        detail:
                          type: string
                        status:
                          type: string
                        title:
                          type: string
                      type: object
                      x-apidog-orders:
                        - detail
                        - status
                        - title
                      required:
                        - title
                        - status
                        - detail
                    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:
                properties:
                  errors:
                    items:
                      properties:
                        status:
                          type: string
                        title:
                          type: string
                      type: object
                      x-apidog-orders:
                        - status
                        - title
                      required:
                        - title
                        - status
                    type: array
                type: object
                x-apidog-orders:
                  - errors
                examples:
                  - errors:
                      - status: '500'
                        title: Internal Server Error
                required:
                  - errors
              example:
                errors:
                  - status: '500'
                    title: Internal Server Error
          headers: {}
          x-apidog-name: Server Error
      security:
        - Access  or  Import token: []
          x-apidog:
            schemeGroups:
              - id: E6NpaNbnvi31H667KekQf
                schemeIds:
                  - Access  or  Import token
            required: true
            use:
              id: E6NpaNbnvi31H667KekQf
            scopes:
              E6NpaNbnvi31H667KekQf: {}
      x-apidog-folder: Profiles to Enectiva
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/1003855/apis/api-19188099-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: []

```
