# Create a query run Creates a new query run job. Endpoint: POST /query_runs Version: 2025-11-12 Security: bearerAuth ## Query parameters: - `fields[]` (array) Allows you to specify which fields are returned in the response. Accepted values created_by_id, id, sql, remaining_attempts, updated_time, file, number_of_rows, processing_duration, state, column_separator Example: ["id,created_time"] - `expand[]` (array) Allows you to expand responses by including related object information in a single call. See the Expand responses section of the Quickstart API Tutorials for detailed instructions. - `filter[]` (array) A case-sensitive filter on the list. See the Filter lists section of the Quickstart API Tutorial for detailed instructions. Note that the filters on this operation are only applicable to the related objects. For example, when you are calling the "Retrieve a billing document" operation, you can use the filter[] parameter on the related objects such as filter[]=items[account_id].EQ:8ad09e208858b5cf0188595208151c63 - `page_size` (integer) The maximum number of results to return in a single page. If the specified page_size is less than 1 or greater than 99, Zuora will return a 400 error. - `query_run.fields[]` (array) Allows you to specify which fields are returned in the response. Accepted values created_by_id, id, sql, remaining_attempts, updated_time, file, number_of_rows, processing_duration, state, column_separator Example: ["id,created_time"] ## Header parameters: - `zuora-track-id` (string) A custom identifier for tracking API requests. If you set a value for this header, Zuora returns the same value in the response header. This header enables you to track your API calls to assist with troubleshooting in the event of an issue. The value of this field must use the US-ASCII character set and must not include any of the following characters: colon (:), semicolon (;), double quote ("), or quote ('). - `async` (boolean) Making asynchronous requests allows you to scale your applications more efficiently by leveraging Zuora's infrastructure to enqueue and execute requests for you without blocking. These requests also use built-in retry semantics, which makes them much less likely to fail for non-deterministic reasons, even in extreme high-throughput scenarios. Meanwhile, when you send a request to one of these endpoints, you can expect to receive a response in less than 150 milliseconds and these calls are unlikely to trigger rate limit errors. If set to true, Zuora returns a 202 Accepted response, and the response body contains only a request ID. - `zuora-entity-ids` (string) An entity ID. If you have Multi-entity enabled and the authorization token is valid for more than one entity, you must use this header to specify which entity to perform the operation on. If the authorization token is only valid for a single entity or you do not have Multi-entity enabled, you do not need to set this header. - `idempotency-key` (string) Specify a unique idempotency key if you want to perform an idempotent POST or PATCH request. Do not use this header in other request types. This idempotency key should be a unique value, and the Zuora server identifies subsequent retries of the same request using this value. For more information, see Idempotent Requests. - `accept-encoding` (string) Include a accept-encoding: gzip header to compress responses, which can reduce the bandwidth required for a response. If specified, Zuora automatically compresses responses that contain over 1000 bytes. For more information about this header, see Request and Response Compression. - `content-encoding` (string) Include a content-encoding: gzip header to compress a request. Upload a gzipped file for the payload if you specify this header. For more information, see Request and Response Compression. ## Request fields (application/json): - `column_separator` (string) The character used as delimiter to separate values in the output file. This field is only applicable when content_type is dsv. - `content_encoding` (string) If supplied, Zuora with compress the output file using the specified compression algorithm. Enum: "gzip", "zip", "none" - `encryption_key` (string) Base64-encoded public key of a 1024-bit RSA key-pair. If you set this field, Zuora will encrypt the query results using the provided public key. You must use the corresponding private key to decrypt the query results. - `content_type` (string, required) The type of the file returned. Enum: "json", "csv", "tsv", "dsv" - `sql` (string, required) The SQL statement of the query. - `read_deleted` (boolean) If set to true, any deleted records are included in the response. ## Response 201 fields (application/json): - `created_by_id` (string) Unique identifier of the Zuora user who created the object. - `id` (string) Unique identifier for the object. - `sql` (string) The SQL statement of the query. - `remaining_attempts` (number) The remaining number of times Zuora will attempt the query before terminating the query and setting the state to failed. - `updated_time` (string) The date and time when the object was last updated in ISO-8601 UTC format. - `file` (object) The file object representing the results of the query. - `file.url` (string) The URL from which the file can be downloaded - `file.content_type` (string) The type of the file returned. Enum: "json", "jsonl", "csv", "tsv", "dsv" - `file.type` (string) The type of file. Enum: "query_run" - `number_of_rows` (number) The number of rows in the output file. - `processing_duration` (number) The time taken to process the query in milliseconds. - `state` (string) The query's execution state, which will be completed for successful runs. Enum: "pending", "accepted", "in_progress", "complete", "failed", "canceled" - `column_separator` (string) The character used as delimiter to separate values in the output file. This field is only applicable when content_type is dsv. ## Response 400 fields (application/json): - `type` (string) - `errors` (array) - `errors.code` (string) - `errors.parameter` (string) - `errors.message` (string) - `retryable` (boolean) ## Response 401 fields (application/json): - `type` (string) - `errors` (array) - `errors.code` (string) - `errors.parameter` (string) - `errors.message` (string) - `retryable` (boolean) ## Response 404 fields (application/json): - `type` (string) - `errors` (array) - `errors.code` (string) - `errors.parameter` (string) - `errors.message` (string) - `retryable` (boolean) ## Response 405 fields (application/json): - `type` (string) - `errors` (array) - `errors.code` (string) - `errors.parameter` (string) - `errors.message` (string) - `retryable` (boolean) ## Response 429 fields (application/json): - `type` (string) - `errors` (array) - `errors.code` (string) - `errors.parameter` (string) - `errors.message` (string) - `retryable` (boolean) ## Response 500 fields (application/json): - `type` (string) - `errors` (array) - `errors.code` (string) - `errors.parameter` (string) - `errors.message` (string) - `retryable` (boolean) ## Response 502 fields (application/json): - `type` (string) - `errors` (array) - `errors.code` (string) - `errors.parameter` (string) - `errors.message` (string) - `retryable` (boolean) ## Response 503 fields (application/json): - `type` (string) - `errors` (array) - `errors.code` (string) - `errors.parameter` (string) - `errors.message` (string) - `retryable` (boolean) ## Response 504 fields (application/json): - `type` (string) - `errors` (array) - `errors.code` (string) - `errors.parameter` (string) - `errors.message` (string) - `retryable` (boolean)