Create credit note
curl --request POST \
--url https://api.getlago.com/api/v2/credit_notes \
--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": 100
}
],
"reason": "duplicated_charge",
"description": "Partial credit",
"credit_amount_cents": 100,
"refund_amount_cents": 0,
"offset_amount_cents": 0,
"metadata": {}
}
}
'import requests
url = "https://api.getlago.com/api/v2/credit_notes"
payload = { "credit_note": {
"invoice_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"items": [
{
"fee_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"amount_cents": 100
}
],
"reason": "duplicated_charge",
"description": "Partial credit",
"credit_amount_cents": 100,
"refund_amount_cents": 0,
"offset_amount_cents": 0,
"metadata": {}
} }
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: 100}],
reason: 'duplicated_charge',
description: 'Partial credit',
credit_amount_cents: 100,
refund_amount_cents: 0,
offset_amount_cents: 0,
metadata: {}
}
})
};
fetch('https://api.getlago.com/api/v2/credit_notes', 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/v2/credit_notes",
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' => 100
]
],
'reason' => 'duplicated_charge',
'description' => 'Partial credit',
'credit_amount_cents' => 100,
'refund_amount_cents' => 0,
'offset_amount_cents' => 0,
'metadata' => [
]
]
]),
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/v2/credit_notes"
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\": 100\n }\n ],\n \"reason\": \"duplicated_charge\",\n \"description\": \"Partial credit\",\n \"credit_amount_cents\": 100,\n \"refund_amount_cents\": 0,\n \"offset_amount_cents\": 0,\n \"metadata\": {}\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/v2/credit_notes")
.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\": 100\n }\n ],\n \"reason\": \"duplicated_charge\",\n \"description\": \"Partial credit\",\n \"credit_amount_cents\": 100,\n \"refund_amount_cents\": 0,\n \"offset_amount_cents\": 0,\n \"metadata\": {}\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getlago.com/api/v2/credit_notes")
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\": 100\n }\n ],\n \"reason\": \"duplicated_charge\",\n \"description\": \"Partial credit\",\n \"credit_amount_cents\": 100,\n \"refund_amount_cents\": 0,\n \"offset_amount_cents\": 0,\n \"metadata\": {}\n }\n}"
response = http.request(request)
puts response.read_body{
"credit_note": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"billing_entity_code": "main",
"sequential_id": 1,
"number": "example",
"lago_invoice_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"invoice_number": "INV-001",
"purchase_order_number": "PO-123",
"issuing_date": "2022-04-29",
"credit_status": "available",
"refund_status": "pending",
"reason": "duplicated_charge",
"description": "Example",
"currency": "USD",
"sub_total_excluding_taxes_amount_cents": 100,
"taxes_amount_cents": 100,
"sub_total_including_taxes_amount_cents": 120,
"total_amount_cents": 100,
"balance_amount_cents": 100,
"credit_amount_cents": 100,
"refund_amount_cents": 100,
"offset_amount_cents": 100,
"file_url": "https://documents.example/invoice.pdf",
"xml_url": "https://documents.example/invoice.pdf",
"self_billed": false,
"created_at": "2022-04-29T08:59:51.123456Z",
"updated_at": "2022-04-29T08:59:51.123456Z",
"items": [
{
"lago_fee_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"amount_cents": 100
}
],
"applied_taxes": [
{
"lago_tax_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"tax_name": "example",
"tax_code": "example",
"tax_rate": 20,
"tax_description": "example",
"base_amount_cents": 100,
"amount_cents": 100
}
],
"customer": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"billing_entity_code": "main",
"external_id": "customer_123",
"account_type": "customer",
"name": "example",
"firstname": "example",
"lastname": "example",
"customer_type": "company",
"sequential_id": 100,
"slug": "example",
"country": "example",
"address_line1": "example",
"address_line2": "example",
"state": "example",
"zipcode": "example",
"email": "billing@acme.example",
"city": "example",
"url": "example",
"phone": "example",
"logo_url": "example",
"legal_name": "example",
"legal_number": "example",
"currency": "USD",
"tax_identification_number": "example",
"timezone": "example",
"applicable_timezone": "Europe/Paris",
"external_salesforce_id": "example",
"finalize_zero_amount_invoice": "inherit",
"skip_invoice_custom_sections": false,
"invoice_grace_period": 1,
"periodic_invoice_issuing_date_anchor": "current_period_end",
"periodic_invoice_issuing_date_adjustment": "keep_anchor",
"payment_provider": "example",
"payment_provider_code": "example",
"provider_customer_id": "cus_example",
"provider_payment_methods": [
"card"
],
"document_locale": "example",
"created_at": "2022-04-29T08:59:51.123456Z",
"updated_at": "2022-04-29T08:59:51.123456Z",
"deleted_at": null,
"x402_agent_address": "0x0000000000000000000000000000000000000000"
},
"error_details": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"error_code": "not_provided",
"details": {}
}
],
"metadata": {}
}
}{
"code": "invalid_expand",
"details": [
{
"code": "malformed",
"field": "expands",
"meta": {
"allowed_values": []
}
}
]
}{
"code": "unauthorized",
"details": []
}{
"code": "feature_unavailable",
"details": []
}{
"code": "resource_not_found",
"details": [
{
"code": "resource_not_found",
"field": "base",
"meta": {
"resource": "resource_name"
}
}
]
}{
"code": "validation_errors",
"details": [
{
"code": "value_is_mandatory",
"field": "name",
"meta": {}
}
]
}Credit notes
Create credit note
Requires a premium license and an eligible invoice.
POST
/
credit_notes
Create credit note
curl --request POST \
--url https://api.getlago.com/api/v2/credit_notes \
--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": 100
}
],
"reason": "duplicated_charge",
"description": "Partial credit",
"credit_amount_cents": 100,
"refund_amount_cents": 0,
"offset_amount_cents": 0,
"metadata": {}
}
}
'import requests
url = "https://api.getlago.com/api/v2/credit_notes"
payload = { "credit_note": {
"invoice_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"items": [
{
"fee_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"amount_cents": 100
}
],
"reason": "duplicated_charge",
"description": "Partial credit",
"credit_amount_cents": 100,
"refund_amount_cents": 0,
"offset_amount_cents": 0,
"metadata": {}
} }
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: 100}],
reason: 'duplicated_charge',
description: 'Partial credit',
credit_amount_cents: 100,
refund_amount_cents: 0,
offset_amount_cents: 0,
metadata: {}
}
})
};
fetch('https://api.getlago.com/api/v2/credit_notes', 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/v2/credit_notes",
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' => 100
]
],
'reason' => 'duplicated_charge',
'description' => 'Partial credit',
'credit_amount_cents' => 100,
'refund_amount_cents' => 0,
'offset_amount_cents' => 0,
'metadata' => [
]
]
]),
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/v2/credit_notes"
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\": 100\n }\n ],\n \"reason\": \"duplicated_charge\",\n \"description\": \"Partial credit\",\n \"credit_amount_cents\": 100,\n \"refund_amount_cents\": 0,\n \"offset_amount_cents\": 0,\n \"metadata\": {}\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/v2/credit_notes")
.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\": 100\n }\n ],\n \"reason\": \"duplicated_charge\",\n \"description\": \"Partial credit\",\n \"credit_amount_cents\": 100,\n \"refund_amount_cents\": 0,\n \"offset_amount_cents\": 0,\n \"metadata\": {}\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getlago.com/api/v2/credit_notes")
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\": 100\n }\n ],\n \"reason\": \"duplicated_charge\",\n \"description\": \"Partial credit\",\n \"credit_amount_cents\": 100,\n \"refund_amount_cents\": 0,\n \"offset_amount_cents\": 0,\n \"metadata\": {}\n }\n}"
response = http.request(request)
puts response.read_body{
"credit_note": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"billing_entity_code": "main",
"sequential_id": 1,
"number": "example",
"lago_invoice_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"invoice_number": "INV-001",
"purchase_order_number": "PO-123",
"issuing_date": "2022-04-29",
"credit_status": "available",
"refund_status": "pending",
"reason": "duplicated_charge",
"description": "Example",
"currency": "USD",
"sub_total_excluding_taxes_amount_cents": 100,
"taxes_amount_cents": 100,
"sub_total_including_taxes_amount_cents": 120,
"total_amount_cents": 100,
"balance_amount_cents": 100,
"credit_amount_cents": 100,
"refund_amount_cents": 100,
"offset_amount_cents": 100,
"file_url": "https://documents.example/invoice.pdf",
"xml_url": "https://documents.example/invoice.pdf",
"self_billed": false,
"created_at": "2022-04-29T08:59:51.123456Z",
"updated_at": "2022-04-29T08:59:51.123456Z",
"items": [
{
"lago_fee_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"amount_cents": 100
}
],
"applied_taxes": [
{
"lago_tax_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"tax_name": "example",
"tax_code": "example",
"tax_rate": 20,
"tax_description": "example",
"base_amount_cents": 100,
"amount_cents": 100
}
],
"customer": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"billing_entity_code": "main",
"external_id": "customer_123",
"account_type": "customer",
"name": "example",
"firstname": "example",
"lastname": "example",
"customer_type": "company",
"sequential_id": 100,
"slug": "example",
"country": "example",
"address_line1": "example",
"address_line2": "example",
"state": "example",
"zipcode": "example",
"email": "billing@acme.example",
"city": "example",
"url": "example",
"phone": "example",
"logo_url": "example",
"legal_name": "example",
"legal_number": "example",
"currency": "USD",
"tax_identification_number": "example",
"timezone": "example",
"applicable_timezone": "Europe/Paris",
"external_salesforce_id": "example",
"finalize_zero_amount_invoice": "inherit",
"skip_invoice_custom_sections": false,
"invoice_grace_period": 1,
"periodic_invoice_issuing_date_anchor": "current_period_end",
"periodic_invoice_issuing_date_adjustment": "keep_anchor",
"payment_provider": "example",
"payment_provider_code": "example",
"provider_customer_id": "cus_example",
"provider_payment_methods": [
"card"
],
"document_locale": "example",
"created_at": "2022-04-29T08:59:51.123456Z",
"updated_at": "2022-04-29T08:59:51.123456Z",
"deleted_at": null,
"x402_agent_address": "0x0000000000000000000000000000000000000000"
},
"error_details": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"error_code": "not_provided",
"details": {}
}
],
"metadata": {}
}
}{
"code": "invalid_expand",
"details": [
{
"code": "malformed",
"field": "expands",
"meta": {
"allowed_values": []
}
}
]
}{
"code": "unauthorized",
"details": []
}{
"code": "feature_unavailable",
"details": []
}{
"code": "resource_not_found",
"details": [
{
"code": "resource_not_found",
"field": "base",
"meta": {
"resource": "resource_name"
}
}
]
}{
"code": "validation_errors",
"details": [
{
"code": "value_is_mandatory",
"field": "name",
"meta": {}
}
]
}API v2 is in beta. Endpoints return the
X-Lago-Endpoint-Status: beta header.This endpoint changes billing or financial records. Check the target environment, the resource identifier and the expected effect before you call it. Review the change before you run it in production.
Authorizations
Body
application/json
Request payload