> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developer.crehana.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developer.crehana.com/_mcp/server.

# Create Time Off Request

POST https://www.crehana.com/api/v5/rest/org/{organization_slug}/timeoff/requests/
Content-Type: application/json

Creates a time off request — vacations, leave or a permission — for a user of the organization against one of its time off policies. The request follows the rules of the policy: when the policy needs approvals it is created as `IN_PROGRESS` and its approvers are notified; otherwise it is created as `APPROVED` and the time is discounted from the user's balance. The dates cannot overlap another active request of the user.

Reference: https://developer.crehana.com/api-reference/endpoints/time-off/create-timeoff-request

## Authentication

- `Api-Key` header (required) — API key of the organization. Always sent together with the `Secret-Access` header.

## Servers

- `https://www.crehana.com` (Production, default)
- `https://qa.creha.co` (QA)

## Request

### Path parameters

- `organization_slug` (string, required)

### Body (application/json)

This endpoint expects a CreateTimeoffRequestInput.

- `policy_id` (integer, required) — Id of the time off policy the request consumes: `id` in `GET /org/{organization_slug}/timeoff/policies/`. The person must have a balance in that policy unless the policy is unlimited.
- `start_date` (date, required) — First day of the request, `YYYY-MM-DD`.
- `end_date` (date, required) — Last day of the request, `YYYY-MM-DD`. Same as `start_date` for a single day; never before it.
- `value` (double, required) — Amount of time requested, in the unit of the policy (`quantification`: days or hours). For a full-day request on a policy counted in days the amount is recalculated from the dates, skipping holidays and non-working days. For a request by hours or a half day it is taken as sent.
- `user_id` (integer, optional) — Centralized id of the person the request is for: `user.user_id` in the time off requests listing, or `user.id` in `GET /org/{organization_slug}/users/user-organizations/`. Not the learning user id. Send either `user_id` or `email`, not both.
- `email` (string, optional) — Email of the person the request is for, as an alternative to `user_id`. It must match exactly (case-insensitive) the email of a user of the organization.
- `comment` (string, optional, default: ) — Free text that explains the request to its approvers.
- `allow_request_by_hour` (boolean, optional) — Send `true` to request hours of a single day on a policy counted in days; `value` is then a number of hours and `start_time` / `end_time` are required.
- `start_time` (string, optional) — Start time of a partial-day request, 24-hour `HH:MM` without time zone. Sent together with `end_time`, on a single day. Ignored on a full-day request.
- `end_time` (string, optional) — End time of a partial-day request, 24-hour `HH:MM` without time zone; after `start_time`.

## Response

### 201

Time off request created

- `success` (boolean, required) — True when the request was created.
- `message` (string, required) — Human readable result of the creation.
- `code` (string, required) — Result code of the operation, namespaced by section — not an HTTP status. The reason of a failed creation travels in the error payload instead.
- `datetime` (string, required) — Datetime of the API in ISO Format
- `data` (CreatedTimeoffRequest, required) — Identification and status of the created request.

## Errors

### 400 Bad Request Error

Unknown organization, or a request that breaks the rules of the policy (amount out of its limits, non-working days, time range that does not match the amount)

- `message` (string, required)
- `errors` (list of string, required)
- `datetime` (string, optional)

### 401 Unauthorized Error

Missing or invalid credentials

- `any`

### 403 Forbidden Error

The credentials do not belong to the organization

- `message` (string, required)
- `errors` (list of string, required)
- `datetime` (string, optional)

### 404 Not Found Error

The user or the policy does not exist in the organization

- `message` (string, required)
- `errors` (list of string, required)
- `datetime` (string, optional)

### 409 Conflict Error

The dates overlap another request of the user, or the balance of the user in the policy does not cover the request

- `message` (string, required)
- `errors` (list of string, required)
- `datetime` (string, optional)

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### CreatedTimeoffRequest

The time off request the call created.

- `request_id` (string, required) — Id of the created time off request. It is the `id` of the request in the listing and the `request_id` the deletion endpoint expects.
- `status` (enum, required) — `APPROVED` when the policy needs no approvals: the time is discounted from the balance right away. `IN_PROGRESS` when the request waits for its approvers.
  - Allowed values: `APPROVED`, `DENIED`, `IN_PROGRESS`

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### ValidationErrorLocItems

- string
- integer

## Examples

**Request**

```json
{
  "policy_id": 732,
  "start_date": "2026-12-14",
  "end_date": "2026-12-15",
  "value": 2
}
```

**Response**

```json
{
  "success": true,
  "message": "string",
  "code": "timeoff-002",
  "datetime": "string",
  "data": {
    "request_id": "842",
    "status": "IN_PROGRESS"
  }
}
```

**SDK Code**

```python
import requests

url = "https://www.crehana.com/api/v5/rest/org/organization_slug/timeoff/requests/"

payload = {
    "policy_id": 732,
    "start_date": "2026-12-14",
    "end_date": "2026-12-15",
    "value": 2
}
headers = {
    "Secret-Access": "Secret-Access",
    "Api-Key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://www.crehana.com/api/v5/rest/org/organization_slug/timeoff/requests/';
const options = {
  method: 'POST',
  headers: {
    'Secret-Access': 'Secret-Access',
    'Api-Key': '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"policy_id":732,"start_date":"2026-12-14","end_date":"2026-12-15","value":2}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://www.crehana.com/api/v5/rest/org/organization_slug/timeoff/requests/"

	payload := strings.NewReader("{\n  \"policy_id\": 732,\n  \"start_date\": \"2026-12-14\",\n  \"end_date\": \"2026-12-15\",\n  \"value\": 2\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Secret-Access", "Secret-Access")
	req.Header.Add("Api-Key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://www.crehana.com/api/v5/rest/org/organization_slug/timeoff/requests/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Secret-Access"] = 'Secret-Access'
request["Api-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"policy_id\": 732,\n  \"start_date\": \"2026-12-14\",\n  \"end_date\": \"2026-12-15\",\n  \"value\": 2\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://www.crehana.com/api/v5/rest/org/organization_slug/timeoff/requests/")
  .header("Secret-Access", "Secret-Access")
  .header("Api-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"policy_id\": 732,\n  \"start_date\": \"2026-12-14\",\n  \"end_date\": \"2026-12-15\",\n  \"value\": 2\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://www.crehana.com/api/v5/rest/org/organization_slug/timeoff/requests/', [
  'body' => '{
  "policy_id": 732,
  "start_date": "2026-12-14",
  "end_date": "2026-12-15",
  "value": 2
}',
  'headers' => [
    'Api-Key' => '<apiKey>',
    'Content-Type' => 'application/json',
    'Secret-Access' => 'Secret-Access',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://www.crehana.com/api/v5/rest/org/organization_slug/timeoff/requests/");
var request = new RestRequest(Method.POST);
request.AddHeader("Secret-Access", "Secret-Access");
request.AddHeader("Api-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"policy_id\": 732,\n  \"start_date\": \"2026-12-14\",\n  \"end_date\": \"2026-12-15\",\n  \"value\": 2\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Secret-Access": "Secret-Access",
  "Api-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "policy_id": 732,
  "start_date": "2026-12-14",
  "end_date": "2026-12-15",
  "value": 2
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://www.crehana.com/api/v5/rest/org/organization_slug/timeoff/requests/")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```