Create exports
Learn how to create an export with the Onna API
This article explains how to create exports using the API. This method is useful when you want to:
- Create recurrent exports
- Create exports when specific conditions are met
- Create exports of Datasources in bulk
If you prefer Python
Download our script (opens new window) and embed it into your programs to automate the task described in this article.
Make sure your setup meets all the requirements before running the script.
# Requirements
- An active account. You can create one from the trial signup page (opens new window)
# Retrieve auth token
Authentication is required to perform API calls. Authentication is a two-step process where you first retrieve an auth code and then your auth token. After retrieving the auth token, you can reuse it in your header when you make API calls.
Visit the How to authenticate article for instructions on how to do it.
# Create export from UI
The export request payload requires many settings to their default values.
By creating an export from the UI and copying the request payload from the browser you save time because you avoid having to write all the payload manually.
Follow the tutorial (opens new window) to create an export until you reach the Export configuration: Preview step.
At that step, configure your export, then open the browser's developer tools and select Done.
- Go to the XHR tab and copy the content of the Request Payload.
# Create export from API
You will create the export in user folder, at the username
endpoint,
and then run it by making a request to the @multiFileExport
endpoint.
- Make a
POST
request to theusername
endpoint.
The request must include the authorization bearer token in the header and the export settings in the payload.
For example, you can use the content of the request payload you copied earlier.
This example is incomplete
The payload of this example is incomplete and will make the export fail. For a successful export, copy the full payload from our example script (opens new window).
Where:
TITLE
is the name you want to give to the export. This name will be shown in the UI and used in other stepsUNIQUE_ID
is the unique ID you want to give to the export. This will be used in the export URLWORKSPACE_URL
is the URL of your Workspace. You can check it by making a GET request to/SCOPE/ACCOUNT/@workspaces
SCOPE
is the name of your Onna account. For more info, see the glossaryACCOUNT
is the name of your Onna accountUSERNAME
is the email you signed up with
A successful request returns a 201
response and a JSON payload.
{
"@id": "https://enterprise.onna.com/api/CONTAINER/ACCOUNT/USERNAME/UNIQUE_ID",
"@name": "UNIQUE_ID",
"@type": "Export",
"@uid": "f4ke85b2aefe4157adcd8628da8d8fa6"
}
2
3
4
5
6
Copy the
@id
value from the payload.Run the export by making a POST request to the
@multiFileExport
endpoint.
Include the auth token in the header, the export title and the export URL in the payload.
Where:
TITLE
must be the same value as thetitle
parameter used in the payload of your POST request tousername
RESPONSE_ID
is the value of the@id
parameter from the previous response
When the request is processed successfully, you will receive a 200
response.
# Confirm export from UI
Go to the Exports section to confirm that the export is being created.
When the export is ready, Onna will send an email notification to the address that created the export.
# Examples
Here you can find some common use cases for exporting content.
# Slack Enterprise
This example script (opens new window) creates an export of Slack Enterprise data.
The example sets the file format to CSV and exports:
- Content from the last 7 days
- All attachments, parent files of the result, or both
- All metadata
- Conversations as single messages
Tip
Find more information about exportable fields (opens new window) in our Help Center.