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

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

Updates an existing leave request in your COR instance using its external ID. The user and leave type must have been previously created through the integrations API.

## Path Parameters

<ParamField path="id" type="string" required>
  External leave request ID that was used when creating the leave request
</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="userId" type="string" required>
  External user ID. The user must have been previously created through the integrations API.
</ParamField>

<ParamField body="leaveTypeId" type="string" required>
  External leave type ID. The leave type must have been previously created through the integrations API.
</ParamField>

<ParamField body="start" type="string" required>
  Updated start date and time in ISO 8601 format (e.g., "2026-05-13T00:00:00-00:00")
</ParamField>

<ParamField body="end" type="string" required>
  Updated end date and time in ISO 8601 format (e.g., "2026-05-13T23:59:00-00:00")
</ParamField>

<ParamField body="allDay" type="boolean" required>
  Whether the leave is for the entire day. When true, the time portion is typically ignored.
</ParamField>

## Known Errors

* `ZC001` — Entity is not associated (leave request with the specified external ID not found)
* `LeaveNotFoundError` — No leave request found with the specified external ID for this source
* `ValidationError` — Missing required fields
* `UserNotFoundError` — The specified user does not exist in the integration mappings
* `LeaveTypeNotFoundError` — The specified leave type does not exist in the integration mappings
* `InvalidDateRangeError` — End date must be after or equal to start date

<RequestExample>
  ```bash cURL theme={null}
  curl --location --request PUT 'https://integrations.projectcor.com/v2/integrations/leaves/external-id-3' \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "userId": "external-user-id-3",
    "leaveTypeId": "external-type-3",
    "start": "2026-05-13T00:00:00-00:00",
    "end": "2026-05-13T23:59:00-00:00",
    "allDay": true,
    "metadata": {
      "source": "GLOBANT"
    }
  }'
  ```

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

  url = "https://integrations.projectcor.com/v2/integrations/leaves/external-id-3"

  payload = {
      "userId": "external-user-id-3",
      "leaveTypeId": "external-type-3",
      "start": "2026-05-13T00:00:00-00:00",
      "end": "2026-05-13T23:59:00-00:00",
      "allDay": True,
      "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/leaves/external-id-3',
    {
      method: 'PUT',
      headers: {
        'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        userId: 'external-user-id-3',
        leaveTypeId: 'external-type-3',
        start: '2026-05-13T00:00:00-00:00',
        end: '2026-05-13T23:59:00-00:00',
        allDay: true,
        metadata: {
          source: 'GLOBANT'
        }
      })
    }
  );

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

<ResponseExample>
  ```json 200 theme={null}
  {
    "statusCode": 200,
    "status": "success",
    "data": {
      "id": 12345,
      "userId": 67890,
      "leaveTypeId": 54321,
      "start": "2026-05-13T00:00:00-00:00",
      "end": "2026-05-13T23:59:00-00:00",
      "allDay": true,
      "company_id": 2336,
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-15T11:45:00Z",
      "status": "pending"
    }
  }
  ```

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

  ```json 404 theme={null}
  {
    "error": "LeaveNotFoundError",
    "message": "Leave request with external ID 'external-id-3' not found",
    "code": "ZC004"
  }
  ```

  ```json 404 theme={null}
  {
    "error": "UserNotFoundError",
    "message": "User with external ID 'external-user-id-3' not found",
    "code": "ZC004"
  }
  ```

  ```json 400 theme={null}
  {
    "status": 400,
    "name": "COR_CUSTOM_ERROR",
    "code": "ZC002",
    "message": "End date must be after start date"
  }
  ```
</ResponseExample>
