- Save and export your queries. Copy or export the SQL of each query you want to keep. For more information, refer to Save Your Queries.
- Download your reports. Download the results of the queries you need. For more information, refer to Download Query Results.
- Migrate reports to MoEngage Analytics. Rebuild the reports that MoEngage Analytics supports in custom dashboards.
- Set up data exports. If you don’t use them already, set up MoEngage Data Exports to send your MoEngage data to your own warehouse or data tools. Use them to run these workloads on a recurring basis.
To export historical events, create a support ticket. This export can incur charges and needs admin approval. It can take a few weeks, depending on the number of events and their date range.
- Queries: the SQL text, for backups, code reviews, version control, or migrations.
- Query results: the data a query returns, as CSV, TSV, Excel, or JSON, for reports, spreadsheets, or other tools.
Choose an Export Method
Before You Start
The API and command-line methods need a query ID, an API key, or both.- Query ID: Open the query and copy the number at the end of the browser URL. For example, in
https://<OPEN_ANALYTICS_URL>/queries/4821, the query ID is4821. - API key: Use the key type that matches your task.
Save Your Queries
You can copy the SQL of one query from the editor, or export every query you can access as.sql files. Copying works for a few queries. For more than a few, the bulk export is faster and keeps each query’s name with its SQL.
Copy the SQL From the Editor
1
Open the Query
In the top navigation, click Queries and select the query from the list or from Favorite Queries.
2
Show the SQL
Click Edit Source. The SQL editor opens above the results.
3
Copy the SQL
Click in the editor, press
Cmd+A (macOS) or Ctrl+A (Windows) to select the full query, and copy it. Paste it into a text file or your code repository.
GET request with your user API key. The response is a JSON object that describes the query, and the SQL is in its query field.
Get One Query
Save One Query as SQL
Export All Queries With redash-toolbelt
Theexport-queries command in the official redash-toolbelt Python package saves each query you can access as a query_<QUERY_ID>.sql file in the current folder. Each file starts with a comment that lists the query name, data source, author, and last update time.
1
Install redash-toolbelt
Install
2
Set Your User API Key
Set the API Key
3
Run the Export
Export All Queries
Download Query Results
You can download the results of a query as a file from the console, or read them from a URL with the query API key. Use the console for a one-time file. Use the API when a script needs the latest results.Download Results From the Console
1
Run the Query
Open the query and click Execute so the results are current.
2
Open the Results Menu
Below the results table, click the vertical ellipsis (⋮) next to Edit Visualization.
3
Download the File
Click Download as CSV File, Download as TSV File, or Download as Excel File.

Get Results From the API
Each saved query has its own query API key. With it, a script can read the query’s results over HTTPS without logging in.1
Copy the Query API Key
Open the query, click the horizontal ellipsis (…) next to Edit Source, and click Show API Key. The dialog shows the key and example URLs for CSV and JSON results.
2
Build the Results URL
Add the query ID and key to the URL. To get JSON or Excel instead of CSV, change
.csv to .json or .xlsx.Results URL

- It returns the latest result. If you add a result ID to the path, for example
/results/<RESULT_ID>.csv, the URL stays pinned to that one result and doesn’t update. - It returns cached results only. The URL doesn’t run the query. If the query has never run, you get a
No cached result founderror. Run the query or set a refresh schedule first. - It doesn’t work for queries with parameters. For a query that uses parameters, such as
{{limit}}, you get aNo cached result founderror. To get these results, send aPOSTrequest to/api/queries/<QUERY_ID>/resultswith your user API key. For details, see the Redash API reference. - It can fail on very large results. Results of about 200 MB or more can fail with a
502 Bad Gatewayerror. Filter or aggregate the data, or split the query into smaller date ranges.
Security Practices
- Use the narrowest key. Use a query API key to share or automate results. Use your user API key only in scripts you control.
- Keep keys out of code. Store API keys in environment variables or a secrets manager. Don’t put keys or results URLs in source code or Git.
- Protect customer data. Exported files can contain personally identifiable information (PII). Check who can open a file before you share it.
- Back up on a schedule. Run
export-querieson a schedule into a private Git repository. This gives you a version history and a way to recover a query that someone changes or deletes.