End session (canonical V0)
Canonical V0 session-end endpoint (Decision D1). Ends an active session: signals the SessionOrchestratorDO to tear down Modal/SFU resources (with a 10s timeout), then advances the row to ended (or ended_with_warnings if cleanup timed out).
NOT idempotent: re-POSTing /end against an already-terminal session returns 409. ended / ended_with_warnings map to AVTR_SESSION_ENDED; created / ending / failed map to AVTR_SESSION_CONFLICT. Cross-tenant access returns 404.
Query parameter ?force=true skips the graceful disconnect handshake inside the DO and terminates backend resources immediately.
The deployed Worker also exposes DELETE /v1/sessions/{id} as a bridge/internal alias; new integrations MUST use POST /end.
POST
/v1/sessions/{session_id}/endAuthorization
AuthorizationBearer token · headerrequired`Authorization: Bearer <api_key>`
or
x-api-keyAPI key · headerrequired`x-api-key: <api_key>`
Path parameters
session_idstringrequiredmin length 1 · matches ^session:[A-Za-z0-9_-]+$
Responses
200Session ended. `status` is `ended` on graceful cleanup, or `ended_with_warnings` when the DO cleanup timed out or failed (a `warning` field is then present).
chunks_renderedintegermin 0
duration_snumbermin 0
ended_atinteger<int64>requiredUnix epoch milliseconds when the session ended.
min 0
session_idstringrequiredSession identifier (always prefixed with `session:`).
min length 1 · matches ^session:[A-Za-z0-9_-]+$
statusstringrequiredSession lifecycle status.
Allowed:
createdactivatingactiveendingendedended_with_warningsfailedwarningstringPresent only when cleanup timed out or partially failed (`status: "ended_with_warnings"`). Absent on graceful ends.
401API key missing or invalid.
Any of:
object
codestringrequiredAllowed:
AVTR_PROVIDER_DOWNSTREAM_FAILEDAVTR_PROVIDER_TIMEOUTAVTR_PROVIDER_UNAVAILABLEAVTR_RATE_LIMIT_CONCURRENT_SESSIONSAVTR_RATE_LIMIT_EXCEEDEDAVTR_RATE_LIMIT_PROVIDER_QUOTAAVTR_RENDER_CAPACITYAVTR_RENDER_TIMEOUTAVTR_SESSION_STATE_UNAVAILABLEAVTR_SFU_CONNECTION_FAILEDAVTR_SFU_NEGOTIATION_FAILEDAVTR_SFU_ROOM_FULLdoc_urlstring<uri>requiredAbsolute HTTPS URL to human-facing documentation for this error code.
matches ^https:\/\/
messagestringrequiredHuman-readable, provider-agnostic error message. MUST NOT contain provider names, model ids, infrastructure identifiers (Modal/D1/DO), IP addresses, stack traces, or API keys. Consumers MAY localize.
min length 1
request_idstring<uuid>requiredPer-request correlation UUID. Echoes the `X-Request-Id` response header. Used to locate traces and logs.
retry_afterintegerrequiredSeconds the client SHOULD wait before retrying (1..3600). REQUIRED for retryable codes; FORBIDDEN for non-retryable codes. Clients SHOULD honor this value and SHOULD apply jitter.
min 1 · max 3600
object
codestringrequiredAllowed:
AVTR_AUTH_EXPIRED_TOKENAVTR_AUTH_FORBIDDENAVTR_AUTH_INVALID_KEYAVTR_AUTH_MISSING_CREDENTIALSAVTR_AUTH_MISSING_SCOPEAVTR_PROVIDER_MISCONFIGUREDAVTR_RENDER_FAILEDAVTR_RENDER_MISCONFIGUREDAVTR_SESSION_CANCELLEDAVTR_SESSION_CONFLICTAVTR_SESSION_ENDEDAVTR_SESSION_NOT_FOUNDAVTR_SFU_NOT_CONFIGUREDdoc_urlstring<uri>requiredAbsolute HTTPS URL to human-facing documentation for this error code.
matches ^https:\/\/
messagestringrequiredHuman-readable, provider-agnostic error message. MUST NOT contain provider names, model ids, infrastructure identifiers (Modal/D1/DO), IP addresses, stack traces, or API keys. Consumers MAY localize.
min length 1
request_idstring<uuid>requiredPer-request correlation UUID. Echoes the `X-Request-Id` response header. Used to locate traces and logs.
403Missing `sessions:write` scope.
Any of:
object
codestringrequiredAllowed:
AVTR_PROVIDER_DOWNSTREAM_FAILEDAVTR_PROVIDER_TIMEOUTAVTR_PROVIDER_UNAVAILABLEAVTR_RATE_LIMIT_CONCURRENT_SESSIONSAVTR_RATE_LIMIT_EXCEEDEDAVTR_RATE_LIMIT_PROVIDER_QUOTAAVTR_RENDER_CAPACITYAVTR_RENDER_TIMEOUTAVTR_SESSION_STATE_UNAVAILABLEAVTR_SFU_CONNECTION_FAILEDAVTR_SFU_NEGOTIATION_FAILEDAVTR_SFU_ROOM_FULLdoc_urlstring<uri>requiredAbsolute HTTPS URL to human-facing documentation for this error code.
matches ^https:\/\/
messagestringrequiredHuman-readable, provider-agnostic error message. MUST NOT contain provider names, model ids, infrastructure identifiers (Modal/D1/DO), IP addresses, stack traces, or API keys. Consumers MAY localize.
min length 1
request_idstring<uuid>requiredPer-request correlation UUID. Echoes the `X-Request-Id` response header. Used to locate traces and logs.
retry_afterintegerrequiredSeconds the client SHOULD wait before retrying (1..3600). REQUIRED for retryable codes; FORBIDDEN for non-retryable codes. Clients SHOULD honor this value and SHOULD apply jitter.
min 1 · max 3600
object
codestringrequiredAllowed:
AVTR_AUTH_EXPIRED_TOKENAVTR_AUTH_FORBIDDENAVTR_AUTH_INVALID_KEYAVTR_AUTH_MISSING_CREDENTIALSAVTR_AUTH_MISSING_SCOPEAVTR_PROVIDER_MISCONFIGUREDAVTR_RENDER_FAILEDAVTR_RENDER_MISCONFIGUREDAVTR_SESSION_CANCELLEDAVTR_SESSION_CONFLICTAVTR_SESSION_ENDEDAVTR_SESSION_NOT_FOUNDAVTR_SFU_NOT_CONFIGUREDdoc_urlstring<uri>requiredAbsolute HTTPS URL to human-facing documentation for this error code.
matches ^https:\/\/
messagestringrequiredHuman-readable, provider-agnostic error message. MUST NOT contain provider names, model ids, infrastructure identifiers (Modal/D1/DO), IP addresses, stack traces, or API keys. Consumers MAY localize.
min length 1
request_idstring<uuid>requiredPer-request correlation UUID. Echoes the `X-Request-Id` response header. Used to locate traces and logs.
404Session not found, or cross-tenant access denied.
Any of:
object
codestringrequiredAllowed:
AVTR_PROVIDER_DOWNSTREAM_FAILEDAVTR_PROVIDER_TIMEOUTAVTR_PROVIDER_UNAVAILABLEAVTR_RATE_LIMIT_CONCURRENT_SESSIONSAVTR_RATE_LIMIT_EXCEEDEDAVTR_RATE_LIMIT_PROVIDER_QUOTAAVTR_RENDER_CAPACITYAVTR_RENDER_TIMEOUTAVTR_SESSION_STATE_UNAVAILABLEAVTR_SFU_CONNECTION_FAILEDAVTR_SFU_NEGOTIATION_FAILEDAVTR_SFU_ROOM_FULLdoc_urlstring<uri>requiredAbsolute HTTPS URL to human-facing documentation for this error code.
matches ^https:\/\/
messagestringrequiredHuman-readable, provider-agnostic error message. MUST NOT contain provider names, model ids, infrastructure identifiers (Modal/D1/DO), IP addresses, stack traces, or API keys. Consumers MAY localize.
min length 1
request_idstring<uuid>requiredPer-request correlation UUID. Echoes the `X-Request-Id` response header. Used to locate traces and logs.
retry_afterintegerrequiredSeconds the client SHOULD wait before retrying (1..3600). REQUIRED for retryable codes; FORBIDDEN for non-retryable codes. Clients SHOULD honor this value and SHOULD apply jitter.
min 1 · max 3600
object
codestringrequiredAllowed:
AVTR_AUTH_EXPIRED_TOKENAVTR_AUTH_FORBIDDENAVTR_AUTH_INVALID_KEYAVTR_AUTH_MISSING_CREDENTIALSAVTR_AUTH_MISSING_SCOPEAVTR_PROVIDER_MISCONFIGUREDAVTR_RENDER_FAILEDAVTR_RENDER_MISCONFIGUREDAVTR_SESSION_CANCELLEDAVTR_SESSION_CONFLICTAVTR_SESSION_ENDEDAVTR_SESSION_NOT_FOUNDAVTR_SFU_NOT_CONFIGUREDdoc_urlstring<uri>requiredAbsolute HTTPS URL to human-facing documentation for this error code.
matches ^https:\/\/
messagestringrequiredHuman-readable, provider-agnostic error message. MUST NOT contain provider names, model ids, infrastructure identifiers (Modal/D1/DO), IP addresses, stack traces, or API keys. Consumers MAY localize.
min length 1
request_idstring<uuid>requiredPer-request correlation UUID. Echoes the `X-Request-Id` response header. Used to locate traces and logs.
409Session is not `active`. `AVTR_SESSION_ENDED` for `ended` / `ended_with_warnings`; `AVTR_SESSION_CONFLICT` for `created` / `ending` / `failed`.
Any of:
object
codestringrequiredAllowed:
AVTR_PROVIDER_DOWNSTREAM_FAILEDAVTR_PROVIDER_TIMEOUTAVTR_PROVIDER_UNAVAILABLEAVTR_RATE_LIMIT_CONCURRENT_SESSIONSAVTR_RATE_LIMIT_EXCEEDEDAVTR_RATE_LIMIT_PROVIDER_QUOTAAVTR_RENDER_CAPACITYAVTR_RENDER_TIMEOUTAVTR_SESSION_STATE_UNAVAILABLEAVTR_SFU_CONNECTION_FAILEDAVTR_SFU_NEGOTIATION_FAILEDAVTR_SFU_ROOM_FULLdoc_urlstring<uri>requiredAbsolute HTTPS URL to human-facing documentation for this error code.
matches ^https:\/\/
messagestringrequiredHuman-readable, provider-agnostic error message. MUST NOT contain provider names, model ids, infrastructure identifiers (Modal/D1/DO), IP addresses, stack traces, or API keys. Consumers MAY localize.
min length 1
request_idstring<uuid>requiredPer-request correlation UUID. Echoes the `X-Request-Id` response header. Used to locate traces and logs.
retry_afterintegerrequiredSeconds the client SHOULD wait before retrying (1..3600). REQUIRED for retryable codes; FORBIDDEN for non-retryable codes. Clients SHOULD honor this value and SHOULD apply jitter.
min 1 · max 3600
object
codestringrequiredAllowed:
AVTR_AUTH_EXPIRED_TOKENAVTR_AUTH_FORBIDDENAVTR_AUTH_INVALID_KEYAVTR_AUTH_MISSING_CREDENTIALSAVTR_AUTH_MISSING_SCOPEAVTR_PROVIDER_MISCONFIGUREDAVTR_RENDER_FAILEDAVTR_RENDER_MISCONFIGUREDAVTR_SESSION_CANCELLEDAVTR_SESSION_CONFLICTAVTR_SESSION_ENDEDAVTR_SESSION_NOT_FOUNDAVTR_SFU_NOT_CONFIGUREDdoc_urlstring<uri>requiredAbsolute HTTPS URL to human-facing documentation for this error code.
matches ^https:\/\/
messagestringrequiredHuman-readable, provider-agnostic error message. MUST NOT contain provider names, model ids, infrastructure identifiers (Modal/D1/DO), IP addresses, stack traces, or API keys. Consumers MAY localize.
min length 1
request_idstring<uuid>requiredPer-request correlation UUID. Echoes the `X-Request-Id` response header. Used to locate traces and logs.
429Rate limit exceeded.
Any of:
object
codestringrequiredAllowed:
AVTR_PROVIDER_DOWNSTREAM_FAILEDAVTR_PROVIDER_TIMEOUTAVTR_PROVIDER_UNAVAILABLEAVTR_RATE_LIMIT_CONCURRENT_SESSIONSAVTR_RATE_LIMIT_EXCEEDEDAVTR_RATE_LIMIT_PROVIDER_QUOTAAVTR_RENDER_CAPACITYAVTR_RENDER_TIMEOUTAVTR_SESSION_STATE_UNAVAILABLEAVTR_SFU_CONNECTION_FAILEDAVTR_SFU_NEGOTIATION_FAILEDAVTR_SFU_ROOM_FULLdoc_urlstring<uri>requiredAbsolute HTTPS URL to human-facing documentation for this error code.
matches ^https:\/\/
messagestringrequiredHuman-readable, provider-agnostic error message. MUST NOT contain provider names, model ids, infrastructure identifiers (Modal/D1/DO), IP addresses, stack traces, or API keys. Consumers MAY localize.
min length 1
request_idstring<uuid>requiredPer-request correlation UUID. Echoes the `X-Request-Id` response header. Used to locate traces and logs.
retry_afterintegerrequiredSeconds the client SHOULD wait before retrying (1..3600). REQUIRED for retryable codes; FORBIDDEN for non-retryable codes. Clients SHOULD honor this value and SHOULD apply jitter.
min 1 · max 3600
object
codestringrequiredAllowed:
AVTR_AUTH_EXPIRED_TOKENAVTR_AUTH_FORBIDDENAVTR_AUTH_INVALID_KEYAVTR_AUTH_MISSING_CREDENTIALSAVTR_AUTH_MISSING_SCOPEAVTR_PROVIDER_MISCONFIGUREDAVTR_RENDER_FAILEDAVTR_RENDER_MISCONFIGUREDAVTR_SESSION_CANCELLEDAVTR_SESSION_CONFLICTAVTR_SESSION_ENDEDAVTR_SESSION_NOT_FOUNDAVTR_SFU_NOT_CONFIGUREDdoc_urlstring<uri>requiredAbsolute HTTPS URL to human-facing documentation for this error code.
matches ^https:\/\/
messagestringrequiredHuman-readable, provider-agnostic error message. MUST NOT contain provider names, model ids, infrastructure identifiers (Modal/D1/DO), IP addresses, stack traces, or API keys. Consumers MAY localize.
min length 1
request_idstring<uuid>requiredPer-request correlation UUID. Echoes the `X-Request-Id` response header. Used to locate traces and logs.
503Session state temporarily unavailable.
Any of:
object
codestringrequiredAllowed:
AVTR_PROVIDER_DOWNSTREAM_FAILEDAVTR_PROVIDER_TIMEOUTAVTR_PROVIDER_UNAVAILABLEAVTR_RATE_LIMIT_CONCURRENT_SESSIONSAVTR_RATE_LIMIT_EXCEEDEDAVTR_RATE_LIMIT_PROVIDER_QUOTAAVTR_RENDER_CAPACITYAVTR_RENDER_TIMEOUTAVTR_SESSION_STATE_UNAVAILABLEAVTR_SFU_CONNECTION_FAILEDAVTR_SFU_NEGOTIATION_FAILEDAVTR_SFU_ROOM_FULLdoc_urlstring<uri>requiredAbsolute HTTPS URL to human-facing documentation for this error code.
matches ^https:\/\/
messagestringrequiredHuman-readable, provider-agnostic error message. MUST NOT contain provider names, model ids, infrastructure identifiers (Modal/D1/DO), IP addresses, stack traces, or API keys. Consumers MAY localize.
min length 1
request_idstring<uuid>requiredPer-request correlation UUID. Echoes the `X-Request-Id` response header. Used to locate traces and logs.
retry_afterintegerrequiredSeconds the client SHOULD wait before retrying (1..3600). REQUIRED for retryable codes; FORBIDDEN for non-retryable codes. Clients SHOULD honor this value and SHOULD apply jitter.
min 1 · max 3600
object
codestringrequiredAllowed:
AVTR_AUTH_EXPIRED_TOKENAVTR_AUTH_FORBIDDENAVTR_AUTH_INVALID_KEYAVTR_AUTH_MISSING_CREDENTIALSAVTR_AUTH_MISSING_SCOPEAVTR_PROVIDER_MISCONFIGUREDAVTR_RENDER_FAILEDAVTR_RENDER_MISCONFIGUREDAVTR_SESSION_CANCELLEDAVTR_SESSION_CONFLICTAVTR_SESSION_ENDEDAVTR_SESSION_NOT_FOUNDAVTR_SFU_NOT_CONFIGUREDdoc_urlstring<uri>requiredAbsolute HTTPS URL to human-facing documentation for this error code.
matches ^https:\/\/
messagestringrequiredHuman-readable, provider-agnostic error message. MUST NOT contain provider names, model ids, infrastructure identifiers (Modal/D1/DO), IP addresses, stack traces, or API keys. Consumers MAY localize.
min length 1
request_idstring<uuid>requiredPer-request correlation UUID. Echoes the `X-Request-Id` response header. Used to locate traces and logs.
Try it
Server
Authorization
Parameters
Request
curl -X POST "https://api.avtr.internal/v1/v1/sessions/session%3A02732348-1350-413a-9f0c-d6f47210b417/end" \
-H "Authorization: Bearer YOUR_TOKEN"const response = await fetch("https://api.avtr.internal/v1/v1/sessions/session%3A02732348-1350-413a-9f0c-d6f47210b417/end", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN"
}
});import requests
response = requests.post(
"https://api.avtr.internal/v1/v1/sessions/session%3A02732348-1350-413a-9f0c-d6f47210b417/end",
headers={
"Authorization": "Bearer YOUR_TOKEN"
},
)Response
{
"chunks_rendered": 0,
"duration_s": 0,
"ended_at": 0,
"session_id": "session:02732348-1350-413a-9f0c-d6f47210b417",
"status": "created",
"warning": "string"
}{
"code": "AVTR_PROVIDER_DOWNSTREAM_FAILED",
"doc_url": "http://example.com",
"message": "string",
"request_id": "266ea41d-adf5-480b-af50-15b940c2b846",
"retry_after": 1
}{
"code": "AVTR_PROVIDER_DOWNSTREAM_FAILED",
"doc_url": "http://example.com",
"message": "string",
"request_id": "266ea41d-adf5-480b-af50-15b940c2b846",
"retry_after": 1
}{
"code": "AVTR_PROVIDER_DOWNSTREAM_FAILED",
"doc_url": "http://example.com",
"message": "string",
"request_id": "266ea41d-adf5-480b-af50-15b940c2b846",
"retry_after": 1
}{
"code": "AVTR_PROVIDER_DOWNSTREAM_FAILED",
"doc_url": "http://example.com",
"message": "string",
"request_id": "266ea41d-adf5-480b-af50-15b940c2b846",
"retry_after": 1
}{
"code": "AVTR_PROVIDER_DOWNSTREAM_FAILED",
"doc_url": "http://example.com",
"message": "string",
"request_id": "266ea41d-adf5-480b-af50-15b940c2b846",
"retry_after": 1
}{
"code": "AVTR_PROVIDER_DOWNSTREAM_FAILED",
"doc_url": "http://example.com",
"message": "string",
"request_id": "266ea41d-adf5-480b-af50-15b940c2b846",
"retry_after": 1
}