# Delete a session and its context

> Removes the session row and purges its context permanently. Unlike release, the id stops resolving afterwards.

Source: https://docs.spicrawl.com/api-reference/sessions/sessions-delete

## DELETE /v1/sessions/{sessionID}

Operation ID: `sessionsDelete`. API key scope: `sessions`.

Removes the session row and purges its context permanently. Unlike release, the id stops resolving
afterwards. Request-log entries that reference the session survive.

Pitfalls:
- Idempotent: deleting an unknown or already-deleted id returns 204 (including another tenant's id),
  so a 204 does not prove the session existed.
- While a render holds the lease, returns 409 `ERR::SESSION::BUSY` with `Retry-After`. Wait, or repeat
  with `force=true` to delete anyway and fail the running task.

### Example

```bash
curl -X DELETE "https://api.spicrawl.com/v1/sessions/{sessionID}" \
  -H "Authorization: Bearer $SPICRAWL_API_KEY"
```

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `sessionID` | path | string | yes | Session id from `POST /v1/sessions` (26-character ULID; a UUID is also accepted). A malformed id answers 404 `ERR::SESSION::NOT_FOUND`, the same as an unknown one. |
| `force` | query | boolean; default `false` | no | Set `true` to end the session even while a render holds its lease; the running task fails. Parsed as a Go boolean (`true`, `false`, `1`, `0`, `t`, `f`, any case); other values are refused with 400. |

### Responses

#### 204

Deleted, or did not exist.

#### 400

The request is invalid. Not retryable; fix the request using `code` and `diagnostics.hint`.

Headers: `X-Request-Id`.

`application/problem+json` (`Problem` schema).

#### 401

Missing, invalid, revoked or expired key. Not retryable with the same key.

Headers: `X-Request-Id`.

`application/problem+json` (`Problem` schema).

#### 403

The key lacks the scope this route requires (`ERR::AUTH::INSUFFICIENT_SCOPE`), or the action is not permitted.

Headers: `X-Request-Id`.

`application/problem+json` (`Problem` schema).

#### 404

No such resource for this key's organization.

Headers: `X-Request-Id`.

`application/problem+json` (`Problem` schema).

#### 409

Conflicts with the resource's current state, for example a session in use (`ERR::SESSION::BUSY`, retryable).

Headers: `X-Request-Id`.

`application/problem+json` (`Problem` schema).

#### 500

Internal error. Retryable when `retryable` is true.

Headers: `X-Request-Id`.

`application/problem+json` (`Problem` schema).

Full OpenAPI spec: https://docs.spicrawl.com/openapi.yaml
