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

PUT https://api.salaryboxapp.com/v2/customer/v1/payroll/loan/repayment
Content-Type: application/json

Changes one existing loan repayment entry of a staff member in payroll. It corrects the saved record and moves no money. Shared rules: see [Writing data](/conventions#writing-data). Needs Payroll on your plan.

- There are no entry ids. Find the entry with `GET /payroll/loan/repayment` and send its current values (`salarybox_id`, `date` and `amount`) exactly as listed, plus `new_` fields for what changes. Anything left out stays as it is.
- At least one `new_` field is required; otherwise `400` under `non_field_errors`: "Send at least one new_ field to change."
- No entry matches: `404` "Entry not found." with the error under `amount`.
- More than one entry matches (identical entries on one day): `400` under `amount`: "More than one entry matches. Edit it in the SalaryBox app."
- `salarybox_id` is an active staff member of the company.
- `date` is the entry's current date, `YYYY-MM-DD`. `new_date` is optional, `YYYY-MM-DD` and not in the future.
- `amount` is the entry's current amount, a JSON number, 0 or more with up to 6 decimals; send it as the list returned it. `new_amount` is optional, a JSON number from 0.01 to 10000000 with up to 2 decimals.
- `new_notes` is optional, at max 500 characters, trimmed. Notes can be changed but not cleared.
- `deduct_from_salary` can't be changed here; sending it gives `400` "Unknown field."
- It is refused if the month of `date` or `new_date` is finalised: `400` on that field.
- `new_amount` can't exceed the outstanding loan plus this repayment: `400` on it, for example "This is more than the outstanding loan. The highest it can be is 5000.0."
- The staff member gets an in-app notification that it was updated, and no SMS.
- Changing `new_amount` or any value used to find the entry means a repeat of the same request finds nothing and gets `404`, so nothing changes twice. If only other fields changed, a repeat sets the same values.


Reference: https://docs.salarybox.in/api-reference/payroll/loan-repayment-update

## Authentication

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

## Request

### Body (application/json)

This endpoint expects a PayrollLoanRepaymentUpdateRequest.

- `salarybox_id` (string, required) — SalaryBox ID of an active staff member.
- `date` (date, required) — The entry's current date, `YYYY-MM-DD`.
- `amount` (double, required) — The entry's current amount, up to 6 decimals. Must be a JSON number.
- `new_amount` (double, optional) — Up to 2 decimals. Must be a JSON number.
- `new_date` (date, optional) — `YYYY-MM-DD`. Not in the future. The month it moves to must not be finalised.
- `new_notes` (string, optional) — Notes can be changed but not cleared.

## Response

### 200

The loan repayment was updated. `data` holds the new values.

- `message` (string, optional)
- `status` (boolean, optional)
- `data` (PayrollLoanRepaymentEntry, optional)

## Errors

### 400 Bad Request Error

Validation failed, no `new_` field was sent, the new date is in the future, a payroll month involved is finalised, the new amount is more than the outstanding loan, more than one entry matches, or the staff member is inactive.

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

### 403 Forbidden Error

Your plan does not include payroll.

- `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, or no entry has these values on this date.

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

## Types

### PayrollLoanRepaymentEntry

- `salarybox_id` (string, optional)
- `date` (date, optional)
- `amount` (double, optional)
- `notes` (string, optional)
- `deduct_from_salary` (boolean, optional)

## Examples

**Request**

```json
{
  "salarybox_id": "SBX1234567",
  "date": "2026-11-03",
  "amount": 2500,
  "new_amount": 3000,
  "new_notes": "Revised instalment"
}
```

**Response**

```json
{
  "message": "Loan repayment updated successfully",
  "status": true,
  "data": {
    "salarybox_id": "SBX1234567",
    "date": "2026-11-03",
    "amount": 3000,
    "notes": "Revised instalment",
    "deduct_from_salary": true
  }
}
```

**SDK Code**

```python Example
import requests

url = "https://api.salaryboxapp.com/v2/customer/v1/payroll/loan/repayment"

payload = {
    "salarybox_id": "SBX1234567",
    "date": "2026-11-03",
    "amount": 2500,
    "new_amount": 3000,
    "new_notes": "Revised instalment"
}
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/payroll/loan/repayment';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Api-Key  <apiKey>', 'Content-Type': 'application/json'},
  body: '{"salarybox_id":"SBX1234567","date":"2026-11-03","amount":2500,"new_amount":3000,"new_notes":"Revised instalment"}'
};

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/payroll/loan/repayment"

	payload := strings.NewReader("{\n  \"salarybox_id\": \"SBX1234567\",\n  \"date\": \"2026-11-03\",\n  \"amount\": 2500,\n  \"new_amount\": 3000,\n  \"new_notes\": \"Revised instalment\"\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/payroll/loan/repayment")

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  \"salarybox_id\": \"SBX1234567\",\n  \"date\": \"2026-11-03\",\n  \"amount\": 2500,\n  \"new_amount\": 3000,\n  \"new_notes\": \"Revised instalment\"\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/payroll/loan/repayment")
  .header("Authorization", "Api-Key  <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"salarybox_id\": \"SBX1234567\",\n  \"date\": \"2026-11-03\",\n  \"amount\": 2500,\n  \"new_amount\": 3000,\n  \"new_notes\": \"Revised instalment\"\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/payroll/loan/repayment', [
  'body' => '{
  "salarybox_id": "SBX1234567",
  "date": "2026-11-03",
  "amount": 2500,
  "new_amount": 3000,
  "new_notes": "Revised instalment"
}',
  '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/payroll/loan/repayment");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Api-Key  <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"salarybox_id\": \"SBX1234567\",\n  \"date\": \"2026-11-03\",\n  \"amount\": 2500,\n  \"new_amount\": 3000,\n  \"new_notes\": \"Revised instalment\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Example
import Foundation

let headers = [
  "Authorization": "Api-Key  <apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "salarybox_id": "SBX1234567",
  "date": "2026-11-03",
  "amount": 2500,
  "new_amount": 3000,
  "new_notes": "Revised instalment"
] as [String : Any]

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

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