---
title: "Leave | Docs | HR by R&D Copilot"
description: "Request leave, read a request with its working days counted and the balance it leaves, decide it, cancel it, and read a balance."
canonical: "https://hr.rdcopilot.com/docs/api-reference/leave/"
language: en
updated: 2026-11-22
---

# Leave

Request leave, read a request with its working days counted and the balance it leaves, decide it, cancel it, and read a balance.

## List leave requests

GET `/hr/v1/leave-requests`

Returns leave requests in pages, the one that starts first first.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `employeeId` | query | `string (uuid)` | Nooptional | Only the requests of this person. |
| `status` | query | `string` | Nooptional | Only requests in this status. One of `pending`, `approved`, `rejected`, `cancelled` |
| `from` | query | `string (date)` | Nooptional | Only requests that end on or after this day. |
| `to` | query | `string (date)` | Nooptional | Only requests that start on or before this day. |
| `limit` | query | `integer` | Nooptional | Records per page. Default `100` Range `1` – `500` |
| `cursor` | query | `string` | Nooptional | The `nextCursor` of the previous page. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `200` | A page of records. | `LeaveRequestPage` |
| `400` | The request cannot be read or breaks the contract: the JSON is malformed, a field is missing or unknown, or a type is wrong. `fields` names each one. | `Error` |
| `401` | The token is missing, not valid or has ended. | `Error` |
| `403` | The token does not give access to this data, or to this account. | `Error` |
| `429` | The request was refused. The `code` is `rate_limited`. | `Error` |
| `503` | The request was refused. The `code` is `unavailable`. | `Error` |

### Request

curl

```bash
curl "$RDC_BASE_URL/hr/v1/leave-requests?limit=20" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/hr/v1/leave-requests?limit=20`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
  },
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'GET',
    f'{os.environ["RDC_BASE_URL"]}/hr/v1/leave-requests?limit=20',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/hr/v1/leave-requests?limit=20');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
    ],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/hr/v1/leave-requests?limit=20");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `200`

JSON

```json
{
  "items": [
    {
      "id": "bd9ccb68-cdef-4ec9-b852-dfa82203a948",
      "number": "LR-2026-1044",
      "employeeId": "5f6223ec-cd16-4dcc-bf30-2409b9672912",
      "kind": "annual",
      "from": "2026-11-30",
      "to": "2026-12-04",
      "days": 3,
      "balanceAfter": 10,
      "approverId": "21bd8239-2794-4320-adba-9128b6a6219b",
      "status": "pending",
      "note": null,
      "reason": null,
      "teamAway": {
        "date": "2026-12-02",
        "employeeIds": [
          "11729ba4-78ca-4dfb-9165-03367b42d67a",
          "45b8db4f-180e-40cf-99d6-2864b28b2eab"
        ]
      },
      "revision": 1
    },
    {
      "id": "ca959ba4-323a-43c6-b8fe-1fd6a3888fbb",
      "number": "LR-2026-1047",
      "employeeId": "46419e0c-a16f-4e44-bed0-0b9700635fd6",
      "kind": "annual",
      "from": "2026-12-21",
      "to": "2026-12-24",
      "days": 4,
      "balanceAfter": 8,
      "approverId": "e50d7ef0-7fcc-4201-b93b-817b578ba173",
      "status": "pending",
      "note": null,
      "reason": null,
      "teamAway": null,
      "revision": 1
    }
  ],
  "nextCursor": null
}
```

## Request leave

POST `/hr/v1/leave-requests`

Makes a request for a kind of leave and a range of days. The working days are counted from the calendar, and an annual leave is refused when it counts more days than the balance. The request is `pending` and has the approver of the manager of the person. It changes no balance until it is approved.

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `employeeId` | `string (uuid)` | Yesrequired | The person who asks. |
| `kind` | `string` | Yesrequired | The kind of leave. One of `annual`, `medical`, `unpaid`, `special` |
| `from` | `string (date)` | Yesrequired | The first day. Today or later, except for `medical`. |
| `to` | `string (date)` | Yesrequired | The last day, on or after `from`. |
| `note` | `string` | Nooptional | A note for the approver. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result. | `OperationResult` |
| `400` | The request cannot be read or breaks the contract: the JSON is malformed, a field is missing or unknown, or a type is wrong. `fields` names each one. | `Error` |
| `401` | The token is missing, not valid or has ended. | `Error` |
| `403` | The token does not give access to this data, or to this account. | `Error` |
| `404` | The request was refused. The `code` is `employee_not_found`. | `Error` |
| `409` | The request was refused. The `code` is `operation_reused`. | `Error` |
| `422` | The request was refused. The `code` is `kind_not_valid`, `date_not_valid`, `note_not_valid`, `date_in_the_past`, `outside_calendar`, `before_start`, `after_last_day`, `no_working_days`, `leave_overlaps` or `over_balance`. | `Error` |
| `429` | The request was refused. The `code` is `rate_limited`. | `Error` |
| `503` | The request was refused. The `code` is `unavailable`. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/hr/v1/leave-requests" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "employeeId": "1ae6d1c6-00ec-4dfc-82b8-c19a68bc30cd",
  "kind": "annual",
  "from": "2026-12-14",
  "to": "2026-12-16",
  "note": "A family event.",
  "operationId": "ad35c814-b5ca-467a-9381-c08f55aa20f7"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/hr/v1/leave-requests`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "employeeId": "1ae6d1c6-00ec-4dfc-82b8-c19a68bc30cd",
    "kind": "annual",
    "from": "2026-12-14",
    "to": "2026-12-16",
    "note": "A family event.",
    "operationId": "ad35c814-b5ca-467a-9381-c08f55aa20f7"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/hr/v1/leave-requests',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'employeeId': '1ae6d1c6-00ec-4dfc-82b8-c19a68bc30cd',
        'kind': 'annual',
        'from': '2026-12-14',
        'to': '2026-12-16',
        'note': 'A family event.',
        'operationId': 'ad35c814-b5ca-467a-9381-c08f55aa20f7',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "employeeId": "1ae6d1c6-00ec-4dfc-82b8-c19a68bc30cd",
  "kind": "annual",
  "from": "2026-12-14",
  "to": "2026-12-16",
  "note": "A family event.",
  "operationId": "ad35c814-b5ca-467a-9381-c08f55aa20f7"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/hr/v1/leave-requests');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/hr/v1/leave-requests");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "employeeId": "1ae6d1c6-00ec-4dfc-82b8-c19a68bc30cd",
  "kind": "annual",
  "from": "2026-12-14",
  "to": "2026-12-16",
  "note": "A family event.",
  "operationId": "ad35c814-b5ca-467a-9381-c08f55aa20f7"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "ad35c814-b5ca-467a-9381-c08f55aa20f7",
  "status": "accepted",
  "aggregateRevision": 1
}
```

## Get a leave request

GET `/hr/v1/leave-requests/{requestId}`

Returns the request with its working days counted, the balance it leaves, its approver and, while it is pending, the teammates who are away on a day it covers when there are two or more.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `requestId` | path | `string (uuid)` | Yesrequired | The leave request. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `200` | The record at its current revision. | `LeaveRequest` |
| `401` | The token is missing, not valid or has ended. | `Error` |
| `403` | The token does not give access to this data, or to this account. | `Error` |
| `404` | The request was refused. The `code` is `leave_request_not_found`. | `Error` |
| `429` | The request was refused. The `code` is `rate_limited`. | `Error` |
| `503` | The request was refused. The `code` is `unavailable`. | `Error` |

### Request

curl

```bash
curl "$RDC_BASE_URL/hr/v1/leave-requests/bd9ccb68-cdef-4ec9-b852-dfa82203a948" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/hr/v1/leave-requests/bd9ccb68-cdef-4ec9-b852-dfa82203a948`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
  },
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'GET',
    f'{os.environ["RDC_BASE_URL"]}/hr/v1/leave-requests/bd9ccb68-cdef-4ec9-b852-dfa82203a948',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/hr/v1/leave-requests/bd9ccb68-cdef-4ec9-b852-dfa82203a948');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
    ],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/hr/v1/leave-requests/bd9ccb68-cdef-4ec9-b852-dfa82203a948");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `200`

JSON

```json
{
  "id": "bd9ccb68-cdef-4ec9-b852-dfa82203a948",
  "number": "LR-2026-1044",
  "employeeId": "5f6223ec-cd16-4dcc-bf30-2409b9672912",
  "kind": "annual",
  "from": "2026-11-30",
  "to": "2026-12-04",
  "days": 3,
  "balanceAfter": 10,
  "approverId": "21bd8239-2794-4320-adba-9128b6a6219b",
  "status": "pending",
  "note": null,
  "reason": null,
  "teamAway": {
    "date": "2026-12-02",
    "employeeIds": [
      "11729ba4-78ca-4dfb-9165-03367b42d67a",
      "45b8db4f-180e-40cf-99d6-2864b28b2eab"
    ]
  },
  "revision": 1
}
```

## Approve a leave request

POST `/hr/v1/leave-requests/{requestId}/approve`

Approves a pending request. The person named in `actorId` is the approver of the request or the HR lead, and never the person who made it. The balance is checked again.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `requestId` | path | `string (uuid)` | Yesrequired | The leave request. |

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `expectedRevision` | `integer` | Yesrequired | The revision of the leave request you read. |
| `actorId` | `string (uuid)` | Yesrequired | The person on whose behalf the change is made. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result. | `OperationResult` |
| `400` | The request cannot be read or breaks the contract: the JSON is malformed, a field is missing or unknown, or a type is wrong. `fields` names each one. | `Error` |
| `401` | The token is missing, not valid or has ended. | `Error` |
| `403` | The token does not give access to this data, or to this account. | `Error` |
| `404` | The request was refused. The `code` is `leave_request_not_found` or `employee_not_found`. | `Error` |
| `409` | The request was refused. The `code` is `revision_conflict` or `operation_reused`. | `Error` |
| `422` | The request was refused. The `code` is `not_pending`, `own_request`, `not_approver` or `over_balance`. | `Error` |
| `429` | The request was refused. The `code` is `rate_limited`. | `Error` |
| `503` | The request was refused. The `code` is `unavailable`. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/hr/v1/leave-requests/bd9ccb68-cdef-4ec9-b852-dfa82203a948/approve" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "expectedRevision": 1,
  "actorId": "21bd8239-2794-4320-adba-9128b6a6219b",
  "operationId": "b45282b0-0827-4191-ba70-a0d39dc182c6"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/hr/v1/leave-requests/bd9ccb68-cdef-4ec9-b852-dfa82203a948/approve`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "expectedRevision": 1,
    "actorId": "21bd8239-2794-4320-adba-9128b6a6219b",
    "operationId": "b45282b0-0827-4191-ba70-a0d39dc182c6"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/hr/v1/leave-requests/bd9ccb68-cdef-4ec9-b852-dfa82203a948/approve',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'expectedRevision': 1,
        'actorId': '21bd8239-2794-4320-adba-9128b6a6219b',
        'operationId': 'b45282b0-0827-4191-ba70-a0d39dc182c6',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "expectedRevision": 1,
  "actorId": "21bd8239-2794-4320-adba-9128b6a6219b",
  "operationId": "b45282b0-0827-4191-ba70-a0d39dc182c6"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/hr/v1/leave-requests/bd9ccb68-cdef-4ec9-b852-dfa82203a948/approve');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/hr/v1/leave-requests/bd9ccb68-cdef-4ec9-b852-dfa82203a948/approve");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "expectedRevision": 1,
  "actorId": "21bd8239-2794-4320-adba-9128b6a6219b",
  "operationId": "b45282b0-0827-4191-ba70-a0d39dc182c6"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "b45282b0-0827-4191-ba70-a0d39dc182c6",
  "status": "accepted",
  "aggregateRevision": 2
}
```

## Reject a leave request

POST `/hr/v1/leave-requests/{requestId}/reject`

Rejects a pending request. A reason is required and stays with the request.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `requestId` | path | `string (uuid)` | Yesrequired | The leave request. |

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `expectedRevision` | `integer` | Yesrequired | The revision of the leave request you read. |
| `actorId` | `string (uuid)` | Yesrequired | The person on whose behalf the change is made. |
| `reason` | `string` | Yesrequired | Why the request is rejected. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result. | `OperationResult` |
| `400` | The request cannot be read or breaks the contract: the JSON is malformed, a field is missing or unknown, or a type is wrong. `fields` names each one. | `Error` |
| `401` | The token is missing, not valid or has ended. | `Error` |
| `403` | The token does not give access to this data, or to this account. | `Error` |
| `404` | The request was refused. The `code` is `leave_request_not_found` or `employee_not_found`. | `Error` |
| `409` | The request was refused. The `code` is `revision_conflict` or `operation_reused`. | `Error` |
| `422` | The request was refused. The `code` is `not_pending`, `own_request`, `not_approver` or `reason_required`. | `Error` |
| `429` | The request was refused. The `code` is `rate_limited`. | `Error` |
| `503` | The request was refused. The `code` is `unavailable`. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/hr/v1/leave-requests/bd9ccb68-cdef-4ec9-b852-dfa82203a948/reject" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "expectedRevision": 1,
  "actorId": "21bd8239-2794-4320-adba-9128b6a6219b",
  "reason": "Two of the team are away that week.",
  "operationId": "b1be73c6-13cc-46f4-b06e-0d179d5d758f"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/hr/v1/leave-requests/bd9ccb68-cdef-4ec9-b852-dfa82203a948/reject`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "expectedRevision": 1,
    "actorId": "21bd8239-2794-4320-adba-9128b6a6219b",
    "reason": "Two of the team are away that week.",
    "operationId": "b1be73c6-13cc-46f4-b06e-0d179d5d758f"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/hr/v1/leave-requests/bd9ccb68-cdef-4ec9-b852-dfa82203a948/reject',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'expectedRevision': 1,
        'actorId': '21bd8239-2794-4320-adba-9128b6a6219b',
        'reason': 'Two of the team are away that week.',
        'operationId': 'b1be73c6-13cc-46f4-b06e-0d179d5d758f',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "expectedRevision": 1,
  "actorId": "21bd8239-2794-4320-adba-9128b6a6219b",
  "reason": "Two of the team are away that week.",
  "operationId": "b1be73c6-13cc-46f4-b06e-0d179d5d758f"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/hr/v1/leave-requests/bd9ccb68-cdef-4ec9-b852-dfa82203a948/reject');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/hr/v1/leave-requests/bd9ccb68-cdef-4ec9-b852-dfa82203a948/reject");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "expectedRevision": 1,
  "actorId": "21bd8239-2794-4320-adba-9128b6a6219b",
  "reason": "Two of the team are away that week.",
  "operationId": "b1be73c6-13cc-46f4-b06e-0d179d5d758f"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "b1be73c6-13cc-46f4-b06e-0d179d5d758f",
  "status": "accepted",
  "aggregateRevision": 2
}
```

## Cancel a leave request

POST `/hr/v1/leave-requests/{requestId}/cancel`

Cancels a pending request, or an approved one before its first day. The days return to the balance.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `requestId` | path | `string (uuid)` | Yesrequired | The leave request. |

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `expectedRevision` | `integer` | Yesrequired | The revision of the leave request you read. |
| `actorId` | `string (uuid)` | Yesrequired | The person on whose behalf the change is made. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result. | `OperationResult` |
| `400` | The request cannot be read or breaks the contract: the JSON is malformed, a field is missing or unknown, or a type is wrong. `fields` names each one. | `Error` |
| `401` | The token is missing, not valid or has ended. | `Error` |
| `403` | The token does not give access to this data, or to this account. | `Error` |
| `404` | The request was refused. The `code` is `leave_request_not_found` or `employee_not_found`. | `Error` |
| `409` | The request was refused. The `code` is `revision_conflict` or `operation_reused`. | `Error` |
| `422` | The request was refused. The `code` is `request_closed`, `not_allowed` or `leave_started`. | `Error` |
| `429` | The request was refused. The `code` is `rate_limited`. | `Error` |
| `503` | The request was refused. The `code` is `unavailable`. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/hr/v1/leave-requests/67e16d2f-dc93-4022-bda9-883f8c4a729b/cancel" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "expectedRevision": 2,
  "actorId": "11729ba4-78ca-4dfb-9165-03367b42d67a",
  "operationId": "be2a8c7a-3f1d-457e-b6e7-4a4b8f7d743f"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/hr/v1/leave-requests/67e16d2f-dc93-4022-bda9-883f8c4a729b/cancel`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "expectedRevision": 2,
    "actorId": "11729ba4-78ca-4dfb-9165-03367b42d67a",
    "operationId": "be2a8c7a-3f1d-457e-b6e7-4a4b8f7d743f"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/hr/v1/leave-requests/67e16d2f-dc93-4022-bda9-883f8c4a729b/cancel',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'expectedRevision': 2,
        'actorId': '11729ba4-78ca-4dfb-9165-03367b42d67a',
        'operationId': 'be2a8c7a-3f1d-457e-b6e7-4a4b8f7d743f',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "expectedRevision": 2,
  "actorId": "11729ba4-78ca-4dfb-9165-03367b42d67a",
  "operationId": "be2a8c7a-3f1d-457e-b6e7-4a4b8f7d743f"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/hr/v1/leave-requests/67e16d2f-dc93-4022-bda9-883f8c4a729b/cancel');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/hr/v1/leave-requests/67e16d2f-dc93-4022-bda9-883f8c4a729b/cancel");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "expectedRevision": 2,
  "actorId": "11729ba4-78ca-4dfb-9165-03367b42d67a",
  "operationId": "be2a8c7a-3f1d-457e-b6e7-4a4b8f7d743f"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "be2a8c7a-3f1d-457e-b6e7-4a4b8f7d743f",
  "status": "accepted",
  "aggregateRevision": 3
}
```

## Get the leave balance

GET `/hr/v1/employees/{employeeId}/leave-balance`

Returns the annual leave of the person in days: the entitlement, what was taken, what is pending and what is left. Only approved annual leave is taken; a pending request takes nothing until it is approved.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `employeeId` | path | `string (uuid)` | Yesrequired | The person. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `200` | The record at its current revision. | `LeaveBalance` |
| `401` | The token is missing, not valid or has ended. | `Error` |
| `403` | The token does not give access to this data, or to this account. | `Error` |
| `404` | The request was refused. The `code` is `employee_not_found`. | `Error` |
| `429` | The request was refused. The `code` is `rate_limited`. | `Error` |
| `503` | The request was refused. The `code` is `unavailable`. | `Error` |

### Request

curl

```bash
curl "$RDC_BASE_URL/hr/v1/employees/11729ba4-78ca-4dfb-9165-03367b42d67a/leave-balance" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/hr/v1/employees/11729ba4-78ca-4dfb-9165-03367b42d67a/leave-balance`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
  },
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'GET',
    f'{os.environ["RDC_BASE_URL"]}/hr/v1/employees/11729ba4-78ca-4dfb-9165-03367b42d67a/leave-balance',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/hr/v1/employees/11729ba4-78ca-4dfb-9165-03367b42d67a/leave-balance');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
    ],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/hr/v1/employees/11729ba4-78ca-4dfb-9165-03367b42d67a/leave-balance");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `200`

JSON

```json
{
  "employeeId": "11729ba4-78ca-4dfb-9165-03367b42d67a",
  "year": 2026,
  "entitlement": 21,
  "taken": 13,
  "pending": 0,
  "balance": 8
}
```
