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

# Finalise Staff Payroll

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

Finalises or un-finalises a month's payroll for 1 to 50 staff, as Finalise and Un-finalise do in the app's payroll. Needs Payroll on your plan. Shared rules: see [Writing data](/conventions#writing-data).

- Payroll must already be calculated for the month. Run Create Payroll Summary and wait for Fetch Payroll Summary Status to say `success` first; this endpoint never calculates payroll itself.
- `finalised` is the state you want: `true` (the default) finalises, `false` un-finalises.
- Finalised salaries are locked: attendance and pay changes for that month are blocked until it is un-finalised. Un-finalising recalculates that month's payroll.
- A future month gives `400`.
- Always returns `200` with one entry per staff member, in request order; `outcome` says what happened to each. Unknown staff ids give `400` and nothing is changed.
- Inactive staff (for example, left during the month) are accepted.


Reference: https://docs.salarybox.in/api-reference/payroll/finalise-create

## Authentication

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

## Request

### Body (application/json)

This endpoint expects a PayrollFinaliseRequest.

- `month` (string, required) — `YYYY-MM`. Payroll must already be calculated for this month.
- `salarybox_ids` (list of string, required) — Staff to finalise or un-finalise (1 to 50, no duplicates).
- `finalised` (boolean, optional, default: true) — The state you want. `true` finalises, `false` un-finalises. Must be a boolean.

## Response

### 200

The request was processed. Check `outcome` for each staff member.

- `message` (string, required)
- `status` (boolean, required)
- `data` (list of PayrollFinaliseResponseDataItems, required) — One entry per staff member, in request order.

## Errors

### 400 Bad Request Error

The request was refused, so nothing was changed.

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

### 403 Forbidden Error

Your company has no active subscription.

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

## Types

### PayrollFinaliseResponseDataItems

- `salarybox_id` (string, required)
- `name` (string, required)
- `outcome` (enum, required) — `finalised`: done. `already_finalised`: it was already finalised. `unfinalised`: done, for `finalised: false`. `not_finalised`: it wasn't finalised, for `finalised: false`. `locked_paid_online`: salary was paid online for the month, so payroll can't be changed. `not_computed`: payroll isn't calculated for the month yet. `pf_needs_attention`: fix the staff member's PF settings in the SalaryBox app, then finalise again.
  - Allowed values: `finalised`, `already_finalised`, `unfinalised`, `not_finalised`, `locked_paid_online`, `not_computed`, `pf_needs_attention`
- `message` (string, required)

## Examples

**Request**

```json
{
  "month": "2026-10",
  "salarybox_ids": [
    "SB1234",
    "SB1235"
  ]
}
```

**Response**

```json
{
  "message": "Payroll finalise processed",
  "status": true,
  "data": [
    {
      "salarybox_id": "SB1234",
      "name": "Ravi Kumar",
      "outcome": "finalised",
      "message": "Payroll finalised."
    },
    {
      "salarybox_id": "SB1235",
      "name": "Asha Rao",
      "outcome": "not_computed",
      "message": "Payroll isn't calculated for this month yet. Run /payroll/summary/init for the month, wait for it to finish, then try again."
    }
  ]
}
```

**SDK Code**

```python Example
import requests

url = "https://api.salaryboxapp.com/v2/customer/v1/payroll/finalise"

payload = {
    "month": "2026-10",
    "salarybox_ids": ["SB1234", "SB1235"]
}
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/finalise';
const options = {
  method: 'POST',
  headers: {Authorization: 'Api-Key  <apiKey>', 'Content-Type': 'application/json'},
  body: '{"month":"2026-10","salarybox_ids":["SB1234","SB1235"]}'
};

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/finalise"

	payload := strings.NewReader("{\n  \"month\": \"2026-10\",\n  \"salarybox_ids\": [\n    \"SB1234\",\n    \"SB1235\"\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/finalise")

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  \"month\": \"2026-10\",\n  \"salarybox_ids\": [\n    \"SB1234\",\n    \"SB1235\"\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/finalise")
  .header("Authorization", "Api-Key  <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"month\": \"2026-10\",\n  \"salarybox_ids\": [\n    \"SB1234\",\n    \"SB1235\"\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/finalise', [
  'body' => '{
  "month": "2026-10",
  "salarybox_ids": [
    "SB1234",
    "SB1235"
  ]
}',
  '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/finalise");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Api-Key  <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"month\": \"2026-10\",\n  \"salarybox_ids\": [\n    \"SB1234\",\n    \"SB1235\"\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 = [
  "month": "2026-10",
  "salarybox_ids": ["SB1234", "SB1235"]
] as [String : Any]

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

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