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

POST https://api.salaryboxapp.com/v2/customer/v1/company/branch
Content-Type: application/json

Adds a branch (work location). Shared rules: see [Writing data](/conventions#writing-data).

- The body is closed: an unknown field is refused with `400` `"Unknown field."` Counts toward your write budget.
- `name` is required, at most 200 characters, and must be unique in the company: `400` on `name`, "A branch with this name already exists." Repeating the same request is harmless.
- `address` is at most 500 characters.
- `latitude` (-90 to 90) and `longitude` (-180 to 180) are sent together, otherwise `400` "Send latitude and longitude together."
- `radius` is the location-based attendance radius in metres, 50 to 1000. Default 200.
- A plan with a branch limit refuses more branches with `403`.
- There is no delete.


Reference: https://docs.salarybox.in/api-reference/company/branch-create

## Authentication

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

## Request

### Body (application/json)

This endpoint expects a BranchCreateRequest.

- `name` (string, required) — Branch name. Unique in the company.
- `address` (string, optional) — Address.
- `latitude` (double, optional) — Latitude. Send with `longitude`.
- `longitude` (double, optional) — Longitude. Send with `latitude`.
- `radius` (integer, optional) — Location-based attendance radius in metres. Default 200.

## Response

### 201

The branch was added.

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

## Errors

### 400 Bad Request Error

Validation failed.

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

### 403 Forbidden Error

The requester is not an Admin, the plan's branch limit is reached, or your company has no active subscription.

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

## Types

### BranchWriteResponseData

- `name` (string, optional) — Branch name.
- `address` (string, optional, nullable) — Address, or `null`.
- `latitude` (double, optional, nullable) — Latitude, or `null`.
- `longitude` (double, optional, nullable) — Longitude, or `null`.
- `radius` (integer, optional) — Radius in metres.

## Examples

### Example

**Response**

```json
{
  "message": "Branch added successfully",
  "status": true,
  "data": {
    "name": "Bengaluru HQ",
    "address": "3rd Floor, Prestige Tech Park, Outer Ring Road, Bengaluru, Karnataka 560103",
    "latitude": 12.935192,
    "longitude": 77.692047,
    "radius": 200
  }
}
```

**SDK Code**

```python Example
import requests

url = "https://api.salaryboxapp.com/v2/customer/v1/company/branch"

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

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

print(response.json())
```

```javascript Example
const url = 'https://api.salaryboxapp.com/v2/customer/v1/company/branch';
const options = {method: 'POST', 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/company/branch"

	req, _ := http.NewRequest("POST", 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/company/branch")

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

request = Net::HTTP::Post.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.post("https://api.salaryboxapp.com/v2/customer/v1/company/branch")
  .header("Authorization", "Api-Key  <apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.salaryboxapp.com/v2/customer/v1/company/branch', [
  'headers' => [
    'Authorization' => 'Api-Key  <apiKey>',
  ],
]);

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

```csharp Example
using RestSharp;

var client = new RestClient("https://api.salaryboxapp.com/v2/customer/v1/company/branch");
var request = new RestRequest(Method.POST);
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/company/branch")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```

### Branch with a location

**Request**

```json
{
  "name": "Bengaluru HQ",
  "address": "3rd Floor, Prestige Tech Park, Outer Ring Road, Bengaluru, Karnataka 560103",
  "latitude": 12.935192,
  "longitude": 77.692047,
  "radius": 200
}
```

**Response**

```json
{
  "message": "Branch added successfully",
  "status": true,
  "data": {
    "name": "Bengaluru HQ",
    "address": "3rd Floor, Prestige Tech Park, Outer Ring Road, Bengaluru, Karnataka 560103",
    "latitude": 12.935192,
    "longitude": 77.692047,
    "radius": 200
  }
}
```

**SDK Code**

```python Branch with a location
import requests

url = "https://api.salaryboxapp.com/v2/customer/v1/company/branch"

payload = {
    "name": "Bengaluru HQ",
    "address": "3rd Floor, Prestige Tech Park, Outer Ring Road, Bengaluru, Karnataka 560103",
    "latitude": 12.935192,
    "longitude": 77.692047,
    "radius": 200
}
headers = {
    "Authorization": "Api-Key  <apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Branch with a location
const url = 'https://api.salaryboxapp.com/v2/customer/v1/company/branch';
const options = {
  method: 'POST',
  headers: {Authorization: 'Api-Key  <apiKey>', 'Content-Type': 'application/json'},
  body: '{"name":"Bengaluru HQ","address":"3rd Floor, Prestige Tech Park, Outer Ring Road, Bengaluru, Karnataka 560103","latitude":12.935192,"longitude":77.692047,"radius":200}'
};

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

```go Branch with a location
package main

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

func main() {

	url := "https://api.salaryboxapp.com/v2/customer/v1/company/branch"

	payload := strings.NewReader("{\n  \"name\": \"Bengaluru HQ\",\n  \"address\": \"3rd Floor, Prestige Tech Park, Outer Ring Road, Bengaluru, Karnataka 560103\",\n  \"latitude\": 12.935192,\n  \"longitude\": 77.692047,\n  \"radius\": 200\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 Branch with a location
require 'uri'
require 'net/http'

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

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  \"name\": \"Bengaluru HQ\",\n  \"address\": \"3rd Floor, Prestige Tech Park, Outer Ring Road, Bengaluru, Karnataka 560103\",\n  \"latitude\": 12.935192,\n  \"longitude\": 77.692047,\n  \"radius\": 200\n}"

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

```java Branch with a location
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.salaryboxapp.com/v2/customer/v1/company/branch")
  .header("Authorization", "Api-Key  <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Bengaluru HQ\",\n  \"address\": \"3rd Floor, Prestige Tech Park, Outer Ring Road, Bengaluru, Karnataka 560103\",\n  \"latitude\": 12.935192,\n  \"longitude\": 77.692047,\n  \"radius\": 200\n}")
  .asString();
```

```php Branch with a location
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.salaryboxapp.com/v2/customer/v1/company/branch', [
  'body' => '{
  "name": "Bengaluru HQ",
  "address": "3rd Floor, Prestige Tech Park, Outer Ring Road, Bengaluru, Karnataka 560103",
  "latitude": 12.935192,
  "longitude": 77.692047,
  "radius": 200
}',
  'headers' => [
    'Authorization' => 'Api-Key  <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Branch with a location
using RestSharp;

var client = new RestClient("https://api.salaryboxapp.com/v2/customer/v1/company/branch");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Api-Key  <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Bengaluru HQ\",\n  \"address\": \"3rd Floor, Prestige Tech Park, Outer Ring Road, Bengaluru, Karnataka 560103\",\n  \"latitude\": 12.935192,\n  \"longitude\": 77.692047,\n  \"radius\": 200\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Branch with a location
import Foundation

let headers = [
  "Authorization": "Api-Key  <apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Bengaluru HQ",
  "address": "3rd Floor, Prestige Tech Park, Outer Ring Road, Bengaluru, Karnataka 560103",
  "latitude": 12.935192,
  "longitude": 77.692047,
  "radius": 200
] as [String : Any]

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

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

### Branch with just a name

**Request**

```json
{
  "name": "Pune Plant"
}
```

**Response**

```json
{
  "message": "Branch added successfully",
  "status": true,
  "data": {
    "name": "Bengaluru HQ",
    "address": "3rd Floor, Prestige Tech Park, Outer Ring Road, Bengaluru, Karnataka 560103",
    "latitude": 12.935192,
    "longitude": 77.692047,
    "radius": 200
  }
}
```

**SDK Code**

```python Branch with just a name
import requests

url = "https://api.salaryboxapp.com/v2/customer/v1/company/branch"

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

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

print(response.json())
```

```javascript Branch with just a name
const url = 'https://api.salaryboxapp.com/v2/customer/v1/company/branch';
const options = {
  method: 'POST',
  headers: {Authorization: 'Api-Key  <apiKey>', 'Content-Type': 'application/json'},
  body: '{"name":"Pune Plant"}'
};

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

```go Branch with just a name
package main

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

func main() {

	url := "https://api.salaryboxapp.com/v2/customer/v1/company/branch"

	payload := strings.NewReader("{\n  \"name\": \"Pune Plant\"\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 Branch with just a name
require 'uri'
require 'net/http'

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

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  \"name\": \"Pune Plant\"\n}"

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

```java Branch with just a name
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.salaryboxapp.com/v2/customer/v1/company/branch")
  .header("Authorization", "Api-Key  <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Pune Plant\"\n}")
  .asString();
```

```php Branch with just a name
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.salaryboxapp.com/v2/customer/v1/company/branch', [
  'body' => '{
  "name": "Pune Plant"
}',
  'headers' => [
    'Authorization' => 'Api-Key  <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Branch with just a name
using RestSharp;

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

```swift Branch with just a name
import Foundation

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

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

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