---
title: Avvio rapido
description: >-
  Effettui il suo primo acquisto con una chiave di test, poi passi alla modalità
  reale.
mode: wide
sidebar:
  order: 1
---
## 1. Ottenga l’accesso [#1-get-access]

Richieda l’accesso all’API nella [pagina Sviluppatori](https://trimcarbon.com/developers/access). 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 [#2-create-a-test-key]

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 [#3-get-a-quote]

Un preventivo le indica cosa comprerebbe un acquisto e quanto costerebbe, senza acquistare nulla:

```bash
curl https://trimcarbon.com/api/v1/quotes \
  -H "Authorization: Bearer $TRIMCARBON_KEY" \
  -H "Content-Type: application/json" \
  -d '{"kg": 100}'
```

## 4. Acquisti delle compensazioni [#4-buy-offsets]

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.

```bash
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"}'
```

`POST /offsets`

**Request body** (`application/json`, required)

Exactly one of \`kg\` (whole kg, up to 1,000,000) and \`amount\_cents\`, and an optional \`reference\`.

Request body example, By volume:

```json
{
  "kg": 1000,
  "reference": "fleet-2026-09"
}
```

Request body example, By price:

```json
{
  "amount_cents": 5000
}
```

**Responses**

- `201` — The purchase (or, on a retry, the first one).
- `400` — Bad JSON, or a missing or invalid Idempotency-Key.
- `401` — Missing, unknown or revoked API key.
- `402` — \`insufficient\_balance\`: the balance doesn’t cover the purchase. The error has \`balance\_cents\` and \`required\_cents\`.
- `403` — \`api\_access\_inactive\` (the account is suspended or not approved) or \`insufficient\_permissions\` (a read-only key).
- `409` — \`idempotency\_key\_reused\`: the key was used for a different request.
- `422` — \`validation\_error\` (with \`param\`) or \`amount\_too\_small\`.
- `429` — \`rate\_limited\`: wait for the \`Retry-After\` seconds.

Response example, 201:

```json
{
  "object": "offset",
  "id": "off_8Hq2kP0aZr4mXc1vB7nT3yLw",
  "livemode": true,
  "status": "processing",
  "kg": 0,
  "amount_cents": 0,
  "currency": "usd",
  "rate_millicents_per_kg": 4000,
  "requested": {
    "kg": 0,
    "amount_cents": 0
  },
  "reference": "string",
  "certificate_url": "http://example.com",
  "created": "2026-10-08T14:03:12.000Z",
  "placed": "2026-10-08T14:03:12.000Z"
}
```

## 5. Segua l’ordine [#5-follow-the-order]

La compensazione parte nello stato `processing`. La interroghi periodicamente finché non è `placed`:

```bash
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 [#6-go-live]

1. Ricarichi il suo saldo nella pagina Sviluppatori.
2. Crei una chiave **Reale** e la conservi come segreto sul suo server.
3. Sostituisca la chiave di test con la chiave reale. Non cambia nient’altro.

:::warning
Gli acquisti reali ritirano crediti di carbonio reali. Il saldo è prepagato e non rimborsabile; consulti [Saldo e acquisti](/docs/it/balance).
:::
