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

# Approve or Reject Device Request

PUT https://api.salaryboxapp.com/v2/customer/v1/requests/device-mapping/{salarybox_id}/decision
Content-Type: application/json

Approves or rejects a staff member's pending device verification request (a request to mark attendance from a new phone), as in the app. Shared rules: see [Writing data](/conventions#writing-data).

- Needs the device verification plan feature.
- Find the request with List Device Mappings (`GET /requests/device-mapping`). `action` is `APPROVE` or `REJECT`.
- Approving makes the requested phone the one the staff member marks attendance from, replacing any phone mapped before. Rejecting deletes the request. Either way the staff member is notified.
- You can't decide your own request: `400` on `salarybox_id`.
- No pending request: `404` "Device verification request not found." More than one pending request for the staff member: `400` on `salarybox_id`; decide them in the SalaryBox app.
- Repeating the request after it succeeded returns `404`, which is harmless.


Reference: https://docs.salarybox.in/api-reference/staff/requests-device-mapping-decision-update

## Authentication

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

## Request

### Path parameters

- `salarybox_id` (string, required) — SalaryBox ID of the staff member who made the request.

### Body (application/json)

This endpoint expects a DeviceMappingDecisionRequest.

- `action` (enum, required)
  - Allowed values: `APPROVE`, `REJECT`

## Response

### 200

The decision was saved.

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

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

The requester is not an Admin, or the plan lacks device verification.

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

### 404 Not Found Error

Staff not found, or the staff member has no pending device request.

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

## Types

### DeviceMappingDecisionResponseData

- `salarybox_id` (string, required)
- `name` (string, required)
- `device` (string, required, nullable) — The requested phone's model.
- `status` (enum, required)
  - Allowed values: `approved`, `declined`

## Examples

### Example

**Response**

```json
{
  "message": "Device verification decision saved successfully",
  "status": true,
  "data": {
    "salarybox_id": "SBK7Q2M9TX",
    "name": "Ravi Kumar",
    "device": "Pixel 8",
    "status": "approved"
  }
}
```

**SDK Code**

```python Example
import requests

url = "https://api.salaryboxapp.com/v2/customer/v1/requests/device-mapping/salarybox_id/decision"

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/requests/device-mapping/salarybox_id/decision';
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/requests/device-mapping/salarybox_id/decision"

	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/requests/device-mapping/salarybox_id/decision")

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/requests/device-mapping/salarybox_id/decision")
  .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/requests/device-mapping/salarybox_id/decision', [
  'headers' => [
    'Authorization' => 'Api-Key  <apiKey>',
  ],
]);

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

```csharp Example
using RestSharp;

var client = new RestClient("https://api.salaryboxapp.com/v2/customer/v1/requests/device-mapping/salarybox_id/decision");
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/requests/device-mapping/salarybox_id/decision")! 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()
```

### Approve

**Request**

```json
{
  "action": "APPROVE"
}
```

**Response**

```json
{
  "message": "Device verification decision saved successfully",
  "status": true,
  "data": {
    "salarybox_id": "SBK7Q2M9TX",
    "name": "Ravi Kumar",
    "device": "Pixel 8",
    "status": "approved"
  }
}
```

**SDK Code**

```python Approve
import requests

url = "https://api.salaryboxapp.com/v2/customer/v1/requests/device-mapping/salarybox_id/decision"

payload = { "action": "APPROVE" }
headers = {
    "Authorization": "Api-Key  <apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Approve
const url = 'https://api.salaryboxapp.com/v2/customer/v1/requests/device-mapping/salarybox_id/decision';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Api-Key  <apiKey>', 'Content-Type': 'application/json'},
  body: '{"action":"APPROVE"}'
};

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

```go Approve
package main

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

func main() {

	url := "https://api.salaryboxapp.com/v2/customer/v1/requests/device-mapping/salarybox_id/decision"

	payload := strings.NewReader("{\n  \"action\": \"APPROVE\"\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 Approve
require 'uri'
require 'net/http'

url = URI("https://api.salaryboxapp.com/v2/customer/v1/requests/device-mapping/salarybox_id/decision")

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  \"action\": \"APPROVE\"\n}"

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

```java Approve
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://api.salaryboxapp.com/v2/customer/v1/requests/device-mapping/salarybox_id/decision")
  .header("Authorization", "Api-Key  <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"action\": \"APPROVE\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.salaryboxapp.com/v2/customer/v1/requests/device-mapping/salarybox_id/decision', [
  'body' => '{
  "action": "APPROVE"
}',
  'headers' => [
    'Authorization' => 'Api-Key  <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Approve
using RestSharp;

var client = new RestClient("https://api.salaryboxapp.com/v2/customer/v1/requests/device-mapping/salarybox_id/decision");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Api-Key  <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"action\": \"APPROVE\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Approve
import Foundation

let headers = [
  "Authorization": "Api-Key  <apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["action": "APPROVE"] as [String : Any]

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

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