curl --request POST \
--url https://{projectID}.texterchat.com/server/api/v2/scenarios/manage/import \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"version": "v1",
"name": "(SUB) All Messages",
"description": "Sends a webhook for each new message (incoming & outgoing)",
"triggerEvents": [
"domain.message.created"
],
"loaders": {
"beforeConditions": [
{
"name": "chat",
"alias": "chat",
"params": {
"id": {
"##provide": {
"provider": "message",
"key": "parent_chat"
}
}
},
"confidentialData": false
}
]
},
"conditions": [],
"actions": [
{
"name": "request",
"params": {
"url": "{{yourWebhookURL}}",
"method": "post",
"json": true,
"data": {
"eventName": "newMessage",
"eventData": {
"message": {
"##provide": {
"provider": "message",
"key": "message"
}
},
"chat": {
"##provide": {
"provider": "chat",
"key": "chat"
}
}
}
}
},
"confidentialData": false
}
],
"options": {
"unorderedActions": false
}
},
"asStatus": "active"
}
'
{
"_id": "6970b3c1d2e3f40123456789",
"drafts": [],
"inactiveRevisions": [],
"activeRevision": {
"_id": "6970b3c1d2e3f4012345678a",
"scenarioId": "6970b3c1d2e3f40123456789",
"name": "(SUB) New Incoming Messages",
"description": "Sends a webhook for each new incoming message",
"status": "active",
"version": 1,
"triggerEvents": [
"domain.message.created"
],
"conditions": [
[
{
"name": "filtrex",
"params": {
"expression": "direction == \"incoming\""
},
"confidentialData": false
}
]
],
"loaders": {
"afterConditions": [
{
"name": "chat",
"alias": "chat",
"params": {},
"confidentialData": false
}
]
},
"actions": [
{
"name": "request",
"params": {
"url": "https://example.com/hook",
"method": "post",
"json": true
},
"confidentialData": false
}
],
"options": {
"unorderedActions": false
},
"metadata": {
"authorUid": "4d170fc7-5cd6-4496-98e4-f4f03a11456e",
"created": 1768314807488,
"activated": 1768314808000
}
}
}{
"error": "authorUid: User with ID abc123 not found"
}Subscribe to Events
Import Subscription (Subscribe to an Event)
Create an event subscription by importing one of the pre-defined scenario templates. Pick the template for the event you want from the request examples, then change only:
POST
https://{projectID}.texterchat.com/server/api/v2
/
scenarios
/
manage
/
import
curl --request POST \
--url https://{projectID}.texterchat.com/server/api/v2/scenarios/manage/import \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"version": "v1",
"name": "(SUB) All Messages",
"description": "Sends a webhook for each new message (incoming & outgoing)",
"triggerEvents": [
"domain.message.created"
],
"loaders": {
"beforeConditions": [
{
"name": "chat",
"alias": "chat",
"params": {
"id": {
"##provide": {
"provider": "message",
"key": "parent_chat"
}
}
},
"confidentialData": false
}
]
},
"conditions": [],
"actions": [
{
"name": "request",
"params": {
"url": "{{yourWebhookURL}}",
"method": "post",
"json": true,
"data": {
"eventName": "newMessage",
"eventData": {
"message": {
"##provide": {
"provider": "message",
"key": "message"
}
},
"chat": {
"##provide": {
"provider": "chat",
"key": "chat"
}
}
}
}
},
"confidentialData": false
}
],
"options": {
"unorderedActions": false
}
},
"asStatus": "active"
}
'
{
"_id": "6970b3c1d2e3f40123456789",
"drafts": [],
"inactiveRevisions": [],
"activeRevision": {
"_id": "6970b3c1d2e3f4012345678a",
"scenarioId": "6970b3c1d2e3f40123456789",
"name": "(SUB) New Incoming Messages",
"description": "Sends a webhook for each new incoming message",
"status": "active",
"version": 1,
"triggerEvents": [
"domain.message.created"
],
"conditions": [
[
{
"name": "filtrex",
"params": {
"expression": "direction == \"incoming\""
},
"confidentialData": false
}
]
],
"loaders": {
"afterConditions": [
{
"name": "chat",
"alias": "chat",
"params": {},
"confidentialData": false
}
]
},
"actions": [
{
"name": "request",
"params": {
"url": "https://example.com/hook",
"method": "post",
"json": true
},
"confidentialData": false
}
],
"options": {
"unorderedActions": false
},
"metadata": {
"authorUid": "4d170fc7-5cd6-4496-98e4-f4f03a11456e",
"created": 1768314807488,
"activated": 1768314808000
}
}
}{
"error": "authorUid: User with ID abc123 not found"
}Required token scopes:
Create scenarios, Manage scenarios on behalf of user (both are required)
url(required) - located underdata.actions[0].params.url. Replace{{yourWebhookURL}}with the destination URL that should receive the events.asStatus- keep"active"to enable the subscription immediately,"inactive"to save it as an inactive revision, or"draft"to save it as a draft.- Template-specific placeholders such as
{{word1}}/{{word2}}(Messages with Specific Text) or{{targetLabelId}}(Specific Label Added).
authorUid body field (a Texter user UID) to attribute the action to a specific user - recommended: when omitted, the action is attributed to an arbitrary user account.
Every event also has its own page under Webhooks in the sidebar (e.g. All Messages) with the ready-to-send template, exactly what to change in it, and the payload your URL receives.
If the provided templates don’t satisfy your needs, contact Texter Support and we’ll gladly help modify any triggers, conditions, or actions for your webhook.הרשאות
גוף
application/json
תגובה
The created subscription (scenario object). Field-by-field reference: The Scenario object
An event subscription (scenario) in Texter