# RTSP Usage

Send RTSP commands to remote IP camera devices from the User Console or API.

With the Soracom API’s Remote Command feature, you can send RTSP commands to capture snapshots from IP cameras and video streaming devices that use an IoT SIM.

> [!NOTE]
>
> RTSP Remote Command currently supports the snapshot command, which captures still images from video streams. The response includes the captured image as JPEG binary data.

> [!WARNING]
>
> Ensure your device's RTSP server is configured and accessible before using this feature. The device must support H.264 video encoding.

## Supported Features

- **Authentication**: None or Basic authentication
- **Video Encoding**: H.264
- **Commands**: `snapshot` - Captures a still image from the RTSP stream
- **Default Port**: 554 (customizable)
- **Response Format**: JPEG image binary data (Content-Type: image/jpeg)

## Programmatic Usage

### Soracom API

To access the Soracom API, first use the [**auth**](https://docs.soracom.io/en/api#!/Auth/auth) API to obtain an API Key and Token. Refer to the [**API Usage Guide**](https://docs.soracom.io/en/developers/soracom-api) for instructions on how to use the API Key and Token in API requests.

Then, use the [sendDownlinkRtsp](https://docs.soracom.io/en/api#!/Sim/sendDownlinkRtsp) API to send an RTSP command to a device that has an IoT SIM:

**Global**

```bash
curl -X POST \
  -H 'X-Soracom-API-Key: <MY-API-KEY>' \
  -H 'X-Soracom-Token: <MY-TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
        "command": "snapshot",
        "port": 554,
        "authentication": {
          "type": "basic",
          "username": "admin",
          "password": "password"
        }
      }' \
  https://g.api.soracom.io/v1/sims/<SIM_ID>/downlink/rtsp
```

**Japan**

```bash
curl -X POST \
  -H 'X-Soracom-API-Key: <MY-API-KEY>' \
  -H 'X-Soracom-Token: <MY-TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
        "command": "snapshot",
        "port": 554,
        "authentication": {
          "type": "basic",
          "username": "admin",
          "password": "password"
        }
      }' \
  https://jp.api.soracom.io/v1/sims/<SIM_ID>/downlink/rtsp
```

### Soracom CLI

To use the Soracom CLI, you must first configure it to authenticate with your account information, authorization key, or SAM user credentials.

Run the following command to capture a snapshot from an RTSP stream on a device that has an IoT SIM:

**Global**

```bash
body='{
        "authentication": {
          "type": "basic",
          "username": "admin",
          "password": "password"
        }
      }'
soracom sims downlink-rtsp --sim-id <SIM_ID> --command snapshot --port 554 --body ${body} --coverage-type g
```

**Japan**

```bash
body='{
        "authentication": {
          "type": "basic",
          "username": "admin",
          "password": "password"
        }
      }'
soracom sims downlink-rtsp --sim-id <SIM_ID> --command snapshot --port 554 --body ${body} --coverage-type jp
```
