Session API Reference
Start agent sessions programmatically. The widget uses this API automatically, call it directly for custom integrations.
Base URL
https://api.ojin.aiThere is one endpoint. It is not regional, so there is no region to choose. Every path below already includes the /v1 prefix, so append it to the base URL as written.
Start a Session
POST /v1/public/agents/connect
Start a new session for a given agent. Returns connection details for joining the WebRTC room.
Request
Headers:
Content-Type
Yes
application/json
Body:
agent_id
string
Yes
The ID of the agent to start a session with
client_user_ref
string
No
An opaque identifier for your end user. Appears in call history for analytics and tracking. Max 256 characters.
Response (200 OK)
session_id
string
Unique identifier for this session
room_url
string
WebRTC room URL to connect to
token
string
Authentication token for joining the room
Use room_url and token to connect to the WebRTC room from your client. If you're building a web application, you can use the Daily JavaScript SDK to join the room.
Error Responses
All errors return a JSON body with error_code and message:
For concurrency_limit errors, the response includes an additional retry_after_seconds field indicating how long to wait before retrying:
agent_not_found
404
Agent ID does not exist or is not visible to the caller
agent_unpublished
403
Agent exists but status is unpublished
auth_failed
403
Hostname allowlist validation failed
concurrency_limit
429
Max concurrency reached. Response includes retry_after_seconds
room_creation_failed
502
WebRTC room could not be created
orchestrator_error
502
Agent orchestrator is unreachable or returned an error
internal_error
500
Unexpected server error
Authentication
Currently, the public Session API uses hostname allowlist authentication. When a browser request arrives, the server checks the Origin header against the domains configured on the agent:
If the origin matches an allowed hostname, the request proceeds
If no hostnames are configured, all requests are rejected (agent is private)
If
*is configured, all origins are accepted
No API key or token is needed from the client side when using hostname allowlist.
Cancel a Session by Room
POST /v1/public/agents/connect/{room}
Cancel an active public session after a room has been allocated. This is mainly used by browser clients during unload, tab-hide, or abort cleanup.
{room} is the Daily room name from the room_url returned by POST /v1/public/agents/connect.
Cancel Response (200 OK)
released
number
Number of active sessions released. 0 means the room was already gone or unknown.
Examples
Release the session when the user leaves the page:
Connecting to the Room
After receiving the room_url and token from the Session API, connect to the WebRTC room using the Daily JavaScript SDK:
Last updated
Was this helpful?