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

Set up connections

Set up a workspace's connections, jobs and destination through the API, from choosing a connector to the first run.

This feature is in Beta.

Everything you set up in the platform — a connection, its jobs, the workspace's destination — can also be set up through the API. This lets you build Erathos into your own product: for example, to create a connection for each of your customers from your own onboarding flow, without them ever opening the platform.

The setup follows the same steps as in the platform:

  1. Create a connection and send its credentials

  2. Configure its jobs — the tables or endpoints to sync, and how

  3. Create the destination the data is loaded into

  4. Run the jobs and follow their runs

Before you start

  • Authentication. Every request carries an API key in the Authorization header (Api-Key <API_KEY>). See Authentication. The key acts as its user: each request needs the permissions that user has in the workspace.

  • Plan. The setup endpoints need the Developer API feature in the workspace's plan. Without it, they answer 402 Payment Required.

  • Errors. When a step can't go ahead — the credentials aren't valid yet, a setting is missing, the connector isn't available — the API answers 400 with a message that says what to do next.

The examples below use https://api.erathos.com and these variables:

export ERATHOS_API_KEY="<API_KEY>"
export WORKSPACE_ID="<workspace id>"

1. Find your workspace

Connections are created in an existing workspace. List the workspaces the API key's user belongs to and take the _id of the one to use:

See Workspaces.

2. Create a connection

Choose a connector

A connection is created on a connector — the type of data source, such as HubSpot or PostgreSQL. List the connectors the workspace can use (filter with name, is_api or is_database):

A connector's detail lists the credentials a connection on it takes, so you can collect them before creating anything:

  • auth_fields and advanced_auth_fields: values such as a host, a user or an API token. is_required says which are mandatory; is_hidden marks a secret, whose value is never returned.

  • connector_files: files such as a certificate or a service account key.

  • oauth_fields: accounts the end user signs in to with the provider (see OAuth).

Create it

The connection is created without credentials. The response is the connection as Get connection returns it, with setup_status: awaiting_credentials. Keep its connection_id for every step that follows.

Send its credentials

Send the values by their field _id. Files go base64-encoded. The first time, send every required field. After that, only what you send changes: a field left out keeps its saved value, so you can also use this to replace a single expired token later.

The credentials are checked in the background: has_valid_credentials is null until the check finishes, then true or false.

OAuth

Some connectors don't take a token: the end user signs in with the provider instead. For each of the connection's oauth_fields, start an authorization:

Send the end user to the authorization_url in the response. They sign in with the provider, Erathos receives the authorization and saves it on the connection, and then:

  • With a return_url, the end user is sent back to it, with status (success or error), connection_id, authorization_id and, on failure, an error code added to its query string. The return_url must use https (http is accepted only for localhost).

  • Without one, they see a page saying the authorization is done and they can close the window.

The authorization_url is valid for 30 minutes and can be used once. You can also follow the authorization's status (pending, success or error) with Get OAuth authorization.

For a connector that uses your own OAuth app, save the app's credentials (its auth_fields, such as its client id) before starting the authorization. Until then, starting one answers 400 with the fields still missing.

Follow the setup status

A connection's setup_status says which step is next. Poll it after sending credentials or settings:

setup_status

What to do

awaiting_credentials

Send the credentials.

validating

Wait: a background check is running, such as reading the source's tables. running_validation says which.

lost_authentication

The credentials stopped working: send new ones.

needs_settings

Choose the connection's settings.

no_options_available

The credentials give access to nothing to choose for a setting (e.g. no ad account).

schema_unavailable

The source's tables or endpoints couldn't be read, or none were found.

ready_for_jobs

Configure its jobs.

no_destination

The jobs are set up, but the workspace has no working destination yet.

configured

All set.

Choose its settings

Some connectors need a choice before their data can be read — for example, which ad account or which spreadsheet. List them once the credentials are valid:

For a choice setting, options lists what can be picked (paged per setting with limit/offset; name searches them). Then send every required setting:

A connector with no settings returns none: go straight to its jobs.

3. Configure its jobs

A job syncs one table (database connections) or one endpoint (API connections) on a schedule.

See what can be synced

The available sync frequencies and sync types are listed by Sync options.

Preview, then save

Configuring jobs applies one set of settings to a selection of tables or endpoints — by id (table_ids, endpoint_ids), by schema (schema_names), by name (name_contains) or everything (select_all). Every setting is optional: a new job gets the recommended one (syncing daily at 03:00), and an existing job keeps its own. Call it again for groups with other settings.

It's a dry run by default: the response shows the jobs that would result, without saving them.

Check the response before saving:

  • pipeline lists the resulting job groups, with their sync type and schedule.

  • needs_decision lists the tables that need a choice, such as the cursor column to sync incrementally.

  • errors lists the tables or endpoints that couldn't be configured, and why.

Then send the same request with "dry_run": false to save it.

An incremental sync needs a primary key and a cursor column. recommended syncs incrementally where possible and in full elsewhere. When you ask for an incremental sync, tables that can't have one are left out and listed in needs_decision — unless you send "on_incremental_unavailable": "full", which includes them as full syncs on the fallback_sync_frequency_id/fallback_sync_time schedule.

Jobs can later be switched off and on with Disable jobs and Enable jobs. Disabling a job also disables the jobs that depend on it; enabling one also enables the jobs it depends on.

4. Create the destination

The destination is the data warehouse the jobs load into. A workspace has one, shared by all its connections. List the destination connectors, create the destination and send its credentials — the same way as for a connection:

Check whether the workspace already has a destination with Get destination: if it does, skip this step. Jobs load data only once its has_valid_credentials and has_valid_schema are both true.

The destination can be created at any point before the first run: jobs can be configured without one.

5. Run the jobs

Jobs run on their schedule. To start a run right away — for example, the first load after setup:

This queues all the connection's active jobs; send job_ids to run only some. A run can't start while the workspace has no working destination.

Follow the runs by connection or by job:

FINISHED, FAILED and CANCELED are final; QUEUED, WAITING, EXECUTING and BLOCKED are still in progress. A run's detail adds its metrics, logs and timeline. To stop the connection's runs in progress, use Cancel connection runs.

To trigger work in other tools when a run finishes, see Trigger jobs outside Erathos.

API Reference

Last updated