Targeting API
- Base URL:
https://targeting.sls.epilot.io - Full API Docs: https://docs.epilot.io/api/targeting
Usageโ
import { epilot } from '@epilot/sdk'
epilot.authorize(() => '<token>')
const { data } = await epilot.targeting.changeCampaignStatus(...)
Tree-shakeable importโ
import { getClient, authorize } from '@epilot/sdk/targeting'
const targetingClient = getClient()
authorize(targetingClient, () => '<token>')
const { data } = await targetingClient.changeCampaignStatus(...)
Operationsโ
Campaign
changeCampaignStatusgetCampaignJobStatusgetCampaignPortalssetupCampaignmatchCampaignsdiscoverCampaigns
Campaign Delivery
Target
Campaign Recipient
createRecipientupdateRecipientupdateRecipientPortalStatusupdateRecipientEntityUiStatusrestoreRecipientEntityUiStatusgetRecipientsgetEmailStats
Schemas
BaseErrorServerErrorClientErrorBaseUUIDBaseNanoIDBaseTagsBaseRelationBaseSystemIdBaseEntityOwnerBaseEntityAclBaseSystemFieldsBaseSystemFieldsRequiredCampaignStatusExecutionSummaryItemJobStatusCampaignTargetTargetEntityFiltersTargetSortItemMatchCampaignParamsNextBestActionDiscoverCampaignsParamsDiscoverResultMatchTargetParamsGetTargetQueriesParamsTargetQueryResultAutomationStatusPortalStatusEntityUiStatusEmailStatusEmailBounceTypeRecipientBaseRecipientPayloadAutomationRecipientPayloadPortalRecipientPayloadCreateRecipientPayloadUpdateRecipientPayloadRetriggerAutomationsRequestRetriggerAutomationsResultUpdatePortalStatusRequestUpdateEntityUiStatusRequestSetupCampaignRequestSetupTariffChangeCampaignRequestSetupTariffChangeCampaignResponse
changeCampaignStatusโ
Moves a campaign to its next status, depending on its current one:
POST /v1/campaign/{campaign_id}/status
const { data } = await client.changeCampaignStatus({
campaign_id: 'example',
})
Response
{
"campaign": {
"_id": "b8c01433-5556-4e2b-aad4-6f5348d1df84",
"_org": "string",
"_owners": [
{
"org_id": "123",
"user_id": "123"
}
],
"_schema": "string",
"_title": "string",
"_tags": ["string"],
"_created_at": "1970-01-01T00:00:00.000Z",
"_updated_at": "1970-01-01T00:00:00.000Z",
"_acl": {
"view": ["org:456"],
"edit": ["org:456"],
"delete": ["org:456"]
},
"name": "string",
"goal": "string",
"status": "draft",
"start_date": "1970-01-01T00:00:00.000Z",
"end_date": "1970-01-01T00:00:00.000Z",
"flow_id": "string",
"job_id": "string",
"target": {
"$relation": [
{
"entity_id": "b8c01433-5556-4e2b-aad4-6f5348d1df84",
"_tags": ["string"]
}
]
}
}
}
getCampaignJobStatusโ
Get the status of a campaign's automation job
GET /v1/campaign/{campaign_id}/job
const { data } = await client.getCampaignJobStatus({
campaign_id: 'example',
})
Response
{
"status": "queued",
"execution_summary": [
{
"execution_id": "string",
"execution_status": "string"
}
]
}
getCampaignPortalsโ
Get the list of portals and its widgets where the campaign is used.
GET /v1/campaign/{campaign_id}/portals
const { data } = await client.getCampaignPortals({
campaign_id: 'example',
})
Response
[
{
"portal": {
"origin": "string",
"domain": "string",
"name": "string"
},
"widgets": [
{
"id": "string",
"headline": {
"en": "string",
"de": "string"
}
}
]
}
]
retriggerCampaignAutomationsโ
Retrigger automation executions for specific campaign recipients that have failed.
POST /v1/campaign/{campaign_id}/automations:retrigger
const { data } = await client.retriggerCampaignAutomations(
{
campaign_id: 'example',
},
{
recipient_ids: ['3fa85f64-5717-4562-b3fc-2c963f66afa6']
},
)
Response
{
"message": "string",
"results": [
{
"recipient_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"result": "success",
"execution_id": "string",
"error": "string"
}
]
}
setupCampaignโ
Creates a campaign entity together with its related entities and configurations in a single call.
Used by the campaign wizard UI, but not restricted to it.
POST /v1/campaign:setup
const { data } = await client.setupCampaign(
null,
{
type: 'tariff_change',
product_recommendation: {
name: 'string',
source_product_id: 'b8c01433-5556-4e2b-aad4-6f5348d1df84',
source_price_id: 'b8c01433-5556-4e2b-aad4-6f5348d1df84',
offers: [
{
target_id: 'b8c01433-5556-4e2b-aad4-6f5348d1df84',
items: [
{
product_id: 'b8c01433-5556-4e2b-aad4-6f5348d1df84',
price_id: 'b8c01433-5556-4e2b-aad4-6f5348d1df84',
highlight_config: {}
}
]
}
]
},
campaign: {
name: 'string',
goal: 'string',
target_ids: ['b8c01433-5556-4e2b-aad4-6f5348d1df84'],
start_date: '1970-01-01T00:00:00.000Z',
end_date: '1970-01-01T00:00:00.000Z'
},
journey: {
journey_id: 'b8c01433-5556-4e2b-aad4-6f5348d1df84'
},
channels: {
portal_widget: {
portal_id: 'b8c01433-5556-4e2b-aad4-6f5348d1df84',
block_id: 'b8c01433-5556-4e2b-aad4-6f5348d1df84'
},
email: {
automation_id: 'b8c01433-5556-4e2b-aad4-6f5348d1df84',
template_id: 'b8c01433-5556-4e2b-aad4-6f5348d1df84'
},
entity_ui: {
category: 'string',
icon: {
name: 'string',
color: 'string'
},
title: 'string',
body: 'string',
priority: 'medium',
is_dismissable: true,
cta: {
type: 'journey',
target: 'string',
context_params: [
{
key: 'string',
value: 'string'
}
]
}
}
}
},
)
Response
{
"type": "tariff_change",
"product_recommendation_id": "b8c01433-5556-4e2b-aad4-6f5348d1df84",
"campaign_id": "b8c01433-5556-4e2b-aad4-6f5348d1df84",
"journey_id": "b8c01433-5556-4e2b-aad4-6f5348d1df84",
"portal_widget_id": "b8c01433-5556-4e2b-aad4-6f5348d1df84"
}
matchCampaignsโ
Match campaigns based on target entities.
POST /v1/campaign:match
const { data } = await client.matchCampaigns(
null,
{
entity_refs: [
{
entity_id: 'b8c01433-5556-4e2b-aad4-6f5348d1df84',
entity_schema: 'string'
}
],
campaign_ids: ['b8c01433-5556-4e2b-aad4-6f5348d1df84']
},
)
Response
{
"hits": 0,
"results": [
{
"campaign": {
"_id": "b8c01433-5556-4e2b-aad4-6f5348d1df84",
"_org": "string",
"_owners": [
{
"org_id": "123",
"user_id": "123"
}
],
"_schema": "string",
"_title": "string",
"_tags": ["string"],
"_created_at": "1970-01-01T00:00:00.000Z",
"_updated_at": "1970-01-01T00:00:00.000Z",
"_acl": {
"view": ["org:456"],
"edit": ["org:456"],
"delete": ["org:456"]
},
"name": "string",
"goal": "string",
"status": "draft",
"start_date": "1970-01-01T00:00:00.000Z",
"end_date": "1970-01-01T00:00:00.000Z",
"flow_id": "string",
"job_id": "string",
"target": {
"$relation": [
{
"entity_id": "b8c01433-5556-4e2b-aad4-6f5348d1df84",
"_tags": ["string"]
}
]
}
}
}
]
}
discoverCampaignsโ
Given an entity, returns the Next Best Actions it should see on the Entity-UI channel.
POST /v1/campaign:discover
const { data } = await client.discoverCampaigns(
null,
{
entity_id: 'b8c01433-5556-4e2b-aad4-6f5348d1df84',
entity_schema: 'string'
},
)
Response
{
"hits": 0,
"results": [
{
"campaign_id": "b8c01433-5556-4e2b-aad4-6f5348d1df84",
"nba": {
"category": "string",
"icon": {
"name": "string",
"color": "string"
},
"title": "string",
"body": "string",
"priority": "medium",
"is_dismissable": true,
"cta": {
"type": "journey",
"target": "string",
"context_params": [
{
"key": "string",
"value": "string"
}
]
}
},
"status": "seen",
"status_updated_at": "1970-01-01T00:00:00.000Z"
}
],
"dismissed": [
{
"campaign_id": "b8c01433-5556-4e2b-aad4-6f5348d1df84",
"nba": {
"category": "string",
"icon": {
"name": "string",
"color": "string"
},
"title": "string",
"body": "string",
"priority": "medium",
"is_dismissable": true,
"cta": {
"type": "journey",
"target": "string",
"context_params": [
{
"key": "string",
"value": "string"
}
]
}
},
"status": "seen",
"status_updated_at": "1970-01-01T00:00:00.000Z"
}
]
}
matchTargetsโ
Find targets from the provided list that include the provide entities.
POST /v1/target:match
const { data } = await client.matchTargets(
null,
{
entity_refs: [
{
entity_id: 'b8c01433-5556-4e2b-aad4-6f5348d1df84',
entity_schema: 'string'
}
],
target_ids: ['b8c01433-5556-4e2b-aad4-6f5348d1df84']
},
)
Response
{
"hits": 0,
"results": [
{
"target": {
"_id": "b8c01433-5556-4e2b-aad4-6f5348d1df84",
"_org": "string",
"_owners": [
{
"org_id": "123",
"user_id": "123"
}
],
"_schema": "string",
"_title": "string",
"_tags": ["string"],
"_created_at": "1970-01-01T00:00:00.000Z",
"_updated_at": "1970-01-01T00:00:00.000Z",
"_acl": {
"view": ["org:456"],
"edit": ["org:456"],
"delete": ["org:456"]
},
"name": "string",
"description": "string",
"entity_schema": "string",
"entity_filters": {
"filter": {},
"search": "string",
"sort": [
{
"key": "billing_address.postal_code",
"order": "asc"
}
],
"limit": 1
}
}
}
]
}
getTargetQueriesโ
Transform target filters into Lucene queries for the provided target IDs. Returns the transformed query string for each target along with any errors encountered. If the target defines a sort order or
POST /v1/target/queries
const { data } = await client.getTargetQueries(
null,
{
target_ids: ['b8c01433-5556-4e2b-aad4-6f5348d1df84']
},
)
Response
{
"results": [
{
"target_id": "b8c01433-5556-4e2b-aad4-6f5348d1df84",
"query": "string",
"error": "string",
"sort": ["billing_date:desc", "_title.keyword:asc", "_id:desc"],
"limit": 1
}
]
}
createRecipientโ
Creates a new recipient associated with a campaign.
POST /v1/campaign/{campaign_id}/recipient
const { data } = await client.createRecipient(
{
campaign_id: 'example',
},
{
entity_id: 'b8c01433-5556-4e2b-aad4-6f5348d1df84',
entity_schema: 'string',
automation_status: 'pending',
automation_execution_id: 'string'
},
)
Response
{
"entity_id": "b8c01433-5556-4e2b-aad4-6f5348d1df84",
"entity_schema": "string",
"title": "string",
"automation_status": "pending",
"automation_execution_id": "string",
"portal_status": "sent",
"portal_status_updated_at": "1970-01-01T00:00:00.000Z",
"portal_state": {},
"entity_ui_status": "seen",
"entity_ui_status_updated_at": "1970-01-01T00:00:00.000Z",
"entity_ui_status_before_dismiss": "seen",
"message_entity_id": "string",
"email_status": "sent",
"email_status_updated_at": "1970-01-01T00:00:00.000Z",
"email_bounce_type": "permanent",
"email_bounce_subtype": "string",
"email_complaint_type": "string",
"email_bounce_reason": "string",
"email_send_error": {},
"email_unsubscribed_at": "1970-01-01T00:00:00.000Z",
"email_open_count": 0,
"email_first_opened_at": "1970-01-01T00:00:00.000Z",
"email_last_opened_at": "1970-01-01T00:00:00.000Z",
"email_click_count": 0,
"email_first_clicked_at": "1970-01-01T00:00:00.000Z",
"email_clicked_links": [
{
"url": "string",
"clicked_at": "1970-01-01T00:00:00.000Z"
}
],
"updated_at": "1970-01-01T00:00:00.000Z"
}
updateRecipientโ
Updates a recipient's attributes.
PATCH /v1/campaign/{campaign_id}/recipient/{recipient_id}
const { data } = await client.updateRecipient(
{
campaign_id: 'example',
recipient_id: 'example',
},
{
automation_status: 'pending',
automation_execution_id: 'string',
portal_status: 'sent',
portal_state: {}
},
)
Response
{
"entity_id": "b8c01433-5556-4e2b-aad4-6f5348d1df84",
"entity_schema": "string",
"title": "string",
"automation_status": "pending",
"automation_execution_id": "string",
"portal_status": "sent",
"portal_status_updated_at": "1970-01-01T00:00:00.000Z",
"portal_state": {},
"entity_ui_status": "seen",
"entity_ui_status_updated_at": "1970-01-01T00:00:00.000Z",
"entity_ui_status_before_dismiss": "seen",
"message_entity_id": "string",
"email_status": "sent",
"email_status_updated_at": "1970-01-01T00:00:00.000Z",
"email_bounce_type": "permanent",
"email_bounce_subtype": "string",
"email_complaint_type": "string",
"email_bounce_reason": "string",
"email_send_error": {},
"email_unsubscribed_at": "1970-01-01T00:00:00.000Z",
"email_open_count": 0,
"email_first_opened_at": "1970-01-01T00:00:00.000Z",
"email_last_opened_at": "1970-01-01T00:00:00.000Z",
"email_click_count": 0,
"email_first_clicked_at": "1970-01-01T00:00:00.000Z",
"email_clicked_links": [
{
"url": "string",
"clicked_at": "1970-01-01T00:00:00.000Z"
}
],
"updated_at": "1970-01-01T00:00:00.000Z"
}
updateRecipientPortalStatusโ
Updates the portal status for a specific campaign recipient. The portal_status_updated_at timestamp is automatically set when the status changes.
PATCH /v1/campaign/{campaign_id}/recipient/{recipient_id}/portal:status
const { data } = await client.updateRecipientPortalStatus(
{
campaign_id: 'example',
recipient_id: 'example',
},
{
status: 'sent'
},
)
Response
{
"entity_id": "b8c01433-5556-4e2b-aad4-6f5348d1df84",
"entity_schema": "string",
"title": "string",
"automation_status": "pending",
"automation_execution_id": "string",
"portal_status": "sent",
"portal_status_updated_at": "1970-01-01T00:00:00.000Z",
"portal_state": {},
"entity_ui_status": "seen",
"entity_ui_status_updated_at": "1970-01-01T00:00:00.000Z",
"entity_ui_status_before_dismiss": "seen",
"message_entity_id": "string",
"email_status": "sent",
"email_status_updated_at": "1970-01-01T00:00:00.000Z",
"email_bounce_type": "permanent",
"email_bounce_subtype": "string",
"email_complaint_type": "string",
"email_bounce_reason": "string",
"email_send_error": {},
"email_unsubscribed_at": "1970-01-01T00:00:00.000Z",
"email_open_count": 0,
"email_first_opened_at": "1970-01-01T00:00:00.000Z",
"email_last_opened_at": "1970-01-01T00:00:00.000Z",
"email_click_count": 0,
"email_first_clicked_at": "1970-01-01T00:00:00.000Z",
"email_clicked_links": [
{
"url": "string",
"clicked_at": "1970-01-01T00:00:00.000Z"
}
],
"updated_at": "1970-01-01T00:00:00.000Z"
}
updateRecipientEntityUiStatusโ
Records a Next Best Action interaction for a recipient on the Entity-UI channel.
PATCH /v1/campaign/{campaign_id}/recipient/{recipient_id}/entity_ui:status
const { data } = await client.updateRecipientEntityUiStatus(
{
campaign_id: 'example',
recipient_id: 'example',
},
{
status: 'seen',
entity_schema: 'string'
},
)
Response
{
"entity_id": "b8c01433-5556-4e2b-aad4-6f5348d1df84",
"entity_schema": "string",
"title": "string",
"automation_status": "pending",
"automation_execution_id": "string",
"portal_status": "sent",
"portal_status_updated_at": "1970-01-01T00:00:00.000Z",
"portal_state": {},
"entity_ui_status": "seen",
"entity_ui_status_updated_at": "1970-01-01T00:00:00.000Z",
"entity_ui_status_before_dismiss": "seen",
"message_entity_id": "string",
"email_status": "sent",
"email_status_updated_at": "1970-01-01T00:00:00.000Z",
"email_bounce_type": "permanent",
"email_bounce_subtype": "string",
"email_complaint_type": "string",
"email_bounce_reason": "string",
"email_send_error": {},
"email_unsubscribed_at": "1970-01-01T00:00:00.000Z",
"email_open_count": 0,
"email_first_opened_at": "1970-01-01T00:00:00.000Z",
"email_last_opened_at": "1970-01-01T00:00:00.000Z",
"email_click_count": 0,
"email_first_clicked_at": "1970-01-01T00:00:00.000Z",
"email_clicked_links": [
{
"url": "string",
"clicked_at": "1970-01-01T00:00:00.000Z"
}
],
"updated_at": "1970-01-01T00:00:00.000Z"
}
restoreRecipientEntityUiStatusโ
Undo a dismissal on the Entity-UI (Next Best Action) channel
POST /v1/campaign/{campaign_id}/recipient/{recipient_id}/entity_ui:restore
const { data } = await client.restoreRecipientEntityUiStatus({
campaign_id: 'example',
recipient_id: 'example',
})
Response
{
"entity_id": "b8c01433-5556-4e2b-aad4-6f5348d1df84",
"entity_schema": "string",
"title": "string",
"automation_status": "pending",
"automation_execution_id": "string",
"portal_status": "sent",
"portal_status_updated_at": "1970-01-01T00:00:00.000Z",
"portal_state": {},
"entity_ui_status": "seen",
"entity_ui_status_updated_at": "1970-01-01T00:00:00.000Z",
"entity_ui_status_before_dismiss": "seen",
"message_entity_id": "string",
"email_status": "sent",
"email_status_updated_at": "1970-01-01T00:00:00.000Z",
"email_bounce_type": "permanent",
"email_bounce_subtype": "string",
"email_complaint_type": "string",
"email_bounce_reason": "string",
"email_send_error": {},
"email_unsubscribed_at": "1970-01-01T00:00:00.000Z",
"email_open_count": 0,
"email_first_opened_at": "1970-01-01T00:00:00.000Z",
"email_last_opened_at": "1970-01-01T00:00:00.000Z",
"email_click_count": 0,
"email_first_clicked_at": "1970-01-01T00:00:00.000Z",
"email_clicked_links": [
{
"url": "string",
"clicked_at": "1970-01-01T00:00:00.000Z"
}
],
"updated_at": "1970-01-01T00:00:00.000Z"
}
getRecipientsโ
Get a paginated list of recipients for a campaign.
GET /v1/campaign/{campaign_id}/recipients
const { data } = await client.getRecipients({
campaign_id: 'example',
limit: 1,
next: 'example',
q: 'example',
automation_status: ['...'],
portal_status: 'example',
email_status: 'example',
entity_ui_status: 'example',
})
Response
{
"results": [
{
"entity_id": "b8c01433-5556-4e2b-aad4-6f5348d1df84",
"entity_schema": "string",
"title": "string",
"automation_status": "pending",
"automation_execution_id": "string",
"portal_status": "sent",
"portal_status_updated_at": "1970-01-01T00:00:00.000Z",
"portal_state": {},
"entity_ui_status": "seen",
"entity_ui_status_updated_at": "1970-01-01T00:00:00.000Z",
"entity_ui_status_before_dismiss": "seen",
"message_entity_id": "string",
"email_status": "sent",
"email_status_updated_at": "1970-01-01T00:00:00.000Z",
"email_bounce_type": "permanent",
"email_bounce_subtype": "string",
"email_complaint_type": "string",
"email_bounce_reason": "string",
"email_send_error": {},
"email_unsubscribed_at": "1970-01-01T00:00:00.000Z",
"email_open_count": 0,
"email_first_opened_at": "1970-01-01T00:00:00.000Z",
"email_last_opened_at": "1970-01-01T00:00:00.000Z",
"email_click_count": 0,
"email_first_clicked_at": "1970-01-01T00:00:00.000Z",
"email_clicked_links": [
{
"url": "string",
"clicked_at": "1970-01-01T00:00:00.000Z"
}
],
"updated_at": "1970-01-01T00:00:00.000Z"
}
],
"next": "string",
"total": 0
}
getEmailStatsโ
Aggregate email delivery counts for a campaign, for the KPI summary on the campaign UI.
Counts cover the email (automation) channel only; total_emailed is the number of
recipients with a recorded em
GET /v1/campaign/{campaign_id}/email-stats
const { data } = await client.getEmailStats({
campaign_id: 'example',
})
Response
{
"total_emailed": 0,
"sent": 0,
"delivered": 0,
"bounced": 0,
"bounced_hard": 0,
"bounced_soft": 0,
"complained": 0,
"failed": 0,
"unsubscribed": 0,
"opened": 0,
"clicked": 0,
"total_opens": 0,
"total_clicks": 0
}
Schemasโ
BaseErrorโ
type BaseError = {
status: number
message: string
}
ServerErrorโ
type ServerError = {
status: number
message: string
}
ClientErrorโ
Describes the structure of a client error response, which can be one of several types:
MessageError: Contains a 'message' field for general descriptive errors.CodeError: Contains a 'code' field for specific, machine-readable error codes.StatusedError: Contains 'error' and 'status' f
type ClientError = {
message: string
} | {
code: "CAMPAIGN_NOT_FOUND" | "CAMPAIGN_HAS_NO_TARGET" | "CAMPAIGN_HAS_NO_DELIVERY_METHOD" | "INVALID_NEXT_BEST_ACTION" | "CAMPAIGN_HAS_JOB_IN_PROGRESS" | "CAMPAIGN_HAS_UNEXPECTED_STATUS" | "JOB_TOKEN_MISSING" | "TARGET_WITHOUT_FILTERS"
} | {
error: string
status: number
}
BaseUUIDโ
type BaseUUID = string // uuid
BaseNanoIDโ
type BaseNanoID = string
BaseTagsโ
type BaseTags = string[]
BaseRelationโ
type BaseRelation = {
$relation?: Array<{
entity_id?: string // uuid
_tags?: string[]
}>
}
BaseSystemIdโ
type BaseSystemId = {
_id: string // uuid
}
BaseEntityOwnerโ
The user / organization owning this entity.
Note: Owner implicitly has access to the entity regardless of ACLs.
type BaseEntityOwner = {
org_id: string
user_id?: string
}
BaseEntityAclโ
Access control list (ACL) for an entity. Defines sharing access to external orgs or users.
type BaseEntityAcl = {
view?: string[]
edit?: string[]
delete?: string[]
}
BaseSystemFieldsโ
type BaseSystemFields = {
_id?: string // uuid
_org?: string
_owners?: Array<{
org_id: string
user_id?: string
}>
_schema?: string
_title?: string
_tags?: string[]
_created_at?: string // date-time
_updated_at?: string // date-time
_acl?: {
view?: string[]
edit?: string[]
delete?: string[]
}
}
BaseSystemFieldsRequiredโ
type BaseSystemFieldsRequired = object
CampaignStatusโ
Lifecycle status of a campaign.
draft: not launched yet.scheduled: launched with astart_datestill in the future. It collects no recipients and appears through no delivery method until it starts on its own atstart_date.activating: launching; recipients are being collected.- `
type CampaignStatus = "draft" | "scheduled" | "activating" | "active" | "inactive"
ExecutionSummaryItemโ
type ExecutionSummaryItem = {
execution_id?: string
execution_status?: string
}
JobStatusโ
type JobStatus = {
status?: "queued" | "processing" | "finished" | "failed" | "cancelled" | "send_report"
execution_summary?: Array<{
execution_id?: string
execution_status?: string
}>
}
Campaignโ
type Campaign = {
_id?: string // uuid
_org?: string
_owners?: Array<{
org_id: string
user_id?: string
}>
_schema?: string
_title?: string
_tags?: string[]
_created_at?: string // date-time
_updated_at?: string // date-time
_acl?: {
view?: string[]
edit?: string[]
delete?: string[]
}
name?: string
goal?: string
status?: "draft" | "scheduled" | "activating" | "active" | "inactive"
start_date?: string // date-time
end_date?: string // date-time
flow_id?: string
job_id?: string
target?: {
$relation?: Array<{
entity_id?: { ... }
_tags?: { ... }
}>
}
}
Targetโ
type Target = {
_id?: string // uuid
_org?: string
_owners?: Array<{
org_id: string
user_id?: string
}>
_schema?: string
_title?: string
_tags?: string[]
_created_at?: string // date-time
_updated_at?: string // date-time
_acl?: {
view?: string[]
edit?: string[]
delete?: string[]
}
name?: string
description?: string
entity_schema?: string
entity_filters?: {
filter?: Record<string, unknown>
search?: string
sort?: Array<{
key: { ... }
order: { ... }
}>
limit?: number
}
}
TargetEntityFiltersโ
Search state of the target. filter and search use the same shape as the search state of entity views.
Besides the filters, it optionally defines the order and maximum number of results.
type TargetEntityFilters = {
filter?: Record<string, unknown>
search?: string
sort?: Array<{
key: string
order: "asc" | "desc"
}>
limit?: number
}
TargetSortItemโ
type TargetSortItem = {
key: string
order: "asc" | "desc"
}
MatchCampaignParamsโ
type MatchCampaignParams = {
entity_refs: Array<{
entity_id: string // uuid
entity_schema: string
}>
campaign_ids: string // uuid[]
}
NextBestActionโ
A Next Best Action configured on a campaign's Entity-UI channel.
This is the canonical NBA contract shared by discovery (this API), authoring, and rendering.
NBA content is single-language in v1; text fields may contain {{placeholders}} resolved at render time.
type NextBestAction = {
category?: string
icon?: {
name: string
color?: string
}
title: string
body?: string
priority?: "low" | "medium" | "high"
is_dismissable?: boolean
cta: {
type: "journey" | "workflow" | "flow"
target: string
context_params?: Array<{
key: { ... }
value: { ... }
}>
}
}
DiscoverCampaignsParamsโ
type DiscoverCampaignsParams = {
entity_id: string // uuid
entity_schema: string
}
DiscoverResultโ
One discovered Next Best Action, plus this entity's interaction state for it.
type DiscoverResult = {
campaign_id: string // uuid
nba: {
category?: string
icon?: {
name: { ... }
color?: { ... }
}
title: string
body?: string
priority?: "low" | "medium" | "high"
is_dismissable?: boolean
cta: {
type: { ... }
target: { ... }
context_params?: { ... }
}
}
status?: "seen" | "dismissed" | "clicked"
status_updated_at?: string // date-time
}
MatchTargetParamsโ
type MatchTargetParams = {
entity_refs: Array<{
entity_id: string // uuid
entity_schema: string
}>
target_ids: string // uuid[]
}
GetTargetQueriesParamsโ
type GetTargetQueriesParams = {
target_ids: string // uuid[]
}
TargetQueryResultโ
type TargetQueryResult = {
target_id: string // uuid
query: string
error?: string
sort?: string[]
limit?: number
}
AutomationStatusโ
type AutomationStatus = "pending" | "in_progress" | "success" | "failed" | "cancelled"
PortalStatusโ
type PortalStatus = "sent" | "seen" | "dismissed" | "clicked"
EntityUiStatusโ
Lifecycle status of a Next Best Action on the Entity-UI channel. Unlike the portal
channel there is no sent state: an NBA recipient is born at seen, the moment the
action is first rendered to an agent.
type EntityUiStatus = "seen" | "dismissed" | "clicked"
EmailStatusโ
Delivery status of the email a campaign's automation sends to a recipient. Set to sent
once the automation hands the email off, then updated asynchronously as SES notifications
arrive (bounced / complained; an SES Reject maps to bounced). failed is a send-time
failure (the automation execu
type EmailStatus = "sent" | "delivered" | "bounced" | "complained" | "failed"
EmailBounceTypeโ
SES bounce classification: permanent (hard) or transient (soft).
type EmailBounceType = "permanent" | "transient"
Recipientโ
type Recipient = {
entity_id?: string // uuid
entity_schema?: string
title?: string
automation_status?: "pending" | "in_progress" | "success" | "failed" | "cancelled"
automation_execution_id?: string
portal_status?: "sent" | "seen" | "dismissed" | "clicked"
portal_status_updated_at?: string // date-time
portal_state?: Record<string, unknown>
entity_ui_status?: "seen" | "dismissed" | "clicked"
entity_ui_status_updated_at?: string // date-time
entity_ui_status_before_dismiss?: "seen" | "dismissed" | "clicked"
message_entity_id?: string
email_status?: "sent" | "delivered" | "bounced" | "complained" | "failed"
email_status_updated_at?: string // date-time
email_bounce_type?: "permanent" | "transient"
email_bounce_subtype?: string
email_complaint_type?: string
email_bounce_reason?: string
email_send_error?: Record<string, unknown>
email_unsubscribed_at?: string // date-time
email_open_count?: number
email_first_opened_at?: string // date-time
email_last_opened_at?: string // date-time
email_click_count?: number
email_first_clicked_at?: string // date-time
email_clicked_links?: Array<{
url: string
clicked_at: string // date-time
}>
updated_at?: string // date-time
}
BaseRecipientPayloadโ
type BaseRecipientPayload = {
entity_id: string // uuid
entity_schema: string
}
AutomationRecipientPayloadโ
type AutomationRecipientPayload = {
automation_status: "pending" | "in_progress" | "success" | "failed" | "cancelled"
automation_execution_id: string
}
PortalRecipientPayloadโ
type PortalRecipientPayload = {
portal_status: "sent" | "seen" | "dismissed" | "clicked"
portal_state?: Record<string, unknown>
}
CreateRecipientPayloadโ
type CreateRecipientPayload = {
entity_id: string // uuid
entity_schema: string
automation_status: "pending" | "in_progress" | "success" | "failed" | "cancelled"
automation_execution_id: string
} | {
entity_id: string // uuid
entity_schema: string
portal_status: "sent" | "seen" | "dismissed" | "clicked"
portal_state?: Record<string, unknown>
} | {
entity_id: string // uuid
entity_schema: string
automation_status: "pending" | "in_progress" | "success" | "failed" | "cancelled"
automation_execution_id: string
portal_status: "sent" | "seen" | "dismissed" | "clicked"
portal_state?: Record<string, unknown>
}
UpdateRecipientPayloadโ
type UpdateRecipientPayload = {
automation_status?: "pending" | "in_progress" | "success" | "failed" | "cancelled"
automation_execution_id?: string
portal_status?: "sent" | "seen" | "dismissed" | "clicked"
portal_state?: Record<string, unknown>
}
RetriggerAutomationsRequestโ
type RetriggerAutomationsRequest = {
recipient_ids: string // uuid[]
}
RetriggerAutomationsResultโ
type RetriggerAutomationsResult = {
recipient_id: string // uuid
result: "success" | "failure" | "not_found" | "invalid_status"
execution_id?: string
error?: string
}
UpdatePortalStatusRequestโ
type UpdatePortalStatusRequest = {
status: "sent" | "seen" | "dismissed" | "clicked"
}
UpdateEntityUiStatusRequestโ
type UpdateEntityUiStatusRequest = {
status: "seen" | "dismissed" | "clicked"
entity_schema?: string
}
SetupCampaignRequestโ
Discriminated by type. Each campaign variant has its own request shape;
new variants are added by introducing a new schema and extending the oneOf list.
type SetupCampaignRequest = {
type: "tariff_change"
product_recommendation: {
name?: string
source_product_id?: string // uuid
source_price_id?: string // uuid
offers?: Array<{
target_id?: { ... }
items: { ... }
}>
}
campaign: {
name: string
goal?: string
target_ids: string // uuid[]
start_date?: string // date-time
end_date?: string // date-time
}
journey?: {
journey_id: string // uuid
}
channels?: {
portal_widget?: {
portal_id: { ... }
block_id: { ... }
}
email?: {
automation_id?: { ... }
template_id?: { ... }
}
entity_ui?: {
category?: { ... }
icon?: { ... }
title: { ... }
body?: { ... }
priority?: { ... }
is_dismissable?: { ... }
cta: { ... }
}
}
}
SetupTariffChangeCampaignRequestโ
type SetupTariffChangeCampaignRequest = {
type: "tariff_change"
product_recommendation: {
name?: string
source_product_id?: string // uuid
source_price_id?: string // uuid
offers?: Array<{
target_id?: { ... }
items: { ... }
}>
}
campaign: {
name: string
goal?: string
target_ids: string // uuid[]
start_date?: string // date-time
end_date?: string // date-time
}
journey?: {
journey_id: string // uuid
}
channels?: {
portal_widget?: {
portal_id: { ... }
block_id: { ... }
}
email?: {
automation_id?: { ... }
template_id?: { ... }
}
entity_ui?: {
category?: { ... }
icon?: { ... }
title: { ... }
body?: { ... }
priority?: { ... }
is_dismissable?: { ... }
cta: { ... }
}
}
}
SetupTariffChangeCampaignResponseโ
type SetupTariffChangeCampaignResponse = {
type: "tariff_change"
product_recommendation_id: string // uuid
campaign_id: string // uuid
journey_id?: string // uuid
portal_widget_id?: string // uuid
}