Update contract
curl --request PUT \
--url https://api.getlago.com/api/v2/contracts/{external_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contract": {
"name": "Annual agreement",
"status": "draft",
"plan_code": "standard",
"billing_anchor_date": null,
"started_at": null,
"ended_at": null,
"consolidate_invoice": true,
"purchase_order_number": "PO-123",
"invoice_custom_section": {
"skip_invoice_custom_sections": false,
"invoice_custom_section_codes": [
"legal_terms"
]
}
}
}
'import requests
url = "https://api.getlago.com/api/v2/contracts/{external_id}"
payload = { "contract": {
"name": "Annual agreement",
"status": "draft",
"plan_code": "standard",
"billing_anchor_date": None,
"started_at": None,
"ended_at": None,
"consolidate_invoice": True,
"purchase_order_number": "PO-123",
"invoice_custom_section": {
"skip_invoice_custom_sections": False,
"invoice_custom_section_codes": ["legal_terms"]
}
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
contract: {
name: 'Annual agreement',
status: 'draft',
plan_code: 'standard',
billing_anchor_date: null,
started_at: null,
ended_at: null,
consolidate_invoice: true,
purchase_order_number: 'PO-123',
invoice_custom_section: {
skip_invoice_custom_sections: false,
invoice_custom_section_codes: ['legal_terms']
}
}
})
};
fetch('https://api.getlago.com/api/v2/contracts/{external_id}', 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/contracts/{external_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'contract' => [
'name' => 'Annual agreement',
'status' => 'draft',
'plan_code' => 'standard',
'billing_anchor_date' => null,
'started_at' => null,
'ended_at' => null,
'consolidate_invoice' => true,
'purchase_order_number' => 'PO-123',
'invoice_custom_section' => [
'skip_invoice_custom_sections' => false,
'invoice_custom_section_codes' => [
'legal_terms'
]
]
]
]),
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/contracts/{external_id}"
payload := strings.NewReader("{\n \"contract\": {\n \"name\": \"Annual agreement\",\n \"status\": \"draft\",\n \"plan_code\": \"standard\",\n \"billing_anchor_date\": null,\n \"started_at\": null,\n \"ended_at\": null,\n \"consolidate_invoice\": true,\n \"purchase_order_number\": \"PO-123\",\n \"invoice_custom_section\": {\n \"skip_invoice_custom_sections\": false,\n \"invoice_custom_section_codes\": [\n \"legal_terms\"\n ]\n }\n }\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.getlago.com/api/v2/contracts/{external_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contract\": {\n \"name\": \"Annual agreement\",\n \"status\": \"draft\",\n \"plan_code\": \"standard\",\n \"billing_anchor_date\": null,\n \"started_at\": null,\n \"ended_at\": null,\n \"consolidate_invoice\": true,\n \"purchase_order_number\": \"PO-123\",\n \"invoice_custom_section\": {\n \"skip_invoice_custom_sections\": false,\n \"invoice_custom_section_codes\": [\n \"legal_terms\"\n ]\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getlago.com/api/v2/contracts/{external_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"contract\": {\n \"name\": \"Annual agreement\",\n \"status\": \"draft\",\n \"plan_code\": \"standard\",\n \"billing_anchor_date\": null,\n \"started_at\": null,\n \"ended_at\": null,\n \"consolidate_invoice\": true,\n \"purchase_order_number\": \"PO-123\",\n \"invoice_custom_section\": {\n \"skip_invoice_custom_sections\": false,\n \"invoice_custom_section_codes\": [\n \"legal_terms\"\n ]\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"contract": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_id": "example",
"code": "initial",
"lago_customer_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_customer_id": "customer_123",
"name": "example",
"plan_code": "standard",
"status": "pending",
"consolidate_invoice": false,
"purchase_order_number": "example",
"billing_anchor_date": null,
"effective_billing_anchor_date": null,
"skip_invoice_custom_sections": false,
"started_at": null,
"ended_at": null,
"terminated_at": null,
"canceled_at": null,
"created_at": "2022-04-29T08:59:51.123456Z",
"updated_at": "2022-04-29T08:59:51.123456Z",
"applied_rate_cards": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_contract_id": "contract_123",
"rate_card_code": "compute_usd",
"product_code": "api_requests",
"product_filter_code": "eu",
"units": "1.5",
"effective_date": "2022-04-29",
"billing_anchor_date": "2022-04-29",
"next_billing_at": null,
"created_at": "2022-04-29T08:59:51.123456Z",
"updated_at": "2022-04-29T08:59:51.123456Z",
"deleted_at": null,
"billing_scope": "cycle"
}
],
"plan": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "example",
"code": "example",
"description": "example",
"invoice_display_name": "example",
"currency": "USD",
"created_at": "2022-04-29T08:59:51.123456Z",
"deleted_at": null,
"taxes": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "VAT",
"code": "standard_vat",
"rate": 20,
"description": "Standard VAT",
"created_at": "2022-04-29T08:59:51.123456Z",
"updated_at": "2022-04-29T09:30:00.123456Z",
"deleted_at": null
}
]
},
"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"
},
"invoice_custom_sections": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"code": "example",
"name": "example",
"description": "example",
"details": "example",
"display_name": "example",
"created_at": "2022-04-29T08:59:51.123456Z",
"updated_at": "2022-04-29T08:59:51.123456Z",
"deleted_at": null
}
]
}
}{
"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": {}
}
]
}Contracts
Update contract
PUT and PATCH both accept partial updates.
PUT
/
contracts
/
{external_id}
Update contract
curl --request PUT \
--url https://api.getlago.com/api/v2/contracts/{external_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contract": {
"name": "Annual agreement",
"status": "draft",
"plan_code": "standard",
"billing_anchor_date": null,
"started_at": null,
"ended_at": null,
"consolidate_invoice": true,
"purchase_order_number": "PO-123",
"invoice_custom_section": {
"skip_invoice_custom_sections": false,
"invoice_custom_section_codes": [
"legal_terms"
]
}
}
}
'import requests
url = "https://api.getlago.com/api/v2/contracts/{external_id}"
payload = { "contract": {
"name": "Annual agreement",
"status": "draft",
"plan_code": "standard",
"billing_anchor_date": None,
"started_at": None,
"ended_at": None,
"consolidate_invoice": True,
"purchase_order_number": "PO-123",
"invoice_custom_section": {
"skip_invoice_custom_sections": False,
"invoice_custom_section_codes": ["legal_terms"]
}
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
contract: {
name: 'Annual agreement',
status: 'draft',
plan_code: 'standard',
billing_anchor_date: null,
started_at: null,
ended_at: null,
consolidate_invoice: true,
purchase_order_number: 'PO-123',
invoice_custom_section: {
skip_invoice_custom_sections: false,
invoice_custom_section_codes: ['legal_terms']
}
}
})
};
fetch('https://api.getlago.com/api/v2/contracts/{external_id}', 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/contracts/{external_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'contract' => [
'name' => 'Annual agreement',
'status' => 'draft',
'plan_code' => 'standard',
'billing_anchor_date' => null,
'started_at' => null,
'ended_at' => null,
'consolidate_invoice' => true,
'purchase_order_number' => 'PO-123',
'invoice_custom_section' => [
'skip_invoice_custom_sections' => false,
'invoice_custom_section_codes' => [
'legal_terms'
]
]
]
]),
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/contracts/{external_id}"
payload := strings.NewReader("{\n \"contract\": {\n \"name\": \"Annual agreement\",\n \"status\": \"draft\",\n \"plan_code\": \"standard\",\n \"billing_anchor_date\": null,\n \"started_at\": null,\n \"ended_at\": null,\n \"consolidate_invoice\": true,\n \"purchase_order_number\": \"PO-123\",\n \"invoice_custom_section\": {\n \"skip_invoice_custom_sections\": false,\n \"invoice_custom_section_codes\": [\n \"legal_terms\"\n ]\n }\n }\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.getlago.com/api/v2/contracts/{external_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contract\": {\n \"name\": \"Annual agreement\",\n \"status\": \"draft\",\n \"plan_code\": \"standard\",\n \"billing_anchor_date\": null,\n \"started_at\": null,\n \"ended_at\": null,\n \"consolidate_invoice\": true,\n \"purchase_order_number\": \"PO-123\",\n \"invoice_custom_section\": {\n \"skip_invoice_custom_sections\": false,\n \"invoice_custom_section_codes\": [\n \"legal_terms\"\n ]\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getlago.com/api/v2/contracts/{external_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"contract\": {\n \"name\": \"Annual agreement\",\n \"status\": \"draft\",\n \"plan_code\": \"standard\",\n \"billing_anchor_date\": null,\n \"started_at\": null,\n \"ended_at\": null,\n \"consolidate_invoice\": true,\n \"purchase_order_number\": \"PO-123\",\n \"invoice_custom_section\": {\n \"skip_invoice_custom_sections\": false,\n \"invoice_custom_section_codes\": [\n \"legal_terms\"\n ]\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"contract": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_id": "example",
"code": "initial",
"lago_customer_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_customer_id": "customer_123",
"name": "example",
"plan_code": "standard",
"status": "pending",
"consolidate_invoice": false,
"purchase_order_number": "example",
"billing_anchor_date": null,
"effective_billing_anchor_date": null,
"skip_invoice_custom_sections": false,
"started_at": null,
"ended_at": null,
"terminated_at": null,
"canceled_at": null,
"created_at": "2022-04-29T08:59:51.123456Z",
"updated_at": "2022-04-29T08:59:51.123456Z",
"applied_rate_cards": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_contract_id": "contract_123",
"rate_card_code": "compute_usd",
"product_code": "api_requests",
"product_filter_code": "eu",
"units": "1.5",
"effective_date": "2022-04-29",
"billing_anchor_date": "2022-04-29",
"next_billing_at": null,
"created_at": "2022-04-29T08:59:51.123456Z",
"updated_at": "2022-04-29T08:59:51.123456Z",
"deleted_at": null,
"billing_scope": "cycle"
}
],
"plan": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "example",
"code": "example",
"description": "example",
"invoice_display_name": "example",
"currency": "USD",
"created_at": "2022-04-29T08:59:51.123456Z",
"deleted_at": null,
"taxes": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "VAT",
"code": "standard_vat",
"rate": 20,
"description": "Standard VAT",
"created_at": "2022-04-29T08:59:51.123456Z",
"updated_at": "2022-04-29T09:30:00.123456Z",
"deleted_at": null
}
]
},
"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"
},
"invoice_custom_sections": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"code": "example",
"name": "example",
"description": "example",
"details": "example",
"display_name": "example",
"created_at": "2022-04-29T08:59:51.123456Z",
"updated_at": "2022-04-29T08:59:51.123456Z",
"deleted_at": null
}
]
}
}{
"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.Authorizations
Query Parameters
Code of the contract to select. Required when multiple contracts share the external ID, including canceled and terminated contracts. Otherwise, it can be omitted. Omitting it when the external ID is ambiguous returns 422 value_is_mandatory on contract_code; a blank value returns 422 value_is_invalid. Exact contract code.
Minimum string length:
1Example:
"initial"