# Retrieve a Query Run Fetches the current state and details of a previously created `QueryRun`. If the `QueryRun` has succeeded, the endpoint will provide details for how to retrieve the results. ## Returns ## Response attributes - `id` (string) The unique identifier of the `QueryRun` object. - `object` (string, value is "v2.data.reporting.query_run") String representing the object’s type. Objects of the same type share the same value of the object field. - `created` (timestamp) Time at which the object was created. - `livemode` (boolean) Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. - `result` (object, nullable) Details how to retrieve the results of a successfully completed `QueryRun`. - `result.file` (object, nullable) Contains metadata about the file produced by the `ReportRun` or `QueryRun`, including its content type, size, and a URL to download its contents. - `result.file.content_type` (enum) The content type of the file. Possible enum values: - `csv` CSV content type. Mime type of `text/csv`. - `zip` ZIP content type. Mime type of `application/zip`. - `result.file.download_url` (object) A pre-signed URL that allows secure, time-limited access to download the file. - `result.file.download_url.expires_at` (timestamp, nullable) The time that the URL expires. - `result.file.download_url.url` (string) The URL that can be used for accessing the file. - `result.file.size` (int64) The total size of the file in bytes. - `result.type` (enum) The type of the `ReportRun` or `QueryRun` result. Possible enum values: - `file` File result type. - `result_options` (object, nullable) The options specified for customizing the output of the `QueryRun`. - `result_options.compress_file` (boolean, nullable) If set, the generated results file will be compressed into a ZIP folder. This is useful for reducing file size and download time for large results. - `sql` (string) The SQL that was executed. - `status` (enum) The current status of the `QueryRun`. Possible enum values: - `failed` Query has failed to complete due to an error. - `running` Query is in progress. - `succeeded` Query has successfully completed. - `status_details` (map) Additional details about the current state of the `QueryRun`. Populated when the `QueryRun` is in the `failed` state, providing more information about why the query failed. ## Error Codes | HTTP status code | Code | Description | | ---------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 403 | query_run_api_inaccessible | Returned when the query runs API is not accessible to the request. The error message provides the reason (e.g. feature not enabled, compartment not allowed). | | 404 | not_found | The resource wasn’t found. | #### Running #### Running ```curl curl https://api.stripe.com/v2/data/reporting/query_runs/qryrun_test_xxx \ -H "Authorization: Bearer <>" \ -H "Stripe-Version: 2026-04-22.preview" ``` ### Response ```json { "created": "2025-08-26T00:00:00.000Z", "id": "qryrun_test_xxx", "object": "v2.data.reporting.query_run", "sql": "select * from balance_transactions limit 10", "result": null, "result_options": { "compress_file": false }, "status": "running", "status_details": {}, "livemode": false } ``` #### Succeeded #### Succeeded ```curl curl https://api.stripe.com/v2/data/reporting/query_runs/qryrun_test_xxx \ -H "Authorization: Bearer <>" \ -H "Stripe-Version: 2026-04-22.preview" ``` ### Response ```json { "created": "2025-08-26T00:00:00.000Z", "id": "qryrun_test_xxx", "object": "v2.data.reporting.query_run", "sql": "select * from balance_transactions limit 10", "result": { "file": { "content_type": "csv", "download_url": { "expires_at": "2025-08-26T21:53:30.446396574Z", "url": "https://stripeusercontent.com/files/us-west-2/..." }, "size": "500" }, "type": "file" }, "result_options": { "compress_file": false }, "status": "succeeded", "status_details": {}, "livemode": false } ``` #### Failed #### Failed ```curl curl https://api.stripe.com/v2/data/reporting/query_runs/qryrun_test_xxx \ -H "Authorization: Bearer <>" \ -H "Stripe-Version: 2026-04-22.preview" ``` ### Response ```json { "created": "2025-08-26T00:00:00.000Z", "id": "qryrun_test_xxx", "object": "v2.data.reporting.query_run", "sql": "select * from balance_transactions limit 10", "result": null, "result_options": { "compress_file": false }, "status": "failed", "status_details": { "failed": { "error_code": "file_size_above_limit", "error_message": "The file generated by this request exceeds the 5 GB limit." } }, "livemode": false } ```