# Jobs

> How long tasks run in the background, how to follow them, and what happens to their credits when they fail.

Web page: https://www.gotopeach.com/docs/api-jobs (updated 2026-11-03)

> **In short.** A task that takes more than a few seconds answers `202` with a job straight away and runs in the background. Follow it with `GET /jobs/{id}`, or receive a webhook when it ends. A job that fails gives its credits back.

All paths are relative to `https://app.gotopeach.com/api/v1`.

## Which endpoints run as jobs

| Endpoint | What it does | Credits | Key permission |
|---|---|---|---|
| `POST /analyses` | Run a full analysis of a site (about a minute): its questions, competitors, answers and actions. Runs as a background job: answers 202 with a job. MCP: `run_analysis`. | 50 | `sites` + `write` + `spend` |
| `POST /sites/{domain}/topics/generate` | Generate this month's topics from the site's latest analysis (a background job). Runs as a background job: answers 202 with a job. | 10 | `content` + `write` + `spend` |
| `POST /outlines/{id}/article` | Write the article for an approved outline (1 to 3 minutes; a background job). Runs as a background job: answers 202 with a job. MCP: `write_article`. | 90 | `content` + `write` + `spend` |

They answer:

```json
{ "job": { "id": "JOB_ID", "status": "queued", "url": "/api/v1/jobs/JOB_ID" } }
```

Checks run in the background too, but have their own record: follow them with `GET /checks/{id}`. See [Checks](https://www.gotopeach.com/docs/api-questions-and-checks.md#checks).

## Following a job

| Endpoint | What it does | Credits | Key permission |
|---|---|---|---|
| `GET /jobs/{id}` | A background job (an article, an analysis, a topic batch): its status and, when done, its result. MCP: `get_job`. | Free | Any key |

```json
{
  "job": {
    "id": "JOB_ID",
    "route": "articles.generate",
    "status": "succeeded",
    "createdAt": "2026-11-03T09:12:04.000Z",
    "finishedAt": "2026-11-03T09:14:31.000Z",
    "creditsCharged": 90,
    "result": { "articleId": "ARTICLE_ID", "quality": { "passed": true }, "alreadyGenerated": false },
    "error": null
  }
}
```

- `status` is `queued`, `running`, `succeeded` or `failed`.
- `result` is what the endpoint itself would have answered, once the job has succeeded.
- `error` holds `{ code, message }` once it has failed.
- `creditsCharged` is what the job cost after any refund.
- Ask every 10 to 30 seconds. An article takes one to three minutes, an analysis about one.

## Webhooks instead of asking

Each job sends a [webhook](https://www.gotopeach.com/docs/api-webhooks.md) when it ends: `analysis.finished`, `topics.generated` or `article.generated` when it succeeds, and `job.failed` when it doesn't.

## Credits

- A job is charged when it is accepted, so it never stops halfway for lack of credits.
- A job that fails is refunded. So is a job that stopped before it could finish: its credits come back the next time it is read, or within a day.
- A job that found its work already done, such as an article the outline already had, is refunded too.

## Who can see a job

Any key on the account can read its jobs, except a key limited to some sites, which sees only the jobs it started itself.
