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

# Attach Users to Team

> Associates one or more users with an existing team

Associates one or more users with an existing team. This operation validates that all provided users exist and are already mapped in COR before attaching them to the team.

## Path Parameters

<ParamField path="id" type="string" required>
  External team ID
</ParamField>

## Request Body Requirements

<ParamField body="metadata" type="object" required>
  <Expandable title="properties">
    <ParamField body="source" type="string" required>
      Integration source identifier
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="users" type="array" required>
  Array of external user IDs to attach to the team
</ParamField>

## Known Errors

* `ZC001` — Entity is not associated (team with the specified external ID not found) or missing associations for users
* `ValidationError` — Missing required fields or empty users array

### Per-User Errors

When some users fail validation, the response still returns `200` but includes an `errors` array alongside the successfully attached `users`. Each error object contains:

| Field     | Type    | Description                |
| --------- | ------- | -------------------------- |
| `user_id` | integer | Internal COR user ID       |
| `name`    | string  | Error name                 |
| `code`    | string  | Error code                 |
| `message` | string  | Human-readable description |

| Code    | Name                 | Description                                                |
| ------- | -------------------- | ---------------------------------------------------------- |
| `UT011` | `ALREADY_ASSIGNED`   | User is already assigned to this team                      |
| `UT012` | `NOT_IN_WORKSPACE`   | User does not belong to the team's workspace               |
| `UT013` | `WORKSPACE_CONFLICT` | User already belongs to another team in the same workspace |

<RequestExample>
  ```bash cURL theme={null}
  curl --location 'https://integrations.projectcor.com/v2/integrations/teams/{{external_team_id}}/attach' \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "users": ["{{external_user_id}}"],
    "metadata": {
      "source": "GLOBANT"
    }
  }'
  ```

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

  url = "https://integrations.projectcor.com/v2/integrations/teams/{{external_team_id}}/attach"

  payload = {
      "users": ["{{external_user_id}}"],
      "metadata": {
          "source": "GLOBANT"
      }
  }

  headers = {
      "Authorization": "Bearer YOUR_ACCESS_TOKEN",
      "Content-Type": "application/json"
  }

  response = requests.put(url, json=payload, headers=headers)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://integrations.projectcor.com/v2/integrations/teams/{{external_team_id}}/attach',
    {
      method: 'PUT',
      headers: {
        'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        users: ['{{external_user_id}}'],
        metadata: {
          source: 'GLOBANT'
        }
      })
    }
  );

  const data = await response.json();
  console.log(data);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 All users attached theme={null}
  {
    "users": [
      {
        "team_id": 4241,
        "user_id": 48878,
        "created_at": "2026-01-08 19:20:47",
        "updated_at": "2026-01-08 19:20:47",
        "id": 178148,
        "__meta__": {
          "company_id": 2336,
          "user": {
            "id": 48878,
            "first_name": "JOTA",
            "last_name": "Olaechea",
            "email": "gracie.mccullough@yahoo.com",
            "company_id": 2336
          }
        }
      }
    ],
    "errors": []
  }
  ```

  ```json 200 Partial success theme={null}
  {
    "users": [
      {
        "team_id": 4241,
        "user_id": 48878,
        "created_at": "2026-01-08 19:20:47",
        "updated_at": "2026-01-08 19:20:47",
        "id": 178148,
        "__meta__": {
          "company_id": 2336,
          "user": {
            "id": 48878,
            "first_name": "JOTA",
            "last_name": "Olaechea",
            "email": "gracie.mccullough@yahoo.com",
            "company_id": 2336
          }
        }
      }
    ],
    "errors": [
      {
        "user_id": 48914,
        "name": "NOT_IN_WORKSPACE",
        "code": "UT012",
        "message": "User does not belong to the team's workspace"
      }
    ]
  }
  ```

  ```json 404 theme={null}
  {
    "status": "ERROR",
    "code": "ZC001",
    "message": "Entity is not associated"
  }
  ```

  ```json 400 theme={null}
  {
    "status": "ERROR",
    "code": "ZC001",
    "message": "Missing associations for users: external_user_1123323245433adasd3353342334431"
  }
  ```
</ResponseExample>
