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

# Assign Links to Group

> Add or remove links from a group

## Request

### Headers

<ParamField header="Content-Type" type="string" required>
  Must be `application/json`
</ParamField>

### Path Parameters

<ParamField path="groupId" type="string" required>
  The group ID

  **Example:** `grp_abc123xyz`
</ParamField>

### Body

<ParamField body="linkIds" type="array" required>
  Array of link IDs to add to this group

  **Example:** `["link_abc123", "link_def456", "link_ghi789"]`
</ParamField>

<ParamField body="action" type="string" default="add">
  Action to perform

  **Options:** `add`, `remove`
  **Default:** `add`
</ParamField>

## Response

<ResponseField name="groupId" type="string">
  Group ID
</ResponseField>

<ResponseField name="message" type="string">
  Success message
</ResponseField>

<ResponseField name="updated" type="number">
  Number of links updated
</ResponseField>

<ResponseField name="failed" type="array">
  Array of link IDs that failed (if any)

  <Expandable title="properties">
    <ResponseField name="linkId" type="string">
      Link ID that failed
    </ResponseField>

    <ResponseField name="error" type="object">
      Error details
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL (Add Links) theme={null}
  curl -X PATCH https://api.bouncy.ai/v1/groups/grp_abc123xyz/links \
    -H "Authorization: Bearer bcy_live_pk_YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "linkIds": ["link_abc123", "link_def456", "link_ghi789"],
      "action": "add"
    }'
  ```

  ```bash cURL (Remove Links) theme={null}
  curl -X PATCH https://api.bouncy.ai/v1/groups/grp_abc123xyz/links \
    -H "Authorization: Bearer bcy_live_pk_YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "linkIds": ["link_abc123"],
      "action": "remove"
    }'
  ```

  ```javascript JavaScript theme={null}
  // Add links to group
  const response = await fetch(
    'https://api.bouncy.ai/v1/groups/grp_abc123xyz/links',
    {
      method: 'PATCH',
      headers: {
        'Authorization': 'Bearer bcy_live_pk_YOUR_API_KEY',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        linkIds: ['link_abc123', 'link_def456', 'link_ghi789'],
        action: 'add'
      })
    }
  );

  const result = await response.json();
  console.log(`Added ${result.updated} links to group`);
  ```

  ```python Python theme={null}
  import requests

  # Add links to group
  response = requests.patch(
      'https://api.bouncy.ai/v1/groups/grp_abc123xyz/links',
      headers={
          'Authorization': 'Bearer bcy_live_pk_YOUR_API_KEY',
          'Content-Type': 'application/json'
      },
      json={
          'linkIds': ['link_abc123', 'link_def456', 'link_ghi789'],
          'action': 'add'
      }
  )

  result = response.json()
  print(f"Added {result['updated']} links to group")
  ```
</RequestExample>

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "groupId": "grp_abc123xyz",
    "message": "Links assigned to group successfully",
    "updated": 3,
    "failed": []
  }
  ```

  ```json 200 Partial Success theme={null}
  {
    "groupId": "grp_abc123xyz",
    "message": "Some links assigned successfully",
    "updated": 2,
    "failed": [
      {
        "linkId": "link_xyz999",
        "error": {
          "code": "link_not_found",
          "message": "Link not found"
        }
      }
    ]
  }
  ```

  ```json 404 Not Found theme={null}
  {
    "error": {
      "code": "group_not_found",
      "message": "Group not found"
    }
  }
  ```
</ResponseExample>
