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

# Create Leave

> Creates a new leave request in your COR instance with external ID mapping

Creates a new leave request in your COR instance through the integrations service. The user and leave type must have been previously created through the integrations API.

## 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="id" type="string" required>
  External leave request ID from your source system
</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>
  Start date and time in ISO 8601 format (e.g., "2026-05-11T00:00:00-00:00")
</ParamField>

<ParamField body="end" type="string" required>
  End date and time in ISO 8601 format (e.g., "2026-05-11T23: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

* `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
* `DuplicateExternalIdError` — A leave request with this external ID already exists for this source

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

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

  url = "https://integrations.projectcor.com/v2/integrations/leaves"

  payload = {
      "metadata": {
          "source": "GLOBANT"
      },
      "id": "external-id-3",
      "userId": "external-user-id-3",
      "leaveTypeId": "external-type-3",
      "start": "2026-05-11T00:00:00-00:00",
      "end": "2026-05-11T23:59:00-00:00",
      "allDay": True
  }

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

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

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://integrations.projectcor.com/v2/integrations/leaves',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        metadata: {
          source: 'GLOBANT'
        },
        id: 'external-id-3',
        userId: 'external-user-id-3',
        leaveTypeId: 'external-type-3',
        start: '2026-05-11T00:00:00-00:00',
        end: '2026-05-11T23:59:00-00:00',
        allDay: true
      })
    }
  );

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

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

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

  ```json 404 theme={null}
  {
    "error": "LeaveTypeNotFoundError",
    "message": "Leave type with external ID 'external-type-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>
