For the complete documentation index, see llms.txt. This page is also available as Markdown.

Export

Create an ndjson export from an OTQL query, run it, and download the result.

Your goal

Get the result of an OTQL query out of the platform as a file - for an analyst, a partner, or a one-off need.

Expected outcome

An ndjson file containing exactly the properties you selected in your query.

The objects involved

An export is a definition with:

  • a name,

  • an output format - always JSON for now,

  • a type - always QUERY for now,

  • an associated query,

  • an associated organisation,

  • an associated datamart.

Each export has executions, representing its result at a given time.

The resulting file is formatted as ndjson and contains the properties you selected in the SELECT part of the OTQL query.

Run an export

1

Write and save the query

Create the OTQL query the export is based on. See OTQL.

2

Create the export definition

Definitions can be listed with GET /v1/exports?organisation_id=:orgId and read with GET /v1/exports/:exportId?organisation_id=:orgId.

3

Generate an execution

The body must be an empty JSON object: {}.

4

Follow it

Watch status, and once it succeeds, read result.output_files - it holds the technical name of the file to download, usually export when there is a single file.

num_tasks, completed_tasks, and erroneous_tasks tell you how much of the export succeeded.

5

Download the file

Use one of these methods, the exports API being the recommended one:

technical_name is a value from result.output_files.

For a query such as SELECT {emails {id}} FROM UserPoint WHERE segments {id="<SEGMENTID>"}, the file looks like:

Note the empty arrays: a UserPoint matching the query but with no email still produces a line.

A 404 means the file does not exist or has been removed.

When an execution fails

Download the error file:

Verify

  • The query returns the expected results before you create the export.

  • The execution reaches Succeeded, and erroneous_tasks is zero or explained.

  • The downloaded file has the number of lines you expected, and the properties you selected.

Last updated

Was this helpful?