> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lumenaza.de/llms.txt
> Use this file to discover all available pages before exploring further.

# Post v3consumers contracts relationships



## OpenAPI

````yaml /lumx_openapi.yaml post /v3/consumers/{userID}/contracts/{contractID}/relationships/
openapi: 3.0.3
info:
  title: Lumenaza external API
  version: 3.8.0 (v3)
  description: Specification of the Lumenaza external API.
servers:
  - url: https://api.lumenaza.de/
    description: Produktivserver
  - url: https://api.test.lumenaza.de/
    description: Testserver
security: []
tags:
  - name: Community Data API
    description: >-
      The API is used to retrieve master data and measurement data for a
      community. A community is defined by all customers that belong to your
      company.
paths:
  /v3/consumers/{userID}/contracts/{contractID}/relationships/:
    post:
      tags:
        - consumers
      operationId: consumers_contracts_relationships_create
      parameters:
        - in: path
          name: contractID
          schema:
            type: string
          required: true
        - in: path
          name: userID
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CustomerContractRelationshipCreation'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/CustomerContractRelationshipCreation'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/CustomerContractRelationshipCreation'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerContractRelationshipCreation'
          description: ''
        '400':
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: array
                  items:
                    type: string
                example:
                  email:
                    - Enter a valid email address.
                  non_field_errors:
                    - Invalid combination of fields.
              examples:
                ValidationError:RelationshipTypeNotSupported:
                  value:
                    detail: >-
                      relationship type not supported by product of source
                      contract
                    product: <currently active product>
                    relationship_type: <requested relationship_type>
                    source_contract: <identical to contract_id in the url slug>
                  summary: 'ValidationError: Relationship Type Not Supported'
                ValidationError:TargetContractIDNotFound:
                  value:
                    detail: target_contract_id not found in database
                  summary: 'ValidationError: Target Contract ID Not Found'
                ValidationError:TargetContractIDIsIdenticalToSourceContractID:
                  value:
                    detail: target_contract_id is identical to source contract id
                  summary: >-
                    ValidationError: Target Contract ID is Identical to Source
                    Contract ID
                ValidationError:ActiveRelationshipAlreadyExists:
                  value:
                    detail: >-
                      an active relationship of the selected type and the chosen
                      source and target already exists
                  summary: 'ValidationError: Active Relationship Already Exists'
          description: >-
            DRF validation errors from the runtime relationship creation
            serializer.
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundResponse'
              examples:
                NoActiveProductFound:
                  value:
                    detail: No active product found in database
                  summary: No active product found
                ContractIDNotFound:
                  value:
                    detail: Contract ID not found in database
                  summary: ContractID Not Found
          description: The source contract or its active product could not be found.
components:
  schemas:
    CustomerContractRelationshipCreation:
      type: object
      properties:
        relationship_id:
          type: string
          readOnly: true
        source_contract_id:
          type: string
          title: Vertragsnummer
          readOnly: true
        target_contract_id:
          type: string
          title: Vertragsnummer
        relationship_type:
          type: string
        valid_from:
          type: string
          format: date
          writeOnly: true
      required:
        - relationship_id
        - relationship_type
        - source_contract_id
        - target_contract_id
    NotFoundResponse:
      type: object
      properties:
        detail:
          type: string
      required:
        - detail

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.