# Billing

> How credits are reserved, charged, topped up, and audited.

Datapoint bills per **response collected**, not per job created. Jobs and streams that require [skills](/docs/skills) your account created are also charged for each answered assessment; shared skills are free. Credits are purchased in advance and spent as jobs run.

## How cost is computed

A standalone job's maximum normal response cost is:

```
max_responses × datapoints × num_dimensions × per-response rate
```

- `datapoints`: length of the `datapoints` array in your job.
- `max_responses`: the job's `max_responses_per_datapoint` (default 10).
- `num_dimensions`: 1 for single-instruction jobs, N for multi-dimension jobs. This factor applies to **standalone jobs only** and is mutually exclusive with `steps` — a job is either dimensional or a chain, never both.

A **chain job** (a job with `steps`) is priced instead by:

```
max_responses × steps × datapoints × per-response rate
```

where `steps` is the number of chain steps (1–5). Each datapoint fans out into one task per step, and every step is capped at `max_responses`.

Either formula gives the normal response reservation — what you'd pay if every task collected its full response cap. Partial chains (walks abandoned mid-way) and jobs that settle with unused capacity consume less; the unspent portion is released back to your `available` balance (see below).

A job that requires skills you created also reserves its `skill_budget_credits`, and `estimated_cost_credits` includes both. The assessment budget is a spending limit, not a promised number of qualified responses, and you can [raise it](#increase-a-jobs-skill-budget) while the job runs.

<DocCallout type="note" title="Sandbox jobs are free">
A job created with `serving_environment: "sandbox"` prices at **0**, reserves nothing, and is served only by a test pool — it never collects production responses. Use it to dry-run a job shape end to end at no cost. The valid `serving_environment` values are `all`, `sandbox`, and `prod`.
</DocCallout>

### Targeting surcharges

Jobs that target a specific audience pay a per-response surcharge on top of your account's base rate:

- **Geography targeting** (`annotator_filter` with `country`, `country_name`, `region`, `city`, `postal`, or `median_household_income`): the surcharge depends on the countries targeted — some countries carry a premium. When multiple countries are listed, the highest applicable surcharge is used. Targeting `region`, `city`, or `postal` **without** naming the countries is priced at the highest country premium — list the countries (by `country` code or `country_name`) to get their actual rates. Income targeting (`median_household_income`) is a geographic attribute and is priced as a geo surcharge, not a demographic one.
- **Demographic targeting** (`annotator_filter` with `gender`, `age_range`, or a custom dimension, or a chain with screening steps — demographic questions or early-exit rules): a flat surcharge, applied once regardless of how many demographic dimensions you combine.

The effective rate — base plus surcharges — is **fixed when the job is created** and returned as `credits_per_response` (with a `pricing` breakdown) by `POST /jobs`. Later pricing changes never affect a running job: reservation, the running `cost_credits`, and final settlement all use the job's own rate. Untargeted jobs pay the base rate.

Surcharge amounts are part of the platform's pricing configuration and can change over time — any credit values in the examples on this page are illustrative. To see the exact rate a targeted job would be priced at, use the [quote endpoint](#quote-a-per-response-rate) below.

<DocCallout type="note" title="Pricing">
For current pricing, volume discounts, or enterprise terms, [contact us](mailto:sales@trydatapoint.com). Your per-response rate is configured on your account and is reflected in the `estimated_cost_credits` returned by `POST /jobs` and the running `cost_credits` on `GET /jobs/{id}`.
</DocCallout>

## Credit lifecycle

Every job's credit moves through these ledger entries:

1. **Reserve**: at job creation, the full estimated cost is moved from `available` to `reserved`. If `available` isn't enough, the API rejects with `402 Payment Required` and returns `needed_credits` and `available_credits`.
2. **Release** (settlement): when the job reaches a terminal state — it completes, is cancelled, or every datapoint fails or is blocked during ingestion — the job is billed for the responses actually collected (capped at the response reservation) plus its answered assessments of skills you created (within the assessment budget). Any unspent reservation is returned to `available`. Settlement happens at the job level; a single datapoint failing mid-run does not release credits on its own.
3. **Release** (dispatch failure): if tasks can't be dispatched (a transient `503` from `POST /jobs`), the entire reservation is released immediately and the failed job is renamed, so you can resubmit under the same `name`.

A job that stalls without ever completing is settled automatically by a background sweep after roughly 14 days, releasing its unused reservation the same way.

Your `reserved_credits` grows when you submit jobs and shrinks as they settle. Your `available_credits` is the amount you could safely reserve for a new job.

Other ledger entries can appear on your account:

- **Purchase**: a top-up adds to `available`.
- **Grant**: promotional or signup credits added to `available` (also reflected in `granted_credits`). New accounts receive a one-time signup grant.
- **Refund**: a reversed purchase. It removes the credits the original purchase granted, so it *lowers* `available`.
- **Planner fee**: a successful `POST /surveys/plan` costs a small flat fee (see the [survey planner](/docs/api/survey-planner)).
- **Message fee**: a signed charge for a dashboard-chat turn. Any account that used the chat builder sees these entries; if a turn fails after being charged, a matching positive `message_fee` entry nets it back out.

---

## Check balance

<EndpointHeader method="GET" path="/billing/balance" />

Returns your account's current credit balance.

```bash
curl https://api.trydatapoint.com/data-labelling/v1/billing/balance \
  -H "X-API-Key: $DATAPOINT_KEY"
```

### Response (`200 OK`)

```json
{
  "available_credits": 4725,
  "reserved_credits": 275,
  "total_purchased_credits": 5000,
  "granted_credits": 100
}
```

<ParamTable
  params={[
    { name: "available_credits", type: "int", description: "Credits you can reserve for a new job right now." },
    { name: "reserved_credits", type: "int", description: "Credits held against in-flight jobs. Released when a job settles." },
    { name: "total_purchased_credits", type: "int", description: "Lifetime purchased credits for the account." },
    { name: "granted_credits", type: "int", description: "Promotional or signup credits granted to the account. Spendable, tracked separately from purchased credits." }
  ]}
/>

---

## Quote a per-response rate

<EndpointHeader method="POST" path="/billing/pricing/quote" />

Returns the effective per-response rate a job with the given targeting would be priced at — before any job exists. Use it to show an accurate cost preview while the user is still choosing their audience. Read-only and free to call.

```bash
curl -X POST https://api.trydatapoint.com/data-labelling/v1/billing/pricing/quote \
  -H "X-API-Key: $DATAPOINT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"annotator_filter": {"country": ["US", "GB"]}}'
```

### Request body

<ParamTable
  params={[
    { name: "annotator_filter", type: "object", description: "The audience filter you would pass to POST /jobs, restricted to allow-list columns (e.g. `{\"country\": [\"US\"]}`). Omit for an untargeted quote." },
    { name: "has_screening_steps", type: "boolean", default: "false", description: "Set true when the prospective job is a chain with screening steps (demographic questions or early-exit rules) — they price like a demographic filter." }
  ]}
/>

<DocCallout type="warning" title="Income filters can't be quoted directly">
Unlike `POST /jobs`, this endpoint accepts only allow-list (string/boolean) filter columns. The numeric range shape used for income — `{"median_household_income": {"gte": 50000}}` — returns `422` here. Income still prices as a geo surcharge on the job itself; to preview that rate, quote the geography you're targeting alongside it (e.g. `country`).
</DocCallout>

### Response (`200 OK`)

```json
{
  "base_credits_per_response": 5,
  "demographic_surcharge_credits": 0,
  "geo_surcharge_credits": 3,
  "priority": "basic",
  "credits_per_skill_assessment": 0,
  "skill_budget_credits": 0,
  "priority_surcharge_credits": 0,
  "credits_per_response": 8
}
```

`credits_per_response` (base plus the surcharges) is the rate `POST /jobs` will reserve at for the same filter — the example values above are illustrative; the endpoint returns your account's current rates. Allow-list keys the filter validator would ultimately reject still return a quote — that validation happens at job creation, not here.

---

## Skill assessment pricing

<EndpointHeader method="GET" path="/billing/pricing" />

Returns your account's standard response rate and its separate rate for assessments of skills you created:

```bash
curl https://api.trydatapoint.com/data-labelling/v1/billing/pricing \
  -H "X-API-Key: $DATAPOINT_KEY"
```

| Field | Meaning |
|---|---|
| `credits_per_response` | Your account's standard rate per response, before audience-targeting surcharges. For the rate `POST /jobs` will reserve at, use the [quote endpoint](#quote-a-per-response-rate). |
| `credits_per_skill_assessment` | Credits per answered assessment of a skill you created, separate from your response rate. |
| `credits_per_shared_skill_assessment` | Always `0`: shared skills are free. |

[Contact us](mailto:sales@trydatapoint.com) for account-specific assessment pricing. A job's or stream's assessment rate is fixed when it is created; later pricing changes don't reprice it.

### What is charged

- Each answered assessment of a skill you created is charged once, whether the answer is right or wrong, including when the annotator doesn't qualify.
- In `adaptive` mode, an annotator who already holds a passing score usually starts real work without a new assessment, but is re-checked from time to time. Each re-check is charged.
- In `enforced` mode, every annotator answers an assessment for each required skill on each job, even with an existing score, and each one is charged.
- An assessment that is served but never answered isn't charged, and neither is an answer that arrives after the assessment expires. Retrying the same submission doesn't charge it twice.
- Responses rejected by skill requirements aren't charged as responses. Their answered assessments are still charged.
- Shared skills and sandbox jobs have no assessment charge.

### Set a budget

When a job requires skills you created, include `skill_budget_credits` in `POST /jobs`. It must cover at least one assessment for each of those skills, or the request is a `400`. Plan for many more: every new annotator is assessed, some won't qualify, and passing annotators are re-checked. Omit `skill_budget_credits` (or send `0`) for jobs that require only shared skills and for sandbox jobs; a non-zero budget there is a `400`.

For example, at an **illustrative** rate of 8 credits per assessment, a 240-credit budget covers at most 30 paid assessments, not necessarily 30 qualified responses. The normal response reservation is additional.

Each served assessment holds its cost against the budget (`skill_in_flight_credits`) until it is answered or expires. When the remaining budget can't fund another assessment, annotators who still need one aren't served the job, which can slow or stop collection; annotators who already qualify keep contributing. Check `skill_budget_available_credits` on the job and raise the budget if needed. Unused budget is returned when the job settles.

[Streams](/docs/api/streams#skill-requirements) have no separate assessment budget: they pay for assessments as they go from the stream's balance and `budget_credits`.

The [quote endpoint](#quote-a-per-response-rate) prices responses only: it doesn't estimate how many assessments a job will need, and its `credits_per_skill_assessment` and `skill_budget_credits` are always `0`. Add your budget separately when estimating the total reservation.

## Increase a job's skill budget

<EndpointHeader method="POST" path="/jobs/{job_id}/skill-budget" />

Supply a new **total budget**, not an amount to add. For example, to raise a budget from 200 to 400 credits:

```bash
curl -X POST "https://api.trydatapoint.com/data-labelling/v1/jobs/$JOB_ID/skill-budget" \
  -H "X-API-Key: $DATAPOINT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"skill_budget_credits": 400}'
```

This reserves the additional 200 credits and raises the job's `estimated_cost_credits` by the same amount. Repeating the request with the same total reserves nothing more. A budget can't be reduced, and it can only be raised while the job is running (paused included), before it settles.

The `200 OK` response contains `job_id`, `skill_budget_credits`, `skill_spent_credits`, `skill_in_flight_credits`, and `credits_per_skill_assessment`. Note that this endpoint names spent assessment credits `skill_spent_credits`; the job status endpoint uses `skill_cost_credits`.

| Status | Cause |
|---|---|
| `400` | The new total is lower than the current budget; the job is completed, cancelled, failed, or already settled; it is a stream; it has no paid assessments; or the job's total reservation would exceed the maximum. |
| `402` | Your available balance can't cover the increase. `detail` is a message string. |
| `404` | Unknown job or a job outside your account. |
| `422` | Invalid budget value. |

## Separate response and skill spend

`GET /jobs/{job_id}` reports `response_cost_credits` and `skill_cost_credits` separately. Their sum is `cost_credits`. It also returns the total assessment budget, pending commitments (`skill_in_flight_credits`), and remaining available budget (`skill_budget_available_credits`).

For account-level reporting:

<EndpointHeader method="GET" path="/billing/spend" />

```bash
curl https://api.trydatapoint.com/data-labelling/v1/billing/spend \
  -H "X-API-Key: $DATAPOINT_KEY"
```

Illustrative response:

```json
{
  "settled": {
    "response_cost_credits": 1200,
    "skill_cost_credits": 240,
    "total_cost_credits": 1440
  },
  "unsettled_skill_cost_credits": 80,
  "total_skill_cost_credits": 320
}
```

`settled` covers jobs and streams whose final cost is recorded. `unsettled_skill_cost_credits` covers answered paid assessments on jobs and streams that haven't settled yet, not unanswered ones. `total_skill_cost_credits` includes both settled and unsettled assessment spending; do not add it again to the settled skill total.

This report excludes planner and chat-message fees. Use individual job status for ongoing normal response costs and [billing history](#view-history) for account transactions.

---

## Top up

<EndpointHeader method="POST" path="/billing/checkout" />

Starts a hosted checkout session. Redirect the user to the returned `checkout_url`. On success the payment provider notifies Datapoint and your `available_credits` updates within a few seconds.

```bash
curl -X POST https://api.trydatapoint.com/data-labelling/v1/billing/checkout \
  -H "X-API-Key: $DATAPOINT_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

### Request body

<ParamTable
  params={[
    { name: "product_id", type: "string", description: "Optional. A specific purchasable product to check out. When omitted, the response opens a product picker chosen from your billing state rather than a single fixed product." },
    { name: "metadata", type: "object", description: "Optional string-keyed map forwarded with the checkout, echoed back so post-payment side-effects can be routed." }
  ]}
/>

Empty body (`{}`) is valid — it opens the default picker.

### Response (`200 OK`)

```json
{
  "checkout_url": "https://buy.polar.sh/s/...",
  "session_id": "cs_abc..."
}
```

### Error cases

| Status | Cause |
|---|---|
| `400` | Unknown or disallowed `product_id`. |
| `403` | Credit packs are not available (`code: "credit_packs_disabled"`). |
| `429` | Rate limit exceeded. |
| `500` | Checkout products are not configured for this environment. |

<DocCallout type="tip" title="Need invoicing?">
There's no balance-triggered auto-top-up today. If you need invoicing or enterprise payment terms, reach out and we'll arrange manual credit.
</DocCallout>

---

## View history

<EndpointHeader method="GET" path="/billing/history" />

Paginated transaction history: every purchase, grant, reserve, release, refund, and fee.

### Query parameters

<ParamTable
  params={[
    { name: "page", type: "integer", default: "1", description: "1-indexed page (min 1)." },
    { name: "per_page", type: "integer", default: "50", description: "Entries per page (min 1, max 200)." }
  ]}
/>

```bash
curl "https://api.trydatapoint.com/data-labelling/v1/billing/history?page=1&per_page=50" \
  -H "X-API-Key: $DATAPOINT_KEY"
```

### Response (`200 OK`)

```json
{
  "entries": [
    {
      "entry_type": "purchase",
      "amount_credits": 5000,
      "job_id": null,
      "description": "Credit purchase (5000 credits, $50.00 paid, order=ord_...)",
      "created_at": "2026-04-15 08:21:04.123456+00:00"
    },
    {
      "entry_type": "reserve",
      "amount_credits": -150,
      "job_id": "f3a7...",
      "description": "Reserved for job",
      "created_at": "2026-04-15 09:10:22.123456+00:00"
    },
    {
      "entry_type": "release",
      "amount_credits": 15,
      "job_id": "f3a7...",
      "description": "Released unused credits (15 credits)",
      "created_at": "2026-04-15 11:42:17.123456+00:00"
    },
    {
      "entry_type": "planner_fee",
      "amount_credits": -50,
      "job_id": null,
      "description": "Survey planner fee",
      "created_at": "2026-04-15 12:01:09.123456+00:00"
    }
  ],
  "total": 4,
  "page": 1,
  "per_page": 50
}
```

<ParamTable
  title="Ledger entry"
  params={[
    { name: "entry_type", type: '"purchase" | "grant" | "reserve" | "release" | "refund" | "planner_fee" | "message_fee"', description: "Kind of credit movement. `purchase`, `grant`, and `release` add to `available`; `reserve` and `refund` are debits (a `refund` reverses the credits of the original purchase, so its `amount_credits` is negative); `planner_fee` and `message_fee` are signed (a charge is negative, and a same-type refund is positive)." },
    { name: "amount_credits", type: "int", description: "Signed integer credits. Credits to your balance are positive; debits are negative." },
    { name: "job_id", type: "string | null", description: "A stable job reference shared by that job's ledger entries — not the `job_id` returned by `POST /jobs`. Null for purchases, grants, and fees." },
    { name: "description", type: "string | null", description: "Human-readable note — a provider order reference or a fixed system string such as `Reserved for job` or `Released unused credits`." },
    { name: "created_at", type: "string", description: "Datetime string: `'YYYY-MM-DD HH:MM:SS.ffffff+00:00'`." }
  ]}
/>

---

## Handling insufficient balance

When `POST /jobs` responds with 402, parse `detail` to show a clear top-up prompt. The global error envelope mirrors `detail` into a top-level `message` field; see the [errors page](/docs/errors#402-insufficient-balance) for the full shape.

```json
{
  "detail": {
    "message": "Insufficient balance",
    "needed_credits": 150,
    "available_credits": 75
  }
}
```

Direct the user through `POST /billing/checkout`, wait for the balance to update, and retry the job with the same request body. Job creation is idempotent on `name`: if the original request was already received, the retry returns that job's original fields (and omits the `pricing` breakdown, which is only present on a fresh creation) rather than reserving again.

## Next

- [Errors](/docs/errors): handling 402 and other status codes
- [Jobs](/docs/api/jobs): creating jobs that draw from your balance
- [Skills and qualification](/docs/skills): requiring annotators to pass an assessment
