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

# Update Staff Early Leaving Fine Settings

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

Sets the **early leaving fine settings** for one staff member. The first call creates the setting and later calls update it. Shared rules: see [Writing data](/conventions#writing-data). Needs Payroll on your plan.

- `salarybox_id`, `fine_type` (`daily` or `hourly`), `amount_type` (`fixed` or `multiplier`) and `fine_amount` are required.
- `amount_type` `fixed` means `fine_amount` is money; `multiplier` means `fine_amount` multiplies the staff member's rate.
- `fine_amount` is a JSON number from 0 to 10000000 with up to 2 decimals.
- `grace_period_minutes` is **Only deduct if late by more than** (or **Only deduct if they leave earlier than**) in the app: optional, a whole number of minutes from 0 to 1439. Left out, it stays as it is (0 for a new setting).
- `waive_off_days` is **Allowed Late Days** (or **Allowed Early Leaving Days**) in the app: optional, a whole number from 0 to 31. Left out, it stays as it is (0 for a new setting).
- `GET /payroll/config/early-fine` returns the grace period as `HH:MM:SS`, while this request takes whole minutes.
- Changing the setting makes SalaryBox recalculate that staff member's saved payroll, as in the app.


Reference: https://docs.salarybox.in/api-reference/payroll/config-early-fine-set

## Authentication

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

## Request

### Body (application/json)

This endpoint expects a PayrollConfigFineSetRequest.

- `salarybox_id` (string, required) — SalaryBox ID of an active staff member.
- `fine_type` (enum, required)
  - Allowed values: `daily`, `hourly`
- `amount_type` (enum, required) — `fixed` means `fine_amount` is money; `multiplier` means it multiplies the staff member's rate.
  - Allowed values: `fixed`, `multiplier`
- `fine_amount` (double, required) — Up to 2 decimals.
- `grace_period_minutes` (integer, optional) — Only deduct if late by more than (Only deduct if they leave earlier than, for early leaving) in the app, in whole minutes. Left out, it stays as it is (0 for a new setting).
- `waive_off_days` (integer, optional) — Allowed Late Days (Allowed Early Leaving Days, for early leaving) in the app: late days forgiven each payroll month. Left out, it stays as it is (0 for a new setting).

## Response

### 200

The settings were saved.

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

## Errors

### 400 Bad Request Error

Validation failed (unknown field, wrong type, value out of range) or the staff member is inactive.

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

### 403 Forbidden Error

Your plan does not include payroll.

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

### PayrollConfigFineSetResponseData

- `salarybox_id` (string, optional)
- `config` (FineConfig, optional) — A staff member's late arrival or early leaving fine settings. See the endpoint description for how payroll applies them.

### FineConfig

A staff member's late arrival or early leaving fine settings. See the endpoint description for how payroll applies them.

- `fine_type` (enum, required) — - `daily`: a fine for each late (or early) day, however long. - `hourly`: a fine for each hour of late (or early) time, pro rata.
  - Allowed values: `daily`, `hourly`
- `amount_type` (enum, required) — How `fine_amount` is read. - `fixed`: `fine_amount` is money (Fixed Daily Rate or Fixed Hourly Rate in the app). - `multiplier`: `fine_amount` is a multiple of the staff member's per-day salary (`daily`) or per-hour salary (`hourly`).
  - Allowed values: `fixed`, `multiplier`
- `fine_amount` (string, required) — The fine as money or as a multiplier, depending on `amount_type`, as a 2-decimal string. For example `"100.00"` is ₹100 with `fixed`, or 100 times the salary with `multiplier`; `"0.50"` with `multiplier` is half.
- `grace_period` (string, required) — The app's Only deduct if late by more than (Only deduct if they leave earlier than, for early leaving), as a duration, `HH:MM:SS`. A day counts only if the late (or early) time is more than this, compared to the exact second; then the full time counts. `"00:00:00"` means any lateness counts.
- `waive_off_days` (integer, required) — The app's Allowed Late Days (Allowed Early Leaving Days, for early leaving), the number of late (or early) days forgiven in each payroll month, starting from the first one. `0` means none.

## Examples

**Request**

```json
{
  "salarybox_id": "SBX1234567",
  "fine_type": "daily",
  "amount_type": "fixed",
  "fine_amount": 100,
  "grace_period_minutes": 15,
  "waive_off_days": 2
}
```

**Response**

```json
{
  "message": "Early leaving fine settings saved successfully",
  "status": true,
  "data": {
    "salarybox_id": "SBX1234567",
    "config": {
      "fine_type": "daily",
      "amount_type": "fixed",
      "fine_amount": "100.00",
      "grace_period": "00:15:00",
      "waive_off_days": 2
    }
  }
}
```

**SDK Code**

```python Example
import requests

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

payload = {
    "salarybox_id": "SBX1234567",
    "fine_type": "daily",
    "amount_type": "fixed",
    "fine_amount": 100,
    "grace_period_minutes": 15,
    "waive_off_days": 2
}
headers = {
    "Authorization": "Api-Key  <apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Example
const url = 'https://api.salaryboxapp.com/v2/customer/v1/payroll/config/early-fine';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Api-Key  <apiKey>', 'Content-Type': 'application/json'},
  body: '{"salarybox_id":"SBX1234567","fine_type":"daily","amount_type":"fixed","fine_amount":100,"grace_period_minutes":15,"waive_off_days":2}'
};

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

	payload := strings.NewReader("{\n  \"salarybox_id\": \"SBX1234567\",\n  \"fine_type\": \"daily\",\n  \"amount_type\": \"fixed\",\n  \"fine_amount\": 100,\n  \"grace_period_minutes\": 15,\n  \"waive_off_days\": 2\n}")

	req, _ := http.NewRequest("PUT", 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/config/early-fine")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Api-Key  <apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"salarybox_id\": \"SBX1234567\",\n  \"fine_type\": \"daily\",\n  \"amount_type\": \"fixed\",\n  \"fine_amount\": 100,\n  \"grace_period_minutes\": 15,\n  \"waive_off_days\": 2\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.put("https://api.salaryboxapp.com/v2/customer/v1/payroll/config/early-fine")
  .header("Authorization", "Api-Key  <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"salarybox_id\": \"SBX1234567\",\n  \"fine_type\": \"daily\",\n  \"amount_type\": \"fixed\",\n  \"fine_amount\": 100,\n  \"grace_period_minutes\": 15,\n  \"waive_off_days\": 2\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.salaryboxapp.com/v2/customer/v1/payroll/config/early-fine', [
  'body' => '{
  "salarybox_id": "SBX1234567",
  "fine_type": "daily",
  "amount_type": "fixed",
  "fine_amount": 100,
  "grace_period_minutes": 15,
  "waive_off_days": 2
}',
  '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/config/early-fine");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Api-Key  <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"salarybox_id\": \"SBX1234567\",\n  \"fine_type\": \"daily\",\n  \"amount_type\": \"fixed\",\n  \"fine_amount\": 100,\n  \"grace_period_minutes\": 15,\n  \"waive_off_days\": 2\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",
  "fine_type": "daily",
  "amount_type": "fixed",
  "fine_amount": 100,
  "grace_period_minutes": 15,
  "waive_off_days": 2
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.salaryboxapp.com/v2/customer/v1/payroll/config/early-fine")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
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()
```