Chatbot External API
Manage keyword-triggered chatbot flow records programmatically. These endpoints operate on the same flows as the portal Chatbot Builders (v1 and V2).
Base path: https://chatyug.com/api/external
Auth: Authorization: Bearer ck_<your_api_key>
Relationship to the portal builders
- List / create / get / update flow metadata and
flowDataJSON - Design complex graphs most easily in the portal UI, then manage publish state or sync via API
- Only the four endpoints below are exposed under
/api/external/chatbot— there is no separate External API publish-only route; usePUTwithisPublished/isActive
List flows
Auth: Bearer API key (required)
Query parameters
| Param | Required | Description |
|---|---|---|
phoneNumberId | No | Filter by WhatsApp phone number ID |
published | No | true to filter published flows |
active | No | true to filter active flows |
curl -X GET "https://chatyug.com/api/external/chatbot/flows?published=true" \ -H "Authorization: Bearer ck_your_api_key_here"
Success: { "success": true, "flows": [ ... ] }
Create flow
Body fields
| Field | Required | Type | Description |
|---|---|---|---|
flowName | Yes | string | Display name |
triggerKeywords | Yes | string | Comma-separated keywords (at least one after trim) |
flowData | Yes | object | string | Flow graph JSON (object or JSON string). Must parse as valid JSON |
flowDescription | No | string | Optional description |
phoneNumberId | No | string | Scope to a phone number; omit for WABA-level |
sessionTimeoutMinutes | No | number | Accepted on create body when provided by clients |
isActive | No | boolean | Active flag when supported by create path |
curl -X POST https://chatyug.com/api/external/chatbot/flows \
-H "Authorization: Bearer ck_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"flowName": "Shop keyword",
"triggerKeywords": "SHOP,CATALOGUE",
"flowDescription": "Menu for shoppers",
"flowData": { "nodes": [], "edges": [] }
}'Success (201): { "success": true, "message": "Chatbot flow created successfully", "flowId": <id> }
Keyword conflict (409): { "success": false, "message": "...", "conflictType": "...", "conflictName": "..." }
Invalid flowData: HTTP 400 with message Invalid flowData JSON format.
Get one flow
curl -X GET https://chatyug.com/api/external/chatbot/flows/42 \ -H "Authorization: Bearer ck_your_api_key_here"
Success: { "success": true, "flow": { ... } }. When possible, Flow_Data_JSON is parsed into a JSON object in the response.
Not found: HTTP 404.
Update flow
Body fields (all optional; send only what you change)
| Field | Type | Description |
|---|---|---|
flowName | string | New name |
flowDescription | string | New description |
triggerKeywords | string | Revalidated for conflicts excluding this flowId |
flowData | object | string | Replacement flow JSON |
phoneNumberId | string | Phone scope |
isActive | boolean | Active flag |
isPublished | boolean | Publish / unpublish via API |
curl -X PUT https://chatyug.com/api/external/chatbot/flows/42 \
-H "Authorization: Bearer ck_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"flowName": "Updated name",
"isActive": true,
"isPublished": true
}'Success: { "success": true, "message": "Chatbot flow updated successfully" }
Keyword updates that conflict return HTTP 409 with the same conflict payload shape as create.
flowData shape
Flows built in the portal store a JSON graph of nodes (ids, types, positions, data configs, and connections). When creating via API, supply a valid JSON object compatible with the ChatYug chatbot engine (nodes/edges or the structure exported from the portal).
Recommended workflow for complex bots:
- Design in Chatbot Builder v1 or V2
- Export from
/chatbot-flows.htmlif you need a JSON backup - Use External API to list, sync, or toggle
isPublished/isActive
Error summary
| HTTP | Meaning |
|---|---|
| 400 | Missing required fields, invalid JSON, or update/create rejected by procedure |
| 403 | Automation access denied for the WABA |
| 404 | Flow not found for this user/WABA |
| 409 | Keyword conflict with another flow or Auto-Reply |
| 500 | Server error |