> For the complete documentation index, see [llms.txt](https://docs.mediarithmics.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mediarithmics.io/api-reference/datamart-operations/query-exports.md).

# Query Exports

Operations related to Query Exports for exporting data matching a specific OTQL query. Enables flexible data extraction beyond segment-based exports, allowing custom queries to retrieve and export specific user attributes, event data, profiles, or aggregated analytics results to files for external analysis and reporting.

## GET /exports

> Find exports

```json
{"openapi":"3.1.1","info":{"title":"mediarithmics openapi API","version":"1.0.0"},"tags":[{"name":"Mediarithmics most used API","description":"These operations where flagged by mediarithmics teams as most useful."},{"name":"Query Exports","description":"Operations related to Query Exports for exporting data matching a specific OTQL query. Enables flexible data extraction beyond segment-based exports, allowing custom queries to retrieve and export specific user attributes, event data, profiles, or aggregated analytics results to files for external analysis and reporting."}],"servers":[{"url":"http://api.mediarithmics.local/v1","description":"Development server"},{"url":"https://api.mediarithmics.com/v1","description":"Production server"}],"paths":{"/exports":{"get":{"tags":["Query Exports","Mediarithmics most used API"],"description":"","summary":"Find exports","responses":{"200":{"description":"Success !","content":{"application/json":{"schema":{"type":"object","properties":{"total":{"type":"integer"},"max_results":{"type":"integer"},"data":{"type":"array","items":{"$ref":"#/components/schemas/ExportResource"}},"status":{"type":"string","enum":["ok"]},"count":{"type":"integer"},"first_result":{"type":"integer"}},"required":["count","data","first_result","max_results","status","total"]}}}},"400":{"$ref":"#/components/responses/error"},"401":{"$ref":"#/components/responses/error"},"403":{"$ref":"#/components/responses/error"},"404":{"$ref":"#/components/responses/error"},"500":{"$ref":"#/components/responses/error"},"503":{"$ref":"#/components/responses/error"}},"parameters":[{"schema":{"type":"integer","format":"int64"},"style":"form","required":true,"description":"The organisation id owning the export","explode":true,"name":"organisation_id","in":"query"},{"name":"export_type","explode":true,"required":false,"description":"The export type","in":"query","schema":{"type":"array","items":{"$ref":"#/components/schemas/ExportType"}},"style":"form"},{"required":false,"name":"keywords","style":"form","explode":true,"description":"matching export name","schema":{"type":"string"},"in":"query"},{"name":"name","required":false,"in":"query","schema":{"type":"string"},"explode":true,"style":"form","description":"The export name"},{"explode":true,"name":"start_date","required":false,"style":"form","schema":{"type":"string"},"description":"The export starting date","in":"query"},{"schema":{"type":"string"},"in":"query","explode":true,"name":"end_date","description":"The export end date","required":false,"style":"form"},{"description":"Filter archived exports","style":"form","required":false,"name":"archived","explode":true,"schema":{"type":"boolean"},"in":"query"},{"name":"order_by","required":false,"schema":{"type":"array","items":{"type":"string"}},"explode":true,"style":"form","in":"query","description":"Oredring"},{"required":false,"style":"form","explode":true,"description":"label ids","in":"query","name":"label_ids","schema":{"type":"array","items":{"type":"integer","format":"int64"}}},{"description":"Offset from which the search must be performed","schema":{"type":"integer","format":"int32"},"style":"form","name":"first_result","required":false,"in":"query","explode":true},{"schema":{"type":"integer","format":"int32"},"in":"query","name":"max_results","required":false,"explode":true,"description":"Number of maximum items that shall be return by this search","style":"form"}],"operationId":"findExports"}}},"components":{"schemas":{"ExportResource":{"discriminator":{"propertyName":"type","mapping":{"QUERY":"#/components/schemas/QueryExportResource"}},"oneOf":[{"$ref":"#/components/schemas/QueryExportResource"}],"properties":{"type":{"type":"string","enum":["QUERY"]}},"required":["type"]},"QueryExportResource":{"type":"object","properties":{"organisation_id":{"type":"string","readOnly":true},"priority":{"$ref":"#/components/schemas/JobExecPriorityForOrganizationAndDefinition"},"datamart_id":{"type":"string","readOnly":true},"name":{"type":"string","readOnly":false},"id":{"type":"string","readOnly":true},"created_ts":{"type":"integer","format":"int64","default":0,"readOnly":true},"query_id":{"type":"string","readOnly":false},"output_format":{"$ref":"#/components/schemas/DatamartExportJobResultFormat"}},"required":["created_ts","datamart_id","id","name","organisation_id","output_format","priority","query_id"]},"JobExecPriorityForOrganizationAndDefinition":{"type":"string","enum":["LOW","MEDIUM","HIGH"],"readOnly":false},"DatamartExportJobResultFormat":{"type":"string","enum":["CSV","JSON"],"readOnly":false},"errorResponse":{"type":"object","properties":{"status":{"type":"string","enum":["error"]},"error_code":{"type":"string","enum":["AUTHENTICATION_ERROR","AUTHORIZATION_ERROR","BAD_REQUEST_DATA","BAD_REQUEST_FORMAT","CONSTRAINT_VIOLATION_EXCEPTION","EMAIL_ALREADY_EXISTS","MAC_ERROR","RESOURCE_NOT_FOUND","SERVICE_UNAVAILABLE","TOKEN_ERROR"]},"error_id":{"type":"string"},"error":{"type":"string"}},"required":["error","error_code","error_id","status"]},"ExportType":{"type":"string","enum":["QUERY"],"readOnly":false}},"responses":{"error":{"description":"Error response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errorResponse"}}}}}}}
```

## POST /exports

> Create new export

```json
{"openapi":"3.1.1","info":{"title":"mediarithmics openapi API","version":"1.0.0"},"tags":[{"name":"Mediarithmics most used API","description":"These operations where flagged by mediarithmics teams as most useful."},{"name":"Query Exports","description":"Operations related to Query Exports for exporting data matching a specific OTQL query. Enables flexible data extraction beyond segment-based exports, allowing custom queries to retrieve and export specific user attributes, event data, profiles, or aggregated analytics results to files for external analysis and reporting."}],"servers":[{"url":"http://api.mediarithmics.local/v1","description":"Development server"},{"url":"https://api.mediarithmics.com/v1","description":"Production server"}],"paths":{"/exports":{"post":{"responses":{"200":{"description":"Success !","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["ok"]},"data":{"$ref":"#/components/schemas/ExportResource"}},"required":["data","status"]}}}},"400":{"$ref":"#/components/responses/error"},"401":{"$ref":"#/components/responses/error"},"403":{"$ref":"#/components/responses/error"},"404":{"$ref":"#/components/responses/error"},"500":{"$ref":"#/components/responses/error"},"503":{"$ref":"#/components/responses/error"}},"requestBody":{"description":"The name of the api token to create","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExportResource"}}},"required":true},"description":"","operationId":"createExport","tags":["Query Exports","Mediarithmics most used API"],"summary":"Create new export","parameters":[{"in":"query","schema":{"type":"integer","format":"int64"},"name":"organisation_id","explode":true,"required":true,"style":"form","description":"The organisation id owning the export"}]}}},"components":{"schemas":{"ExportResource":{"discriminator":{"propertyName":"type","mapping":{"QUERY":"#/components/schemas/QueryExportResource"}},"oneOf":[{"$ref":"#/components/schemas/QueryExportResource"}],"properties":{"type":{"type":"string","enum":["QUERY"]}},"required":["type"]},"QueryExportResource":{"type":"object","properties":{"organisation_id":{"type":"string","readOnly":true},"priority":{"$ref":"#/components/schemas/JobExecPriorityForOrganizationAndDefinition"},"datamart_id":{"type":"string","readOnly":true},"name":{"type":"string","readOnly":false},"id":{"type":"string","readOnly":true},"created_ts":{"type":"integer","format":"int64","default":0,"readOnly":true},"query_id":{"type":"string","readOnly":false},"output_format":{"$ref":"#/components/schemas/DatamartExportJobResultFormat"}},"required":["created_ts","datamart_id","id","name","organisation_id","output_format","priority","query_id"]},"JobExecPriorityForOrganizationAndDefinition":{"type":"string","enum":["LOW","MEDIUM","HIGH"],"readOnly":false},"DatamartExportJobResultFormat":{"type":"string","enum":["CSV","JSON"],"readOnly":false},"errorResponse":{"type":"object","properties":{"status":{"type":"string","enum":["error"]},"error_code":{"type":"string","enum":["AUTHENTICATION_ERROR","AUTHORIZATION_ERROR","BAD_REQUEST_DATA","BAD_REQUEST_FORMAT","CONSTRAINT_VIOLATION_EXCEPTION","EMAIL_ALREADY_EXISTS","MAC_ERROR","RESOURCE_NOT_FOUND","SERVICE_UNAVAILABLE","TOKEN_ERROR"]},"error_id":{"type":"string"},"error":{"type":"string"}},"required":["error","error_code","error_id","status"]}},"responses":{"error":{"description":"Error response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errorResponse"}}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mediarithmics.io/api-reference/datamart-operations/query-exports.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
