---
title: "Cancel a background export"
method: POST
path: "/query/{id}/cancel"
tags: ["Query"]
---

# Cancel a background export

`POST /query/{id}/cancel`

## Request

- Base URL: `https://api.cloudglue.dev/v1`
- URL: `https://api.cloudglue.dev/v1/query/{id}/cancel`
- Auth: HTTP bearer

Cancel an in-progress background export. The run is marked cancelled synchronously, the export stream is aborted mid-flight (the partial upload is discarded), and the reserved credits are refunded. A run that has already completed or failed is returned unchanged.

## Path parameters

- `id` string, uuid, required

## Response `200`

The query result, with status 'cancelled' when the cancel took effect (or the run's real status if it had already finished)

- QueryResult
  - `id` string, uuid: Query result ID
  - `object` 'query_result': Object type identifier
  - `status` 'completed' | 'failed' | 'in_progress' | 'cancelled': Current status of the query. Synchronous queries return 'completed' or 'failed'.
  - `created_at` number: Unix timestamp of when the query was created
  - `collections` string[]: Collection IDs the query ran over
  - `sql` string, nullable: The effective SQL that was executed (echoes the request's sql)
  - `columns` object[], nullable: Result columns in select order
    - `name` string: Column name
    - `type` string: SQL type of the column
  - `rows` object[], nullable: Result rows as objects keyed by column name
  - `row_count` integer: Number of rows returned
  - `truncated` boolean: Whether the result was truncated by max_rows or the stored-result size cap
  - `dry_run` boolean: True when the query was only validated/compiled (dry_run request): columns holds the output schema and rows is null.
  - `usage` QueryUsage
    - `files_scanned` integer: Number of files loaded into the files virtual table
    - `entity_rows` integer: Number of rows loaded into the entities virtual table
    - `segment_entity_rows` integer: Number of rows loaded into the segment_entities virtual table
    - `engine_ms` number: SQL execution time in milliseconds
    - `total_ms` number: Total processing time in milliseconds, including dataset preparation
  - `error` object, nullable: Error details if the query failed
    - `code` string
    - `message` string
  - `format` 'json' | 'csv' | 'jsonl', nullable: The result format ('csv'/'jsonl' for background exports)
  - `download_url` string, nullable: Signed URL to download a completed background export. Valid for 24 hours and not refreshed on read (re-run the export if it expires); null for synchronous runs and until a background export completes
  - `download_expires_at` number, nullable: Unix timestamp (ms) when download_url expires
  - `output_bytes` integer, nullable: Compressed size of a completed background export, in bytes

## Other responses

- `404`: Query result not found

## Changes

- **2026-10-30** `23d3f240819f`: 1 info
  - added the optional property `code` to the response with the `404` status
- **2026-08-02** `a7a390d80571`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/cloudglue/apis/cloudglue-api/changes/query/:id/cancel/post.md)

---

[API](https://skmtc.dev/cloudglue/apis/cloudglue-api.md) - [All operations](https://skmtc.dev/cloudglue/apis/cloudglue-api/llms.txt) - [OpenAPI document](https://skmtc.dev/cloudglue/apis/cloudglue-api/revisions/23d3f240819f?raw)
