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.

Sync schedule JSON configuration

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

Strategy: "manual"

When scheduleStrategy is "manual", this field can be excluded altogether. With this strategy, syncs will never be triggered automatically, so they must be requested manually.

Strategy: "periodic"

When scheduleStrategy is "periodic", the only supported 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 config would look like this:

{
  "interval": "1h"
}

Strategy: "specific_days"

When scheduleStrategy is "specific_days", there are only 3 supported 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).

An example config would look like:

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

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

Create Reverse Etl Model

Creates a new Reverse ETL Model.

  • When called, this endpoint may generate the `Model Created` event in the [audit trail](/tag/Audit-Trail).
  
Securitytoken
Request
Request Body schema: application/vnd.segment.v1alpha+json
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.

scheduleStrategy
required
string (scheduleStrategy)

Determines the strategy used for triggering syncs, which will be used in conjunction with scheduleConfig.

Enum: "MANUAL" "PERIODIC" "SPECIFIC_DAYS"
required
object (scheduleConfig)

Depending on the chosen strategy, configures the schedule for this model.

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
200

OK

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",
  • "scheduleStrategy": "MANUAL",
  • "scheduleConfig": { }
}
Response samples
application/vnd.segment.v1alpha+json
{
  • "data": {
    }
}

List Reverse Etl Models

Returns a list of Reverse ETL Models.

Securitytoken
Request
query Parameters
required
object (PaginationInput)

Defines the pagination parameters.

This parameter exists in alpha.

Example: 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({ count: 10 }))
  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](/tag/Audit-Trail).
  
Securitytoken
Request
path Parameters
modelId
required
string [ 1 .. 255 ]
Example: aow61ZsjXFRsUqB5wWmZES
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('aow61ZsjXFRsUqB5wWmZES'))
  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: MaAeg9yDd1UZTBeEYDiVw
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('MaAeg9yDd1UZTBeEYDiVw'))
  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](/tag/Audit-Trail) events:* Model Settings Saved
  • Model State Change Toggled
Securitytoken
Request
path Parameters
modelId
required
string [ 1 .. 255 ]
Example: 37YCmBXayzqG4sit63P5pH
Request Body schema: application/vnd.segment.v1alpha+json
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.

scheduleStrategy
string (scheduleStrategy)

Determines the strategy used for triggering syncs, which will be used in conjunction with scheduleConfig.

Enum: "MANUAL" "PERIODIC" "SPECIFIC_DAYS"
object (scheduleConfig)

Depending on the chosen strategy, configures the schedule for this model.

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"
}
Response samples
application/vnd.segment.v1alpha+json
{
  • "data": {
    }
}