Protocol
API

API Documentation

Use the OkPo API to integrate AI agents, conversations, content generation, and secure external chatbot access.

How To Use The Endpoints

  1. Use AI agent credentials: X-Agent-Key and X-Agent-Secret.
  2. Send first message to /api/v1/ai-agents/external/messages.
  3. Save returned conversation_token in your integration.
  4. Send continuous messages with /api/v1/ai-agents/external/messages/continue.
  5. Pass X-Conversation-Token header with each next message.
  6. Store refreshed token from each response.

Endpoint Flow (Mermaid)

flowchart TD A["Authenticate<br/>X-Agent-Key + X-Agent-Secret"] --> B["One-shot Message<br/>POST /api/v1/ai-agents/external/messages"] B --> C["Receive conversation_token in response"] C --> D["Continue Message<br/>POST /api/v1/ai-agents/external/messages/continue"] D --> E["Assistant Response + refreshed conversation_token"] A --> F["Optional: Create Conversation<br/>POST /api/v1/ai-agents/external/conversations"] A --> G["Manage External Sources/Webhooks"]

Getting started

Authentication

Methods and Endpoints

Messages

POSTExternal Message/api/v1/ai-agents/external/messages

Key-protected external chatbot request.

Production chatbot clients outside admin-client.

POSTBulk External Messages/api/v1/ai-agents/external/messages/bulk

Send up to 10 independent external chat turns in one request.

Batch integrations that need a result for each external user.

POSTCreate External Message (By Token)/api/v1/ai-agents/external/messages/continue

Send message using X-Conversation-Token header (contains conversation/session context).

Continuous conversation turns without passing conversation_id/user_id.

POSTInject Context/api/v1/ai-agents/external/inject-context

Inject a topic and/or prompt into a (new or existing) conversation and trigger an immediate assistant reply.

Constrain the agent to a subject before user input, or seed a conversation programmatically.

POSTInject Context From Post/api/v1/ai-agents/external/inject-context-from-post

Inject context derived from a published public Post (title, description, tags, meta_data, transcript) and trigger an assistant reply.

Bridge a post (e.g., article or recording) into an AI conversation as grounding context.

Conversations

POSTCreate External Conversation/api/v1/ai-agents/external/conversations

Create a new conversation for the agent resolved from the API key and return a conversation_token.

Pre-create a session before any message turns, or to control title/metadata up-front.

POSTSend External Conversation Message/api/v1/ai-agents/external/conversations/{conversationId}/messages

Append a user message to an existing external conversation and receive the assistant reply.

Authoritative turn-by-turn flow when you already hold a conversation_id.

Sources

GETExternal List Sources/api/v1/ai-agents/external/sources

List all knowledge sources attached to the agent resolved from the API key.

Audit or display the agent's current knowledge base.

POSTExternal Create Source/api/v1/ai-agents/external/sources

Create source via external API key.

Programmatic knowledge ingestion.

DELETEExternal Delete Source/api/v1/ai-agents/external/sources/{sourceId}

Delete source via external API key.

Knowledge cleanup.

PUTExternal Update Source/api/v1/ai-agents/external/sources/{sourceId}

Update existing source via external API key.

Knowledge source maintenance.

Webhooks

POSTExternal Create Webhook/api/v1/ai-agents/external/webhooks

Create webhook subscription using API key auth.

External event automation setup.

DELETEExternal Delete Webhook/api/v1/ai-agents/external/webhooks/{webhookId}

Delete webhook via API key auth.

Webhook decommissioning.

GETExternal List Webhook Deliveries/api/v1/ai-agents/external/webhooks/{webhookId}/deliveries?limit=50

List recent delivery attempts for a webhook.

Troubleshooting webhook failures.

GETExternal List Webhooks/api/v1/ai-agents/external/webhooks

List webhook subscriptions via API key auth.

Webhook management dashboards.

POSTExternal Test Webhook/api/v1/ai-agents/external/webhooks/{webhookId}/test

Trigger webhook test delivery via API key auth.

Integration validation.

PUTExternal Update Webhook/api/v1/ai-agents/external/webhooks/{webhookId}

Update webhook via API key auth.

Webhook reconfiguration.

Other

Errors

Error code reference

Use these codes to quickly identify what failed and what to fix.

Error codeWhat happenedWhat to do
AI_AGENT_NOT_FOUNDAI agent does not exist or is outside caller scope.Check agent_id and account ownership.
AI_AGENT_FORBIDDENCaller lacks permission for the agent.Use owner/admin credentials.
API_KEY_CONFLICTAPI key conflicts with an existing one.Use unique key name or rotate existing key.
API_KEY_CREATE_FAILEDBackend failed to create API key.Retry; if persistent, check server logs.
WEBHOOK_VALIDATION_FAILEDWebhook payload/settings are invalid.Fix URL, events, timeout values.
WEBHOOK_CREATE_FAILEDWebhook creation failed internally.Retry and verify backend/database health.
WEBHOOK_NOT_FOUNDWebhook id not found for agent.Verify webhook_id and agent_id.
WEBHOOK_TEST_FAILEDWebhook test delivery failed.Ensure target URL is reachable and returns 2xx.
CONVERSATION_NOT_FOUNDConversation id does not exist or mismatches agent.Check conversation_id.
CONVERSATION_FORBIDDENCaller is not authorized on conversation.Use conversation owner/admin token.
MESSAGE_VALIDATION_FAILEDMessage payload failed validation.Fix content length/shape.
MESSAGE_SEND_FAILEDMessage send/generation failed.Retry and check provider/model configuration.
EXTERNAL_AUTH_FAILEDExternal auth headers invalid.Send valid X-Agent-Key and X-Agent-Secret.
EXTERNAL_MESSAGE_VALIDATION_FAILEDExternal message payload invalid.Fix content/history/image_urls.
EXTERNAL_MESSAGE_SEND_FAILEDExternal send failed.Retry and check backend/provider status.
PUBLIC_AGENT_NOT_FOUNDPublic slug does not map to an agent.Check slug value.
PUBLIC_AGENT_DISABLEDAgent exists but public mode is disabled.Enable public visibility/publish state.
PUBLIC_MESSAGE_VALIDATION_FAILEDPublic message payload invalid.Fix content format/length.
PUBLIC_MESSAGE_SEND_FAILEDPublic message generation failed.Retry and inspect service logs.

Webhooks

Event names

conversation.created, message.received, message.generated, recording.processed, disposition.decided, webhook.test.

Signing

Webhook deliveries are signed with your webhook signing secret (HMAC). Keep this secret server-side only and verify signatures before trusting payloads.

External auth

External endpoints require X-Agent-Key + X-Agent-Secret on every request.

AI Agents

Conversations

Messages

Sources