> ## 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.

# Detach Users from Contract

> Removes one or more users from an existing contract

Removes one or more users from an existing contract. Validates that users are currently attached to the contract before detaching them. On success (`200`), the response body is the updated contract resource.

## Path Parameters

<ParamField path="id" type="string" required>
  External contract 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 detach from the contract
</ParamField>

## Known Errors

* `ContractNotFoundError` — No contract found with the specified external ID
* `UserNotFoundError` — One or more users not found with the specified external IDs
* `ValidationError` — Missing required fields or empty users array
* `NotAttachedError` — One or more users are not attached to this contract

<RequestExample>
  ```bash cURL theme={null}
  curl --location --request PUT 'https://integrations.projectcor.com/v2/integrations/contracts/SF-CONTRACT-12345/detach' \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "metadata": {
      "source": "SALESFORCE"
    },
    "users": [
      "OKTA-USER-67890"
    ]
  }'
  ```

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

  url = "https://integrations.projectcor.com/v2/integrations/contracts/SF-CONTRACT-12345/detach"

  payload = {
      "metadata": {
          "source": "SALESFORCE"
      },
      "users": [
          "OKTA-USER-67890"
      ]
  }

  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/contracts/SF-CONTRACT-12345/detach',
    {
      method: 'PUT',
      headers: {
        'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        metadata: {
          source: 'SALESFORCE'
        },
        users: [
          'OKTA-USER-67890'
        ]
      })
    }
  );

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

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": 23,
    "client_id": 58393,
    "company_id": 2336,
    "name": "Prueba contrato",
    "type": "fixed_price",
    "source": "SALESFORCE",
    "status": "active",
    "url": null,
    "start": "2026-01-01 00:00:00",
    "end": "2026-12-31 00:00:00",
    "frequency": null,
    "currency_id": 1,
    "created_at": "2026-05-08 13:58:38",
    "updated_at": "2026-05-08 13:58:38",
    "deleted_at": null,
    "url_name": null,
    "user_positions_header_id": null,
    "users": []
  }
  ```

  ```json 400 theme={null}
  {
    "error": "NotAttachedError",
    "message": "User 'OKTA-USER-67890' is not attached to this contract",
    "code": "ZC002"
  }
  ```
</ResponseExample>
