Authentication and Security
The raia API lets you interact with your AI agent programmatically. Because agents can execute functions and access proprietary knowledge, authentication depends on the operation: agent operations use Agent-Secret-Key, and organization operations use Organization-Secret-Key. Keep both keys on your backend.
Setting Up API Access
- Open the Launch Pad for your agent
- Go to the Skills tab
Open Agents, choose your agent, then open Skills. These views locate the navigation; follow the skill-specific settings below.
- Highlight 1: Agents
- Highlight 1: Skills
- If API is not on the agent yet, use Add skill and select + on the API card. Then select Edit (pencil) on the API card. Adding the skill does not create a key.
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.
- Highlight 1: + (add API)
Once added, select Edit (pencil) on the API card. Adding the skill does not create a key.
- Highlight 1: Edit (pencil)
- Select Create API Key, enter a Name, choose an Expiration date, then select Create key. The full key is shown once: copy it into a private password manager or secret store before you select Done.
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.
- Highlight 1: Create API Key
- 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.
- Highlight 1: Name
- Highlight 2: Expiration date
- 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.
- Highlight 1: Save your key now - it will never be shown again.
- After Done, the key list shows only a masked preview and cannot reveal the key again. For revoking and replacing keys, see the API skill and browser extension guides.
Worked example
The examples use fictional data. Follow the same checks with approved, non-sensitive information for your own task.
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.
- Highlight 1: Key preview (masked)
- Highlight 2: Active
- 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. Use the documented API reference for the request and authentication header.
- Highlight 1: Revoked key status
- Highlight 2: Delete (only remaining action)
For an authorized authentication check, send the documented agents/by-api-key request from your backend with the intended agent’s key. If it returns HTTP 403 (INVALID_CREDENTIALS), check the header, agent, expiration and revocation status without logging the secret. After revoking a key, confirm Revoked in the list and check that subsequent requests are refused; update approved clients with a replacement key when needed.
- Pass the required key in the matching operation’s request header from your backend, never from public browser code.
Authentication Header
curl -X POST https://api.raia2.com/external/conversations \
-H "Content-Type: application/json" \
-H "Agent-Secret-Key: YOUR_AGENT_SECRET_KEY" \
-d '{ "conversationUserId": "YOUR_CONVERSATION_USER_ID" }'
Illustrative example, checked against the published OpenAPI schema — not a live successful request. Use a real conversationUserId from your own agent.
Recovery: If authentication fails, confirm the required key type in the API reference and check the selected agent or organization. Revoke an exposed key through the approved account procedure. This lesson does not verify key scope or revocation behavior.
Core API Endpoints
| Method | Endpoint | Purpose |
|---|---|---|
| POST | /external/conversations | Create a new conversation. Requires conversationUserId; optional title (max 255 chars) and context (string). |
| POST | /external/conversations/{id}/messages | Send a message to an existing conversation thread. Requires message; optional context and files. |
| GET | /external/conversations/{id} | Retrieve conversation details and metadata (no messages property). |
| GET | /external/conversations/{id}/messages | Retrieve the conversation's saved messages array (transcript/history). |
| POST | /external/conversations/start | Outbound only: contacts a recipient over email, SMS or voice. Requires an authorized channel/account — not for ordinary web chat. |
| GET | /external/agents/{id}/users | Get agent users using an Organization-Secret-Key. |
Starting a Conversation with Context
When you call POST /external/conversations, you create a conversation for a conversation user and can pass optional context for the agent to use:
{
"conversationUserId": "YOUR_CONVERSATION_USER_ID",
"title": "Plan upgrade question",
"context": "Enterprise customer since 2022. Currently on Pro plan. Last support ticket was about API rate limits."
}
Then send the user's first message with POST /external/conversations/{id}/messages:
{
"message": "Hi, I need help upgrading my plan."
}
The agent can use this context so the user doesn't have to repeat it. Test with fictional data to check how your agent actually uses each field.
Outbound conversations are separate: POST /external/conversations/start contacts a recipient over email, SMS or voice (each channel has its own required fields, such as email/emailSubject or phoneNumber) and requires an authorized channel/account. It is not the way to start an ordinary web chat, and no outbound request should be sent just to try it.
Building Custom Interfaces
While raia provides native channels (Live Chat, SMS, Email, Voice), the API lets you build completely custom user interfaces while relying on raia for the intelligence.
Common custom UI patterns:
- In-App Copilots: Embed the agent directly into your SaaS product's dashboard to help users navigate features
- Internal Tools: Build a custom Slack bot or internal portal where employees can query HR policies or IT documentation
- Headless E-commerce: Use the agent as a conversational search engine on a custom storefront
In this architecture, you own the frontend UI and user experience; raia handles RAG, tool calling, and LLM orchestration.
API Documentation
- Interactive Swagger UI:
https://api.raia2.com/api/external/docs - OpenAPI JSON (for SDK generation):
https://api.raia2.com/api/external/docs/openapi.json
Rate Limits
API requests may be rate-limited. If you receive a 429 Too Many Requests response, implement exponential backoff in your retry logic.
FAQ: Can I fetch the raw vector search results via the API? The endpoints in this lesson return the agent's response, not raw search results. Check the API reference for what each endpoint returns.