# cancel_operation

Cancel a running async operation

`POST /v1/operations/{operation_id}/cancel`

| | |
| --- | --- |
| Risk | write |
| Authentication | API key or OAuth access token |
| Scopes | none (any valid credential) |
| Idempotency | natural: repeating the call gives the same result |
| Dry run | not applicable |
| Success status | 200 |
| Response type | application/json |

## What it does

- Use when: You started a bulk call by mistake; items not yet applied are skipped.
- Do not use when: it already finished (nothing changes) or you want to undo applied items.
- Side effects: Skips pending items; Items already applied stay applied.
- Reversible: No.
- Required scope: none (any valid credential).
- Idempotency: safe to repeat (same result).
- Typical next step: call get_operation to see what was applied.

## Side effects

- Skips pending items
- Items already applied stay applied

## Request

### Path parameters

| Field | Type | Description |
| --- | --- | --- |
| `operation_id` | string |  |

### Query parameters

None.

## Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes |  |
| `kind` | string | yes |  |
| `state` | one of "queued", "running", "succeeded", "failed", "canceled" | yes |  |
| `progress` | object | yes |  |
| `progress.total` | integer, min -9007199254740991, max 9007199254740991 | yes |  |
| `progress.done` | integer, min -9007199254740991, max 9007199254740991 | yes |  |
| `progress.counts` | object | yes |  |
| `result` | any or null | yes |  |
| `problem` | any or null | yes |  |
| `created_at` | string (date-time) | yes |  |
| `finished_at` | string (date-time) or null | yes |  |
| `poll_after_seconds` | integer, min -9007199254740991, max 9007199254740991 or null | yes | Suggested wait before asking again; null once finished |

## Examples

### canceled

Request:

```bash
curl -X POST 'https://api.seemly.com/v1/operations/opn_0123456789abcdefghjkmnpq/cancel' \
  -H "Authorization: Bearer $SEEMLY_API_KEY"
```

Response: `200`:

```json
{
  "id": "opn_0123456789abcdefghjkmnpq",
  "kind": "bulk_upsert_subscribers",
  "state": "canceled",
  "progress": {
    "total": 500,
    "done": 120,
    "counts": {
      "added_pending": 118,
      "invalid": 2
    }
  },
  "result": null,
  "problem": null,
  "created_at": "2026-02-01T10:00:00Z",
  "finished_at": "2026-02-01T10:01:00Z",
  "poll_after_seconds": null
}
```

## Errors

| Status | Codes |
| --- | --- |
| 400 | [`validation_failed`](/developers/md/errors/validation_failed) |
| 401 | [`unauthenticated`](/developers/md/errors/unauthenticated), [`credential_revoked`](/developers/md/errors/credential_revoked), [`credential_expired`](/developers/md/errors/credential_expired) |
| 403 | [`plan_does_not_include`](/developers/md/errors/plan_does_not_include), [`workspace_paused`](/developers/md/errors/workspace_paused), [`api_suspended`](/developers/md/errors/api_suspended), [`consent_required`](/developers/md/errors/consent_required) |
| 404 | [`not_found`](/developers/md/errors/not_found) |
| 409 | [`conflict`](/developers/md/errors/conflict) |
| 429 | [`rate_limited`](/developers/md/errors/rate_limited), [`quota_exceeded`](/developers/md/errors/quota_exceeded) |
| 503 | [`service_unavailable`](/developers/md/errors/service_unavailable) |

Every error is an `application/problem+json` body with a `code`, a `fix` sentence and `next_actions`. See [reading a problem response](/developers/md/guides/agents#reading-a-problem-response).

## Typical next steps

- [`get_operation`](/developers/md/operations/get_operation)

## Related

- [OpenAPI document](https://api.seemly.com/v1/openapi.json)
- [Agent guide](/developers/md/guides/agents)
