Avvio rapido
Effettui il suo primo acquisto con una chiave di test, poi passi alla modalità reale.
1. Ottenga l’accesso
Richieda l’accesso all’API nella pagina Sviluppatori. Per poter approvare una richiesta, l’account deve avere l’autenticazione a due fattori o una passkey. Le invieremo un’email non appena l’account sarà attivo.
2. Crei una chiave di test
Nella pagina Sviluppatori, crei una chiave in modalità Test con accesso Lettura e acquisto. La copi: la mostriamo una sola volta.
Le chiavi di test usano un saldo simulato di 1000 USD. Non viene addebitato nulla e non viene ritirato alcun credito, quindi può sviluppare la sua integrazione in sicurezza.
3. Richieda un preventivo
Un preventivo le indica cosa comprerebbe un acquisto e quanto costerebbe, senza acquistare nulla:
curl https://trimcarbon.com/api/v1/quotes \
-H "Authorization: Bearer $TRIMCARBON_KEY" \
-H "Content-Type: application/json" \
-d '{"kg": 100}'
4. Acquisti delle compensazioni
Invii una Idempotency-Key univoca con ogni acquisto. Se la richiesta va in timeout, la ripeta con la stessa chiave: riceverà il primo acquisto invece di acquistare due volte.
curl https://trimcarbon.com/api/v1/offsets \
-H "Authorization: Bearer $TRIMCARBON_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"kg": 100, "reference": "fleet-2026-09"}'
/offsetsAuthorizationBearer token · headerrequiredAn API key from the developer page: tc_live_… for real purchases, tc_test_… for tests. Keep it on your server.
Idempotency-KeystringrequiredA unique value per purchase, such as a UUID. Retrying with the same key and body returns the first purchase (with Idempotent-Replayed: true) instead of buying again. The same key with a different body is refused with 409.
application/jsonExactly one of kg (whole kg, up to 1,000,000) and amount_cents, and an optional reference.
kgintegerrequiredkg of CO₂ to offset.
referencestringYour own label, such as a trip or invoice ID. Returned as you sent it; never public, never sent to the credit supplier.
amount_centsintegerrequiredUS cents to spend. Buys the most whole kg whose charge fits in this amount.
referencestringYour own label, such as a trip or invoice ID. Returned as you sent it; never public, never sent to the credit supplier.
{
"kg": 1000,
"reference": "fleet-2026-09"
}{
"amount_cents": 5000
}The purchase (or, on a retry, the first one).
objectstringrequiredidstringrequiredlivemodebooleanrequiredFalse for test keys: nothing was charged or retired.
statusstringrequiredprocessing until the credits are bought and retired; placed once they are; refunded if we could not place the order and returned the charge to your balance.
processingplacedrefundedkgintegerrequiredkg of CO₂ offset.
amount_centsintegerrequiredWhat the purchase took from your balance.
currencystringrequiredrate_millicents_per_kgintegerrequiredYour rate in thousandths of a cent per kg: 4000 is $0.04/kg ($40 per tonne).
requestedobjectrequiredWhat you asked for: kg, or an amount to spend.
Show propertiesHide properties
kginteger | nullrequiredShow propertiesHide properties
integernullamount_centsinteger | nullrequiredShow propertiesHide properties
integernullreferencestring | nullrequiredcertificate_urlstring<uri> | nullrequiredThe public certificate on trimcarbon.com, once the order is placed. Null for test offsets.
createdstring<date-time>requiredplacedstring<date-time> | nullrequiredShow propertiesHide properties
string<date-time>nullBad JSON, or a missing or invalid Idempotency-Key.
errorobjectrequiredShow propertiesHide properties
typestringrequiredauthentication_errorpermission_errorinvalid_request_errorrate_limit_errorapi_errorcodestringrequiredmessagestringrequiredparamstringThe request field that is wrong.
balance_centsintegerWith insufficient_balance: your balance now.
required_centsintegerWith insufficient_balance: what the purchase costs.
Missing, unknown or revoked API key.
errorobjectrequiredShow propertiesHide properties
typestringrequiredauthentication_errorpermission_errorinvalid_request_errorrate_limit_errorapi_errorcodestringrequiredmessagestringrequiredparamstringThe request field that is wrong.
balance_centsintegerWith insufficient_balance: your balance now.
required_centsintegerWith insufficient_balance: what the purchase costs.
insufficient_balance: the balance doesn’t cover the purchase. The error has balance_cents and required_cents.
errorobjectrequiredShow propertiesHide properties
typestringrequiredauthentication_errorpermission_errorinvalid_request_errorrate_limit_errorapi_errorcodestringrequiredmessagestringrequiredparamstringThe request field that is wrong.
balance_centsintegerWith insufficient_balance: your balance now.
required_centsintegerWith insufficient_balance: what the purchase costs.
api_access_inactive (the account is suspended or not approved) or insufficient_permissions (a read-only key).
errorobjectrequiredShow propertiesHide properties
typestringrequiredauthentication_errorpermission_errorinvalid_request_errorrate_limit_errorapi_errorcodestringrequiredmessagestringrequiredparamstringThe request field that is wrong.
balance_centsintegerWith insufficient_balance: your balance now.
required_centsintegerWith insufficient_balance: what the purchase costs.
idempotency_key_reused: the key was used for a different request.
errorobjectrequiredShow propertiesHide properties
typestringrequiredauthentication_errorpermission_errorinvalid_request_errorrate_limit_errorapi_errorcodestringrequiredmessagestringrequiredparamstringThe request field that is wrong.
balance_centsintegerWith insufficient_balance: your balance now.
required_centsintegerWith insufficient_balance: what the purchase costs.
validation_error (with param) or amount_too_small.
errorobjectrequiredShow propertiesHide properties
typestringrequiredauthentication_errorpermission_errorinvalid_request_errorrate_limit_errorapi_errorcodestringrequiredmessagestringrequiredparamstringThe request field that is wrong.
balance_centsintegerWith insufficient_balance: your balance now.
required_centsintegerWith insufficient_balance: what the purchase costs.
rate_limited: wait for the Retry-After seconds.
errorobjectrequiredShow propertiesHide properties
typestringrequiredauthentication_errorpermission_errorinvalid_request_errorrate_limit_errorapi_errorcodestringrequiredmessagestringrequiredparamstringThe request field that is wrong.
balance_centsintegerWith insufficient_balance: your balance now.
required_centsintegerWith insufficient_balance: what the purchase costs.
5. Segua l’ordine
La compensazione parte nello stato processing. La interroghi periodicamente finché non è placed:
curl https://trimcarbon.com/api/v1/offsets/off_8Hq2kP0aZr4mXc1vB7nT3yLw \
-H "Authorization: Bearer $TRIMCARBON_KEY"
Una compensazione di test viene effettuata in pochi secondi. Una reale richiede di solito alcuni minuti; poi certificate_url rimanda al relativo certificato pubblico.
6. Passi alla modalità reale
- Ricarichi il suo saldo nella pagina Sviluppatori.
- Crei una chiave Reale e la conservi come segreto sul suo server.
- Sostituisca la chiave di test con la chiave reale. Non cambia nient’altro.