> ## 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 Workspaces to User

> Attaches one or more workspaces to a user in COR

Attaches multiple workspaces to a specific user in your COR instance. This endpoint allows batch assignment of workspace access to a user.

<Note>
  **Prerequisites**: Workspaces must be created first using the [Create Workspace](/api-reference/integrations/workspaces/create) endpoint before they can be attached to users.
</Note>

## Response

The endpoint returns the complete user object including all attached workspaces. Each workspace includes a `pivot` table with the relationship details (`workspace_id`, `user_id`, `percentage`).

## Request Body Requirements

<ParamField body="metadata" type="object" required>
  <Expandable title="properties">
    <ParamField body="source" type="string" required>
      Integration source identifier. Must be one of: `JIRA`, `SALESFORCE`, `ADVERTMIND`, `QUICKBOOKS`, `ZAPIER`, `OKTA`, `MICROSOFT_DYNAMICS`, `GITHUB`, `MICROSOFT_TEAMS`, `VBS`, `SAP`, `GLOBANT`
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="workspaces" type="array" required>
  Array of workspace assignments with percentage allocation

  <Expandable title="items">
    <ParamField body="workspaceId" type="string" required>
      External workspace ID from your source system
    </ParamField>

    <ParamField body="percentage" type="number" required>
      Percentage allocation of user's time to this workspace (0-100)
    </ParamField>
  </Expandable>
</ParamField>

## Path Parameters

<ParamField path="userId" type="string" required>
  External user ID from your source system
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl --location --request PUT 'https://integrations.projectcor.com/v2/integrations/users/OKTA-USER-12345/attach' \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "workspaces": [
      {
        "workspaceId": "Workspaces-example-5",
        "percentage": 10
      },
      {
        "workspaceId": "Workspaces-example-6",
        "percentage": 20
      }
    ],
    "metadata": {
      "source": "MICROSOFT_DYNAMICS"
    }
  }'
  ```

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

  url = "https://integrations.projectcor.com/v2/integrations/users/OKTA-USER-12345/attach"

  payload = {
      "workspaces": [
          {
              "workspaceId": "Workspaces-example-5",
              "percentage": 10
          },
          {
              "workspaceId": "Workspaces-example-6",
              "percentage": 20
          }
      ],
      "metadata": {
          "source": "MICROSOFT_DYNAMICS"
      }
  }

  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/users/OKTA-USER-12345/attach',
    {
      method: 'PUT',
      headers: {
        'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        workspaces: [
          {
            workspaceId: 'Workspaces-example-5',
            percentage: 10
          },
          {
            workspaceId: 'Workspaces-example-6',
            percentage: 20
          }
        ],
        metadata: {
          source: 'MICROSOFT_DYNAMICS'
        }
      })
    }
  );

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

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": 8545,
    "name": "John Doe",
    "email": "john.doe@example.com",
    "workspaces": [
      {
        "id": 1,
        "name": "Workspaces test 5",
        "active": true,
        "metadata": {},
        "json_integrations": {
          "integration_id": 16,
          "is_active": true,
          "source": "MICROSOFT_DYNAMICS",
          "destination": null,
          "status": "NOT_SEND",
          "origin_external_id": "Workspaces-example-5",
          "destination_external_id": null
        },
        "created_at": "2026-01-15 22:42:15",
        "updated_at": "2026-01-15 22:42:15",
        "pivot": {
          "workspace_id": 1,
          "user_id": 8545,
          "percentage": 10
        }
      },
      {
        "id": 2,
        "name": "Workspaces test 6",
        "active": true,
        "metadata": {},
        "json_integrations": {
          "integration_id": 16,
          "is_active": true,
          "source": "MICROSOFT_DYNAMICS",
          "destination": null,
          "status": "NOT_SEND",
          "origin_external_id": "Workspaces-example-6",
          "destination_external_id": null
        },
        "created_at": "2026-01-15 22:42:15",
        "updated_at": "2026-01-15 22:42:15",
        "pivot": {
          "workspace_id": 2,
          "user_id": 8545,
          "percentage": 20
        }
      }
    ]
  }
  ```

  ```json 400 theme={null}
  {
      "status": "ERROR",
      "code": "ZC001",
      "message": "Source is required in metadata"
  }
  ```

  ```json 401 theme={null}
  {
    "status": "ERROR",
    "code": "AT004",
    "message": "E_INVALID_JWT_TOKEN: jwt must be provided"
  }
  ```

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