> ## Client identification
>
> Requests to this API should include a `Client-Platform` header alongside
> `Authorization`, identifying the application, tool, or model making the
> request. This is used for integration support and analytics.
>
> Use your model or tool name, for example `claude-code` or `chatgpt`.
>
> Example:
>
> ```bash
> curl https://api.salaryboxapp.com/... \
>   -H "Authorization: Api-Key <api-key>" \
>   -H "Client-Platform: claude-code"
> ```

# Apply Staff Leave

POST https://api.salaryboxapp.com/v2/customer/v1/leave/request
Content-Type: application/json

Raises a leave request for a staff member on their behalf. Shared rules: see [Writing data](/conventions#writing-data).

- The request is not approved by this call. It waits for a decision in the SalaryBox app or the approval flow, and the response `status` is `pending`. In the rare case an approval flow has nobody at any level to act, it is approved straight away and `status` is `approved`.
- A pending request appears in `GET /requests/leave`.
- `leave_type` is the exact (case-sensitive) leave type name from `GET /leave/balance`. System leave types are refused.
- `to_date` must be on or after `from_date`, and the request can cover at most 60 days, counting both ends.
- `is_half_day` needs `from_date` and `to_date` to be the same day.
- A paid leave type needs enough balance (a half day counts 0.5, otherwise every calendar day in the range counts). If the balance is too low the request is refused; raise it as an unpaid leave type instead. Unpaid leave types skip this check.
- Dates before the staff member's joining date or in a finalised payroll month are refused.
- Admins and approvers get the usual notifications and email, and the staff member sees the request in their feed, as if they had applied.
- A request overlapping a pending or approved one for the same staff member is refused with `400` on `from_date`, so repeating is harmless.

API keys need no extra permission.


Reference: https://docs.salarybox.in/api-reference/leave/request-create

## Authentication

- `Authorization` header (required) (prefixed with ` Api-Key   `) — Format: "Api-Key \{api-key}"

## Request

### Body (application/json)

This endpoint expects a LeaveRequestCreateRequest.

- `salarybox_id` (string, required) — SalaryBox ID of an active staff member.
- `leave_type` (string, required) — Exact (case-sensitive) leave type name from `GET /leave/balance`. System leave types are refused.
- `from_date` (string, required) — First day of leave, `YYYY-MM-DD`.
- `to_date` (string, required) — Last day of leave, `YYYY-MM-DD`. On or after `from_date`, and at most 60 days in the request, counting both ends.
- `is_half_day` (boolean, optional, default: false) — Half-day leave. `true` needs `from_date` and `to_date` to be the same day.
- `reason` (string, optional) — Reason for the leave. Outer spaces are trimmed.

## Response

### 201

The leave request was raised.

- `message` (string, optional)
- `status` (boolean, optional)
- `data` (LeaveRequestCreateResponseData, optional)

## Errors

### 400 Bad Request Error

Validation failed, an unknown, ambiguous or system leave type name, not enough paid leave balance, an overlapping request, a date that is not allowed, or an inactive staff member.

- `message` (string, required)
- `status` (boolean, required)
- `errors` (map from string to any, optional, nullable)

### 403 Forbidden Error

The key owner lost access.

- `message` (string, required)
- `status` (boolean, required)
- `errors` (map from string to any, optional, nullable)

### 404 Not Found Error

Staff not found.

- `message` (string, required)
- `status` (boolean, required)
- `errors` (map from string to any, optional, nullable)

## Types

### LeaveRequestCreateResponseData

- `salarybox_id` (string, optional)
- `leave_type` (string, optional)
- `from_date` (string, optional)
- `to_date` (string, optional)
- `is_half_day` (boolean, optional)
- `reason` (string, optional)
- `status` (string, optional) — `pending` while it waits for a decision. `approved` in the rare case an approval flow has nobody at any level to act and approves it straight away.

## Examples

**Request**

```json
{
  "salarybox_id": "SBX1234567",
  "leave_type": "Casual Leave",
  "from_date": "2026-11-10",
  "to_date": "2026-11-11",
  "is_half_day": false,
  "reason": "Family function"
}
```

**Response**

```json
{
  "message": "Leave request raised successfully",
  "status": true,
  "data": {
    "salarybox_id": "SBX1234567",
    "leave_type": "Casual Leave",
    "from_date": "2026-11-10",
    "to_date": "2026-11-11",
    "is_half_day": false,
    "reason": "Family function",
    "status": "pending"
  }
}
```

**SDK Code**

```python Example
import requests

url = "https://api.salaryboxapp.com/v2/customer/v1/leave/request"

payload = {
    "salarybox_id": "SBX1234567",
    "leave_type": "Casual Leave",
    "from_date": "2026-11-10",
    "to_date": "2026-11-11",
    "is_half_day": False,
    "reason": "Family function"
}
headers = {
    "Authorization": "Api-Key  <apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Example
const url = 'https://api.salaryboxapp.com/v2/customer/v1/leave/request';
const options = {
  method: 'POST',
  headers: {Authorization: 'Api-Key  <apiKey>', 'Content-Type': 'application/json'},
  body: '{"salarybox_id":"SBX1234567","leave_type":"Casual Leave","from_date":"2026-11-10","to_date":"2026-11-11","is_half_day":false,"reason":"Family function"}'
};

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

```go Example
package main

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

func main() {

	url := "https://api.salaryboxapp.com/v2/customer/v1/leave/request"

	payload := strings.NewReader("{\n  \"salarybox_id\": \"SBX1234567\",\n  \"leave_type\": \"Casual Leave\",\n  \"from_date\": \"2026-11-10\",\n  \"to_date\": \"2026-11-11\",\n  \"is_half_day\": false,\n  \"reason\": \"Family function\"\n}")

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

	req.Header.Add("Authorization", "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 Example
require 'uri'
require 'net/http'

url = URI("https://api.salaryboxapp.com/v2/customer/v1/leave/request")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Api-Key  <apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"salarybox_id\": \"SBX1234567\",\n  \"leave_type\": \"Casual Leave\",\n  \"from_date\": \"2026-11-10\",\n  \"to_date\": \"2026-11-11\",\n  \"is_half_day\": false,\n  \"reason\": \"Family function\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.salaryboxapp.com/v2/customer/v1/leave/request")
  .header("Authorization", "Api-Key  <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"salarybox_id\": \"SBX1234567\",\n  \"leave_type\": \"Casual Leave\",\n  \"from_date\": \"2026-11-10\",\n  \"to_date\": \"2026-11-11\",\n  \"is_half_day\": false,\n  \"reason\": \"Family function\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.salaryboxapp.com/v2/customer/v1/leave/request', [
  'body' => '{
  "salarybox_id": "SBX1234567",
  "leave_type": "Casual Leave",
  "from_date": "2026-11-10",
  "to_date": "2026-11-11",
  "is_half_day": false,
  "reason": "Family function"
}',
  'headers' => [
    'Authorization' => 'Api-Key  <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Example
using RestSharp;

var client = new RestClient("https://api.salaryboxapp.com/v2/customer/v1/leave/request");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Api-Key  <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"salarybox_id\": \"SBX1234567\",\n  \"leave_type\": \"Casual Leave\",\n  \"from_date\": \"2026-11-10\",\n  \"to_date\": \"2026-11-11\",\n  \"is_half_day\": false,\n  \"reason\": \"Family function\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Example
import Foundation

let headers = [
  "Authorization": "Api-Key  <apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "salarybox_id": "SBX1234567",
  "leave_type": "Casual Leave",
  "from_date": "2026-11-10",
  "to_date": "2026-11-11",
  "is_half_day": false,
  "reason": "Family function"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.salaryboxapp.com/v2/customer/v1/leave/request")! 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()
```