# cancel_job

Source: https://modulify.ai/docs/api/chat/cancel-job

Stops a generation that is currently running on a site.

- Title: Cancel a running generation
- Scope: `chat:write`
- Access: Makes changes
- Endpoint: `POST /v1/cancel_job`

Work the agent has already written to the site is kept. Leave out `jobId` to cancel whichever generation is running, and when none is, the call answers `There is no generation running for this site!`

Stopping a generation parks the site's message queue, so anything queued waits until `resume_queue` releases it. Set `clearSession` to also reset the agent session, so the next message starts a fresh conversation. See [Stop a run](https://modulify.ai/docs/build/site-chat#stop-a-run).

## Request

Call it with a `POST` to `https://api.modulify.ai/v1/cancel_job`, sending the inputs below as a JSON object. The token needs the `chat:write` scope.

It makes changes, so send an [Idempotency-Key](https://modulify.ai/docs/api/idempotency) header whenever you might retry it. A retry with the same key gets the first answer back instead of running again.

```bash
curl -X POST https://api.modulify.ai/v1/cancel_job \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"projectId":"PROJECT_ID"}'
```

Over MCP, the same method is the [cancel_job tool](https://modulify.ai/docs/mcp/chat/cancel-job).

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | string | Yes | The site id. |
| `jobId` | string | No | The generation to cancel. Leave it out for the one running now. |
| `clearSession` | boolean | No | True to also reset the agent session, so the next message starts a fresh conversation. |

## Response

Every call answers with the [JSON envelope](https://modulify.ai/docs/api/requests-and-responses#the-response) of `success`, `message`, `data`, `code` and `version`. `data` holds the result described above, and on a method that returns a total, `count` carries it. The [response headers](https://modulify.ai/docs/api/requests-and-responses#headers-on-every-method-call) carry the call's `X-Request-Id` and what is left of your per-minute budget in `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. [Errors](https://modulify.ai/docs/api/errors) explains every status code a call can answer with.