Customer Credits
Link customer credit
Links a customer credit to a sales invoice
POST
/
v1
/
customer-credits
/
{customerCreditId}
/
invoice-receivables
/
{invoiceReceivableId}
Link customer credit
curl --request POST \
--url https://api.light.inc/v1/customer-credits/{customerCreditId}/invoice-receivables/{invoiceReceivableId} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json;charset=UTF-8' \
--data '{
"amount": 123
}'import requests
url = "https://api.light.inc/v1/customer-credits/{customerCreditId}/invoice-receivables/{invoiceReceivableId}"
payload = { "amount": 123 }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json;charset=UTF-8"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify({amount: 123})
};
fetch('https://api.light.inc/v1/customer-credits/{customerCreditId}/invoice-receivables/{invoiceReceivableId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.light.inc/v1/customer-credits/{customerCreditId}/invoice-receivables/{invoiceReceivableId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json;charset=UTF-8"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.light.inc/v1/customer-credits/{customerCreditId}/invoice-receivables/{invoiceReceivableId}"
payload := strings.NewReader("{\n \"amount\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json;charset=UTF-8")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.light.inc/v1/customer-credits/{customerCreditId}/invoice-receivables/{invoiceReceivableId}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json;charset=UTF-8")
.body("{\n \"amount\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.light.inc/v1/customer-credits/{customerCreditId}/invoice-receivables/{invoiceReceivableId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json;charset=UTF-8'
request.body = "{\n \"amount\": 123\n}"
response = http.request(request)
puts response.read_body{
"companyId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customerCredit": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"documentNumber": "<string>",
"documentDate": "2023-12-25",
"status": "DRAFT",
"amount": 123,
"currency": "USD"
},
"invoiceReceivable": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"documentNumber": "<string>",
"documentDate": "2023-12-25",
"status": "DRAFT",
"amount": 123,
"currency": "USD"
},
"amount": 123,
"linkedAt": "2023-11-07T05:31:56Z"
}Authorizations
apiKeyAuthbearerAuth
Basic authentication header of the form Basic <api_key>, where <api_key> is your api key.
Body
application/json;charset=UTF-8
Amount of the customer credit to apply to the sales invoice, in the smallest currency unit. If omitted, the remaining unallocated customer-credit balance is applied, capped by the invoice receivable's remaining balance. Partial allocation is not supported for entities configured with an e-invoicing provider.
Response
default - application/json;charset=UTF-8
default response
ID of the company
Invoice payable details
Show child attributes
Show child attributes
Invoice payable details
Show child attributes
Show child attributes
Amount of the customer credit applied to the sales invoice, in the smallest currency unit
Timestamp when the customer credit was linked to the sales invoice
⌘I
Link customer credit
curl --request POST \
--url https://api.light.inc/v1/customer-credits/{customerCreditId}/invoice-receivables/{invoiceReceivableId} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json;charset=UTF-8' \
--data '{
"amount": 123
}'import requests
url = "https://api.light.inc/v1/customer-credits/{customerCreditId}/invoice-receivables/{invoiceReceivableId}"
payload = { "amount": 123 }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json;charset=UTF-8"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify({amount: 123})
};
fetch('https://api.light.inc/v1/customer-credits/{customerCreditId}/invoice-receivables/{invoiceReceivableId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.light.inc/v1/customer-credits/{customerCreditId}/invoice-receivables/{invoiceReceivableId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json;charset=UTF-8"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.light.inc/v1/customer-credits/{customerCreditId}/invoice-receivables/{invoiceReceivableId}"
payload := strings.NewReader("{\n \"amount\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json;charset=UTF-8")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.light.inc/v1/customer-credits/{customerCreditId}/invoice-receivables/{invoiceReceivableId}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json;charset=UTF-8")
.body("{\n \"amount\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.light.inc/v1/customer-credits/{customerCreditId}/invoice-receivables/{invoiceReceivableId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json;charset=UTF-8'
request.body = "{\n \"amount\": 123\n}"
response = http.request(request)
puts response.read_body{
"companyId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customerCredit": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"documentNumber": "<string>",
"documentDate": "2023-12-25",
"status": "DRAFT",
"amount": 123,
"currency": "USD"
},
"invoiceReceivable": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"documentNumber": "<string>",
"documentDate": "2023-12-25",
"status": "DRAFT",
"amount": 123,
"currency": "USD"
},
"amount": 123,
"linkedAt": "2023-11-07T05:31:56Z"
}