> ## 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"
> ```

# Add Staff Early Leaving Fines

POST https://api.salaryboxapp.com/v2/customer/v1/payroll/early-leaving-fine
Content-Type: application/json

Saves the early leaving fines of a payroll month that has nothing saved yet, with your own amount per day. Payroll then uses the saved month's total. Shared rules: see [Writing data](/conventions#writing-data). Needs Payroll on your plan.

`deduct_for` is how much of the day is fined: hours on an `hourly` fine (the app's Deduct For), `1` (fined) or `0` (not fined) on a `daily` fine (the app's Deduct fine for the day?).

- Call `GET /payroll/early-leaving-fine` first to see which days have a fine and the current `deduct_for`.
- Send only the days to change. Every other day is saved exactly as it stands now, with the same amount.
- `salarybox_id` is required, at max 50 characters. `month` is required, `YYYY-MM`, and must be a payroll month that has ended and is not finalised.
- `entries` is required, 1-31 items, each date at most once. Each `date` must be a day listed in `days` by `GET /payroll/early-leaving-fine`.
- `deduct_for` must be a JSON number, 0 to 24 with up to 2 decimals. The day's `amount` is worked out as `deduct_for` x that day's `rate`.
- A month that is already saved gives `400`; change it with `PUT /payroll/early-leaving-fine`. So a retried POST cannot overwrite later edits.
- How saved totals behave when attendance changes: see Fetch Single Staff Early Leaving Fines.


Reference: https://docs.salarybox.in/api-reference/payroll/early-leaving-fine-create

## Authentication

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

## Request

### Body (application/json)

This endpoint expects a PayrollEarlyLeavingFineSaveRequest.

- `salarybox_id` (string, required) — SalaryBox ID of the staff member.
- `month` (string, required) — Payroll month, `YYYY-MM`. Must have ended and not be finalised.
- `entries` (list of PayrollEarlyLeavingFineSaveRequestEntriesItems, required) — The days to change, each date at most once.

## Response

### 201

The month's early leaving fines were saved. `data` is the month after the save.

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

## Errors

### 400 Bad Request Error

Validation failed, the month has not ended or is finalised, the early leaving fines for the month are already saved, a date has no fine counted, a daily fine has a `deduct_for` other than 0 or 1, or setup is missing (fine settings, salary structure or payroll settings).

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

### 403 Forbidden Error

Your plan does not include payroll, or you cannot act on this staff member.

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

### 404 Not Found Error

No eligible active staff member with this `salarybox_id` exists in your company.

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

## Types

### PayrollEarlyLeavingFineSaveRequestEntriesItems

- `date` (date, required) — `YYYY-MM-DD`. Must be a day listed in `days` by the Get endpoint.
- `deduct_for` (double, required) — On an `hourly` fine, hours fined (up to 2 decimals). On a `daily` fine, `1` (fined) or `0` (not fined). Must be a JSON number.

### PayrollEarlyLeavingFineMonth

- `salarybox_id` (string, optional)
- `month` (string, optional)
- `attendance_from_date` (date, optional)
- `attendance_to_date` (date, optional)
- `fine_type` (enum, optional)
  - Allowed values: `hourly`, `daily`
- `is_saved` (boolean, optional) — Whether an admin has saved this month. `false` means these are the computed values.
- `total_fine` (string, optional)
- `days` (list of PayrollEarlyLeavingFineDay, optional) — Sorted by date. May be empty.

### PayrollEarlyLeavingFineDay

- `date` (date, optional)
- `left_early_by_hours` (string, optional) — Hours the staff member left early that day. 2 decimals.
- `waive_off_applied` (boolean, optional) — The day is inside the staff member's waive-off days (computed amount 0).
- `deduct_for` (string, optional) — Hours fined (`hourly`) or `1.00` / `0.00` (`daily`). 2 decimals.
- `rate` (string, optional)
- `amount` (string, optional)

## Examples

**Request**

```json
{
  "salarybox_id": "SBX1234567",
  "month": "2026-10",
  "entries": [
    {
      "date": "2026-10-03",
      "deduct_for": 1.5
    },
    {
      "date": "2026-10-07",
      "deduct_for": 0
    }
  ]
}
```

**Response**

```json
{
  "message": "Early leaving fines saved successfully",
  "status": true,
  "data": {
    "salarybox_id": "SBX1234567",
    "month": "2026-10",
    "attendance_from_date": "2026-10-01",
    "attendance_to_date": "2026-10-31",
    "fine_type": "hourly",
    "is_saved": true,
    "total_fine": "150.00",
    "days": [
      {
        "date": "2026-10-03",
        "left_early_by_hours": "1.75",
        "waive_off_applied": false,
        "deduct_for": "1.50",
        "rate": "100.00",
        "amount": "150.00"
      }
    ]
  }
}
```

**SDK Code**

```python Example
import requests

url = "https://api.salaryboxapp.com/v2/customer/v1/payroll/early-leaving-fine"

payload = {
    "salarybox_id": "SBX1234567",
    "month": "2026-10",
    "entries": [
        {
            "date": "2026-10-03",
            "deduct_for": 1.5
        },
        {
            "date": "2026-10-07",
            "deduct_for": 0
        }
    ]
}
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/payroll/early-leaving-fine';
const options = {
  method: 'POST',
  headers: {Authorization: 'Api-Key  <apiKey>', 'Content-Type': 'application/json'},
  body: '{"salarybox_id":"SBX1234567","month":"2026-10","entries":[{"date":"2026-10-03","deduct_for":1.5},{"date":"2026-10-07","deduct_for":0}]}'
};

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/payroll/early-leaving-fine"

	payload := strings.NewReader("{\n  \"salarybox_id\": \"SBX1234567\",\n  \"month\": \"2026-10\",\n  \"entries\": [\n    {\n      \"date\": \"2026-10-03\",\n      \"deduct_for\": 1.5\n    },\n    {\n      \"date\": \"2026-10-07\",\n      \"deduct_for\": 0\n    }\n  ]\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/payroll/early-leaving-fine")

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  \"month\": \"2026-10\",\n  \"entries\": [\n    {\n      \"date\": \"2026-10-03\",\n      \"deduct_for\": 1.5\n    },\n    {\n      \"date\": \"2026-10-07\",\n      \"deduct_for\": 0\n    }\n  ]\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/payroll/early-leaving-fine")
  .header("Authorization", "Api-Key  <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"salarybox_id\": \"SBX1234567\",\n  \"month\": \"2026-10\",\n  \"entries\": [\n    {\n      \"date\": \"2026-10-03\",\n      \"deduct_for\": 1.5\n    },\n    {\n      \"date\": \"2026-10-07\",\n      \"deduct_for\": 0\n    }\n  ]\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/payroll/early-leaving-fine', [
  'body' => '{
  "salarybox_id": "SBX1234567",
  "month": "2026-10",
  "entries": [
    {
      "date": "2026-10-03",
      "deduct_for": 1.5
    },
    {
      "date": "2026-10-07",
      "deduct_for": 0
    }
  ]
}',
  '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/payroll/early-leaving-fine");
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  \"month\": \"2026-10\",\n  \"entries\": [\n    {\n      \"date\": \"2026-10-03\",\n      \"deduct_for\": 1.5\n    },\n    {\n      \"date\": \"2026-10-07\",\n      \"deduct_for\": 0\n    }\n  ]\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",
  "month": "2026-10",
  "entries": [
    [
      "date": "2026-10-03",
      "deduct_for": 1.5
    ],
    [
      "date": "2026-10-07",
      "deduct_for": 0
    ]
  ]
] as [String : Any]

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

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