> ## 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 Attendance Settings

PUT https://api.salaryboxapp.com/v2/customer/v1/attendance/staff-settings
Content-Type: application/json

Applies the same attendance settings to every staff member in `salarybox_ids` (1 to 50). Settings you don't send stay as they are. Shared rules: see [Writing data](/conventions#writing-data).

`automation_rules` needs a plan with Attendance Automation Rules, otherwise `403`.

- Send at least one of `timezone`, `can_view_own_attendance`, `attendance_modes` or `automation_rules`. Anything you leave out keeps its current value, including inside `smartphone` and `automation_rules`.
- All or nothing: if any staff member is refused (unknown or inactive), nothing is saved.
- Biometric and face recognition cannot be set here. Biometric comes from biometric device mapping, and face recognition from face enrolment in the SalaryBox app. `face_recognition` still appears in the response when the staff member has enrolled.
- To see current values first, use List Staff Attendance Settings.


Reference: https://docs.salarybox.in/api-reference/attendance/employee-settings-update

## Authentication

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

## Request

### Body (application/json)

This endpoint expects an EmployeeAttendanceSettingsSetRequest.

- `salarybox_ids` (list of string, required) — The staff members to change (1 to 50, each listed once).
- `timezone` (string, optional) — IANA time zone name.
- `can_view_own_attendance` (boolean, optional) — Whether the staff member can see their own attendance in the app.
- `attendance_modes` (EmployeeAttendanceModesSetRequest, optional) — How staff may mark attendance. Only `smartphone` can be set here.
- `automation_rules` (EmployeeAutomationRulesSetRequest, optional) — Rules that turn punches into a daily status. Send at least one rule. Needs a plan with Attendance Automation Rules.

## Response

### 200

The settings were saved. One entry per staff member, in the same shape as List Staff Attendance Settings.

- `message` (string, required)
- `status` (boolean, required)
- `data` (list of EmployeeAttendanceSetting, required) — One entry per staff member, in the same shape as List Staff Attendance Settings. Not paginated.

## Errors

### 400 Bad Request Error

The request was refused, so nothing was saved.

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

### 403 Forbidden Error

Refused for permission, plan or team reasons (or no active subscription), so nothing was saved.

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

### 404 Not Found Error

A `salarybox_id` does not belong to a staff member of your company.

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

## Types

### EmployeeAttendanceModesSetRequest

How staff may mark attendance. Only `smartphone` can be set here.

- `smartphone` (EmployeeAttendanceModesSetRequestSmartphone, required) — Smartphone attendance. Send at least one of `enabled`, `geofence` or `modes`.

### EmployeeAutomationRulesSetRequest

Rules that turn punches into a daily status. Send at least one rule. Needs a plan with Attendance Automation Rules.

- `auto_present` (boolean, optional) — Marked present every working day, even without punching.
- `present_on_punch_in` (boolean, optional) — Marked present on punch-in.
- `present_on_duration_seconds` (integer, optional, nullable) — Present after working at least this long. Also the minimum hours used for overtime. `null` turns it off.
- `half_day_on_duration_seconds` (integer, optional, nullable) — Half day after working at least this long. `null` turns it off.
- `half_day_on_late_by_duration_seconds` (integer, optional, nullable) — Half day when the first punch-in is at least this late. `null` turns it off.

### EmployeeAttendanceSetting

- `salarybox_id` (string, required) — The staff member's SalaryBox ID.
- `employee_id` (string, required, nullable) — Your company's own employee ID for this person. `null` or an empty string when not set.
- `name` (string, required) — Full name from the staff profile.
- `branches` (list of string, required) — Names of the branches the person is assigned to. Deleted branches are left out.
- `departments` (list of string, required) — Names of the departments the person is in. Deleted departments are left out.
- `timezone` (string, required) — The time zone the person's attendance is recorded in (IANA name). Their own setting, or your company's time zone when they have none (`Asia/Kolkata` if the company has none either). Never `null`.
- `can_view_own_attendance` (boolean, required) — True when the person can see their own attendance in the SalaryBox app. Their own setting when saved, otherwise their older per-person "view own attendance" setting, and true when neither was ever set.
- `attendance_modes` (AttendanceModes, required) — How the staff member is allowed to mark attendance.
- `automation_rules` (AutomationRules, required) — Rules that turn the staff member's punches into a daily status. See "Automation rules" in the endpoint description for the order they are applied in. All durations are in seconds; `null` means the rule is off.

### EmployeeAttendanceModesSetRequestSmartphone

Smartphone attendance. Send at least one of `enabled`, `geofence` or `modes`.

- `enabled` (boolean, optional) — Turns smartphone attendance on or off.
- `geofence` (boolean, optional) — Punches only inside the branch geofence.
- `modes` (list of enum, optional) — Replaces the list of allowed modes. `[]` allows neither. `face_recognition` cannot be set here.
  - Allowed values: `qr`, `selfie`

### AttendanceModes

How the staff member is allowed to mark attendance.

- `smartphone` (AttendanceModesSmartphone, required) — Marking attendance from the SalaryBox app on their phone.
- `biometric` (AttendanceModesBiometric, required) — Marking attendance on a biometric device.

### AutomationRules

Rules that turn the staff member's punches into a daily status. See "Automation rules" in the endpoint description for the order they are applied in. All durations are in seconds; `null` means the rule is off.

- `auto_present` (boolean, required) — True when the person is marked present automatically every working day, even without a punch. Holidays and their days off are skipped.
- `present_on_punch_in` (boolean, required) — True when a punch-in marks the day present.
- `present_on_duration_seconds` (integer, required, nullable) — Mark the day present once the person has worked at least this long. Also the expected working time for overtime and for per-hour salary when set. For example `28800` is 8 hours.
- `half_day_on_duration_seconds` (integer, required, nullable) — Mark the day a half day once the person has worked at least this long (unless the present duration above is also reached). For example `14400` is 4 hours.
- `half_day_on_late_by_duration_seconds` (integer, required, nullable) — Mark the day a half day when the first punch-in of the day is at least this late against the shift start. For example `7200` is 2 hours late.

### AttendanceModesSmartphone

Marking attendance from the SalaryBox app on their phone.

- `enabled` (boolean, required) — True when the person can punch from their phone. When nothing has been saved for this setting, it is true.
- `geofence` (boolean, required, nullable) — True when phone punches are only allowed inside the person's allowed location (geofence); false when turned off; `null` when it has never been set.
- `modes` (list of enum, required) — Extra checks required for a phone punch. Empty list when none are required. - `qr`: the person scans a QR code to punch. - `selfie`: the person takes a photo when punching. - `face_recognition`: the photo is also matched against their registered face. Shown when face match is turned on for the person.
  - Allowed values: `qr`, `selfie`, `face_recognition`

### AttendanceModesBiometric

Marking attendance on a biometric device.

- `enabled` (boolean, required) — True when biometric attendance is turned on for the person. False when it is off or was never set.

## Examples

**Request**

```json
{
  "salarybox_ids": [
    "SBK7Q2M9TX",
    "SBR4T8W2PL"
  ],
  "timezone": "Asia/Kolkata",
  "can_view_own_attendance": true,
  "attendance_modes": {
    "smartphone": {
      "enabled": true,
      "geofence": true,
      "modes": [
        "selfie",
        "qr"
      ]
    }
  },
  "automation_rules": {
    "auto_present": false,
    "present_on_punch_in": true,
    "present_on_duration_seconds": 28800,
    "half_day_on_duration_seconds": 14400,
    "half_day_on_late_by_duration_seconds": null
  }
}
```

**Response**

```json
{
  "message": "Attendance settings saved successfully",
  "status": true,
  "data": [
    {
      "salarybox_id": "SBK7Q2M9TX",
      "employee_id": "EMP-0042",
      "name": "Aarav Sharma",
      "branches": [
        "Bengaluru HQ"
      ],
      "departments": [
        "Sales"
      ],
      "timezone": "Asia/Kolkata",
      "can_view_own_attendance": true,
      "attendance_modes": {
        "smartphone": {
          "enabled": true,
          "geofence": true,
          "modes": [
            "selfie",
            "qr"
          ]
        },
        "biometric": {
          "enabled": false
        }
      },
      "automation_rules": {
        "auto_present": false,
        "present_on_punch_in": true,
        "present_on_duration_seconds": 28800,
        "half_day_on_duration_seconds": 14400,
        "half_day_on_late_by_duration_seconds": null
      }
    },
    {
      "salarybox_id": "SBR4T8W2PL",
      "employee_id": "EMP-0063",
      "name": "Rohan Verma",
      "branches": [
        "Pune Plant"
      ],
      "departments": [],
      "timezone": "Asia/Kolkata",
      "can_view_own_attendance": true,
      "attendance_modes": {
        "smartphone": {
          "enabled": true,
          "geofence": true,
          "modes": [
            "selfie",
            "qr"
          ]
        },
        "biometric": {
          "enabled": true
        }
      },
      "automation_rules": {
        "auto_present": false,
        "present_on_punch_in": true,
        "present_on_duration_seconds": 28800,
        "half_day_on_duration_seconds": 14400,
        "half_day_on_late_by_duration_seconds": null
      }
    }
  ]
}
```

**SDK Code**

```python Example
import requests

url = "https://api.salaryboxapp.com/v2/customer/v1/attendance/staff-settings"

payload = {
    "salarybox_ids": ["SBK7Q2M9TX", "SBR4T8W2PL"],
    "timezone": "Asia/Kolkata",
    "can_view_own_attendance": True,
    "attendance_modes": { "smartphone": {
            "enabled": True,
            "geofence": True,
            "modes": ["selfie", "qr"]
        } },
    "automation_rules": {
        "auto_present": False,
        "present_on_punch_in": True,
        "present_on_duration_seconds": 28800,
        "half_day_on_duration_seconds": 14400,
        "half_day_on_late_by_duration_seconds": None
    }
}
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/attendance/staff-settings';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Api-Key  <apiKey>', 'Content-Type': 'application/json'},
  body: '{"salarybox_ids":["SBK7Q2M9TX","SBR4T8W2PL"],"timezone":"Asia/Kolkata","can_view_own_attendance":true,"attendance_modes":{"smartphone":{"enabled":true,"geofence":true,"modes":["selfie","qr"]}},"automation_rules":{"auto_present":false,"present_on_punch_in":true,"present_on_duration_seconds":28800,"half_day_on_duration_seconds":14400,"half_day_on_late_by_duration_seconds":null}}'
};

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/attendance/staff-settings"

	payload := strings.NewReader("{\n  \"salarybox_ids\": [\n    \"SBK7Q2M9TX\",\n    \"SBR4T8W2PL\"\n  ],\n  \"timezone\": \"Asia/Kolkata\",\n  \"can_view_own_attendance\": true,\n  \"attendance_modes\": {\n    \"smartphone\": {\n      \"enabled\": true,\n      \"geofence\": true,\n      \"modes\": [\n        \"selfie\",\n        \"qr\"\n      ]\n    }\n  },\n  \"automation_rules\": {\n    \"auto_present\": false,\n    \"present_on_punch_in\": true,\n    \"present_on_duration_seconds\": 28800,\n    \"half_day_on_duration_seconds\": 14400,\n    \"half_day_on_late_by_duration_seconds\": null\n  }\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/attendance/staff-settings")

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_ids\": [\n    \"SBK7Q2M9TX\",\n    \"SBR4T8W2PL\"\n  ],\n  \"timezone\": \"Asia/Kolkata\",\n  \"can_view_own_attendance\": true,\n  \"attendance_modes\": {\n    \"smartphone\": {\n      \"enabled\": true,\n      \"geofence\": true,\n      \"modes\": [\n        \"selfie\",\n        \"qr\"\n      ]\n    }\n  },\n  \"automation_rules\": {\n    \"auto_present\": false,\n    \"present_on_punch_in\": true,\n    \"present_on_duration_seconds\": 28800,\n    \"half_day_on_duration_seconds\": 14400,\n    \"half_day_on_late_by_duration_seconds\": null\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.put("https://api.salaryboxapp.com/v2/customer/v1/attendance/staff-settings")
  .header("Authorization", "Api-Key  <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"salarybox_ids\": [\n    \"SBK7Q2M9TX\",\n    \"SBR4T8W2PL\"\n  ],\n  \"timezone\": \"Asia/Kolkata\",\n  \"can_view_own_attendance\": true,\n  \"attendance_modes\": {\n    \"smartphone\": {\n      \"enabled\": true,\n      \"geofence\": true,\n      \"modes\": [\n        \"selfie\",\n        \"qr\"\n      ]\n    }\n  },\n  \"automation_rules\": {\n    \"auto_present\": false,\n    \"present_on_punch_in\": true,\n    \"present_on_duration_seconds\": 28800,\n    \"half_day_on_duration_seconds\": 14400,\n    \"half_day_on_late_by_duration_seconds\": null\n  }\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/attendance/staff-settings', [
  'body' => '{
  "salarybox_ids": [
    "SBK7Q2M9TX",
    "SBR4T8W2PL"
  ],
  "timezone": "Asia/Kolkata",
  "can_view_own_attendance": true,
  "attendance_modes": {
    "smartphone": {
      "enabled": true,
      "geofence": true,
      "modes": [
        "selfie",
        "qr"
      ]
    }
  },
  "automation_rules": {
    "auto_present": false,
    "present_on_punch_in": true,
    "present_on_duration_seconds": 28800,
    "half_day_on_duration_seconds": 14400,
    "half_day_on_late_by_duration_seconds": null
  }
}',
  '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/attendance/staff-settings");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Api-Key  <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"salarybox_ids\": [\n    \"SBK7Q2M9TX\",\n    \"SBR4T8W2PL\"\n  ],\n  \"timezone\": \"Asia/Kolkata\",\n  \"can_view_own_attendance\": true,\n  \"attendance_modes\": {\n    \"smartphone\": {\n      \"enabled\": true,\n      \"geofence\": true,\n      \"modes\": [\n        \"selfie\",\n        \"qr\"\n      ]\n    }\n  },\n  \"automation_rules\": {\n    \"auto_present\": false,\n    \"present_on_punch_in\": true,\n    \"present_on_duration_seconds\": 28800,\n    \"half_day_on_duration_seconds\": 14400,\n    \"half_day_on_late_by_duration_seconds\": null\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_ids": ["SBK7Q2M9TX", "SBR4T8W2PL"],
  "timezone": "Asia/Kolkata",
  "can_view_own_attendance": true,
  "attendance_modes": ["smartphone": [
      "enabled": true,
      "geofence": true,
      "modes": ["selfie", "qr"]
    ]],
  "automation_rules": [
    "auto_present": false,
    "present_on_punch_in": true,
    "present_on_duration_seconds": 28800,
    "half_day_on_duration_seconds": 14400,
    "half_day_on_late_by_duration_seconds": 
  ]
] as [String : Any]

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

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