# Start an ephemeral session (/en/api-reference/api-ref/conversational-ai/platform/start-ephemeral-session)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

> Documentation: Conversational AI API.
> Documentation version: Preview.
> This document describes only this version. [Version index](/llms/doc-versions-convoai-api-v2.txt).


Starts a session with an agent configuration that you pass in the request.

- OpenAPI: /openapi/conversational-ai/rest-api-platform.en.yaml
- Operation ID: start-ephemeral-session
- Method: POST
- Path: /v1/projects/{appid}/sessions/ephemeral
- Endpoint: https://preview.ai.agora.io/conversational-ai/v1/projects/{appid}/sessions/ephemeral

## Servers

- https://preview.ai.agora.io/conversational-ai

Use this endpoint to start a session without saving an agent first, for example to test a configuration. The request body is the same as [Start a session](/en/api-reference/api-ref/conversational-ai/platform/start-session), but with the agent configuration in `agent` instead of `agent_id`. The configuration isn't saved.


## Authorization

This endpoint requires authentication.

- `tokenAuth`
- `basicAuth`

## Parameters

- `appid` (path, required, string) - The App ID of your project.
- `Idempotency-Key` (header, optional, string) - A unique key, so that retrying the request can't start a second session. If a session was already started with this key, the request fails with `409` and reason `IdempotencyKeyConflict`, and no new session starts. The API doesn't return the original response. To find the session, [list sessions](/en/api-reference/api-ref/conversational-ai/platform/list-sessions). Keep the same key when you retry; never switch keys.
  - Min length: `1`
  - Max length: `256`
  - Pattern: `^[\x21-\x7E]+$`

## Request body

- `agent` (object, required) - The agent configuration for this session. It has the same fields as [Create an agent](/en/api-reference/api-ref/conversational-ai/platform/create-agent), except `agent_name`. The configuration isn't saved.
  - `agent.instructions` (string) - The system instructions that define how the agent behaves. The model receives them as the first `system` message, before `messages`.
  - `agent.messages` (array) - Messages that start the conversation history. They follow `instructions`.
    - `agent.messages.items` (object)
      - `agent.messages.items.role` (string, required) - The author of the message:

- `system`: An instruction to the model.
- `user`: A message from the user.
- `assistant`: A message from the agent.
        - Allowed: `system` | `user` | `assistant`
      - `agent.messages.items.content` (string, required) - The text of the message.
  - `agent.variables` (object) - Every variable the agent uses, keyed by variable name. A name starts with a lowercase letter and contains up to 64 lowercase letters, digits, and underscores. Reference a variable as `{{variable_name}}` in `instructions`, `messages`, `greeting.text`, `pipeline.llm.failure_message`, `pipeline.silence_config.content`, and generated filler instructions. The agent doesn't store values: pass them in `values` when you start a session, or in each campaign contact. Expansion is single-pass, so a value that contains a placeholder isn't expanded again.
    - Example: `{"customer_name":{"type":"str","required":true},"resolution_status":{"type":"str","options":["resolved","follow_up","unresolved"],"extract":true,"description":"Outcome of the conversation."}}`
  - `agent.greeting` (object) - The message the agent speaks when a participant joins. If you omit it, the agent doesn't greet participants automatically.
    - `agent.greeting.mode` (string, required) - `text`: The agent speaks `text` using the TTS stage.
    - `agent.greeting.on` (string) - Which participants the agent greets:

- `each_join`: Every participant who joins.
- `first_join`: Only the first participant to join.
      - Allowed: `each_join` | `first_join`
      - Default: `each_join`
    - `agent.greeting.delay_ms` (integer) - The delay in milliseconds between a participant joining and the agent starting the greeting.
      - Default: `0`
      - Range: `[0, 5000]`
    - `agent.greeting.text` (string, required) - The greeting text.
  - `agent.pipeline` (object) - The models that power the agent: separate ASR, LLM, and TTS stages. When you pass a pipeline, `llm` and `tts` are required.
    - `agent.pipeline.mode` (string, required) - `cascaded`: Separate ASR, LLM, and TTS stages.
    - `agent.pipeline.asr` (object) - The automatic speech recognition (ASR) stage, which transcribes the user's speech.
      - `agent.pipeline.asr.credential` (object) - How this stage authenticates with the provider. Set it explicitly on each stage. Pass the fields of one credential mode only. Responses return only `mode`.
        - `agent.pipeline.asr.credential.mode` (string, required) - `managed`: Agora provides the provider authentication.
        - `agent.pipeline.asr.credential.fields` (object) - Your provider credentials, keyed by the provider's field name. Most providers take one field, `api_key`. Some use other names, such as `key` or `credentials`, or take more than one field, such as an AWS access key ID and secret access key. Each model page lists its provider's fields. In an agent, each value must be a `$secrets.<set_name>.<key>` reference to a [secret set](/en/api-reference/api-ref/conversational-ai/platform/create-secret-set). An ephemeral session also accepts the values themselves. Agora resolves references when each session starts. The values are never returned.
      - `agent.pipeline.asr.vendor` (string) - The ASR provider, for example `deepgram`.
      - `agent.pipeline.asr.model` (string) - The provider model, for example `nova-3`.
      - `agent.pipeline.asr.language` (string) - The language of the user's speech, for example `en-US`.
      - `agent.pipeline.asr.url` (string) - A custom provider endpoint. Don't also put the endpoint in `params`.
      - `agent.pipeline.asr.params` (object) - Provider-specific settings that aren't secret, such as `keywords`, passed to the provider as they are. Keep API keys in `credential`, not here.
    - `agent.pipeline.llm` (object, required) - The large language model (LLM) stage, which generates the agent's replies.
      - `agent.pipeline.llm.credential` (object) - How this stage authenticates with the provider. Set it explicitly on each stage. Pass the fields of one credential mode only. Responses return only `mode`.
        - `agent.pipeline.llm.credential.mode` (string, required) - `managed`: Agora provides the provider authentication.
        - `agent.pipeline.llm.credential.fields` (object) - Your provider credentials, keyed by the provider's field name. Most providers take one field, `api_key`. Some use other names, such as `key` or `credentials`, or take more than one field, such as an AWS access key ID and secret access key. Each model page lists its provider's fields. In an agent, each value must be a `$secrets.<set_name>.<key>` reference to a [secret set](/en/api-reference/api-ref/conversational-ai/platform/create-secret-set). An ephemeral session also accepts the values themselves. Agora resolves references when each session starts. The values are never returned.
      - `agent.pipeline.llm.vendor` (string) - The LLM provider, for example `openai`.
      - `agent.pipeline.llm.style` (string) - The API style used to communicate with the model, for example `openai` for OpenAI and OpenAI-compatible APIs.
      - `agent.pipeline.llm.model` (string) - The provider model.
      - `agent.pipeline.llm.url` (string) - A custom provider endpoint. Don't also put the endpoint in `params`. For Google Gemini in an ephemeral session, the URL can include your API key as `key=<your_api_key>`, with `credential.fields` left out. A saved agent's `url` can't contain a key.
      - `agent.pipeline.llm.headers` (object) - Custom HTTP headers sent to the provider endpoint, at most 32. They are write-only and are never returned. A value can be a whole `$secrets.<set>.<key>` reference when the stage uses `byok` and an approved provider endpoint. Agora resolves it when each session starts. A header name that looks like a credential, such as `X-Api-Key`, must use a reference. Transport, identity, and provider authentication headers are reserved. Set provider authentication in `credential`.
      - `agent.pipeline.llm.params` (object) - Provider-specific settings that aren't secret, such as `reasoning_effort`, passed to the provider as they are. Keep API keys in `credential`, not here.
      - `agent.pipeline.llm.input_modalities` (array) - The input types sent to the model, for example `["text"]`.
        - `agent.pipeline.llm.input_modalities.items` (string)
      - `agent.pipeline.llm.output_modalities` (array) - The output types requested from the model, for example `["text"]`.
        - `agent.pipeline.llm.output_modalities.items` (string)
      - `agent.pipeline.llm.max_history` (integer) - The number of recent conversation messages the LLM keeps as context. It counts messages, not user and agent pairs. The agent's `instructions` don't count toward this limit.
        - Default: `32`
        - Range: `[1, 1024]`
      - `agent.pipeline.llm.failure_message` (string) - The message the agent speaks with the TTS stage when the LLM fails to produce a response.
      - `agent.pipeline.llm.tools` (array) - Function tools the model can call. An agent can have up to 32 tools in total, including tools discovered from `mcp_servers`. Tool names must be unique, ignoring case.
        - Max items: `32`
        - `agent.pipeline.llm.tools.items` (object)
          - `agent.pipeline.llm.tools.items.type` (string, required) - Always `function`.
          - `agent.pipeline.llm.tools.items.name` (string, required) - The tool name shown to the model. It starts with a letter and contains only letters and digits, up to 64 characters. It can't start with `mcp`, can't be `ragsearch_tool`, and can't match an MCP, built-in, or model-native tool.
            - Max length: `64`
          - `agent.pipeline.llm.tools.items.description` (string, required) - What the tool does, 1 to 1,024 characters. The model uses it to decide when to call the tool.
            - Min length: `1`
            - Max length: `1024`
          - `agent.pipeline.llm.tools.items.parameters` (object, required) - A JSON Schema that describes the tool's arguments.
          - `agent.pipeline.llm.tools.items.execution` (object, required) - How the agent runs the tool.
            - `agent.pipeline.llm.tools.items.execution.mode` (string, required) - `sync`: The agent waits for the tool response before it continues.
          - `agent.pipeline.llm.tools.items.server` (object, required) - The HTTP endpoint the agent calls to run the tool.
            - `agent.pipeline.llm.tools.items.server.method` (string, required) - The HTTP method.
              - Allowed: `GET` | `POST`
            - `agent.pipeline.llm.tools.items.server.url` (string, required) - The HTTPS URL of the endpoint, up to 2,048 characters.
              - Min length: `1`
              - Max length: `2048`
              - Pattern: `^https://`
            - `agent.pipeline.llm.tools.items.server.headers` (object) - HTTP headers sent to the endpoint, up to 32. They are write-only and are never returned.
            - `agent.pipeline.llm.tools.items.server.body` (object) - Additional fields to include in the request body.
            - `agent.pipeline.llm.tools.items.server.timeout_ms` (integer) - The request timeout in milliseconds.
              - Default: `10000`
              - Range: `[1000, 100000]`
      - `agent.pipeline.llm.mcp_servers` (array) - MCP servers whose tools the model can call.
        - `agent.pipeline.llm.mcp_servers.items` (object)
          - `agent.pipeline.llm.mcp_servers.items.name` (string, required) - A name for the MCP server, 1 to 48 letters and digits.
            - Min length: `1`
            - Max length: `48`
          - `agent.pipeline.llm.mcp_servers.items.endpoint` (string, required) - The HTTPS URL of the MCP server, up to 2,048 characters.
            - Min length: `1`
            - Max length: `2048`
            - Pattern: `^https://`
          - `agent.pipeline.llm.mcp_servers.items.transport` (string, required) - The MCP transport. `streamable_http`: Streamable HTTP.
          - `agent.pipeline.llm.mcp_servers.items.headers` (object) - HTTP headers sent to the MCP server, up to 32. They are write-only and are never returned.
          - `agent.pipeline.llm.mcp_servers.items.allowed_tools` (array) - The tools the model can call from this server:

- Omit the field, or include `*` in the list, to allow every tool.
- Pass an empty list to allow no tools.
- Otherwise, only the listed tools are allowed.
            - `agent.pipeline.llm.mcp_servers.items.allowed_tools.items` (string)
              - Min length: `1`
          - `agent.pipeline.llm.mcp_servers.items.timeout_ms` (integer) - The request timeout in milliseconds.
            - Range: `[1000, 100000]`
    - `agent.pipeline.tts` (object, required) - The text-to-speech (TTS) stage, which converts the agent's replies to speech.
      - `agent.pipeline.tts.credential` (object) - How this stage authenticates with the provider. Set it explicitly on each stage. Pass the fields of one credential mode only. Responses return only `mode`.
        - `agent.pipeline.tts.credential.mode` (string, required) - `managed`: Agora provides the provider authentication.
        - `agent.pipeline.tts.credential.fields` (object) - Your provider credentials, keyed by the provider's field name. Most providers take one field, `api_key`. Some use other names, such as `key` or `credentials`, or take more than one field, such as an AWS access key ID and secret access key. Each model page lists its provider's fields. In an agent, each value must be a `$secrets.<set_name>.<key>` reference to a [secret set](/en/api-reference/api-ref/conversational-ai/platform/create-secret-set). An ephemeral session also accepts the values themselves. Agora resolves references when each session starts. The values are never returned.
      - `agent.pipeline.tts.vendor` (string) - The TTS provider, for example `microsoft`.
      - `agent.pipeline.tts.model` (string) - The TTS model the agent uses. Returned in responses only.
      - `agent.pipeline.tts.url` (string) - A custom provider endpoint. Don't also put the endpoint in `params`.
      - `agent.pipeline.tts.headers` (object) - Custom HTTP headers sent to the provider endpoint, at most 32. They are write-only and are never returned. A value can be a whole `$secrets.<set>.<key>` reference when the stage uses `byok` and an approved provider endpoint. Agora resolves it when each session starts. A header name that looks like a credential, such as `X-Api-Key`, must use a reference. Transport, identity, and provider authentication headers are reserved. Set provider authentication in `credential`.
      - `agent.pipeline.tts.params` (object) - Provider-specific settings that aren't secret, such as the voice and, where the provider requires it, the model, passed to the provider as they are. Keep API keys in `credential`, not here.
      - `agent.pipeline.tts.skip_patterns` (array) - Bracketed text that the agent doesn't speak, such as tone or action notes in the LLM
output:

- `fullwidth_parentheses`: Text in `（）`.
- `lenticular_brackets`: Text in `【】`.
- `parentheses`: Text in `( )`.
- `square_brackets`: Text in `[ ]`.
- `curly_braces`: Text in `{ }`.
        - `agent.pipeline.tts.skip_patterns.items` (string)
          - Allowed: `fullwidth_parentheses` | `lenticular_brackets` | `parentheses` | `square_brackets` | `curly_braces`
    - `agent.pipeline.turn_detection` (object) - How the agent detects when the user starts and stops speaking, and handles interruptions.
      - `agent.pipeline.turn_detection.speech_threshold` (number) - The speech detection threshold. Lower values detect speech more easily. Higher values ignore weak speech.
        - Default: `0.5`
        - Range: `[0, 1]`
      - `agent.pipeline.turn_detection.start_of_speech` (object) - How the agent detects that the user starts speaking. Pass the fields of one detection type only. If you omit it, the agent uses `semantic` detection with its defaults.
        - `agent.pipeline.turn_detection.start_of_speech.type` (string, required) - `semantic`: Detects a meaningful start of speech. If you omit `type`, the agent uses `semantic`.
          - Default: `semantic`
        - `agent.pipeline.turn_detection.start_of_speech.interrupt_duration_ms` (integer) - Speech shorter than this, in milliseconds, is ignored.
          - Default: `160`
          - Range: `[120, 1200]`
        - `agent.pipeline.turn_detection.start_of_speech.speaking_interrupt_duration_ms` (integer) - How long in milliseconds the user must speak to interrupt the agent while it's speaking.
          - Default: `160`
        - `agent.pipeline.turn_detection.start_of_speech.prefix_padding_ms` (integer) - How many milliseconds of audio before the detected start of speech to keep, so the beginning of the speech isn't clipped.
          - Default: `800`
          - Range: `[0, 5000]`
      - `agent.pipeline.turn_detection.end_of_speech` (object) - How the agent detects that the user has finished speaking. Pass the fields of one detection type only. If you omit it, the agent uses `semantic` detection with its defaults.
        - `agent.pipeline.turn_detection.end_of_speech.type` (string, required) - `semantic`: Considers whether the utterance sounds complete. If you omit `type`, the agent uses `semantic`.
          - Default: `semantic`
        - `agent.pipeline.turn_detection.end_of_speech.silence_duration_ms` (integer) - The silence in milliseconds that ends the turn.
          - Default: `320`
          - Range: `[120, 2000]`
        - `agent.pipeline.turn_detection.end_of_speech.max_wait_ms` (integer) - The maximum time in milliseconds to wait before ending the turn, from 500 to 10,000. Set to `-1` to wait without a timeout.
          - Default: `3000`
          - Range: `[500, 10000]`
        - `agent.pipeline.turn_detection.end_of_speech.pause_state_enabled` (boolean) - Whether the agent detects a pause within an utterance, such as "hold on", and waits for more input.
          - Default: `true`
      - `agent.pipeline.turn_detection.interruption` (object) - How the user can interrupt the agent while it speaks or thinks. Pass the fields of one interruption mode only. If you omit it, any user speech interrupts the agent.
        - Default: `{"mode":"start_of_speech"}`
        - `agent.pipeline.turn_detection.interruption.mode` (string, required) - `start_of_speech`: Any user speech interrupts the agent.
        - `agent.pipeline.turn_detection.interruption.when_off` (string) - What happens to user speech that arrives while the agent speaks or thinks:

- `append`: The agent responds to the speech after the current reply.
- `ignore`: The agent discards the speech.
          - Allowed: `append` | `ignore`
          - Default: `append`
        - `agent.pipeline.turn_detection.interruption.keywords` (array, required) - The phrases that interrupt the agent, 1 to 128.
          - Min items: `1`
          - Max items: `128`
          - `agent.pipeline.turn_detection.interruption.keywords.items` (string)
            - Min length: `1`
    - `agent.pipeline.silence_config` (object) - What the agent does after a period of silence. This only prompts the user. To hang up a phone call after silence, use `call_policy.max_silence_duration_ms`.
      - `agent.pipeline.silence_config.enabled` (boolean, required) - Whether to act on silence.
      - `agent.pipeline.silence_config.timeout_ms` (integer, required) - How long the silence lasts, in milliseconds, before the agent acts, up to 60,000. Applies only when `enabled` is `true`.
        - Range: `[0, 60000]`
      - `agent.pipeline.silence_config.action` (string, required) - What the agent does when the timeout is reached:

- `speak`: Speaks `content` as written.
- `think`: Gives `content` to the LLM as an instruction, and responds to it.
        - Allowed: `speak` | `think`
      - `agent.pipeline.silence_config.content` (string, required) - The text to speak, or the instruction for the LLM, depending on `action`.
    - `agent.pipeline.avatar` (object) - The avatar that represents the agent on video.
      - `agent.pipeline.avatar.enabled` (boolean) - Whether to show the avatar.
        - Default: `false`
      - `agent.pipeline.avatar.credential` (object) - How this stage authenticates with the provider. Set it explicitly on each stage. Pass the fields of one credential mode only. Responses return only `mode`.
        - `agent.pipeline.avatar.credential.mode` (string, required) - `managed`: Agora provides the provider authentication.
        - `agent.pipeline.avatar.credential.fields` (object) - Your provider credentials, keyed by the provider's field name. Most providers take one field, `api_key`. Some use other names, such as `key` or `credentials`, or take more than one field, such as an AWS access key ID and secret access key. Each model page lists its provider's fields. In an agent, each value must be a `$secrets.<set_name>.<key>` reference to a [secret set](/en/api-reference/api-ref/conversational-ai/platform/create-secret-set). An ephemeral session also accepts the values themselves. Agora resolves references when each session starts. The values are never returned.
      - `agent.pipeline.avatar.vendor` (string) - The avatar provider. `generic` passes provider-neutral parameters through.
        - Allowed: `akool` | `liveavatar` | `anam` | `sensetime` | `spatius` | `generic`
      - `agent.pipeline.avatar.params` (object) - Provider-specific settings, passed to the provider as they are.
  - `agent.filler_words` (object) - Short phrases the agent says while it waits for the LLM to respond, such as when it waits for a tool call.
    - `agent.filler_words.enable` (boolean) - Whether to play filler words.
      - Default: `false`
    - `agent.filler_words.trigger` (object) - When to play a filler word.
      - `agent.filler_words.trigger.mode` (string, required) - `fixed_time`: Play a filler word when the LLM hasn't responded within `response_wait_ms`.
      - `agent.filler_words.trigger.response_wait_ms` (integer, required) - How long in milliseconds to wait for the LLM response before playing a filler word, for example `1500`.
        - Range: `[100, 10000]`
    - `agent.filler_words.content` (object) - Where the filler words come from. Pass the fields of one source only.
      - `agent.filler_words.content.mode` (string, required) - `static`: Pick a phrase from `phrases`.
      - `agent.filler_words.content.instructions` (string, required) - The instructions used to generate filler phrases. They can't be empty or only whitespace.
        - Min length: `1`
      - `agent.filler_words.content.fallback_strategy` (string) - What to use when a generated phrase isn't available.
        - Default: `static`
      - `agent.filler_words.content.phrases` (array, required) - The filler phrases, 1 to 100 non-empty strings.
        - Min items: `1`
        - Max items: `100`
        - `agent.filler_words.content.phrases.items` (string)
          - Min length: `1`
      - `agent.filler_words.content.selection_rule` (string) - How the agent picks the next phrase:

- `shuffle`: In random order.
- `round_robin`: In list order, starting over after the last phrase.
        - Allowed: `shuffle` | `round_robin`
        - Default: `shuffle`
- `transport` (object, required) - How the agent connects to the participant. Pass the fields of one transport type only.
  - `transport.type` (string, required) - `rtc`: The agent joins an RTC channel.
  - `transport.from` (string, required) - The `number_id` of the number in the project to call from. Phone numbers aren't accepted. [Import the number](/en/api-reference/api-ref/conversational-ai/platform/create-number) first.
    - Format: `uuid`
  - `transport.to` (string, required) - The phone number to call, in E.164 format, for example `+14155550100`.
    - Pattern: `^\+[1-9][0-9]{1,14}$`
  - `transport.call_policy` (object) - Limits and behavior for outbound phone calls. Each limit you omit adds no limit.
    - `transport.call_policy.max_ring_duration_ms` (integer) - The maximum time in milliseconds from starting the dial until the call is answered. If the call isn't answered in time, the dial attempt ends.
      - Minimum: `1`
    - `transport.call_policy.max_call_duration_seconds` (integer) - The maximum length of the call in seconds, measured from when it's answered. The session's `lifecycle` limits can end the call earlier.
      - Minimum: `1`
    - `transport.call_policy.max_silence_duration_ms` (integer) - Hang up when nobody on the call has spoken for this many milliseconds. This is separate from `pipeline.silence_config`, which only prompts the user.
      - Minimum: `1`
    - `transport.call_policy.end_call` (object) - Conditions under which the agent can end the call itself. Every condition is off unless you set it to `true`.
      - `transport.call_policy.end_call.on_user_request` (boolean) - End the call when the caller clearly says goodbye or asks to hang up.
        - Default: `false`
      - `transport.call_policy.end_call.on_voicemail` (boolean) - End the call when the agent reaches voicemail, such as a "please leave a message after the tone" announcement.
        - Default: `false`
      - `transport.call_policy.end_call.on_ai_assistant` (boolean) - End the call when the call is answered by an AI assistant, a voice secretary, or another automated answering system.
        - Default: `false`
  - `transport.channel` (string, required) - The name of the RTC channel to join, 1 to 256 characters.
    - Min length: `1`
    - Max length: `256`
  - `transport.token` (string) - The RTC token the agent uses to join the channel. Required when the project has an App Certificate enabled. To renew it, [update the session](/en/api-reference/api-ref/conversational-ai/platform/update-session).
  - `transport.uid` (string) - The user ID the agent uses in the channel. Pass a string of up to 255 characters, such as `"1002"` or `"agent-bot"`, or an integer from 0 to 4294967295, such as `1002`. Omit it, or pass `0`, to let Agora assign a user ID that differs from `subscribe_uids`.
    - Default: `0`
    - Range: `[0, 4294967295]`
    - Min length: `1`
    - Max length: `255`
  - `transport.subscribe_uids` (array, required) - The user ID of the participant the agent talks to, as a string or an integer. Pass exactly one user ID.
    - Min items: `1`
    - Max items: `1`
    - `transport.subscribe_uids.items` (string)
      - Range: `[1, 4294967295]`
      - Min length: `1`
      - Max length: `255`
  - `transport.audio_scenario` (string) - The audio scenario of the agent in the channel:

- `aiserver`: Optimized for latency and network resilience in conversations with an
  agent.
- `chorus`: For participants with good network conditions who need ultra-low latency.
    - Allowed: `aiserver` | `chorus`
    - Default: `aiserver`
  - `transport.encryption` (object) - Media encryption for the RTC channel. These values are never returned.
    - `transport.encryption.mode` (string, required) - The encryption mode. Agora recommends `aes_128_gcm2` or `aes_256_gcm2`, which use a salt.
      - Allowed: `aes_128_xts` | `aes_128_ecb` | `aes_256_xts` | `sm4_128_ecb` | `aes_128_gcm` | `aes_256_gcm` | `aes_128_gcm2` | `aes_256_gcm2`
    - `transport.encryption.key` (string, required) - The encryption key.
      - Min length: `1`
    - `transport.encryption.salt` (string) - A Base64-encoded salt that is 32 bytes long after decoding. Required when `mode` is `aes_128_gcm2` or `aes_256_gcm2`.
      - Pattern: `^[A-Za-z0-9+/]{43}=$`
- `values` (object) - Values for the agent's variables, keyed by variable name, for this session only. Each key must be a variable the agent declares, and each value must match its `type` and `options`. Pass a value for every `required` variable. `null` values are rejected.
  - Example: `{"customer_name":"Ada"}`
- `lifecycle` (object) - When the session ends on its own.
  - `lifecycle.idle_timeout_ms` (integer) - How long in milliseconds the session continues with no participant present: after the subscribed user leaves the RTC channel, or after the other side of a phone call hangs up. It isn't silence detection. Set to `0` to turn off the idle timer. Can't be greater than `max_duration_ms`.
    - Default: `30000`
    - Range: `[0, 3600000]`
  - `lifecycle.max_duration_ms` (integer) - The maximum length of the session in milliseconds, measured from `start_ts`. Defaults to 5 minutes. The maximum is 1 hour.
    - Default: `300000`
    - Range: `[1000, 3600000]`
  - `lifecycle.graceful_stop` (object) - How the agent finishes when you stop the session, or when the idle timer expires. It doesn't extend `max_duration_ms`, and it doesn't add a farewell message.
    - `lifecycle.graceful_stop.enabled` (boolean) - Whether the agent finishes what it's saying before it leaves.
      - Default: `false`
    - `lifecycle.graceful_stop.timeout_ms` (integer) - The longest time in milliseconds the agent can take to finish.
      - Default: `30000`
      - Range: `[0, 120000]`
- `data_policy` (object) - How Agora handles the session's data. You set it when the session starts and can't change it afterward.
  - `data_policy.retention` (string) - How long Agora keeps the conversation data:

- `30_days`: Agora keeps the data for 30 days.
- `none`: Agora doesn't keep the data, and variable extraction doesn't run. Use it, for
  example, when a caller declines recording.
    - Allowed: `30_days` | `none`
    - Default: `30_days`
- `labels` (object) - Key-value labels for this session, such as a team or customer ID. They're included in the `payload` of [notification events](/en/ai/reference/event-types).

### Request body example

```json
{
  "agent": {
    "instructions": "Answer account questions concisely.",
    "pipeline": {
      "mode": "cascaded",
      "asr": {
        "credential": {
          "mode": "managed"
        },
        "vendor": "deepgram",
        "model": "nova-3",
        "language": "en-US"
      },
      "llm": {
        "credential": {
          "mode": "byok",
          "fields": {
            "api_key": "$secrets.support_prod.llm"
          }
        },
        "vendor": "openai",
        "style": "openai",
        "model": "<model_name>"
      },
      "tts": {
        "credential": {
          "mode": "managed"
        },
        "vendor": "minimax",
        "params": {
          "model": "speech-2.6-turbo",
          "voice_setting": {
            "voice_id": "English_captivating_female1",
            "speed": 1
          }
        }
      }
    }
  },
  "transport": {
    "type": "rtc",
    "channel": "support-4821",
    "token": "<your_rtc_token>",
    "uid": "1002",
    "subscribe_uids": [
      "1001"
    ]
  }
}
```

## Responses

### 200

The session was created.

- `agent_session_id` (string, required) - The ID of the session.
  - Pattern: `^[a-z0-9]{32}$`
- `create_ts` (integer, required) - The time the session was created, as a Unix timestamp in seconds.
- `status` (string, required) - The status of the session when it starts. For a phone call, `RUNNING` doesn't mean the call was answered.
  - Allowed: `STARTING` | `RUNNING`
### 400

The request was rejected and no session was created. For example, `InvalidModuleParameter` when the pipeline is invalid, or `UnknownSecretReference` when a `$secrets` reference doesn't exist.

- `detail` (string, required) - A human-readable description of the error. It names the field or resource involved, when there is one. Don't parse it; branch on `reason` instead.
- `reason` (string, required) - A machine-readable error reason, such as `InvalidFieldValue` or `ResourceNotFound`. For all reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).
### 401

Authentication is missing or invalid. The reason is `InvalidPermission`.

- `detail` (string, required) - A human-readable description of the error. It names the field or resource involved, when there is one. Don't parse it; branch on `reason` instead.
- `reason` (string, required) - A machine-readable error reason, such as `InvalidFieldValue` or `ResourceNotFound`. For all reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).
### 404

The resource in the path doesn't exist. The reason is `ResourceNotFound`.

- `detail` (string, required) - A human-readable description of the error. It names the field or resource involved, when there is one. Don't parse it; branch on `reason` instead.
- `reason` (string, required) - A machine-readable error reason, such as `InvalidFieldValue` or `ResourceNotFound`. For all reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).
### 409

`TaskConflict`: An agent is already running with the same RTC channel and UID. `IdempotencyKeyConflict`: A session was already started with this `Idempotency-Key`.

- `detail` (string, required) - A human-readable description of the error. It names the field or resource involved, when there is one. Don't parse it; branch on `reason` instead.
- `reason` (string, required) - A machine-readable error reason, such as `InvalidFieldValue` or `ResourceNotFound`. For all reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).
### 422

The request failed. The response body contains the `reason` and `detail` of the failure. For possible reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).

- `detail` (string, required) - A human-readable description of the error. It names the field or resource involved, when there is one. Don't parse it; branch on `reason` instead.
- `reason` (string, required) - A machine-readable error reason, such as `InvalidFieldValue` or `ResourceNotFound`. For all reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).
### 429

`ConcurrencyLimitExceeded`: The project has reached its concurrent session limit. Stop a session, or retry later with exponential backoff.

- `detail` (string, required) - A human-readable description of the error. It names the field or resource involved, when there is one. Don't parse it; branch on `reason` instead.
- `reason` (string, required) - A machine-readable error reason, such as `InvalidFieldValue` or `ResourceNotFound`. For all reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).
### 503

The request failed. The response body contains the `reason` and `detail` of the failure. For possible reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).

- `detail` (string, required) - A human-readable description of the error. It names the field or resource involved, when there is one. Don't parse it; branch on `reason` instead.
- `reason` (string, required) - A machine-readable error reason, such as `InvalidFieldValue` or `ResourceNotFound`. For all reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).
### 504

The request failed. The response body contains the `reason` and `detail` of the failure. For possible reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).

- `detail` (string, required) - A human-readable description of the error. It names the field or resource involved, when there is one. Don't parse it; branch on `reason` instead.
- `reason` (string, required) - A machine-readable error reason, such as `InvalidFieldValue` or `ResourceNotFound`. For all reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).
### default

The request failed. The response body contains the `reason` and `detail` of the failure. For possible reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).

- `detail` (string, required) - A human-readable description of the error. It names the field or resource involved, when there is one. Don't parse it; branch on `reason` instead.
- `reason` (string, required) - A machine-readable error reason, such as `InvalidFieldValue` or `ResourceNotFound`. For all reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).

## Response examples

### 200

```json
{
  "agent_session_id": "a42al97tw77hv93ja98dm74fk56lw97x",
  "create_ts": 1737111452,
  "status": "RUNNING"
}
```
