Skip to main content

Public API Webhooks

PublicAPI Webhooks deliver real-time notifications to your application when events occur in your TimelinesAI workspace. Instead of polling the API for changes, your server receives instant HTTP POST callbacks whenever messages arrive, chats are created, accounts change status, and more.

How it works

1

Register a webhook

Use POST /webhooks to subscribe to an event type and provide your endpoint URL
2

An event occurs

A new message arrives, a chat is created, or an account status changes
3

You receive a POST request

TimelinesAI sends the event payload to your endpoint in real-time
4

Acknowledge receipt

Your server responds with a 2xx status within 5 seconds

Available events

Message events

Real-time notifications for all message activity in your workspace.
EventTriggerDescription
message:newAny new messageFires for both incoming and outgoing messages
message:received:newIncoming messageA customer or contact sends you a message
message:sent:newOutgoing messageA message you sent is processed

Chat events

Track conversation lifecycle and assignment changes.
EventTriggerDescription
chat:createdNew chat (any)A new direct or group chat appears
chat:received:createdNew incoming chatA contact initiates a conversation with you
chat:sent:createdNew outgoing chatYou start a new conversation
chat:assignedChat reassignedA chat is assigned to a team member
chat:unassignedChat unassignedA chat’s assignment is removed

WhatsApp account events

Monitor the connection status of your WhatsApp numbers.
EventTriggerDescription
Account reconnectedWhatsApp reconnectsA previously disconnected account comes back online
Account disconnectedWhatsApp disconnectsAn account loses its connection
Syncing suspendedSyncing pausedMessage syncing stops (e.g., subscription change)
Syncing resumedSyncing restartedMessage syncing resumes after suspension

Use case examples

Build an automated responder that handles common questions instantly.
  1. Subscribe to message:received:new
  2. Parse the incoming message text for keywords
  3. Send an appropriate reply using POST /chats/{id}/messages
  4. Escalate complex queries by assigning the chat to a human agent
Keep your CRM updated the moment a conversation happens.
  1. Subscribe to message:new and chat:created
  2. On new chat — create a lead/contact in your CRM
  3. On new message — log the interaction as an activity
  4. Use chat assignment events to sync agent ownership
Alert your team in Slack, Teams, or email when important events happen.
  1. Subscribe to message:received:new and chat:assigned
  2. Filter events by label or content keywords
  3. Forward the notification to Slack, Teams, or a custom dashboard
  4. Monitor WhatsApp account events to alert admins about disconnections
Track message delivery rates and response times.
  1. Subscribe to message:sent:new to track outgoing deliveries
  2. Subscribe to message:received:new to measure response times
  3. Aggregate data to build delivery rate dashboards
  4. Alert on anomalies like high failure rates or unusual activity

Webhook payload example

When a new message arrives, your endpoint receives a payload like:
{
  "event_type": "message:received:new",
  "chat": {
    "full_name": "John Doe",
    "chat_url": "https://app.timelines.ai/chat/123456/messages/",
    "chat_id": 123456,
    "is_group": false,
    "phone": "+15551234567",
    "responsible_name": "Agent Brown",
    "responsible_email": "agent-brown@example.com"
  },
  "whatsapp_account": {
    "full_name": "Agent Brown",
    "email": "agent-brown@example.com",
    "phone": "+15559876543"
  },
  "message": {
    "text": "Hi, here is the signed contract",
    "direction": "received",
    "origin": "WhatsApp",
    "timestamp": "2024-01-15 10:30:00 +0200",
    "message_uid": "a5bbb005-37f2-402c-96fa-e479a2e09b02",
    "reply_to_uid": "c7ec509d-0171-1ead-a84b-c6943a644768",
    "sender": {
      "full_name": "John Doe",
      "phone": "+15551234567"
    },
    "recipient": {
      "full_name": "Agent Brown",
      "phone": "+15559876543"
    },
    "attachments": [
      {
        "temporary_download_url": "https://example.s3.amazonaws.com/att/...",
        "filename": "contract.pdf",
        "size": 1234567,
        "mimetype": "application/pdf"
      }
    ],
    "reactions": {
      "👍": "2",
      "❤️": "1"
    }
  }
}
Attachments — The temporary_download_url for each attachment is a pre-signed URL valid for 15 minutes from the moment the webhook is delivered. Download or forward attachment files immediately upon receiving the webhook. After expiration, you can retrieve the file again using the Public API.
Reactions — The reactions object is a map of emoji characters to their count as strings (e.g., "👍": "2"). This field is included when the message has reactions.

Endpoint requirements

Your webhook endpoint must:
Be publicly accessible (no localhost in production)
Use HTTPS
Respond with a 2xx status within 5 seconds
Accept POST requests with JSON body

Best practices

  • Respond immediately — return 200 first, then process the event asynchronously
  • Handle duplicates — use message_uid to deduplicate events that may be delivered more than once
  • Monitor errors — check errors_counter on your webhooks to catch delivery failures early
  • Use a queue — for high-volume workspaces, push events to a message queue (Redis, SQS, RabbitMQ) and process separately
If your endpoint consistently fails, TimelinesAI will notify the workspace owner via email. Fix endpoint issues promptly to avoid missing events.

Managing webhooks

Webhook subscriptions are managed via the Public API:
ActionEndpoint
List allGET /webhooks
CreatePOST /webhooks
Get detailsGET /webhooks/{id}
UpdatePUT /webhooks/{id}
DeleteDELETE /webhooks/{id}
See the Webhooks guide for setup instructions and code examples.

Next steps