Setu Recipes: reusable digital workers across every app.Browse templates

Integrations / Segment

Segment

Twilio Segment Public API: list and inspect sources, destinations, tracking plans, functions and Engage audiences, and read the workspace. US and EU workspaces are supported through the region field.

8 actions API key 8 read0 write Calls api.segmentapis.com

Connect

TypeScript
const conn = await setu.connections.initiate({ userId: "user_1", toolkit: "segment" });
console.log(conn.connectUrl); // show this to your user
await conn.waitUntilActive();

Permissions requested

This toolkit uses a single credential and requests no scopes.

Actions

Get destinationreadsegment.get_destinationGet one destination by id, with its settings and enabled state.
InputTypeDescription
destination_idstringRequiredDestination id
TypeScript
await setu.execute({
  userId: "user_1",
  action: "segment.get_destination",
  input: {
    "destination_id": "<destination_id>"
  },
});
Get sourcereadsegment.get_sourceGet one source by id, including its tracking plan id if one is attached.
InputTypeDescription
source_idstringRequiredSource id
TypeScript
await setu.execute({
  userId: "user_1",
  action: "segment.get_source",
  input: {
    "source_id": "<source_id>"
  },
});
Get workspacereadsegment.get_workspaceGet the workspace the token belongs to: id, name and slug.

No input.

TypeScript
await setu.execute({
  userId: "user_1",
  action: "segment.get_workspace",
  input: {},
});
List audiencesreadsegment.list_audiencesList Engage audiences in a space (Unify/Engage required). The space id is in the space's settings URL.
InputTypeDescription
space_idstringRequiredSpace id
countintegerOptionalPage size
cursorstringOptionalPagination cursor from the previous page's pagination.next
TypeScript
await setu.execute({
  userId: "user_1",
  action: "segment.list_audiences",
  input: {
    "space_id": "<space_id>"
  },
});
List destinationsreadsegment.list_destinationsList the workspace's destinations with the source each one receives data from.
InputTypeDescription
countintegerOptionalPage size
cursorstringOptionalPagination cursor from the previous page's pagination.next
TypeScript
await setu.execute({
  userId: "user_1",
  action: "segment.list_destinations",
  input: {},
});
List functionsreadsegment.list_functionsList Functions of one type (source, destination or insert). The workspace needs Functions.
InputTypeDescription
resource_typestringRequiredFunction type
countintegerOptionalPage size
cursorstringOptionalPagination cursor from the previous page's pagination.next
TypeScript
await setu.execute({
  userId: "user_1",
  action: "segment.list_functions",
  input: {
    "resource_type": "<resource_type>"
  },
});
List sourcesreadsegment.list_sourcesList the workspace's sources with ids, slugs, enabled state and write keys.
InputTypeDescription
countintegerOptionalPage size
cursorstringOptionalPagination cursor from the previous page's pagination.next
TypeScript
await setu.execute({
  userId: "user_1",
  action: "segment.list_sources",
  input: {},
});
List tracking plansreadsegment.list_tracking_plansList Protocols tracking plans, optionally of one type. The workspace needs Protocols.
InputTypeDescription
typestringOptionalOnly plans of this type
countintegerOptionalPage size
cursorstringOptionalPagination cursor from the previous page's pagination.next
TypeScript
await setu.execute({
  userId: "user_1",
  action: "segment.list_tracking_plans",
  input: {},
});