The Dynamic Ad Insertion (DAI) Stream Activity Monitor (SAM) API lets you
inspect and troubleshoot individual livestream and video-on-demand (VOD) viewing
sessions.

To visually inspect and troubleshoot an individual livestream or VOD viewing session, use the
[Stream Activity Monitor](https://support.google.com/admanager/answer/7009058) in
the Google Ad Manager UI.
To programmatically retrieve diagnostic data for a session, use the Ad
Manager API
[`networks.daiSessions`](https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.daiSessions.md.txt)
resource.

## Understand the use cases

With the SAM API, you can automate stream diagnostics and resolve ad delivery
issues across your DAI integrations, such as the following:

- **Verify stream session creation** : Confirm the parameters, stitching mode of `STITCHED` or `POD_SERVING`, reporting mode, and content metadata that Google DAI receives when creating a livestream or VOD session.
- **Audit ad requests and responses**: Inspect outgoing Video Ad Serving Template (VAST) and Video Multiple Ad Playlist (VMAP) ad tags, HTTP status codes, response latencies, raw XML response bodies, and wrapper redirect chains.
- **Troubleshoot ad pod decisioning and creatives**: Verify which ads Google DAI selects or drops for each pod, the duration of each ad in the pod, and the source ad system of the ad creative.
- **Track ad prefetch execution**: Determine whether Google DAI prefetches an ad pod and check the prefetch stage of each ad pod.
- **Validate DAI Ad Break API and Pod serving DAI API calls**: Check actual break execution, served ad durations, and inserted slate durations against API calls, such as the DAI Ad Break API and Pod serving DAI API.
- **Verify ad event tracking**: Confirm whether client-side or server-side tracking pings succeeded and inspect the HTTP responses from ad servers.
- **Automate session monitoring and alerting** : Parse structured findings entries with an `INFO`, `WARNING`, or `ERROR` severity to detect playback or monetization issues in automated integration tests and production monitoring pipelines.

## Learn the top level resource

The SAM API is part of the Google Ad Manager REST API (Beta) on the
`admanager.googleapis.com` endpoint and exposes the
[`networks.daiSessions.get`](https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.daiSessions/get.md.txt)
read-only method. You can query a [`DaiSession` resource](https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.daiSessions.md.txt#resource:-daisession)
with a DAI session ID or a custom debug key. DAI retains the session records for
up to three days after playback.

The SAM API doesn't support listing all `DaiSession` resources in a Google Ad
Manager network.

## Inspect DAI stream responses with SAM

To verify how Google DAI processes your stream requests, examine
the `DaiSession` response:

- **Full-service DAI API** : Inspect the `creationContext.streamCreateRequest` field to verify the stream registration call, check the `adSelections` and `adPods` maps to review ad decisioning, and examine the `adBreaks` map to confirm stitched ad, slate creative, and underlying content durations.
- **Pod serving DAI API** : Confirm that the `creationContext.stitchingType` field is set to the `POD_SERVING` value, cross-check the `adBreakId` field in the `adPods` and `adBreaks` maps with your pod manifest or pod segment request calls, and inspect server-side or media-verification beacons in the `trackingPings` map.
- **DAI Ad Break API** : Match the `breakSequence` value of an `AdBreak` object against the [`AdBreak.breakSequence` property](https://developers.google.com/ad-manager/dynamic-ad-insertion/api/ad-break/rest/v1/adBreak.networks.assets.adBreaks.md.txt).

## Make your first request

To set up authentication and retrieve DAI session resources, see
[Use the Stream Activity Monitor API](https://developers.google.com/ad-manager/dynamic-ad-insertion/api/stream-activity-monitor/use-sam-api.md.txt).