> ## 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 Shift

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

Renames an existing shift. Shared rules: see [Writing data](/conventions#writing-data).

- Only the name can change. A shift's times are what past attendance was worked out with; to change them, add a new shift and assign it.
- `name` is the current shift name, matched exactly (see `GET /attendance/shift`).
- `new_name` must be unique in the company, ignoring upper/lower case and outer spaces, excluding this shift.


Reference: https://docs.salarybox.in/api-reference/attendance/shift-rename

## Authentication

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

## Request

### Body (application/json)

This endpoint expects an AttendanceShiftRenameRequest.

- `name` (string, required) — Current exact shift name.
- `new_name` (string, required) — New shift name. Unique in the company, ignoring case.

## Response

### 200

The shift was renamed.

- `message` (string, required)
- `status` (boolean, required)
- `data` (AttendanceShiftResponseData, required)

## Errors

### 400 Bad Request Error

Validation failed, or an unknown or ambiguous shift name.

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

### AttendanceShiftResponseData

- `name` (string, required)
- `start_time` (string, required) — 24-hour `HH:MM`.
- `end_time` (string, required) — 24-hour `HH:MM`.
- `is_overnight` (boolean, required)
- `min_punch_in_minutes` (integer, required, nullable) — Minutes before start a punch-in is accepted; `null` means no limit.
- `max_punch_out_minutes` (integer, required, nullable) — Minutes after end a punch-out is accepted; `null` means no limit.

## Examples

### Example

**Response**

```json
{
  "message": "Shift renamed successfully",
  "status": true,
  "data": {
    "name": "Morning (Office)",
    "start_time": "09:00",
    "end_time": "18:00",
    "is_overnight": false,
    "min_punch_in_minutes": 30,
    "max_punch_out_minutes": null
  }
}
```

**SDK Code**

```python Example
import requests

url = "https://api.salaryboxapp.com/v2/customer/v1/attendance/shift"

headers = {"Authorization": "Api-Key  <apiKey>"}

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

print(response.json())
```

```javascript Example
const url = 'https://api.salaryboxapp.com/v2/customer/v1/attendance/shift';
const options = {method: 'PUT', headers: {Authorization: 'Api-Key  <apiKey>'}};

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"
	"net/http"
	"io"
)

func main() {

	url := "https://api.salaryboxapp.com/v2/customer/v1/attendance/shift"

	req, _ := http.NewRequest("PUT", url, nil)

	req.Header.Add("Authorization", "Api-Key  <apiKey>")

	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/shift")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Api-Key  <apiKey>'

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/shift")
  .header("Authorization", "Api-Key  <apiKey>")
  .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/shift', [
  'headers' => [
    'Authorization' => 'Api-Key  <apiKey>',
  ],
]);

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

```csharp Example
using RestSharp;

var client = new RestClient("https://api.salaryboxapp.com/v2/customer/v1/attendance/shift");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Api-Key  <apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Example
import Foundation

let headers = ["Authorization": "Api-Key  <apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.salaryboxapp.com/v2/customer/v1/attendance/shift")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers

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

### Rename

**Request**

```json
{
  "name": "Morning",
  "new_name": "Morning (Office)"
}
```

**Response**

```json
{
  "message": "Shift renamed successfully",
  "status": true,
  "data": {
    "name": "Morning (Office)",
    "start_time": "09:00",
    "end_time": "18:00",
    "is_overnight": false,
    "min_punch_in_minutes": 30,
    "max_punch_out_minutes": null
  }
}
```

**SDK Code**

```python Rename
import requests

url = "https://api.salaryboxapp.com/v2/customer/v1/attendance/shift"

payload = {
    "name": "Morning",
    "new_name": "Morning (Office)"
}
headers = {
    "Authorization": "Api-Key  <apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Rename
const url = 'https://api.salaryboxapp.com/v2/customer/v1/attendance/shift';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Api-Key  <apiKey>', 'Content-Type': 'application/json'},
  body: '{"name":"Morning","new_name":"Morning (Office)"}'
};

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

```go Rename
package main

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

func main() {

	url := "https://api.salaryboxapp.com/v2/customer/v1/attendance/shift"

	payload := strings.NewReader("{\n  \"name\": \"Morning\",\n  \"new_name\": \"Morning (Office)\"\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 Rename
require 'uri'
require 'net/http'

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

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  \"name\": \"Morning\",\n  \"new_name\": \"Morning (Office)\"\n}"

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

```java Rename
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/shift")
  .header("Authorization", "Api-Key  <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Morning\",\n  \"new_name\": \"Morning (Office)\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.salaryboxapp.com/v2/customer/v1/attendance/shift', [
  'body' => '{
  "name": "Morning",
  "new_name": "Morning (Office)"
}',
  'headers' => [
    'Authorization' => 'Api-Key  <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Rename
using RestSharp;

var client = new RestClient("https://api.salaryboxapp.com/v2/customer/v1/attendance/shift");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Api-Key  <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Morning\",\n  \"new_name\": \"Morning (Office)\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Rename
import Foundation

let headers = [
  "Authorization": "Api-Key  <apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Morning",
  "new_name": "Morning (Office)"
] as [String : Any]

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

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