*** id: 5e4a19d3-3f73-42af-83f0-99f62390d983 title: record\_call slug: /reference/record-call description: Record call in the background. max-toc-depth: 3 ---------------- [statuscallbacks]: #statuscallbacks Record call in the background. Unlike the [`record` method](/docs/swml/reference/record), the `record_call` method will start the recording and continue executing the SWML script while allowing the recording to happen in the background. To stop call recordings started with `record_call`, use the [`stop_call_record`](/docs/swml/reference/stop-record-call) method. ## **Properties** An object that accepts the following properties. Identifier for this recording, to use with [`stop_record_call`](/docs/swml/reference/stop-record-call) Whether to record in stereo mode Format (`"wav"`, `"mp3"`, or `"mp4"`) Direction of the audio to record: `"speak"` for what party says, `"listen"` for what party hears, `"both"` for what the party hears and says String of digits that will stop the recording when pressed. Default is empty (no terminators). Whether to play a beep before recording How sensitive the recording voice activity detector is to background noise? A larger value is more sensitive. Allowed values from `0.0` to `100.0`. How long, in seconds, to wait for speech to start? How much silence, in seconds, will end the recording? Maximum length of the recording in seconds. HTTP or HTTPS URL to deliver record status events. Learn more about [status callbacks][statuscallbacks]. ## **Variables** Set by the method: * **record\_call\_url:** (out) the URL of the newly started recording. * **record\_call\_result:** (out) `success` | `failed`. * **record\_control\_id:** (out) control ID of this recording. ## **StatusCallbacks** A POST request will be sent to `status_url` with a JSON payload like the following: The type of event. Always `calling.call.record` for this method. The channel for the event, includes the SWML session ID. Unix timestamp (float) when the event was generated. The project ID associated with the call. The Space ID associated with the call. An object containing recording-specific parameters. The call ID. The node handling the call. The control ID for this record operation. The current recording state. **Valid values:** `recording`, `paused`, `finished`, `no_input`, `error`. Recording result details (present when state is `finished`). URL to download the recording. Recording duration in seconds. Recording file size in bytes. Recording format. **Valid values:** `wav`, `mp3`. ### Raw JSON example ```json { "event_type": "calling.call.record", "event_channel": "swml:xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "timestamp": 1640000000.123, "project_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "space_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "params": { "call_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "node_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "control_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "state": "finished", "record": { "url": "https://your-space.signalwire.com/api/v1/recordings/rec-uuid/download", "duration": 15.5, "size": 248320, "format": "wav" } } } ``` *** ## **Examples** ### Start an MP3 recording of the call ```yaml version: 1.0.0 sections: main: - record_call: format: mp3 ``` ```json { "version": "1.0.0", "sections": { "main": [ { "record_call": { "format": "mp3" } } ] } } ``` ### Record and play back #### Record both sides of the conversation: ```yaml version: 1.0.0 sections: main: - record_call: beep: true terminators: '#' - play: urls: - 'say:Leave your message now' - 'silence:10' - stop_record_call: {} - play: urls: - 'say:Playing back' - '${record_call_url}' ``` ```json { "version": "1.0.0", "sections": { "main": [ { "record_call": { "beep": true, "terminators": "#" } }, { "play": { "urls": [ "say:Leave your message now", "silence:10" ] } }, { "stop_record_call": {} }, { "play": { "urls": [ "say:Playing back", "${record_call_url}" ] } } ] } } ``` #### Record only the speaker's side ```yaml version: 1.0.0 sections: main: - record_call: beep: true direction: speak - play: urls: - 'say:Leave your message now' - 'silence:10' - stop_record_call: {} - play: urls: - 'say:Playing back' - '${record_call_url}' ``` ```json { "version": "1.0.0", "sections": { "main": [ { "record_call": { "beep": true, "direction": "speak" } }, { "play": { "urls": [ "say:Leave your message now", "silence:10" ] } }, { "stop_record_call": {} }, { "play": { "urls": [ "say:Playing back", "${record_call_url}" ] } } ] } } ```