---
title: "Start a checkout"
canonical_url: "https://tweetstream.io/docs/api/create-agent-checkout"
last_updated: 2026-11-05
---

# Start a checkout

Start a checkout and get one payment page for the person to open. Crypto is the default rail; send paymentRail CARD for a card. A trial is used when the account still has one. The response's next step says what to do: open_payment (give the person paymentUrl, then poll pollUrl), join_discord, or wait. Replaying the same Idempotency-Key returns the same checkout.

Canonical URL: https://tweetstream.io/docs/api/create-agent-checkout

## `POST /api/agent/checkout`

`https://tweetstream.io/api/agent/checkout`

## Authorization

| Name | Type | Description |
| --- | --- | --- |
| `Authorization` | `string`, required | Bearer authentication with your TweetStream API key: `Bearer <key>`. |

## Headers

| Name | Type | Description |
| --- | --- | --- |
| `Idempotency-Key` | `string`, required | Required. Generate one key per intended purchase or change and reuse it on retries; the same key returns the same result. |
| `X-TweetStream-Setup-Proof` | `string` | Optional. The setupProof returned by email verification; when present, a Discord step includes its join URL. |

## Body

| Name | Type | Description |
| --- | --- | --- |
| `billingCycle` | `enum<string>` |  |
| `paymentRail` | `enum<string>` |  |
| `trial` | `enum<string>` |  |
| `family` | `enum<string>`, required |  |
| `planType` | `enum<string>`, required |  |

### Body example

```json
{
  "billingCycle": "MONTHLY",
  "paymentRail": "CRYPTO",
  "trial": "if_eligible",
  "family": "BASE",
  "planType": "BASIC"
}
```

## Response fields

| Name | Type | Description |
| --- | --- | --- |
| `checkoutId` | `string` | a string matching the pattern ^pl_[a-z0-9]{1,64}$ |
| `family` | `enum<string>`, required |  |
| `next` | `object`, required |  |
| `next.message` | `string` | a string at most 500 character(s) long |
| `next.action` | `enum<string>`, required |  |
| `next.method` | `enum<string>`, required |  |
| `next.url` | `string`, required | a string matching the pattern ^(https\|wss):\/\/[^\s]+$ |
| `next.who` | `enum<string>`, required |  |
| `offer` | `object` |  |
| `offer.amountDueNow` | `object`, required |  |
| `offer.amountDueNow.currency` | `enum<string>`, required |  |
| `offer.amountDueNow.minor` | `string`, required | a string matching the pattern ^(0\|[1-9][0-9]*)$ |
| `offer.mode` | `enum<string>`, required |  |
| `offer.planName` | `string`, required |  |
| `offer.renewal` | `object`, required |  |
| `offer.renewal.amount` | `object`, required |  |
| `offer.renewal.amount.currency` | `enum<string>`, required |  |
| `offer.renewal.amount.minor` | `string`, required | a string matching the pattern ^(0\|[1-9][0-9]*)$ |
| `offer.renewal.at` | `string`, required | a string to be decoded into a Date |
| `offer.renewal.billingCycle` | `enum<string>`, required |  |
| `offer.renewal.thenAmount` | `object`, required |  |
| `offer.renewal.thenAmount.currency` | `enum<string>`, required |  |
| `offer.renewal.thenAmount.minor` | `string`, required | a string matching the pattern ^(0\|[1-9][0-9]*)$ |
| `paymentUrl` | `string` | a string matching the pattern ^(https\|wss):\/\/[^\s]+$ |
| `reason` | `enum<string>`, required |  |
| `status` | `enum<string>`, required |  |

## Responses

| Status | Description | Headers |
| --- | --- | --- |
| `200` | A replay, the product is already ready, or the person must join Discord first |  |
| `201` | Checkout created |  |
| `202` | Checkout is being prepared; poll status |  |
| `400` | Invalid request, wrong code, or the Terms were not accepted |  |
| `401` | Missing or invalid API key, or the setup proof is missing or expired |  |
| `403` | The account is restricted, or the request carried a foreign Origin |  |
| `409` | Idempotency, checkout, offer or trial conflict |  |
| `429` | Rate limit or activation budget reached; retry after retryAfterSeconds |  |
| `503` | Temporarily unavailable; retry later |  |

### 200

```json
{
  "status": "community_required",
  "family": "BASE",
  "reason": "COMMUNITY_REQUIRED",
  "checkoutId": "pl_8k2m4q7x",
  "discord": {
    "url": "https://tweetstream.io/connect/discord/EXAMPLE_DISCORD_LINK",
    "expiresAt": "2026-10-29T13:00:00.000Z"
  },
  "next": {
    "action": "join_discord",
    "who": "human",
    "url": "https://tweetstream.io/connect/discord/EXAMPLE_DISCORD_LINK",
    "pollUrl": "https://tweetstream.io/api/agent/status?checkoutId=pl_8k2m4q7x",
    "afterSeconds": 5
  }
}
```

### 201

```json
{
  "status": "payment_required",
  "family": "BASE",
  "reason": "new",
  "checkoutId": "pl_8k2m4q7x",
  "offer": {
    "mode": "trial",
    "planName": "Pro",
    "amountDueNow": {
      "currency": "USD",
      "minor": "0"
    },
    "renewal": {
      "amount": {
        "currency": "USD",
        "minor": "49900"
      },
      "at": "2026-11-01T12:00:00.000Z",
      "billingCycle": "MONTHLY",
      "thenAmount": {
        "currency": "USD",
        "minor": "49900"
      }
    }
  },
  "paymentUrl": "https://tweetstream.io/pay/EXAMPLE_PAYMENT_LINK",
  "next": {
    "action": "open_payment",
    "who": "human",
    "url": "https://tweetstream.io/pay/EXAMPLE_PAYMENT_LINK",
    "pollUrl": "https://tweetstream.io/api/agent/status?family=BASE",
    "afterSeconds": 5
  }
}
```

### 202

```json
{
  "status": "processing",
  "family": "BASE",
  "checkoutId": "pl_8k2m4q7x",
  "next": {
    "action": "wait",
    "who": "agent",
    "pollUrl": "https://tweetstream.io/api/agent/status?checkoutId=pl_8k2m4q7x",
    "afterSeconds": 5
  }
}
```

### 400

```json
{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "<string>",
    "reason": "not_offered",
    "retryAfterSeconds": 123
  },
  "next": {
    "message": "<string>",
    "action": "call_action",
    "method": "POST",
    "name": "<string>",
    "url": "<string>",
    "who": "agent"
  }
}
```

### 401

```json
{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "<string>",
    "reason": "not_offered",
    "retryAfterSeconds": 123
  },
  "next": {
    "message": "<string>",
    "action": "call_action",
    "method": "POST",
    "name": "<string>",
    "url": "<string>",
    "who": "agent"
  }
}
```

### 403

```json
{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "<string>",
    "reason": "not_offered",
    "retryAfterSeconds": 123
  },
  "next": {
    "message": "<string>",
    "action": "call_action",
    "method": "POST",
    "name": "<string>",
    "url": "<string>",
    "who": "agent"
  }
}
```

### 409

```json
{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "<string>",
    "reason": "not_offered",
    "retryAfterSeconds": 123
  },
  "next": {
    "message": "<string>",
    "action": "call_action",
    "method": "POST",
    "name": "<string>",
    "url": "<string>",
    "who": "agent"
  }
}
```

### 429

```json
{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "<string>",
    "reason": "not_offered",
    "retryAfterSeconds": 123
  },
  "next": {
    "message": "<string>",
    "action": "call_action",
    "method": "POST",
    "name": "<string>",
    "url": "<string>",
    "who": "agent"
  }
}
```

### 503

```json
{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "<string>",
    "reason": "not_offered",
    "retryAfterSeconds": 123
  },
  "next": {
    "message": "<string>",
    "action": "call_action",
    "method": "POST",
    "name": "<string>",
    "url": "<string>",
    "who": "agent"
  }
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url https://tweetstream.io/api/agent/checkout \
  --header "Authorization: Bearer $TWEETSTREAM_API_KEY" \
  --header 'Idempotency-Key: 7c9e6679-7425-40de-944b-e07fc1f90ae7' \
  --header 'Content-Type: application/json' \
  --data '{
  "billingCycle": "MONTHLY",
  "paymentRail": "CRYPTO",
  "trial": "if_eligible",
  "family": "BASE",
  "planType": "BASIC"
}'
```

### JavaScript

```javascript
const response = await fetch("https://tweetstream.io/api/agent/checkout", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.TWEETSTREAM_API_KEY}`,
    "Idempotency-Key": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "billingCycle": "MONTHLY",
    "paymentRail": "CRYPTO",
    "trial": "if_eligible",
    "family": "BASE",
    "planType": "BASIC"
  }),
});

console.log(response.status, await response.json());
```

### Python

```python
import os
import requests

response = requests.post(
    "https://tweetstream.io/api/agent/checkout",
    headers={"Authorization": f"Bearer {os.environ['TWEETSTREAM_API_KEY']}", "Idempotency-Key": "7c9e6679-7425-40de-944b-e07fc1f90ae7"},
    json={
        "billingCycle": "MONTHLY",
        "paymentRail": "CRYPTO",
        "trial": "if_eligible",
        "family": "BASE",
        "planType": "BASIC",
    },
)

print(response.status_code, response.json())
```
