---
title: "Answer a ringing or early-media inbound SIP leg (asynchronous)"
method: POST
path: "/legs/{id}/answer"
tags: ["Legs"]
---

# Answer a ringing or early-media inbound SIP leg (asynchronous)

`POST /legs/{id}/answer`

Signals the inbound-call goroutine to send 200 OK. The HTTP call returns 202 immediately; the actual SIP 200 OK is sent in the background, and the leg's transition is observed via `leg.connected`. Pre-condition failures (wrong state, unknown codec) still return 4xx synchronously. When the caller offers several m=audio sections they are all accepted; `streams` optionally routes each accepted stream beyond the primary into its own room, applied once the answer is negotiated.

## Request body

- AnswerLegRequest
  - `speech_detection` boolean — If true, emit speaking.started and speaking.stopped events for this leg. If false, suppress them. Omit to use the server default (SPEECH_DETECTION_ENABLED env var, default false).
  - `codec` 'PCMU' | 'PCMA' | 'G722' | 'opus' | 'AMR-WB' | 'AMR-NB' — Explicit codec for the answer SDP. Must appear in the remote offer's offered_codecs list. Omit to use the server's default preference order.
  - `streams` AnswerLegStream[] — Rooms for the caller's additional audio streams, applied once the answer is negotiated. Positional: entry i addresses the i-th accepted stream beyond the primary, in m-line order — the caller's offer decides how many exist, so an entry with no matching stream is ignored. Use POST /v1/legs/{id}/streams/{streamId}/room to re-route a stream later.
    - `room_id` string — Room to mix this stream into once the answer is negotiated. May differ from the room the leg itself joins.
    - `role` string — Routing role for this stream inside its room.

## Response `202`

Answer queued

## Other responses

- `400` — Not a SIP inbound leg, invalid body, or codec not in offer
- `404` — Leg not found
- `409` — Leg is not in ringing or early_media state

---

[API](https://skmtc.net/voiceblender/apis/voiceblender-api.md) · [All operations](https://skmtc.net/voiceblender/apis/voiceblender-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/voiceblender/voiceblender-api/versions/ad30827d3b57/schema)
