> ## Documentation Index
> Fetch the complete documentation index at: https://developer.energy-hub.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Link meters

> Connects the provided list of meters from the vendor account to the Energy Hub.



## OpenAPI

````yaml post /v1.0.0/link/users/{userId}/vendor-accounts/{vendorAccountId}/meters
openapi: 3.0.1
info:
  description: A service used for battery and pv inverter devices
  title: home-power-service
  version: 1.0.0
servers:
  - description: Generated server url
    url: https://api.energy-hub.io
security: []
paths:
  /v1.0.0/link/users/{userId}/vendor-accounts/{vendorAccountId}/meters:
    post:
      tags:
        - Home Power Link Controller
      summary: Link meters
      description: >-
        Connects the provided list of meters from the vendor account to the
        Energy Hub.
      operationId: linkMetersToVendorAccount
      parameters:
        - schema:
            type: string
          in: path
          name: userId
          description: User ID
          required: true
        - schema:
            format: uuid
            type: string
          in: path
          name: vendorAccountId
          description: Vendor account ID
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MetersAddingRequest'
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/MeterLinkDto'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorMessageDto'
              examples:
                BAD_REQUEST:
                  $ref: '#/components/examples/BAD_REQUEST'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessageDto'
              examples:
                UNAUTHORIZED:
                  $ref: '#/components/examples/UNAUTHORIZED'
        '402':
          description: Payment required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessageDto'
              examples:
                DEVICE_LIMIT_REACHED:
                  $ref: '#/components/examples/DEVICE_LIMIT_REACHED'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessageDto'
              examples:
                METER_NOT_FOUND:
                  $ref: '#/components/examples/METER_NOT_FOUND'
                VENDOR_ACCOUNT_NOT_FOUND:
                  $ref: '#/components/examples/VENDOR_ACCOUNT_NOT_FOUND'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessageDto'
              examples:
                VENDOR_ACCOUNT_IS_DISCONNECTED:
                  $ref: '#/components/examples/VENDOR_ACCOUNT_IS_DISCONNECTED'
                VENDOR_COMMUNICATION_ERROR:
                  $ref: '#/components/examples/VENDOR_COMMUNICATION_ERROR'
                VENDOR_AUTHENTICATION_ERROR:
                  $ref: '#/components/examples/VENDOR_AUTHENTICATION_ERROR'
                VENDOR_CONNECTION_ERROR:
                  $ref: '#/components/examples/VENDOR_CONNECTION_ERROR'
      security:
        - API_Key: []
components:
  schemas:
    MetersAddingRequest:
      description: Object for meters IDs request that should be added to the Energy Hub.
      type: object
      required:
        - externalMeters
      properties:
        externalMeters:
          uniqueItems: true
          description: List of external IDs of meters to be linked to the Energy Hub.
          type: array
          items:
            description: List of external IDs of meters to be linked to the Energy Hub.
            type: string
            example: '["8413731391660801"]'
          example:
            - '8413731391660801'
    MeterLinkDto:
      description: Object of meter for linking process.
      type: object
      required:
        - externalId
        - id
        - isLinked
        - name
        - vendor
      properties:
        isLinked:
          description: Indicates if the meter is linked to the Energy Hub.
          type: boolean
        vendor:
          description: The vendor of the meter.
          type: string
          enum:
            - FRONIUS
            - TESLA
            - HUAWEI
            - SMA
        name:
          description: The display name of the meter.
          type: string
          example: Fronius Primary Meter
        externalId:
          description: The ID of the meter in external vendor system.
          type: string
          example: '8413731391660801'
        siteName:
          description: The site name of the home energy device.
          type: string
          example: My Home
        id:
          format: uuid
          description: The ID of the meter.
          type: string
    ValidationErrorMessageDto:
      allOf:
        - $ref: '#/components/schemas/ErrorMessageDto'
        - type: object
          properties:
            errorCode:
              description: The error code
              type: string
              example: EXAMPLE_ERROR_CODE
            validationErrors:
              description: List of validation errors
              type: array
              items:
                $ref: '#/components/schemas/ValidationError'
            id:
              format: uuid
              description: The error identifier
              type: string
              example: 7958818d-64d2-4ede-b12b-4786dd2f348b
            message:
              description: The error message
              type: string
              example: Example error message
      type: object
      required:
        - errorCode
        - id
        - message
    ErrorMessageDto:
      type: object
      required:
        - errorCode
        - id
        - message
      properties:
        errorCode:
          description: The error code
          type: string
          example: EXAMPLE_ERROR_CODE
        id:
          format: uuid
          description: The error identifier
          type: string
          example: 7958818d-64d2-4ede-b12b-4786dd2f348b
        message:
          description: The error message
          type: string
          example: Example error message
    ValidationError:
      type: object
      properties:
        field:
          description: Affected field
          type: string
        message:
          description: Validation message
          type: string
  examples:
    BAD_REQUEST:
      value:
        errorCode: BAD_REQUEST
        validationErrors:
          - field: Affected field
            message: Validation message
        id: 57da008b-bd4d-442e-b8f8-584cb9058e29
        message: Bad request
    UNAUTHORIZED:
      value:
        errorCode: UNAUTHORIZED
        id: 57da008b-bd4d-442e-b8f8-584cb9058e29
        message: Unauthorized
    DEVICE_LIMIT_REACHED:
      value:
        errorCode: DEVICE_LIMIT_REACHED
        id: 57da008b-bd4d-442e-b8f8-584cb9058e29
        message: Device limit reached
    METER_NOT_FOUND:
      value:
        errorCode: METER_NOT_FOUND
        id: 57da008b-bd4d-442e-b8f8-584cb9058e29
        message: '[METER] Meter not found'
    VENDOR_ACCOUNT_NOT_FOUND:
      value:
        errorCode: VENDOR_ACCOUNT_NOT_FOUND
        id: 57da008b-bd4d-442e-b8f8-584cb9058e29
        message: '[VENDOR_ACCOUNT] Requested vendor account is not found.'
    VENDOR_ACCOUNT_IS_DISCONNECTED:
      value:
        errorCode: VENDOR_ACCOUNT_IS_DISCONNECTED
        id: 57da008b-bd4d-442e-b8f8-584cb9058e29
        message: '[VENDOR_ACCOUNT] Vendor account is disconnected'
    VENDOR_COMMUNICATION_ERROR:
      value:
        errorCode: VENDOR_COMMUNICATION_ERROR
        id: 57da008b-bd4d-442e-b8f8-584cb9058e29
        message: '[VENDOR API] Communication error with Vendor API'
    VENDOR_AUTHENTICATION_ERROR:
      value:
        errorCode: VENDOR_AUTHENTICATION_ERROR
        id: 57da008b-bd4d-442e-b8f8-584cb9058e29
        message: '[VENDOR API] Authentication error with Vendor API'
    VENDOR_CONNECTION_ERROR:
      value:
        errorCode: VENDOR_CONNECTION_ERROR
        id: 57da008b-bd4d-442e-b8f8-584cb9058e29
        message: '[VENDOR API] Connection cannot be established with Vendor API'
  securitySchemes:
    API_Key:
      in: header
      name: X-API-KEY
      description: API key used for authorization and authentication.
      type: apiKey

````