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

# Create a relationship instance

> Creates a relationship instance between two records



## OpenAPI

````yaml post /v1/records/{record_id}/relationships
openapi: 3.0.0
info:
  description: >-
    REST API for accessing and managing your Nex data. Generate API keys from
    the Nex web UI and use them to authenticate requests.
  title: Nex Developer API
  contact: {}
  version: '1.0'
servers:
  - url: https://app.nex.ai/api/developers
security: []
paths:
  /v1/records/{record_id}/relationships:
    post:
      tags:
        - Relationships
      summary: Create a relationship instance
      description: Creates a relationship instance between two records
      operationId: createRelationshipInstance
      parameters:
        - description: Record ID
          name: record_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/developer.CreateRelationshipRequest'
        description: Relationship instance to create
        required: true
      responses:
        '200':
          description: Created relationship instance
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/developer.RelationshipInstanceResponse'
        '400':
          description: Bad request - Invalid data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/httpx.APIError'
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/httpx.APIError'
        '404':
          description: Record not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/httpx.APIError'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/httpx.APIError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    developer.CreateRelationshipRequest:
      type: object
      required:
        - definition_id
        - entity_1_id
        - entity_2_id
      properties:
        definition_id:
          type: string
          description: Relationship definition ID
        entity_1_id:
          type: string
          description: First record ID
        entity_2_id:
          type: string
          description: Second record ID
      example:
        definition_id: '789'
        entity_1_id: '1001'
        entity_2_id: '2002'
    developer.RelationshipInstanceResponse:
      type: object
      properties:
        id:
          type: string
        definition_id:
          type: string
        entity_1_id:
          type: string
        entity_2_id:
          type: string
        created_at:
          type: string
          format: date-time
      example:
        id: '5001'
        definition_id: '789'
        entity_1_id: '1001'
        entity_2_id: '2002'
        created_at: '2024-01-15T10:00:00Z'
    httpx.APIError:
      type: object
      properties:
        code:
          type: integer
        message:
          type: string
  securitySchemes:
    ApiKeyAuth:
      description: 'API key for authentication (format: "Bearer YOUR_API_KEY")'
      type: apiKey
      name: Authorization
      in: header

````