Create exports

Learn how to create an export with the Onna API


💡 5 min read

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 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

# 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.

  1. Follow the tutorial to create an export until you reach the Export configuration: Preview step.

  2. At that step, configure your export, then open the browser's developer tools and select Done.

export-configuration-preview

  1. Go to the XHR tab and copy the content of the Request Payload.

export-dev-tools-xhr

# 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.

  1. Make a POST request to the username 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.

Where:

  • TITLE is the name you want to give to the export. This name will be shown in the UI and used in other steps
  • UNIQUE_ID is the unique ID you want to give to the export. This will be used in the export URL
  • WORKSPACE_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 glossary
  • ACCOUNT is the name of your Onna account
  • USERNAME 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"
}
1
2
3
4
5
6
  1. Copy the @id value from the payload.

  2. 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 the title parameter used in the payload of your POST request to username
  • 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.

export-onna-ui-exports

When the export is ready, Onna will send an email notification to the address that created the export.

export-onna-ui-export-ready

# Examples

Here you can find some common use cases for exporting content.

# Slack Enterprise

This example script 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 in our Help Center.

Last Updated: 12/17/2020, 2:23:06 PM