---
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.
  - `custom_data` unknown

## 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

## Changes

- **2026-09-01** `89ff267f0958` — 1 info
  - added the new optional request property `custom_data`
- **2026-08-04** `9b0a18aea1e2` — 1 info
  - added the new optional request property `streams`
- **2026-06-15** `41268cfc6143` — 1 info
  - added the new `AMR-NB` enum value to the request property `codec`
- **2026-06-12** `dee6706a7730` — 1 info
  - added the new `AMR-WB` enum value to the request property `codec`
- **2026-05-08** `20957badcc90` — 1 breaking, 2 info
  - removed the success response with the status `200`
  - added the new optional request property `codec`
  - added the success response with the status `202`

[Full history](https://skmtc.dev/voiceblender/apis/voiceblender-api/changes/legs/:id/answer/post.md)

---

[API](https://skmtc.dev/voiceblender/apis/voiceblender-api.md) · [All operations](https://skmtc.dev/voiceblender/apis/voiceblender-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/voiceblender/voiceblender-api/revisions/89ff267f0958/schema)
