Subscription Upsert

Upsert a new Subscription. Subscriptions allow you to listen and recieve
notification of events inside of Lytics, most common would be listen
to users entering/leaving segments to serve as triggers.

When creating subscriptions they have the following fields.

fieldDataTypeDescription
channelstringRequired: What Type of subscription. [kinesis, webhook]
namestringName of this Subscription
descriptionstringLong text description (optional)
segment_ids[]stringList of segment Ids
withbackfillboolShould all members of this segment be included? They will be marked as "entered" segment.

Webhook only fields:

fieldDataTypeDescription
webhook_urlstringRequired for Webhooks, only used on webhooks, url to post to.
headersmap[string]stringOptional map of headers to send with webhook
segmentio_writekeystringOptional api key for sending to segment.io

Kinesis only fields:

fieldDataTypeDescription
regionstringRequired. AWS Region
streamstringRequired. Kinesis stream
role_arnstringAWS IAM Role to use for assume-role (see integrations doc)
identifier_fieldstringOptional. If provided, pull this field from user field and use as shard-key in Kinesis Put.

Create a Webhook Subscription that includes the Segment definition and custom headers (optional)


curl -s -H "Authorization: $LIOKEY" -H "Content-Type: application/json" \
  -XPOST "https://api.lytics.io/api/subscription" -d '
{
    "segmentql": "FILTER AND ( score_momentum > 25, score_quantity > 25 ) ALIAS seg_webhook1",
    "name":"test1",
    "channel" : "webhook",
    "description":"hello world",
    "webhook_url":"https://demo.appspot.com/log",
    "headers": {"Authorization": "dGhpczp0aGF0"}
}
' | jq "."

Create a Webhook subscription with list of SegmentId's (previously created)
to listen to.

curl -s -H "Authorization: $LIOKEY" -H "Content-Type: application/json" \
  -XPOST "https://api.lytics.io/api/subscription" -d '
{
    "segment_ids": ["1234abcd","abc345"],
    "channel":"webhook",
    "name":"test2",
    "description":"hello world",
    "webhook_url":"https://demo.appspot.com/log"
}
' | jq "."

Create a Kinesis Subscription


curl -s -H "Authorization: $LIOKEY" -H "Content-Type: application/json" \
  -XPOST "https://api.lytics.io/api/subscription" -d '
{
    "channel":"kinesis",
    "segment_ids": ["1234abcd","abc345"],
    "name":"test2",
    "description":"hello world",
    "stream":"lytics_triggers_stream",
    "region": "us-east-1",
    "identifier_field":"user_id",
    "role_arn":"arn:aws:iam::4444444444444:role/LyticsWriteToKinesis"
}
' | jq "."



Language
Authorization
Header
Click Try It! to start a request and see the response here!