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

# Create Relation for you associated entities.

> Create Relation.See: https://help.hoopai.com/api-reference/overview/associations



## OpenAPI

````yaml /api-reference/associations/openapi.json post /associations/relations
openapi: 3.0.0
info:
  title: Associations API
  description: Documentation for Associations API
  version: '1.0'
  contact: {}
servers:
  - url: https://services.leadconnectorhq.com
security: []
tags:
  - name: Associations
    description: Documentation for Associations API
  - name: Relations
    description: Documentation for Associations API
paths:
  /associations/relations:
    post:
      tags:
        - Relations
      summary: Create Relation for you associated entities.
      description: >-
        Create Relation.See:
        https://help.hoopai.com/api-reference/overview/associations
      operationId: create-relation
      parameters:
        - name: Version
          in: header
          description: API Version
          required: true
          schema:
            type: string
            enum:
              - '2021-07-28'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/createRelationReqDto'
      responses:
        '201':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetPostSuccessfulResponseDto'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestDTO'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedDTO'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnprocessableDTO'
      security:
        - bearer:
            - associations/relation.write
      externalDocs:
        url: https://help.hoopai.com/api-reference/overview/associations
        description: Click here for more information
components:
  schemas:
    createRelationReqDto:
      type: object
      properties:
        locationId:
          type: string
          example: clF1LD04GTUKN3b3XuOj
          description: Your Sub Account's ID
        associationId:
          type: string
          example: ve9EPM428h8vShlRW1KT
          description: Association's Id
        firstRecordId:
          type: string
          example: ve9EPM428h8vShlRW1KT
          description: >-
            First Record's Id. For instance, if you have an association between
            a contact and a custom object, and you specify the contact as the
            first object while creating the association, then your firstRecordId
            would be the contactId 
        secondRecordId:
          type: string
          example: ve9EPM428h8vShlRW1KT
          description: >-
            Second Record's Id.For instance, if you have an association between
            a contact and a custom object, and you specify the custom object as
            the second entity while creating the association, then your
            secondRecordId would be the customObject record Id
      required:
        - locationId
        - associationId
        - firstRecordId
        - secondRecordId
    GetPostSuccessfulResponseDto:
      type: object
      properties:
        locationId:
          type: string
          example: string
        id:
          type: string
          example: ve9EPM428h8vShlRW1KT
        key:
          type: string
          example: student
          description: First Objects Association Label (custom_objects.children)
        firstObjectLabel:
          type: string
          example: student
          description: First Objects Association Label (custom_objects.children)
        firstObjectKey:
          type: string
          example: custom_objects.children
          description: First Objects Key
        secondObjectLabel:
          type: string
          example: Teacher
          description: Second Object Association Label (contact)
        secondObjectKey:
          type: string
          example: contact
          description: Second Objects Key
        associationType:
          type: string
          example: USER_DEFINED
          description: Association Type can be USER_DEFINED or SYSTEM_DEFINED
      required:
        - locationId
        - id
        - key
        - firstObjectLabel
        - firstObjectKey
        - secondObjectLabel
        - secondObjectKey
        - associationType
    BadRequestDTO:
      type: object
      properties:
        statusCode:
          type: number
          example: 400
        message:
          type: string
          example: Bad Request
      required:
        - statusCode
        - message
    UnauthorizedDTO:
      type: object
      properties:
        statusCode:
          type: number
          example: 401
        message:
          type: string
          example: 'Invalid token: access token is invalid'
        error:
          type: string
          example: Unauthorized
      required:
        - statusCode
        - message
        - error
    UnprocessableDTO:
      type: object
      properties:
        statusCode:
          type: number
          example: 422
        message:
          type: array
          items:
            type: string
          example:
            - Unprocessable Entity
        error:
          type: string
          example: Unprocessable Entity
      required:
        - statusCode
        - message
        - error
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Use the Access Token generated with user type as Sub-Account (OR)
        Private Integration Token of Sub-Account.
      type: http

````