---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://truto.one/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Redeem a code

> Source: https://truto.one/docs/api-reference/admin/billing/redeem-promotion-code/

`POST /billing/promotion-code`

Resource: **Billing**

**Gives the team (`team_id`) the code's offer: credits, discounts, Pro, features, limits and services.** Only a team admin can redeem. All of it lands at once, or none. Codes are not case sensitive. Never refused for no card (credits switch on when the team saves one) or for credits the team already holds (credits add up). A later discount on the same thing replaces the earlier one. The same team redeeming the same code again gets its team offer back. Pro is turned on once: with no card it waits for one (`pro_outcome` `no_card`).

## Request body

- **`team_id`** _(string)_
  Or `?team_id=`.
- **`code`** _(string)_
- **`pro_continue_consent`** _(boolean)_
  The person ticked "Pro continues after the credits", for an offer that asks it.
- **`pro_continue_consent_text`** _(string)_
  The text of the box they ticked.

## Response body

- **`result`** _(object)_
  An offer the team got, by a code or from Truto, and what it gives.
  - **`id`** _(string)_
  - **`team_id`** _(string)_
  - **`offer_id`** _(string)_
  - **`offer_key`** _(string)_
  - **`offer_name`** _(string)_
  - **`code`** _(string)_
  - **`code_id`** _(string)_
  - **`status`** _(string)_
    Allowed: `live`, `ended`
  - **`effects`** _(array<object>)_
    What the offer gives, as blocks (`credits`, `discount`, `pro`, `features`, `limits`, `services`), copied when the team got it.
  - **`lines`** _(array<string>)_
    The same, in plain lines.
  - **`starts_at`** _(string)_
  - **`ends_at`** _(string)_
  - **`ended_at`** _(string)_
  - **`end_reason`** _(string)_
    Allowed: `expired`, `staff`, `done`
  - **`credit_grant`** _(object)_
    One credit grant, from one offer the team got (for example Truto for Startups). Kept apart from the prepaid balance. Credits pay usage past the free calls (never calls through Truto's own Google and QuickBooks apps), and Pro when the offer includes it. Locked until the team saves a card; they last `valid_days` from then.
    - **`id`** _(string)_
    - **`team_offer_id`** _(string)_
    - **`offer_id`** _(string)_
    - **`offer_key`** _(string)_
    - **`offer_name`** _(string)_
    - **`amount_cents`** _(integer)_
      Credits given, in cents.
    - **`left_cents`** _(integer)_
      Credits left, in cents. 0 once ended.
    - **`status`** _(string)_
      `locked` until the team saves a card.
      Allowed: `locked`, `active`, `ended`
    - **`pays_for`** _(object)_
      - **`usage`** _(boolean)_
      - **`pro`** _(boolean)_
    - **`includes_pro`** _(boolean)_
      Pro is turned on, paid by the credits, when they switch on.
    - **`pro_continue_ask`** _(boolean)_
      The card dialog asks whether Pro continues on the card after the credits end (`pro_continue_consent`).
    - **`pro_cap_cents`** _(integer)_
      The most these credits pay of Pro. Null for no cap.
    - **`pro_cap_left_cents`** _(integer)_
      What is left of `pro_cap_cents`. Null for no cap, and once ended.
    - **`granted_at`** _(string)_
    - **`activated_at`** _(string)_
    - **`expires_at`** _(string)_
    - **`ended_at`** _(string)_
    - **`end_reason`** _(string)_
      `replaced` only on grants from before credits added up.
      Allowed: `expired`, `used_up`, `revoked`, `enterprise`, `replaced`
    - **`pro_paid_by_credits`** _(boolean)_
      This grant pays Pro now.
  - **`discounts`** _(array<object>)_
    - **`id`** _(string)_
    - **`team_offer_id`** _(string)_
    - **`offer_id`** _(string)_
    - **`offer_name`** _(string)_
    - **`name`** _(string)_
    - **`percent_off`** _(integer)_
    - **`amount_off_cents`** _(integer)_
    - **`applies_to`** _(string)_
      `usage` never covers calls through Truto's own Google and QuickBooks apps.
      Allowed: `pro`, `usage`
    - **`duration`** _(string)_
      Allowed: `once`, `repeating`, `forever`
    - **`duration_months`** _(integer)_
    - **`status`** _(string)_
      Allowed: `scheduled`, `active`, `ended`
    - **`starts_at`** _(string)_
    - **`ends_at`** _(string)_
      Null for a discount with no end (`forever`, or `once` until the charge that uses it).
    - **`ended_at`** _(string)_
    - **`end_reason`** _(string)_
      Allowed: `expired`, `used`, `staff`, `replaced`
    - **`source`** _(string)_
      Allowed: `staff`, `code`
    - **`description`** _(string)_
    - **`features_back_at`** _(string)_
      For an offer that took features out of Pro: when they come back (full price means full Pro). The discount's end, or for a used `once`, the 1st after the month it paid; after that, when they came back. Null for any other discount, and while the end is not known (`forever`, `once` not used yet).
  - **`features_off`** _(array<string>)_
  - **`limits`** _(object)_
    Limits the offer sets while it is live. Null means no limit.
  - **`pro_on`** _(boolean)_
    The offer turns Pro on.
  - **`pro_outcome`** _(string)_
    `no_card`: Pro turns on when the team saves a card, within 30 days and while the offer is open. A card is then charged only if the team agreed Pro goes on its card; credits or a discount that pay all of the month need no agreement. `needs_consent`: the card would be charged and the team never agreed. `expired`: the 30 days passed or the offer closed. In both, the team can turn Pro on in Billing.
    Allowed: `trying`, `already_on`, `credits`, `no_card`, `on`, `failed`, `needs_consent`, `expired`
  - **`overrides_synced_at`** _(string)_
  - **`restored_at`** _(string)_
    When what the offer changed was put back, after it ended.
  - **`created_at`** _(string)_

## Errors

| Status | Description |
| :----- | :---------- |
| `400` | The code does not apply. `truto_error_code`: `credit_code_invalid` (unknown or paused), `code_expired` (the link is past its `redeem_by`), `credit_code_expired` (the offer ended), `credit_code_used_up`, `credit_code_locked` (this link is for another email), `credit_code_not_eligible` (the offer is not for this team), `promotion_closed` (the offer is paused, not started, ended or full), `credit_invoiced_team` (an Enterprise team, paid by invoice), `promotion_redeemed` (the team already has this offer from another code). |
| `403` | Forbidden if the caller is not an admin of the team |

## Code examples

### curl

```bash
curl -X POST 'https://api.truto.one/billing/promotion-code' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "team_id": "your_team_id",
  "code": "STARTUPS-7KQ2MZ4P",
  "pro_continue_consent": true,
  "pro_continue_consent_text": "your_pro_continue_consent_text"
}'
```

### JavaScript

```javascript
const body = {
  "team_id": "your_team_id",
  "code": "STARTUPS-7KQ2MZ4P",
  "pro_continue_consent": true,
  "pro_continue_consent_text": "your_pro_continue_consent_text"
};

const response = await fetch('https://api.truto.one/billing/promotion-code', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <your_api_token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

url = "https://api.truto.one/billing/promotion-code"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}
payload = {
    "team_id": "your_team_id",
    "code": "STARTUPS-7KQ2MZ4P",
    "pro_continue_consent": True,
    "pro_continue_consent_text": "your_pro_continue_consent_text"
}

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