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

# Update a CRM Record Relation

> Add or remove individual record and team-member links on a relation or user attribute of a Zeeg CRM record without overwriting existing linked IDs

Adds or removes individual IDs from a `relation` or `user` attribute on a CRM record. Unlike [Patch](/api/crm/patch-a-crm-record), which replaces the entire array, this endpoint performs surgical add/remove operations — existing linked IDs not mentioned in the request are untouched.

## Path parameters

| Parameter    | Type          | Description                                                         |
| ------------ | ------------- | ------------------------------------------------------------------- |
| `objectSlug` | string        | The slug of the custom CRM object the record belongs to.            |
| `recordId`   | string (UUID) | The UUID of the record whose relation attribute you want to modify. |

## Request body

| Field           | Type      | Required | Description                                                                                                                                          |
| --------------- | --------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `attributeSlug` | string    | Yes      | The key of the `relation` or `user` attribute to modify. Must exist on the object and be of type `relation` or `user`.                               |
| `add`           | string\[] | No       | IDs to add to the relation. For `relation` attributes: UUIDs of records in the related object. For `user` attributes: UUIDs of organization members. |
| `remove`        | string\[] | No       | IDs to remove from the relation. The same ID format as `add`.                                                                                        |

**Rules:**

* At least one of `add` or `remove` must be present and non-empty.
* The same ID cannot appear in both `add` and `remove` in the same request.
* Passing an ID in `add` that is already linked is a no-op (not an error).
* Passing an ID in `remove` that is not linked is a no-op (not an error).

## Attribute types that support this endpoint

| Attribute type | What IDs to pass                                                                           |
| -------------- | ------------------------------------------------------------------------------------------ |
| `relation`     | UUIDs of records from the related object (obtained from `GET /v2/crm/{relatedObjectSlug}`) |
| `user`         | UUIDs of organization members (obtained from `GET /v2/organizations/users`)                |

Passing this endpoint for a `text`, `number`, `select`, or any non-relation attribute returns an error. Use [Patch](/api/crm/patch-a-crm-record) for those.

## Example: link products to an order

Your `orders` object has a `relation` attribute called `products` that links to the `products` object. To add two products to an order:

```json theme={null}
PATCH /v2/crm/orders/a1b2c3d4-e5f6-7890-abcd-ef1234567890/relation
{
  "attributeSlug": "products",
  "add": [
    "c1d2e3f4-a5b6-7890-cdef-123456789012",
    "d2e3f4a5-b6c7-8901-defa-234567890123"
  ]
}
```

## Example: swap a linked record

Remove one product and add a replacement in a single request:

```json theme={null}
{
  "attributeSlug": "products",
  "add": ["new-product-uuid-here"],
  "remove": ["old-product-uuid-here"]
}
```

## Example: unlink all products one at a time

To remove products, pass their IDs in `remove`:

```json theme={null}
{
  "attributeSlug": "products",
  "remove": ["c1d2e3f4-a5b6-7890-cdef-123456789012"]
}
```

## Example: assign a team member to a deal

Your `deals` object has a `user` attribute called `owners`. To assign a team member:

```json theme={null}
PATCH /v2/crm/deals/deal-uuid-here/relation
{
  "attributeSlug": "owners",
  "add": ["org-member-uuid-here"]
}
```

## Finding the attribute slug

Relation attribute slugs are defined when the attribute is created. You can look them up via [`GET /v2/crm/objects/{slug}`](/api/crm/get-a-crm-object) — look for attributes with `type: relation` or `type: user` and use their `key` field as `attributeSlug`.

## Update Relation vs. PATCH

|              | `PATCH /relation`                   | `PATCH /{recordId}`                 |
| ------------ | ----------------------------------- | ----------------------------------- |
| Operation    | Adds/removes individual IDs         | Replaces the entire attribute value |
| Existing IDs | Preserved unless explicitly removed | Overwritten                         |
| Use case     | Add or remove one or a few links    | Set the complete list in one go     |

Use `PATCH /relation` when you need additive or subtractive changes. Use `PATCH /{recordId}` when you want to set the exact final state of a relation (replacing whatever was there before).

## When to use this endpoint

* **Add a linked record** — a user picks a related product, company, or person to attach.
* **Remove a linked record** — a user detaches a relation without affecting others.
* **Assign / unassign owners** — add or remove team members from a user-type attribute.
* **Incremental sync** — when your source system sends delta events ("product X was added to order Y") rather than full state.


## OpenAPI

````yaml PATCH /crm/{objectSlug}/{recordId}/relation
openapi: 3.0.0
info:
  title: Zeeg Public API
  description: >-
    Zeeg public API documentation.


    ## Authentication

    All endpoints require a Bearer token. You can generate an API token from
    [your Zeeg dashboard](https://app.zeeg.me/account/settings/api-access).


    Each token is scoped to specific permissions (e.g. `events:read`,
    `webhooks:write`). Make sure your token has the required scopes for the
    endpoints you want to use.


    ## Recommended Headers

    We recommend including the `Accept: application/json` header in all API
    requests to ensure you receive JSON responses.
  version: 2.0.0
  x-logo:
    url: https://app.zeeg.me/img/logo-dark.2ca83593.svg
    backgroundColor: '#f7f7f9'
    altText: zeeg
  contact:
    name: Zeeg Support
    email: support@zeeg.me
    url: https://zeeg.me/en/contact
  license:
    name: Proprietary
    url: https://zeeg.me/en/legal/terms
  termsOfService: https://zeeg.me/en/legal/terms
servers:
  - url: https://api.zeeg.me/v2
    description: Production
security:
  - bearer: []
tags:
  - name: Scheduled Events
    description: Management of events scheduled via Zeeg
  - name: Scheduling Pages
    description: Scheduling pages information and management
  - name: Availability Schedule
    description: Read and change availability for users
  - name: Webhooks
    description: Webhooks management
  - name: Notes
    description: Notes for scheduled events
  - name: Workspaces & Teams
    description: Workspace users and team member management
  - name: AI Agent
    description: AI Agent integration endpoints
  - name: Payloads
    description: Webhook payload schemas
  - name: CRM - Objects
    description: >-
      Discover the schema of CRM objects (standard and custom) including all
      attribute definitions
  - name: CRM - Companies
    description: Create, read, update, and delete CRM company records
  - name: CRM - People
    description: Create, read, update, and delete CRM person records
paths:
  /crm/{objectSlug}/{recordId}/relation:
    patch:
      tags:
        - CRM - Records
      summary: Update a CRM record relation
      description: >-
        Adds or removes record IDs (or organization member IDs for `user` type
        attributes) from a relation or user attribute on a CRM record.


        Supply `add` with IDs to link and/or `remove` with IDs to unlink. At
        least one of the two arrays must be non-empty, and the same ID cannot
        appear in both.


        **Required scope:** `crm:write`
      operationId: update-crm-record-relation
      parameters:
        - name: objectSlug
          in: path
          required: true
          schema:
            type: string
          description: Slug of the custom CRM object.
          example: orders
        - name: recordId
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: UUID of the record to update.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - attributeSlug
              properties:
                attributeSlug:
                  type: string
                  description: Key of the relation or user attribute to modify.
                  example: products
                add:
                  type: array
                  description: IDs to add to the relation.
                  items:
                    type: string
                  example:
                    - c1d2e3f4-a5b6-7890-cdef-123456789012
                remove:
                  type: array
                  description: IDs to remove from the relation.
                  items:
                    type: string
                  example: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  status:
                    type: integer
                    example: 200
                  record:
                    $ref: '#/components/schemas/CrmRecord'
        '401':
          $ref: '#/components/responses/401'
        '403':
          description: Forbidden — missing scope or CRM not enabled
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  status:
                    type: integer
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  status:
                    type: integer
              examples:
                Not found:
                  value:
                    success: false
                    message: Record not found.
                    status: 404
        '422':
          $ref: '#/components/responses/422'
      security:
        - bearer: []
components:
  schemas:
    CrmRecord:
      type: object
      description: A record for a custom CRM object.
      required:
        - id
        - objectSlug
        - attributes
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the record.
          example: c1d2e3f4-a5b6-7890-cdef-123456789012
        objectSlug:
          type: string
          description: Slug of the CRM object this record belongs to.
          example: products
        attributes:
          type: object
          description: >-
            Key/value pairs for the custom attributes defined on the object.
            Keys are attribute slugs.
          additionalProperties: true
          example:
            sku: DRESS-001
            price: 29
            inventory_count: 150
        createdAt:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the record was created.
          example: '2025-06-01T10:00:00+00:00'
        updatedAt:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the record was last updated.
          example: '2025-06-01T12:00:00+00:00'
  responses:
    '401':
      description: Unauthorized
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                example: Unauthenticated.
          examples:
            Unauthenticated:
              value:
                message: Unauthenticated.
    '422':
      description: Unprocessable Entity
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                example: The given data was invalid.
              errors:
                type: object
                additionalProperties:
                  type: array
                  items:
                    type: string
                example:
                  field_name:
                    - The field_name field is required.
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: ''

````