<br />

# CameraClipPreview Schema

[Nest Doorbell (battery)](https://developers.google.com/nest/device-access/api/doorbell-battery.md.txt) [Nest Doorbell (wired)](https://developers.google.com/nest/device-access/api/doorbell-wired.md.txt)

`sdm.devices.traits.CameraClipPreview`

This trait belongs to any device that supports the download of a clip preview.

<br />

## Fields


There are no fields available for this trait.

<br />

## Commands

There are no commands available for this trait.

## Events

<br />

### ClipPreview

A video clip is available for preview.

A clip preview is a 10 frame video file in mp4 format. You can choose to show the mp4 video file, or transcode it to another format (for example, an animated gif) in order to show a complete 10 frame sequence. The device client capabilities should be considered when selecting a clip preview method.

This event is supported for the following events:

| Type | Element | Description |
|---|---|---|
| Event | [Motion](https://developers.google.com/nest/device-access/traits/device/camera-motion.md.txt#motion) event of the CameraMotion trait | Motion has been detected by the camera. |
| Event | [Person](https://developers.google.com/nest/device-access/traits/device/camera-person.md.txt#person) event of the CameraPerson trait | A person has been detected by the camera. |
| Event | [Chime](https://developers.google.com/nest/device-access/traits/device/doorbell-chime.md.txt#chime) event of the DoorbellChime trait | The doorbell has been pressed. |

Use the `eventSessionId` to associate this event and the related `previewUrl` with one or more supported events.

<br />

#### ClipPreview event

### Payload

    {
      "eventId" : "f563f89d-e47e-4846-a0a9-1f2d89e18a5a",
      "timestamp" : "2019-01-01T00:00:01Z",
      "resourceUpdate" : {
        "name" : "enterprises/project-id/devices/device-id",
        "events" : {
          "sdm.devices.events.CameraClipPreview.ClipPreview" : {
            "eventSessionId" : "CjY5Y3VKaTZwR3o4Y19YbTVfMF...",
            "previewUrl" : "https://previewUrl/..."
          }
        }
      }
      "userId" : "AVPHwEuBfnPOnTqzVFT4IONX2Qqhu9EJ4ubO-bNnQ-yi",
      "resourceGroup" : [
        "enterprises/project-id/devices/device-id"
      ]
    }

#### ClipPreview event fields

| Field | Description | Data Type |
|---|---|---|
| `eventSessionId` | An ID given to events occurring as part of a single session of related events. May be used for consolidating events. | `string` Example: "CjY5Y3VKaTZwR3o4Y19YbTVfMF..." |
| `previewUrl` | The URL at which to preview the video clip. The default video codec is H264. | `string` Example: "https://<var translate="no">previewUrl</var>/..." |

#### Event payload fields

| Field | Description | Data Type |
|---|---|---|
| `eventId` | The unique identifier for the event. | `string` Example: "f563f89d-e47e-4846-a0a9-1f2d89e18a5a" |
| `timestamp` | The time when the event occurred. | `string` Example: "2019-01-01T00:00:01Z" |
| `resourceUpdate` | An object that details information about the resource update. | `object` |
| `userId` | A unique, obfuscated identifier that represents the user. | `string` Example: "AVPHwEuBfnPOnTqzVFT4IONX2Qqhu9EJ4ubO-bNnQ-yi" |
| `resourceGroup` | An object that indicates resources that might have similar updates to this event. The resource of the event itself (from the `resourceUpdate` object) will always be present in this object. | `object` |

See [Events](https://developers.google.com/nest/device-access/api/events.md.txt) for more information on the different
types of events and how they work.

<br />

#### Preview the clip

<br />

To preview the clip, make a GET call to the `previewUrl` using the OAuth access token in the HTTP Authorization header:

### Preview

    curl -H 'Authorization: Bearer access-token' \
      https://previewUrl/...

<br />

<br />


## Errors

See the [API Error Code Reference](https://developers.google.com/nest/device-access/reference/errors/api.md.txt) for
the full list of API error codes.

<br />