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

PUT https://api.salaryboxapp.com/v2/customer/v1/staff/{salarybox_id}/employment-history
Content-Type: application/json

Changes one past job in a staff member's employment history. Shared rules: see [Writing data](/conventions#writing-data).

- `salarybox_id` goes in the URL path, not the body.
- You never send ids. Name the entry by its **current** `company_name` (matched trimmed and case-insensitively). If the staff member has more than one entry with that company, also send its current `joining_date`.
- Send the values you want in the `new_` fields. This is a PUT that sets values: a `new_` field that is `null` or left out keeps its current value, and nothing is ever cleared.
- Send at least one non-null `new_` field, or you get `400` "Send at least one new_ field to change."
- Dates are checked against what the entry will hold once saved: a new joining date against the stored leaving date, and the other way round. Errors are reported under the `new_` field you sent.
- `salary` is returned as a string with 2 decimals, or `null`.
- As in the app, changing an entry cancels the staff member's past-employment verification result, and a staff member who was marked verified shows "Details changed" in Staff Verification.
- Repeating the same request is safe. Use List Staff Employment History to read entries back.


Reference: https://docs.salarybox.in/api-reference/staff/employment-history-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.

### Body (application/json)

This endpoint expects a StaffEmploymentHistoryUpdateRequest.

- `company_name` (string, required) — The entry's CURRENT company name. Matched trimmed and case-insensitively.
- `joining_date` (date, optional) — The entry's CURRENT joining date, `YYYY-MM-DD`. Only needed when the staff member has more than one entry with that company.
- `new_company_name` (string, optional, nullable) — New company name (trimmed). `null` or left out keeps the current value.
- `new_designation` (string, optional, nullable) — New job title (trimmed). `null` or left out keeps the current value.
- `new_joining_date` (date, optional, nullable) — `YYYY-MM-DD`; not in the future. `null` or left out keeps the current value.
- `new_leaving_date` (date, optional, nullable) — `YYYY-MM-DD`; not in the future. `null` or left out keeps the current value.
- `new_salary` (double, optional, nullable) — A number (not text), 0 or more, up to 2 decimal places and 12 digits in total. `null` or left out keeps the current value.
- `new_company_gst` (string, optional, nullable) — A valid GSTIN (upper-cased for you); otherwise `400` "Invalid GSTIN." `null` or left out keeps the current value.
- `new_currency` (enum, optional, nullable) — `null` or left out keeps the current value.
  - Allowed values: `BDT`, `ZAR`, `MYR`, `SGD`, `PHP`, `MUR`, `AED`, `IDR`, `INR`, `USD`, `THB`, `MXN`, `GB`, `KW`, `QA`, `SA`, `EG`

## Response

### 200

The employment history entry was updated. `data` has the same shape as Add Staff Employment History.

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

## Errors

### 400 Bad Request Error

Validation failed, the staff member is inactive, or more than one entry matches.

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

### 404 Not Found Error

The staff member was not found, or they have no employment history matching `company_name` (and `joining_date` when sent).

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

## Types

### StaffEmploymentHistoryCreateResponseData

- `salarybox_id` (string, required)
- `company_name` (string, required)
- `designation` (string, optional, nullable)
- `joining_date` (date, optional, nullable)
- `leaving_date` (date, optional, nullable)
- `salary` (string, optional, nullable) — Returned as a string with 2 decimal places, or null if not provided.
- `currency` (string, optional, nullable)
- `company_gst` (string, optional, nullable)

## Examples

**Request**

```json
{
  "company_name": "Acme Pvt Ltd",
  "new_designation": "Senior Accountant",
  "new_leaving_date": "2024-03-31"
}
```

**Response**

```json
{
  "message": "Employment history updated successfully",
  "status": true,
  "data": {
    "salarybox_id": "SB1001",
    "company_name": "Acme Pvt Ltd",
    "designation": "Senior Accountant",
    "joining_date": "2021-04-01",
    "leaving_date": "2024-03-31",
    "salary": "45000.00",
    "currency": "INR",
    "company_gst": "27AAPFU0939F1ZV"
  }
}
```

**SDK Code**

```python Example
import requests

url = "https://api.salaryboxapp.com/v2/customer/v1/staff/ABCDEFGHIJ/employment-history"

payload = {
    "company_name": "Acme Pvt Ltd",
    "new_designation": "Senior Accountant",
    "new_leaving_date": "2024-03-31"
}
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/staff/ABCDEFGHIJ/employment-history';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Api-Key  <apiKey>', 'Content-Type': 'application/json'},
  body: '{"company_name":"Acme Pvt Ltd","new_designation":"Senior Accountant","new_leaving_date":"2024-03-31"}'
};

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/staff/ABCDEFGHIJ/employment-history"

	payload := strings.NewReader("{\n  \"company_name\": \"Acme Pvt Ltd\",\n  \"new_designation\": \"Senior Accountant\",\n  \"new_leaving_date\": \"2024-03-31\"\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/staff/ABCDEFGHIJ/employment-history")

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  \"company_name\": \"Acme Pvt Ltd\",\n  \"new_designation\": \"Senior Accountant\",\n  \"new_leaving_date\": \"2024-03-31\"\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/staff/ABCDEFGHIJ/employment-history")
  .header("Authorization", "Api-Key  <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"company_name\": \"Acme Pvt Ltd\",\n  \"new_designation\": \"Senior Accountant\",\n  \"new_leaving_date\": \"2024-03-31\"\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/staff/ABCDEFGHIJ/employment-history', [
  'body' => '{
  "company_name": "Acme Pvt Ltd",
  "new_designation": "Senior Accountant",
  "new_leaving_date": "2024-03-31"
}',
  '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/staff/ABCDEFGHIJ/employment-history");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Api-Key  <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"company_name\": \"Acme Pvt Ltd\",\n  \"new_designation\": \"Senior Accountant\",\n  \"new_leaving_date\": \"2024-03-31\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Example
import Foundation

let headers = [
  "Authorization": "Api-Key  <apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "company_name": "Acme Pvt Ltd",
  "new_designation": "Senior Accountant",
  "new_leaving_date": "2024-03-31"
] as [String : Any]

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

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