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

# Add Staff Employment History

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

Adds one past job to a staff member's employment history. Shared rules: see [Writing Data](/writing-data).

- `salarybox_id` goes in the URL path, not the body.
- Each call adds a new entry.
- Dates can't be in the future, and the leaving date can't be before the joining date.
- `salary` is returned as a string with 2 decimals, or `null`.
- Editing an entry is not available; correct it in the SalaryBox app. Use List Staff Employment History to read entries back.

**Custom role needs:** `staff_details:edit`.


Reference: https://docs.salarybox.in/api-reference/staff/employment-history-create

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

- `company_name` (string, required) — Previous employer (extra spaces around it are trimmed).
- `designation` (string, optional) — Job title held there (up to 100 characters).
- `joining_date` (date, optional) — `YYYY-MM-DD`; not in the future.
- `leaving_date` (date, optional) — `YYYY-MM-DD`; not in the future and not before `joining_date`.
- `salary` (double, optional) — A number (not text), 0 or more, up to 2 decimal places and 12 digits in total.
- `company_gst` (string, optional) — A valid GSTIN, for example `24AAACB5343E1Z7` (upper-cased for you).
- `currency` (enum, optional)
  - Allowed values: `BDT`, `ZAR`, `MYR`, `SGD`, `PHP`, `MUR`, `AED`, `IDR`, `INR`, `USD`, `THB`, `MXN`, `GB`, `KW`, `QA`, `SA`, `EG`

## Response

### 201

The employment history entry was added.

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

## Errors

### 400 Bad Request Error

Validation failed, or the staff member is inactive.

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

### 403 Forbidden Error

The key owner may not make this change: they no longer have access, or (Custom role) lack the permission or scope.

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

### 404 Not Found Error

No eligible active staff member with this `salarybox_id` exists in your company.

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

### Example

**Request**

```json
{
  "company_name": "Globex Pvt Ltd",
  "designation": "Analyst",
  "joining_date": "2022-04-01",
  "leaving_date": "2025-03-31",
  "salary": 45000,
  "company_gst": "24AAACB5343E1Z7",
  "currency": "INR"
}
```

**Response**

```json
{
  "message": "Employment history added successfully",
  "status": true,
  "data": {
    "salarybox_id": "ABCDEFGHIJ",
    "company_name": "Globex Pvt Ltd",
    "designation": "Analyst",
    "joining_date": "2022-04-01",
    "leaving_date": "2025-03-31",
    "salary": "45000.00",
    "currency": "INR",
    "company_gst": "24AAACB5343E1Z7"
  }
}
```

**SDK Code**

```python Example
import requests

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

payload = {
    "company_name": "Globex Pvt Ltd",
    "designation": "Analyst",
    "joining_date": "2022-04-01",
    "leaving_date": "2025-03-31",
    "salary": 45000,
    "company_gst": "24AAACB5343E1Z7",
    "currency": "INR"
}
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/staff/ABCDEFGHIJ/employment-history';
const options = {
  method: 'POST',
  headers: {Authorization: 'Api-Key  <apiKey>', 'Content-Type': 'application/json'},
  body: '{"company_name":"Globex Pvt Ltd","designation":"Analyst","joining_date":"2022-04-01","leaving_date":"2025-03-31","salary":45000,"company_gst":"24AAACB5343E1Z7","currency":"INR"}'
};

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\": \"Globex Pvt Ltd\",\n  \"designation\": \"Analyst\",\n  \"joining_date\": \"2022-04-01\",\n  \"leaving_date\": \"2025-03-31\",\n  \"salary\": 45000,\n  \"company_gst\": \"24AAACB5343E1Z7\",\n  \"currency\": \"INR\"\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/staff/ABCDEFGHIJ/employment-history")

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  \"company_name\": \"Globex Pvt Ltd\",\n  \"designation\": \"Analyst\",\n  \"joining_date\": \"2022-04-01\",\n  \"leaving_date\": \"2025-03-31\",\n  \"salary\": 45000,\n  \"company_gst\": \"24AAACB5343E1Z7\",\n  \"currency\": \"INR\"\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/staff/ABCDEFGHIJ/employment-history")
  .header("Authorization", "Api-Key  <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"company_name\": \"Globex Pvt Ltd\",\n  \"designation\": \"Analyst\",\n  \"joining_date\": \"2022-04-01\",\n  \"leaving_date\": \"2025-03-31\",\n  \"salary\": 45000,\n  \"company_gst\": \"24AAACB5343E1Z7\",\n  \"currency\": \"INR\"\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/staff/ABCDEFGHIJ/employment-history', [
  'body' => '{
  "company_name": "Globex Pvt Ltd",
  "designation": "Analyst",
  "joining_date": "2022-04-01",
  "leaving_date": "2025-03-31",
  "salary": 45000,
  "company_gst": "24AAACB5343E1Z7",
  "currency": "INR"
}',
  '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.POST);
request.AddHeader("Authorization", "Api-Key  <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"company_name\": \"Globex Pvt Ltd\",\n  \"designation\": \"Analyst\",\n  \"joining_date\": \"2022-04-01\",\n  \"leaving_date\": \"2025-03-31\",\n  \"salary\": 45000,\n  \"company_gst\": \"24AAACB5343E1Z7\",\n  \"currency\": \"INR\"\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": "Globex Pvt Ltd",
  "designation": "Analyst",
  "joining_date": "2022-04-01",
  "leaving_date": "2025-03-31",
  "salary": 45000,
  "company_gst": "24AAACB5343E1Z7",
  "currency": "INR"
] 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 = "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()
```

### Only the required field

**Request**

```json
{
  "company_name": "Globex Pvt Ltd"
}
```

**Response**

```json
{
  "message": "Employment history added successfully",
  "status": true,
  "data": {
    "salarybox_id": "ABCDEFGHIJ",
    "company_name": "Globex Pvt Ltd",
    "designation": "Analyst",
    "joining_date": "2022-04-01",
    "leaving_date": "2025-03-31",
    "salary": "45000.00",
    "currency": "INR",
    "company_gst": "24AAACB5343E1Z7"
  }
}
```

**SDK Code**

```python Only the required field
import requests

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

payload = { "company_name": "Globex Pvt Ltd" }
headers = {
    "Authorization": "Api-Key  <apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Only the required field
const url = 'https://api.salaryboxapp.com/v2/customer/v1/staff/ABCDEFGHIJ/employment-history';
const options = {
  method: 'POST',
  headers: {Authorization: 'Api-Key  <apiKey>', 'Content-Type': 'application/json'},
  body: '{"company_name":"Globex Pvt Ltd"}'
};

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

```go Only the required field
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\": \"Globex Pvt Ltd\"\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 Only the required field
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::Post.new(url)
request["Authorization"] = 'Api-Key  <apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"company_name\": \"Globex Pvt Ltd\"\n}"

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

```java Only the required field
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("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\": \"Globex Pvt Ltd\"\n}")
  .asString();
```

```php Only the required field
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.salaryboxapp.com/v2/customer/v1/staff/ABCDEFGHIJ/employment-history', [
  'body' => '{
  "company_name": "Globex Pvt Ltd"
}',
  'headers' => [
    'Authorization' => 'Api-Key  <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Only the required field
using RestSharp;

var client = new RestClient("https://api.salaryboxapp.com/v2/customer/v1/staff/ABCDEFGHIJ/employment-history");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Api-Key  <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"company_name\": \"Globex Pvt Ltd\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Only the required field
import Foundation

let headers = [
  "Authorization": "Api-Key  <apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["company_name": "Globex Pvt Ltd"] 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 = "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()
```