Skip to main content
POST
/
credit_notes
/
estimate
Estimate amounts for a new credit note
curl --request POST \
  --url https://api.getlago.com/api/v1/credit_notes/estimate \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "credit_note": {
    "invoice_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
    "items": [
      {
        "fee_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
        "amount_cents": 10
      },
      {
        "fee_id": "1a901a90-1a90-1a90-1a90-1a901a901a91",
        "amount_cents": 5
      }
    ]
  }
}
'
import requests

url = "https://api.getlago.com/api/v1/credit_notes/estimate"

payload = { "credit_note": {
"invoice_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"items": [
{
"fee_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"amount_cents": 10
},
{
"fee_id": "1a901a90-1a90-1a90-1a90-1a901a901a91",
"amount_cents": 5
}
]
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

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

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
credit_note: {
invoice_id: '1a901a90-1a90-1a90-1a90-1a901a901a90',
items: [
{fee_id: '1a901a90-1a90-1a90-1a90-1a901a901a90', amount_cents: 10},
{fee_id: '1a901a90-1a90-1a90-1a90-1a901a901a91', amount_cents: 5}
]
}
})
};

fetch('https://api.getlago.com/api/v1/credit_notes/estimate', 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.getlago.com/api/v1/credit_notes/estimate",
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([
'credit_note' => [
'invoice_id' => '1a901a90-1a90-1a90-1a90-1a901a901a90',
'items' => [
[
'fee_id' => '1a901a90-1a90-1a90-1a90-1a901a901a90',
'amount_cents' => 10
],
[
'fee_id' => '1a901a90-1a90-1a90-1a90-1a901a901a91',
'amount_cents' => 5
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$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.getlago.com/api/v1/credit_notes/estimate"

payload := strings.NewReader("{\n \"credit_note\": {\n \"invoice_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"items\": [\n {\n \"fee_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"amount_cents\": 10\n },\n {\n \"fee_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a91\",\n \"amount_cents\": 5\n }\n ]\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

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.getlago.com/api/v1/credit_notes/estimate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"credit_note\": {\n \"invoice_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"items\": [\n {\n \"fee_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"amount_cents\": 10\n },\n {\n \"fee_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a91\",\n \"amount_cents\": 5\n }\n ]\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.getlago.com/api/v1/credit_notes/estimate")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"credit_note\": {\n \"invoice_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"items\": [\n {\n \"fee_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\",\n \"amount_cents\": 10\n },\n {\n \"fee_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a91\",\n \"amount_cents\": 5\n }\n ]\n }\n}"

response = http.request(request)
puts response.read_body
{
  "estimated_credit_note": {
    "lago_invoice_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
    "invoice_number": "LAG-1234",
    "currency": "EUR",
    "taxes_amount_cents": 20,
    "precise_taxes_amount_cents": 20.1,
    "taxes_rate": 20,
    "sub_total_excluding_taxes_amount_cents": 100,
    "max_creditable_amount_cents": 100,
    "max_refundable_amount_cents": 0,
    "max_offsettable_amount_cents": 0,
    "coupons_adjustment_amount_cents": 20,
    "precise_coupons_adjustment_amount_cents": 20.1,
    "items": [
      {
        "amount_cents": 100,
        "lago_fee_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
      }
    ],
    "applied_taxes": [
      {
        "lago_tax_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
        "tax_name": "TVA",
        "tax_code": "french_standard_vat",
        "tax_rate": 20,
        "tax_description": "French standard VAT",
        "base_amount_cents": 100,
        "amount_cents": 2000,
        "amount_currency": "USD"
      }
    ]
  }
}
{
"status": 400,
"error": "Bad request"
}
{
"status": 401,
"error": "Unauthorized"
}
{
"status": 422,
"error": "Unprocessable entity",
"code": "validation_errors",
"error_details": {}
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Credit note estimate payload

credit_note
object
required

Response

Credit note amounts

estimated_credit_note
object
required