Skip to content

Module 02 · I connect the systems

Webhooks and the raia API

Outcome

Configure Webhook Skill triggers, authenticate with an Agent Secret Key, and use core raia API endpoints to manage conversations programmatically.

What you will learn

  • Understand the architectural difference between Webhooks and the API.
  • Configure the Webhook Skill and choose the correct trigger type.
  • Authenticate against the raia API using an Agent Secret Key.
  • Call core API endpoints to start conversations and send messages programmatically.
01

Webhook vs API: Two Directions of Data Flow

When integrating raia with your backend systems, you have two primary tools at your disposal: Webhooks and the API. The difference comes down to which system is initiating the data transfer.

Webhook vs API: two directions of data flow.
Conceptual illustration — not the product interface.

01

Webhooks (Push)

raia automatically pushes data out to your system when an event occurs. You do not need to poll for updates; raia tells you when something happens.

02

API (Pull / Send)

Your system calls raia endpoints to pull data in or send commands on demand. You have full programmatic control over when the interaction happens.

Best Practice: The most robust integrations combine both. Your backend uses the API to start a conversation and pass user context, then uses a Webhook to automatically receive the final transcript when the conversation ends.

02

Configuring the Webhook Skill

The Webhook Skill allows your agent to send rich JSON payloads containing conversation data to any external URL (like Zapier, Make, n8n, or your own backend endpoint). The most important decision when configuring the skill is choosing the trigger type.

Choosing the right webhook trigger: onMessageEnd vs onThreadEnd.
Conceptual illustration — not the product interface.
onMessageEnd

Fires after every single reply the agent sends. Ideal for real-time syncing, live lead alerts, or instant CRM updates.

onThreadEnd

Fires only when a conversation goes quiet (typically after 6 minutes of inactivity). Ideal for logging full transcripts, summary reports, or delayed downstream workflows.

The default payload includes the Agent name, User details (if passed via SDK or API), the message content, the Thread ID, and the channel source.

03

The raia API: Authentication and Core Endpoints

If you need to build a custom interface, trigger agent actions from your own application, or manage agents programmatically, use the raia API.

raia API authentication pattern using Agent Secret Key.
Conceptual illustration — not the product interface.

Authentication

API access is not enabled by default. To use the API:

  1. In raia CX, open Agents → your agent → Skills. If API is not listed yet, use Add skill and select + on the API card, then select Edit (pencil).
  2. Select Create API Key, enter a Name and Expiration date, then select Create key. The full key is shown once — copy it into a private store before Done; afterwards the list shows only a masked preview.
  3. For agent-authenticated operations, pass this key in the request header as Agent-Secret-Key: YOUR_KEY. Organization operations use Organization-Secret-Key instead — check each operation in the published spec.

Worked example

The examples use fictional data. Follow the same checks with approved, non-sensitive information for your own task.

If API is not on the agent yet, open Add skill and select + on the API card.

API in Add skill, before adding.
  1. Highlight 1: + (add API)

Once added, select Edit (pencil) on the API card. Adding the skill does not create a key.

Added API card.
  1. Highlight 1: Edit (pencil)

Worked example

The examples use fictional data. Follow the same checks with approved, non-sensitive information for your own task.

With no keys yet, the list is empty. Select Create API Key.

API skill with no keys yet.
  1. Highlight 1: Create API Key
  2. Highlight 2: No API keys yet

Enter a Name that identifies where the key will be used and choose an Expiration date, then Create key. Choose a lifetime that fits your team’s policy and plan how to replace the key before it expires.

Enter a Name and choose an Expiration date before Create key.
  1. Highlight 1: Name
  2. Highlight 2: Expiration date
  3. Highlight 3: Create key

The full key is shown once with Save your key now - it will never be shown again. Copy it into a private password manager or secret store before you select Done. Never share the key in chat, documentation or screenshots.

Store the one-time key privately before Done.
  1. Highlight 1: Save your key now - it will never be shown again.

After Done, the list shows only a masked Key preview with Status, Expires and Created. It cannot reveal the full key again; if you lost it, create a new key and revoke the old one.

The key list shows a masked preview, not the full secret.
  1. Highlight 1: Key preview (masked)
  2. Highlight 2: Active
  3. Highlight 3: Revoke

To stop using a key, select Revoke and reopen the list to check Revoked. Update the application’s stored credential if it needs a replacement, and check that a request using the old key is refused. See the API documentation (https://api.raia2.com/api/external/docs) for the request and authentication header.

A revoked key remains listed with its Revoked status.
  1. Highlight 1: Revoked key status
  2. Highlight 2: Delete (only remaining action)

Security Note: This key is a Bearer Token providing full programmatic access to the agent. Store it securely on your server and never expose it in client-side code (like the JS SDK).

Core Endpoints

POST/external/conversations

Create a new conversation (requires conversationUserId; optional title and context).

POST/external/conversations/{id}/messages

Send a user message (required message field; optional context and files) to an existing conversation.

GET/external/conversations/{id}

Retrieve conversation details and feedback. To read its saved messages, use GET /external/conversations/{id}/messages instead.

GET/external/conversations/{id}/messages

Retrieve the conversation’s saved messages for review.

04

Frequently Asked Questions

What happens if my webhook endpoint is down when raia tries to send data?

Webhook success and failure are tracked in the thread metadata. Admins can view these logs in Mission Control. Failed attempts may require manual review depending on your retry configuration.

Can I customize the JSON payload sent by the webhook?

The base payload structure is fixed to ensure consistency, but you can filter or transform the data downstream using an integration platform like n8n or Zapier before it reaches its final destination.

Are API rate limits applied per agent or per organization?

Rate limits and usage quotas are generally applied at the organization level, though keys can be scoped per agent to enforce least-privilege access.

Progress is saved locally in your browser.