***
id: 922026e9-1a65-4b5b-b786-ca7918b72cf1
title: record
slug: /reference/record
description: >-
Record the call audio in the foreground pausing further SWML execution until
recording ends.
max-toc-depth: 3
----------------
[statuscallbacks]: #statuscallbacks
Record the call audio in the foreground pausing further SWML execution until recording ends. Use this, for example, to record voicemails.
To record calls in the background in a non-blocking fashion, use the [`record_call`](/docs/swml/reference/record-call)
## **Properties**
An object that accepts the following properties.
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
String of digits that will stop the recording when pressed
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\_url:** (out) the URL of the newly created recording.
* **record\_result:** (out) `success` | `failed`.
## **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`.
URL to download the recording.
Recording duration in seconds. Present when `state` is `finished` or `no_input`.
Recording file size in bytes. Present when `state` is `finished` or `no_input`.
The unique identifier for the recording. Present when available.
Unix timestamp (seconds, float) when the recording started. Present when the recording has ended.
Unix timestamp (seconds, float) when the recording ended. Present when the recording has ended.
How paused recording handles audio. Only present when `state` is `paused`. **Valid values:** `silence`, `skip`.
Recording configuration details.
Recording format. **Valid values:** `wav`, `mp3`.
Direction of the audio recorded: `speak` or `listen`.
Whether the recording was made in stereo mode.
### 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": {
"state": "finished",
"control_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"call_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"node_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"url": "https://your-space.signalwire.com/api/v1/recordings/rec-uuid/download",
"duration": 15,
"size": 248320,
"recording_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"start_time": 1640000000.123,
"end_time": 1640000015.623,
"record": {
"audio": {
"format": "wav",
"direction": "speak",
"stereo": false
}
}
}
}
```
***
## **Examples**
### Record some audio and play it back
```yaml
version: 1.0.0
sections:
main:
- play:
url: 'say:Start speaking after the beep. Press hash to end recording.'
- record:
end_silence_timeout: 3
beep: true
- play:
url: 'say:Recording ${record_result}. Playing back recording:'
- play:
url: '${record_url}'
```
```json
{
"version": "1.0.0",
"sections": {
"main": [
{
"play": {
"url": "say:Start speaking after the beep. Press hash to end recording."
}
},
{
"record": {
"end_silence_timeout": 3,
"beep": true
}
},
{
"play": {
"url": "say:Recording ${record_result}. Playing back recording:"
}
},
{
"play": {
"url": "${record_url}"
}
}
]
}
}
```