Reverse ETL

Reverse ETL allows the use of a database (aka: Segment Warehouse) as a source of data to be connected and sent to supported Segment Destinations. Previously, it was only possible to use a Segment Warehouse as a destination.

Reverse ETL Sync schedule JSON configuration

The structure of config varies with the value in strategy. All strategies will employ a key/value object with minimum depth of 1.

Strategy: "manual"

When strategy is "manual", config can be excluded altogether. With this strategy, syncs will never be triggered automatically, so they must be triggered manually through the UI or Public API route.

"reverseETLSchedule": {
  "strategy": "manual"
}

Strategy: "periodic"

When strategy is "periodic", the only supported config key is "interval", which will be a string that is in a format accepted by Go's time.ParseDuration function. For example, "3h" will sync every 3 hours, while "30m" will sync every 30 minutes. The interval must be greater than 10 minutes ("10m") and shorter than 1 week ("168h").

An example schedule would look like this:

"reverseETLSchedule": {
  {
    "config": {
      "interval": "1h"
    },
    "strategy": "periodic"
  }
}

Strategy: "specific_days"

When strategy is "specific_days", there are only 3 supported config keys: "days", "hours" and "timezone".

The "days" field must be an array of numbers, corresponding to the desired days of the week that syncs should run. Each item must be a number from 0 (Sunday) up to 6 (Saturday). There needs to be at least 1 item, but also no more than 7.

For example: [0, 6] would correspond to the weekend (Saturday and Sunday) while [1, 2, 3, 4, 5] would correspond to the weekdays (Monday through Friday).

The "hours" field must be an array of numbers, corresponding to the desired hours of the day that syncs should run. Each item must be a number from 0 (12am or 0:00) up to 23 (11pm or 23:00). There needs to be at least 1 item, but also no more than 24.

For example: [0, 12] would correspond to the running at midnight (12:00am / 0:00) and noon (12:00pm / 12:00).

The "timezone" field must be a valid value from the IANA database used by Golang, which should match the list found here. This allows the "hours" above to reflect your own time zone which may be easier to configure, but you can also choose "UTC" if you want to avoid things like DST (daylight savings).

A simple example config would look like:

"reverseETLSchedule": {
  "config": {
    "days": [1],
    "hours": [15],
    "timezone": "America/New_York"
  },
  "strategy": "specific_days"
}

A more complex example:

"reverseETLSchedule": {
  "config": {
    "days": [0, 6],
    "hours": [0, 6, 12, 18],
    "timezone": "America/Los_Angeles"
  },
  "strategy": "specific_days"
}

This would run syncs 4 times per day (midnight, 6am, noon, 6pm) but only on weekends (Saturday and Sunday).

Strategy: "cron"

Use the cron expression for precise scheduling. Remember to include only five fields, not six, as Segment's smallest time unit is minutes. If you need help, use a cron expression generator to create the ideal schedule.

Note: We do not allow cron expressions lower than 15 minutes.

Here is an example indicating 'At 15 minutes past the hour, every 3 hours, on day 1 of the month', e.g. (Tuesday October 01, 2024 at 12:15 am)

"reverseETLSchedule": {
  "config": {
    "spec": "15 */3 1 * *",
    "timezone": "America/Los_Angeles"
  },
  "strategy": "cron"
}

Cancel Reverse ETL Sync for Model

Cancels a sync for a Reverse ETL Connection. It might take a few seconds to completely cancel the sync.

Will return an error if the sync is already completed or cancelled.

Securitytoken
Request
path Parameters
modelId
required
string [ 1 .. 255 ]
Example: modelId
syncId
required
string [ 1 .. 255 ]
Example: 1
Request Body schema: application/vnd.segment.v1alpha+json
required
reasonForCanceling
number (reasonForCanceling)

The reason for canceling the sync.

  • IncorrectModel = 0
  • IncorrectDest = 1
  • IncorrectKeys = 2
  • IncorrectMapping = 3
  • Other = 4
Responses
200

OK

404

Resource not found

422

Validation failure

429

Too many requests

post/reverse-etl-models/{modelId}/syncs/{syncId}/cancel
Request samples
application/vnd.segment.v1alpha+json
{
  • "reasonForCanceling": 0
}
Response samples
application/vnd.segment.v1alpha+json
{
  • "data": {
    }
}

Create Reverse ETL Manual Sync

Triggers a manual sync for a Reverse ETL Connection.

In the request body, the subscription id is the id that follows after /mappings/ portion in the URL of the sync.

For example, the subscription id would be 2 for this sync: https://app.Segment.com/example-workspace/reverse-etl/destinations/example-destination/sources/example-source/instances/1/mappings/2/source-id/3/model-id/4/sync-details

The rate limit for this endpoint is 20 requests per minute, which is lower than the default due to access pattern restrictions. Once reached, this endpoint will respond with the 429 HTTP status code with headers indicating the limit parameters. See Rate Limiting for more information.

Securitytoken
Request
Request Body schema: application/vnd.segment.v1alpha+json
required
sourceId
required
string (sourceId)

The id of the Source.

modelId
required
string (modelId)

The id of the Model.

subscriptionId
required
string (subscriptionId)

The id of the Subscription.

Responses
200

OK

404

Resource not found

422

Validation failure

429

Too many requests

post/reverse-etl-syncs
Request samples
application/vnd.segment.v1alpha+json
{
  • "sourceId": "sourceId",
  • "modelId": "modelId",
  • "subscriptionId": "subscriptionId"
}
Response samples
application/vnd.segment.v1alpha+json
{
  • "data": {
    }
}

Create Reverse Etl Model

Creates a new Reverse ETL Model.

• When called, this endpoint may generate the Model Created event in the audit trail.

Securitytoken
Request
Request Body schema: application/vnd.segment.v1alpha+json
required
sourceId
required
string (sourceId)

Indicates which Source to attach this model to.

name
required
string (name)

A short, human-readable description of the Model.

description
required
string (description)

A longer, more descriptive explanation of the Model.

enabled
required
boolean (enabled)

Indicates whether the Model should have syncs enabled. When disabled, no syncs will be triggered, regardless of the enabled status of the attached destinations/subscriptions.

query
required
string (query)

The SQL query that will be executed to extract data from the connected Source.

queryIdentifierColumn
required
string (queryIdentifierColumn)

Indicates the column named in query that should be used to uniquely identify the extracted records.

Responses
201

Created

404

Resource not found

422

Validation failure

429

Too many requests

post/reverse-etl-models
Request samples
application/vnd.segment.v1alpha+json
{
  • "sourceId": "qQEHquLrjRDN9j1ByrChyn",
  • "name": "Model 1",
  • "description": "This model is very useful.",
  • "enabled": true,
  • "query": "SELECT 'user_1' AS id",
  • "queryIdentifierColumn": "id"
}
Response samples
application/vnd.segment.v1alpha+json
{
  • "data": {
    }
}

List Reverse Etl Models

Returns a list of Reverse ETL Models.

Securitytoken
Request
query Parameters
object (PaginationInput)

Defines the pagination parameters.

This parameter exists in alpha.

Example: pagination=pagination.count=10
Responses
200

OK

404

Resource not found

422

Validation failure

429

Too many requests

get/reverse-etl-models
Request samples
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript'

const api = configureApis('/* Insert your Public API token here */')

try {
  const result = await unwrap(api.reverseEtl.listReverseEtlModels())
  console.log(JSON.stringify(result))
} catch (e) {
  console.log('ERROR:', e)
}
Response samples
application/vnd.segment.v1alpha+json
{
  • "data": {
    }
}

Delete Reverse Etl Model

Deletes an existing Model.

• When called, this endpoint may generate the Model Deleted event in the audit trail.

Securitytoken
Request
path Parameters
modelId
required
string [ 1 .. 255 ]
Example: fxXMc5bLdKnDfEgBpDbV11
Responses
200

OK

404

Resource not found

422

Validation failure

429

Too many requests

delete/reverse-etl-models/{modelId}
Request samples
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript'

const api = configureApis('/* Insert your Public API token here */')

try {
  const result = await unwrap(api.reverseEtl.deleteReverseEtlModel('fxXMc5bLdKnDfEgBpDbV11'))
  console.log(JSON.stringify(result))
} catch (e) {
  console.log('ERROR:', e)
}
Response samples
application/vnd.segment.v1alpha+json
{
  • "data": {
    }
}

Get Reverse Etl Model

Returns a Reverse ETL Model by its id.

Securitytoken
Request
path Parameters
modelId
required
string [ 1 .. 255 ]
Example: jSAVzDH3z89geNDZwoNY9V
Responses
200

OK

404

Resource not found

422

Validation failure

429

Too many requests

get/reverse-etl-models/{modelId}
Request samples
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript'

const api = configureApis('/* Insert your Public API token here */')

try {
  const result = await unwrap(api.reverseEtl.getReverseEtlModel('jSAVzDH3z89geNDZwoNY9V'))
  console.log(JSON.stringify(result))
} catch (e) {
  console.log('ERROR:', e)
}
Response samples
application/vnd.segment.v1alpha+json
{
  • "data": {
    }
}

Update Reverse Etl Model

Updates an existing Reverse ETL Model.

• When called, this endpoint may generate one or more of the following audit trail events:* Model Settings Saved

  • Model State Change Toggled
Securitytoken
Request
path Parameters
modelId
required
string [ 1 .. 255 ]
Example: 6BthE21tPsXyA2cK3QPQFQ
Request Body schema: application/vnd.segment.v1alpha+json
required
name
string (name)

A short, human-readable description of the Model.

description
string (description)

A longer, more descriptive explanation of the Model.

enabled
boolean (enabled)

Indicates whether the Model should have syncs enabled. When disabled, no syncs will be triggered, regardless of the enabled status of the attached destinations/subscriptions.

query
string (query)

The SQL query that will be executed to extract data from the connected Source.

queryIdentifierColumn
string (queryIdentifierColumn)

Indicates the column named in query that should be used to uniquely identify the extracted records.

Responses
200

OK

404

Resource not found

422

Validation failure

429

Too many requests

patch/reverse-etl-models/{modelId}
Request samples
application/vnd.segment.v1alpha+json
{
  • "name": "My Updated Model",
  • "query": "SELECT 'user_2' AS id"
}
Response samples
application/vnd.segment.v1alpha+json
{
  • "data": {
    }
}

Get Reverse ETL Sync Status

Get the sync status for a Reverse ETL sync. The sync status includes all detailed information about the sync - sync status, duration, details about the extract and load phase if applicable, etc.

The rate limit for this endpoint is 250 requests per minute, which is lower than the default due to access pattern restrictions. Once reached, this endpoint will respond with the 429 HTTP status code with headers indicating the limit parameters. See Rate Limiting for more information.

Securitytoken
Request
path Parameters
modelId
required
string [ 1 .. 255 ]
Example: modelId
syncId
required
string [ 1 .. 255 ]
Example: syncId
Responses
200

OK

404

Resource not found

422

Validation failure

429

Too many requests

get/reverse-etl-models/{modelId}/syncs/{syncId}
Request samples
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript'

const api = configureApis('/* Insert your Public API token here */')

try {
  const result = await unwrap(api.reverseEtl.getReverseETLSyncStatus('modelId', 'syncId'))
  console.log(JSON.stringify(result))
} catch (e) {
  console.log('ERROR:', e)
}
Response samples
application/vnd.segment.v1alpha+json
{
  • "data": {
    }
}

List Reverse ETL Sync Statuses from Model And Subscription Id

Get the sync statuses for a Reverse ETL mapping subscription. The sync status includes all detailed information about the sync - sync status, duration, details about the extract and load phase if applicable, etc. The default page count is 10, and then the next page can be fetched by passing the cursor query parameter.

Securitytoken
Request
path Parameters
modelId
required
string [ 1 .. 255 ]
Example: modelId
subscriptionId
required
string [ 1 .. 255 ]
Example: subscriptionId
query Parameters
count
number (count)

The number of items to retrieve in a page, between 1 and 100. Default is 10

This parameter exists in alpha.

cursor
string (cursor)

The page to request. Acceptable values to use are from the current, next, and previous keys.

This parameter exists in alpha.

Responses
200

OK

404

Resource not found

422

Validation failure

429

Too many requests

get/reverse-etl-models/{modelId}/subscriptionId/{subscriptionId}/syncs
Request samples
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript'

const api = configureApis('/* Insert your Public API token here */')

try {
  const result = await unwrap(api.reverseEtl.listReverseETLSyncStatusesFromModelAndSubscriptionId('modelId', 'subscriptionId'))
  console.log(JSON.stringify(result))
} catch (e) {
  console.log('ERROR:', e)
}
Response samples
application/vnd.segment.v1alpha+json
{
  • "data": {
    }
}