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.
The structure of scheduleConfig
varies with the value in scheduleStrategy
.
All strategies will employ a key/value object with minimum depth of 1.
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.
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"
}
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).
Creates a new Reverse ETL Model.
• When called, this endpoint may generate the `Model Created` event in the [audit trail](/tag/Audit-Trail).
OK
Resource not found
Validation failure
Too many requests
{- "sourceId": "qQEHquLrjRDN9j1ByrChyn",
- "name": "Model 1",
- "description": "This model is very useful.",
- "enabled": true,
- "query": "SELECT 'user_1' AS id",
- "queryIdentifierColumn": "id",
- "scheduleStrategy": "MANUAL",
- "scheduleConfig": { }
}
{- "data": {
- "reverseEtlModel": {
- "id": "qyH51KjvLDyAESPKx7r4mo",
- "sourceId": "qQEHquLrjRDN9j1ByrChyn",
- "name": "Model 1",
- "description": "This model is very useful.",
- "enabled": true,
- "query": "SELECT 'user_1' AS id",
- "queryIdentifierColumn": "id",
- "scheduleStrategy": "MANUAL",
- "scheduleConfig": { }
}
}
}
Returns a list of Reverse ETL Models.
required | object (PaginationInput) Defines the pagination parameters. This parameter exists in alpha. Example: pagination[count]=10 |
OK
Resource not found
Validation failure
Too many requests
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) }
{- "data": {
- "models": [
- {
- "id": "9jkvh31ncg66pbYso3JZZ7",
- "sourceId": "qQEHquLrjRDN9j1ByrChyn",
- "name": "Model 1",
- "description": "This model is very useful.",
- "enabled": true,
- "query": "SELECT 'user_1' AS id",
- "queryIdentifierColumn": "id",
- "scheduleStrategy": "MANUAL",
- "scheduleConfig": { }
}
], - "pagination": {
- "current": "MA==",
- "totalEntries": 1
}
}
}
Deletes an existing Model.
• When called, this endpoint may generate the `Model Deleted` event in the [audit trail](/tag/Audit-Trail).
OK
Resource not found
Validation failure
Too many requests
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) }
{- "data": {
- "status": "SUCCESS"
}
}
Returns a Reverse ETL Model by its id.
OK
Resource not found
Validation failure
Too many requests
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) }
{- "data": {
- "reverseEtlModel": {
- "id": "MaAeg9yDd1UZTBeEYDiVw",
- "sourceId": "qQEHquLrjRDN9j1ByrChyn",
- "name": "Model 1",
- "description": "This model is very useful.",
- "enabled": true,
- "query": "SELECT 'user_1' AS id",
- "queryIdentifierColumn": "id",
- "scheduleStrategy": "MANUAL",
- "scheduleConfig": { }
}
}
}
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
OK
Resource not found
Validation failure
Too many requests
{- "name": "My Updated Model"
}
{- "data": {
- "reverseEtlModel": {
- "id": "37YCmBXayzqG4sit63P5pH",
- "sourceId": "qQEHquLrjRDN9j1ByrChyn",
- "name": "My Updated Model",
- "description": "This model is very useful.",
- "enabled": true,
- "query": "SELECT 'user_1' AS id",
- "queryIdentifierColumn": "id",
- "scheduleStrategy": "MANUAL",
- "scheduleConfig": { }
}
}
}