# Runs

> For the complete documentation index, see [llms.txt](https://www.shortsintel.com/llms.txt). Every docs page is also available as markdown: add .md to its URL. To connect, read [agents.md](https://www.shortsintel.com/agents.md).

> Every charged operation creates a Run; free reads and edits do not. How the four states work, how long a call waits, how to poll one, and why re-reading a finished Run is free.

- Created by: Every charged call. Free reads and edits create no Run.
- States: `running`, then once `completed`, `partial` or `failed`.
- Wait: A paid call waits 30 s by default, 120 s at most, then answers `202` with the Run to poll.
- Reads: `GET /v1/runs/{id}`: Free. It never repeats the work.
- Concurrency: 10 Runs in `running` at once per Customer.

Every charged operation you call creates a Run: one record of one piece of work, what it produced and what it cost. Reads of a Run are free forever, so the id you get back works as a receipt as well as a handle.

## A Run records one charged call

A paid call answers with a Run, finished or still going. Free reads and edits, such as a balance, a rename or a deletion, answer directly and create no Run. Asking for a price with `estimate` creates no Run either.

A Run is in one of four states:

| State | What it means |
| --- | --- |
| `running` | The work is still going. You have a Run id and nothing else yet. Poll it, or wait for the webhook. |
| `completed` | Everything asked for arrived. The result is on the Run and stays there. |
| `partial` | Some of the work landed and some did not, such as one platform timing out or one video that could not be fetched. You are charged for what arrived and nothing else. |
| `failed` | Nothing usable came back. Nothing is charged. The Run carries a problem body saying why. |

A Run only ever moves out of `running` once. It never goes back, and a finished Run is never re-run by reading it.

## Waiting inline

Most calls finish fast enough to answer in the request. Paid operations take a `wait` parameter: the seconds to hold the response open before handing you the Run to poll. It defaults to 30 seconds and caps at 120.

Finish inside the budget and you get `200` with `{ run, result }`. Run out of budget and you get `202` with `{ run }`: the same work, still going, no longer in this response. Both are success. Code that treats `202` as an error breaks on the first slow call.

```bash
curl "{BASE}/v1/videos/tiktok/7300000000000000000" \
  -H "Authorization: Bearer sk_live_YOUR_KEY"

# A link to the file, valid until download_expires_at
curl "{BASE}/v1/videos/tiktok/7300000000000000000?include=download" \
  -H "Authorization: Bearer sk_live_YOUR_KEY"

# Facebook: the numeric video or reel id
curl "{BASE}/v1/videos/facebook/4007941182848761" \
  -H "Authorization: Bearer sk_live_YOUR_KEY" \
  -G --data-urlencode "wait=120"
```

## Poll a Run until it settles

`GET /v1/runs/{id}` returns the Run in the same envelope the original call would have. It is free, but it counts toward the 60 requests per minute per key. Long-poll it, or poll on the interval the response names, rather than in a tight loop.

Every `202` says where and when to poll. Its `Location` header is the Run’s path, `/v1/runs/{id}`. Its `Retry-After` header is the seconds to wait before the next poll (5 today). The body repeats the location as `poll_url`, an absolute URL, for callers that never see headers, such as an Assistant over MCP.

All three are there only while the Run is running. A `200` carries none of them, and an idempotent replay of a still-running Run carries the same ones.

To long-poll, pass `wait` to the Run read, with the same bounds as on a paid call (max 120). The response is held until the Run settles, then answers `200` at once. If the wait runs out first, it is the same `202` with the same hints. Without `wait` the read answers at once.

```bash
curl "{BASE}/v1/runs/run_123" \
  -H "Authorization: Bearer sk_live_YOUR_KEY" \
  -G --data-urlencode "wait=120"
```

A long-poll counts as one request against the rate limit, so it spends far less of your budget than a loop. Polling without `wait` instead, poll after 2 s, then double the gap each time (2 s, 4 s, 8 s) up to 10 s, or sleep the 202’s `Retry-After` (5 s) between reads.

```bash
curl "{BASE}/v1/runs/run_123" \
  -H "Authorization: Bearer sk_live_YOUR_KEY"
```

On a `429`, sleep for the seconds in the `Retry-After` header before the next request. The body carries the same number as `retry_after_seconds`.

For a Run you expect to take longer than a few minutes, such as a Research, register a [webhook](https://www.shortsintel.com/docs/concepts/webhooks) and stop polling. Polling is always available and always free.

## Retrying after a timeout

If a paid call times out or the connection drops before you get a response, you cannot tell whether the Run started. Send the call again with the same `Idempotency-Key` header and the same body.

If the first attempt landed, you get that Run back and are not charged again. If it did not, the work starts now. A new key, or no key, starts and charges a second Run. The same key with a different body is a `409` `idempotency_conflict`.

## What a Run charges

Free. Reading a Run does not repeat the work and does not charge again: the charge happened once, when the work did. Store the Run id and you can fetch the same result tomorrow without paying twice. Someone else’s Run id is a `404`, not a `403`, so you cannot learn that a Run exists unless it is yours.

Operations that fan out, such as a search across three platforms or a research pass over fifty videos, deliver one item at a time. When some items fail, the Run ends `partial` and keeps the ones that worked.

`GET /v1/runs/{id}/items` lists them, each with its own status, its own charge and, where it failed, the problem body saying why. An item that arrived is charged, up to what the Balance covers. An item that failed is not. A `failed` Run costs nothing at all.

```bash
curl "https://www.shortsintel.com/v1/runs/run_123/items?type=videos" \
  -H "Authorization: Bearer sk_live_YOUR_KEY"
```

Almost every paid operation accepts `estimate`, which returns what the call would cost. See the [reference](https://www.shortsintel.com/docs/reference) for the operations that take it.

## Limits

| Limit | Value |
| --- | --- |
| `wait` | 30 s by default, 120 s at most |
| Requests | 60 per minute per key |
| Concurrent Runs | 10 in running at once |
| `Retry-After` | 5 s on a 202 |

A Customer can have 10 concurrent Runs in `running`. A Run counts from the moment it starts until it leaves `running`, including after a `202` has handed it to you to poll.

A paid call made while 10 are running gets `429` `concurrency_limit_exceeded` with a `Retry-After`. Wait for one to finish before starting another.

## Example: call, then poll until the Run settles

1. Call the operation with the longest wait. Pass `wait=120` and an `Idempotency-Key` you keep for retries. Most Runs finish inside it.
2. Read the status code. On `200`, use the result. On `202`, keep the Run id or `poll_url`.
3. Long-poll the Run. Read `GET /v1/runs/{id}` with `wait=120`, repeating on each `202` until `status` leaves `running`. Or poll it, waiting `Retry-After` seconds between reads, or let the webhook tell you.
4. Check a partial Run. On `partial`, read the items to see what is missing before deciding whether to ask again.

## Questions about Runs

### Is a 202 an error?

No. It means the work outlived the `wait` budget. Poll the Run it hands you until it settles.

### Does reading a Run charge again?

No. A read never repeats the work, and the charge happened once, when the work did.

### How do I retry a call that timed out?

Send it again with the same `Idempotency-Key` and body. If the first attempt landed, you get that Run back with no second charge.

### What does a partial Run cost?

Only the items that arrived. Read them on `GET /v1/runs/{id}/items`.
