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

# Update Contract

> Updates an existing contract in your COR instance using its external ID

Updates an existing contract in your COR instance using its external ID. Performs the same validations as creation, including date validation in `YYYY-MM-DD` format, and updates only the provided fields.

The currency ISO sent in the request must have a previously configured currency exchange in COR. If no exchange rate exists from the contract currency to the company base currency, contract update is rejected with `status: 400`, `name: CORCustomError`, and `code: CTR006`.

## Path Parameters

<ParamField path="id" type="string" required>
  External contract ID that was used when creating the contract
</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="name" type="string">
  Updated contract name
</ParamField>

<ParamField body="type" type="string">
  Updated contract type
</ParamField>

<ParamField body="status" type="string">
  Updated contract status
</ParamField>

<ParamField body="start_date" type="string">
  Updated start date in `YYYY-MM-DD` format
</ParamField>

<ParamField body="end_date" type="string">
  Updated end date in `YYYY-MM-DD` format
</ParamField>

<ParamField body="value" type="number">
  Updated contract value
</ParamField>

<ParamField body="description" type="string">
  Updated description
</ParamField>

## Known Errors

* `ZC001` — Entity is not associated (contract with the specified external ID not found)
* `ContractNotFoundError` — No contract found with the specified external ID
* `ValidationError` — Missing required `metadata.source` field
* `ValidationError` — `Invalid start date format: <value>` when `start_date` is not a valid `YYYY-MM-DD` date
* `ValidationError` — `Invalid end date format: <value>` when `end_date` is not a valid `YYYY-MM-DD` date
* `CTR006` (`CORCustomError`, `400`) — `Cannot save contract. Exchange rate not found for ${currency} to ${baseCurrency}. Please sync exchange rates first.`

<RequestExample>
  ```bash cURL theme={null}
  curl --location --request PUT 'https://integrations.projectcor.com/v2/integrations/contracts/SF-CONTRACT-12345' \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "metadata": {
      "source": "SALESFORCE"
    },
    "status": "completed",
    "end_date": "2025-06-30",
    "value": 60000
  }'
  ```

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

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

  payload = {
      "metadata": {
          "source": "SALESFORCE"
      },
      "status": "completed",
      "end_date": "2025-06-30",
      "value": 60000
  }

  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',
    {
      method: 'PUT',
      headers: {
        'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        metadata: {
          source: 'SALESFORCE'
        },
        status: 'completed',
        end_date: '2025-06-30',
        value: 60000
      })
    }
  );

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

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": 30001,
    "name": "Annual Service Agreement",
    "client_id": 25855,
    "type": "retainer",
    "status": "completed",
    "start_date": "2025-01-01",
    "end_date": "2025-06-30",
    "value": 60000,
    "company_id": 1234,
    "created_at": "2025-01-10T14:30:00Z",
    "updated_at": "2025-01-15T10:00:00Z"
  }
  ```

  ```json 400 theme={null}
  {
    "status": 400,
    "name": "CORCustomError",
    "code": "CTR006",
    "message": "Cannot save contract. Exchange rate not found for USD to ARS. Please sync exchange rates first."
  }
  ```

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