TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Meza-dev/Ghostly/llms.txt
Use this file to discover all available pages before exploring further.
POST /v1/runs/:id/cancel endpoint signals the background browser session for a run to stop. If the run has an active execution context in memory, an AbortController signal is raised and the run transitions to "cancelling" — the browser flow exits at the next cancellation checkpoint and the record is finalised asynchronously. If the run is already in a terminal state ("pass" or "fail"), the endpoint returns a 409 error.
Authentication
Pass an API key via theX-Api-Key header or a JWT via the Authorization: Bearer <token> header.
Path Parameters
The run ID returned by
POST /v1/run.Response — 200 OK
Indicates the cancellation signal was accepted.
The run ID that was cancelled.
The run is in the process of being stopped. Subscribe to
GET /v1/runs/:id/events/stream or poll GET /v1/runs/:id to confirm the
transition to "fail".Error Responses
| Status | Body | Meaning |
|---|---|---|
403 | { ok: false, error: "forbidden" } | Run exists but belongs to a different user |
404 | { ok: false, error: "not found" } | Run does not exist or belongs to a different user |
409 | { ok: false, error: "run ya finalizó" } | Run already reached a terminal state |
Orphaned Runs After Server Restart
If the Ghostly API server was restarted while a run was in"running" state, the in-memory AbortController for that run no longer exists. In this case, the cancel endpoint force-finalises the run instead:
- The run record is updated to
status: "fail". - A
run_endassist event is appended with{ cancelled: true, source: "user", staleAfterRestart: true }. - The event bus emits the
run_endand a finalstatus: "fail"event, then closes. - The response body includes an additional
stale: truefield alongsideok: trueandstatus: "cancelled".
Example
After receiving a
cancelling response, the run will eventually settle to
"fail" status. A final run_end event with cancelled: true is emitted on
the event bus before the stream closes — you can observe this via
GET /v1/runs/:id/events/stream.