Create an agent session
import MoreVoice from "@morevoice/sdk";
const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment
const agentSessionWithToken = await mv.agentSessions.create({ external_id: "agent-1042", origin: "https://app.example.com", ttl_s: 28800,});console.log(agentSessionWithToken);from morevoice import MoreVoice
client = MoreVoice() # MOREVOICE_API_KEY from the environment
agent_session_with_token = client.agent_sessions.create({ "external_id": "agent-1042", "origin": "https://app.example.com", "ttl_s": 28800,})print(agent_session_with_token)curl -X POST https://api.morevoice.ai/v1/agent_sessions \ -H "Authorization: Bearer $MOREVOICE_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "external_id": "agent-1042", "origin": "https://app.example.com", "ttl_s": 28800}'Signs one of your agents or supervisors in to the agent desk, from your server: no login page of ours. Returns the session’s bearer token (once) for the desk’s REST calls, and a first one-use socket ticket. The session reaches only the agent desk (other routes answer 403 embedded_route_forbidden), with the member’s own role; bind it to your website with origin. It lasts ttl_s (default eight hours, at most 24) and ends early when you revoke it or deactivate the member. Live keys only.
Try it in the API playground with a test-mode key.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”The API version to use for this request. Defaults to the version the API key is pinned to.
Example
2026-11-01A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice.
Example
5f0c1e8a-7b2d-4c3e-9f1a-2b6d8e4c0a17Request Body
Section titled “Request Body”Who to sign in, for how long, from which website.
object
Or: your own id of a managed user (POST /v1/users).
The only website the session works from (https://app.example.com): every request and socket must carry this Origin. Strongly recommended for sessions used in a browser.
Lifetime in seconds, 300–86400 (default 28800, eight hours). It never slides.
The member to sign in (an agent or supervisor). Give this or external_id.
Example
{ "external_id": "agent-1042", "origin": "https://app.example.com", "ttl_s": 28800}Responses
Section titled “Responses”The session, with its token.
A new agent session, with its token and a first socket ticket.
object
An ISO-8601 timestamp in UTC.
When it ends (a fixed lifetime: using it does not extend it).
Your own id for that member (managed users), else null.
The session’s ID.
true in live mode, false in test mode.
The organisation it is bound to (it never switches).
The only website it works from, or null for any.
The session’s bearer token (Authorization: Bearer mvas_…) for the agent desk’s calls. Returned once: give it to the agent’s browser, never log it.
The member it signs in.
A one-time ticket for the first socket (<ws_url>?ticket=…), valid 60 seconds. Get more with POST /v1/agent_sessions/{id}/ticket.
An ISO-8601 timestamp in UTC.
The agent socket’s URL (offers, presence): wss://…/ws/agent.
Example
{ "created": "2026-11-03T08:00:00.000Z", "expires_at": "2026-11-03T16:00:00.000Z", "external_id": "agent-1042", "id": "ags_H97Oak9qchHXc1hB8b93SK", "last_used": "2026-11-03T09:14:22.000Z", "livemode": true, "object": "agent_session", "org_id": "org_87tzsRJO1egtexauAF8PwX", "origin": "https://app.example.com", "token": "<agent session token: mvas_…, keep it on the agent's device>", "user_id": "usr_2Lm8Pq4Rt6Vx0Zb3Nd5Fh7", "ws_ticket": "<one-time socket ticket>", "ws_ticket_expires_at": "2026-11-03T08:01:00.000Z", "ws_url": "wss://voice.example.com/ws/agent"}The request is invalid: a parameter is missing, malformed or unknown, or the version header is unknown.
Every /v1 error.
object
object
A stable, machine-readable code from the error-code catalogue.
Structured context, e.g. required_scope or the compliance verdict.
object
A link to the documentation of this code.
A human-readable explanation. Do not parse it.
The request parameter the error relates to, e.g. to or metadata[order_id].
The X-Request-Id of this request. Quote it when you contact support.
The category of the error.
Example
{ "error": { "code": "parameter_missing", "doc_url": "https://docs.morevoice.ai/api/errors#parameter-missing", "message": "Missing required parameter: to.", "param": "to", "request_id": "req_7Hk2LmN9pQ4rS6tV8wX0yZ", "type": "invalid_request_error" }}Headers
Section titled “Headers”The request’s ID (req_…). Quote it when you contact support.
No valid API key was sent.
Every /v1 error.
object
object
A stable, machine-readable code from the error-code catalogue.
Structured context, e.g. required_scope or the compliance verdict.
object
A link to the documentation of this code.
A human-readable explanation. Do not parse it.
The request parameter the error relates to, e.g. to or metadata[order_id].
The X-Request-Id of this request. Quote it when you contact support.
The category of the error.
Example
{ "error": { "code": "invalid_api_key", "doc_url": "https://docs.morevoice.ai/api/errors#invalid-api-key", "message": "Invalid API key.", "request_id": "req_7Hk2LmN9pQ4rS6tV8wX0yZ", "type": "authentication_error" }}Headers
Section titled “Headers”The request’s ID (req_…). Quote it when you contact support.
The key may not do this (a missing scope, a plan limit, or a compliance block).
Every /v1 error.
object
object
A stable, machine-readable code from the error-code catalogue.
Structured context, e.g. required_scope or the compliance verdict.
object
A link to the documentation of this code.
A human-readable explanation. Do not parse it.
The request parameter the error relates to, e.g. to or metadata[order_id].
The X-Request-Id of this request. Quote it when you contact support.
The category of the error.
Example
{ "error": { "code": "missing_scope", "doc_url": "https://docs.morevoice.ai/api/errors#missing-scope", "message": "This API key lacks the calls:write scope.", "request_id": "req_7Hk2LmN9pQ4rS6tV8wX0yZ", "type": "permission_error" }}Headers
Section titled “Headers”The request’s ID (req_…). Quote it when you contact support.
No object with this ID (in the path or the body) exists in this organisation and mode.
Every /v1 error.
object
object
A stable, machine-readable code from the error-code catalogue.
Structured context, e.g. required_scope or the compliance verdict.
object
A link to the documentation of this code.
A human-readable explanation. Do not parse it.
The request parameter the error relates to, e.g. to or metadata[order_id].
The X-Request-Id of this request. Quote it when you contact support.
The category of the error.
Example
{ "error": { "code": "resource_missing", "doc_url": "https://docs.morevoice.ai/api/errors#resource-missing", "message": "No such object: 'call_4Gk2'.", "param": "id", "request_id": "req_7Hk2LmN9pQ4rS6tV8wX0yZ", "type": "not_found" }}Headers
Section titled “Headers”The request’s ID (req_…). Quote it when you contact support.
The request conflicts with the object’s state, or the Idempotency-Key was reused with other parameters.
Every /v1 error.
object
object
A stable, machine-readable code from the error-code catalogue.
Structured context, e.g. required_scope or the compliance verdict.
object
A link to the documentation of this code.
A human-readable explanation. Do not parse it.
The request parameter the error relates to, e.g. to or metadata[order_id].
The X-Request-Id of this request. Quote it when you contact support.
The category of the error.
Example
{ "error": { "code": "idempotency_mismatch", "doc_url": "https://docs.morevoice.ai/api/errors#idempotency-mismatch", "message": "This Idempotency-Key was already used with different parameters.", "request_id": "req_7Hk2LmN9pQ4rS6tV8wX0yZ", "type": "idempotency_error" }}Headers
Section titled “Headers”The request’s ID (req_…). Quote it when you contact support.
The request body is larger than the endpoint accepts, or has more parts or files than it takes.
Every /v1 error.
object
object
A stable, machine-readable code from the error-code catalogue.
Structured context, e.g. required_scope or the compliance verdict.
object
A link to the documentation of this code.
A human-readable explanation. Do not parse it.
The request parameter the error relates to, e.g. to or metadata[order_id].
The X-Request-Id of this request. Quote it when you contact support.
The category of the error.
Example
{ "error": { "code": "body_too_large", "doc_url": "https://docs.morevoice.ai/api/errors#body-too-large", "message": "The request body is larger than the endpoint accepts.", "request_id": "req_7Hk2LmN9pQ4rS6tV8wX0yZ", "type": "invalid_request_error" }}Headers
Section titled “Headers”The request’s ID (req_…). Quote it when you contact support.
The request body’s Content-Type is not one the endpoint takes.
Every /v1 error.
object
object
A stable, machine-readable code from the error-code catalogue.
Structured context, e.g. required_scope or the compliance verdict.
object
A link to the documentation of this code.
A human-readable explanation. Do not parse it.
The request parameter the error relates to, e.g. to or metadata[order_id].
The X-Request-Id of this request. Quote it when you contact support.
The category of the error.
Example
{ "error": { "code": "unsupported_media_type", "doc_url": "https://docs.morevoice.ai/api/errors#unsupported-media-type", "message": "This endpoint takes application/json.", "request_id": "req_7Hk2LmN9pQ4rS6tV8wX0yZ", "type": "invalid_request_error" }}Headers
Section titled “Headers”The request’s ID (req_…). Quote it when you contact support.
Too many requests, or no call capacity right now. Retry after the Retry-After delay.
Every /v1 error.
object
object
A stable, machine-readable code from the error-code catalogue.
Structured context, e.g. required_scope or the compliance verdict.
object
A link to the documentation of this code.
A human-readable explanation. Do not parse it.
The request parameter the error relates to, e.g. to or metadata[order_id].
The X-Request-Id of this request. Quote it when you contact support.
The category of the error.
Example
{ "error": { "code": "rate_limited", "doc_url": "https://docs.morevoice.ai/api/errors#rate-limited", "message": "Too many requests. Retry after 1 second.", "request_id": "req_7Hk2LmN9pQ4rS6tV8wX0yZ", "type": "rate_limit_error" }}Headers
Section titled “Headers”Seconds to wait before retrying.
The request’s ID (req_…). Quote it when you contact support.
Something went wrong on MoreVoice’s side. Retry with the same Idempotency-Key.
Every /v1 error.
object
object
A stable, machine-readable code from the error-code catalogue.
Structured context, e.g. required_scope or the compliance verdict.
object
A link to the documentation of this code.
A human-readable explanation. Do not parse it.
The request parameter the error relates to, e.g. to or metadata[order_id].
The X-Request-Id of this request. Quote it when you contact support.
The category of the error.
Example
{ "error": { "code": "internal_error", "doc_url": "https://docs.morevoice.ai/api/errors#internal-error", "message": "Something went wrong on MoreVoice's side.", "request_id": "req_7Hk2LmN9pQ4rS6tV8wX0yZ", "type": "api_error" }}Headers
Section titled “Headers”The request’s ID (req_…). Quote it when you contact support.