> ## Documentation Index
> Fetch the complete documentation index at: https://docs.interactivelayers.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Campaign matching, airings and playback

> Reuse a saved analysis to plan a broadcast or deliver ads in a viewing session.

## Plan against a known asset version

Use a project key, an asset with a completed analysis and an enabled ad profile. List profiles through `GET /v1/ad-providers/profiles` and use the returned provider, account and profile identifiers. This sample is for `POST /v1/vod/matches` or `POST /v1/vod/airings`. Replace all identifiers and the date with your own.

```json theme={null}
{
  "asset_id": "asset-0123456789abcdef0123456789abcdef",
  "channel_id": "channel-0123456789abcdef0123456789abcdef",
  "provider": "gam",
  "connection_id": "default",
  "ad_profile_id": "default",
  "planned_start_at": "2026-12-01T20:00:00-03:00"
}
```

| Step | Request | Essential fields |
| - | - | - |
| 1 | `POST /v1/vod/channels` | `{"name":"Channel A","timezone":"America/Argentina/Cordoba"}` |
| 2 | `POST /v1/vod/matches` | `asset_id`, `channel_id`, `planned_start_at` |
| 3 | `POST /v1/vod/airings` | `asset_id`, `channel_id`, `planned_start_at` |
| 4 | `POST /v1/vod/airings/{airing_id}/events` | `event_id`, `type`, `occurred_at` |

Poll `GET /v1/vod/matches/{match_id}` until a terminal state. The evaluation time for each moment is the planned start plus that moment's offset. Review the per-moment results and provider snapshot. Campaign candidates describe contextual affinity. Delivery and measurement are confirmed later by the relevant provider.

Reschedule with `PATCH /v1/vod/airings/{airing_id}` and cancel with `POST /v1/vod/airings/{airing_id}/cancel`. Use RFC 3339 dates with a zone. Report `started` and `ended` with actual times from your playout. The start notification triggers reevaluation against the actual time. Preserve the same `Idempotency-Key` when retrying an identical supported mutation. The event stream deduplicates by `event_id`.

## Play a client-side VAST ad

1. Create a playback with `POST /v1/vod/playbacks` using `asset_id`, `channel_id` and one routing choice. For a started airing you can provide `airing_id`. Use an explicit VAST profile, `project_routing: true` or a published `adrouter_placement_id` as appropriate.
2. Prepare a break with `POST /v1/vod/playbacks/{playback_id}/opportunities` and `{"cue_seconds":120}`.
3. At the cue, call `POST /v1/vod/playbacks/{playback_id}/opportunities/{opportunity_id}/request`. Pass the opaque `ad_tag_url` to a compatible VAST player such as IMA if `eligible` is true and a URL is present. Continue the content if the opportunity is unavailable, rejected, expired, already consumed or times out.
4. Report progress to `POST /v1/vod/playbacks/{playback_id}/events` with a fresh `event_id`, `type: "progress"` and `data.position_seconds`. Use the ad integration's VAST beacons to measure the spot.

In a project that never saved ordered lists, a direct GAM profile works as before: when no campaign matches the scene, the break is skipped, or the response carries the GAM tag without context key-values (`reason: "provider_inventory"`, `context.fallback: "unmatched"`) if the project requests a common ad. If the project requests a pre-roll, `{"cue_seconds":0}` returns that same tag as a pre-roll (`context.fallback: "preroll"`); otherwise the call returns 422. Both rules are off by default.

In the **At the breaks** row of **Settings → Delivery**, **Mid-roll every (minutes)** (1 to 60, empty means none) asks for a mid-roll at that interval. IL asks the ad server for each break separately, so no ad rule is needed in Google Ad Manager; when you add a mid-roll step with the field empty, the screen fills in 10 minutes. The **Display ad unit for the 300×250 Overlay** is chosen in **Settings → Adservers → Google Ad Manager** and must belong to the network of the default GAM profile. These settings and the ordered lists feed the ad plan that the browser reads to request ads directly from each ad server, without going through this API. [ILPlayer](https://docs.interactivelayers.com/il-player.md) · [Player SDK](https://docs.interactivelayers.com/player-sdk.md)

## Walk the ad-server steps of a break

When AdRouter is off and the project saved its lists (with **Apps and TV** chosen in **Settings → General**), create the playback without `provider`, `connection_id`, `ad_profile_id`, `gam_profile_id`, `airing_id` or `adrouter_placement_id`. The playback then answers `"routing": "steps"`. With AdRouter on, or with any of those fields, the playback works as described above and has no `routing`. [How the order works](https://docs.interactivelayers.com/ad-providers.md#how-the-order-works)

On these playbacks, `/request` answers the first step that can be asked and adds `step` (its index, from 0), `steps_left`, `kind` (`contextual` or `common`), `provider`, `connection_id` and `ad_profile_id`. `context.skipped_steps` lists the steps IL skipped, each with `step`, `provider`, `kind` and `reason`. An iADServer step answers `reason: "requested"`.

If the ad server of that step returns no ad, call `POST /v1/vod/playbacks/{playback_id}/opportunities/{opportunity_id}/next` with the `step` you received as `after_step`. The answer has the same shape. With no step left it answers `{"eligible": false, "reason": "steps_exhausted", "steps_left": 0}`: continue the content.

A mid-roll list with an iADServer contextual step and a Google Ad Manager common step:

```http theme={null}
POST /v1/vod/playbacks/{playback_id}/opportunities/{opportunity_id}/request
```

```json theme={null}
{
  "eligible": true,
  "reason": "requested",
  "provider": "iadserver",
  "ad_tag_url": "https://ads.iadserver.com/gampad/ads?…",
  "step": 0,
  "steps_left": 1,
  "kind": "contextual",
  "connection_id": "default",
  "ad_profile_id": "default",
  "context": {"skipped_steps": []}
}
```

iADServer returns an empty VAST. Ask the next step:

```http theme={null}
POST /v1/vod/playbacks/{playback_id}/opportunities/{opportunity_id}/next
{"after_step": 0}
```

```json theme={null}
{
  "eligible": true,
  "reason": "provider_inventory",
  "provider": "gam",
  "ad_tag_url": "https://pubads.g.doubleclick.net/gampad/ads?…",
  "step": 1,
  "steps_left": 0,
  "kind": "common",
  "connection_id": "default",
  "ad_profile_id": "default",
  "context": {"fallback": "unmatched", "skipped_steps": []}
}
```

Google Ad Manager also returns no ad. `{"after_step": 1}` answers `{"eligible": false, "reason": "steps_exhausted", "steps_left": 0}`.

| Response | Meaning |
| - | - |
| 409 on `/next` | The opportunity was not requested, `after_step` is not the last step answered, the playback does not walk steps, or the playback ended. |
| 409 on `/request` | The opportunity was already requested. Use `/next`. |
| `reason: "midroll_disabled"`, `reason: "preroll_disabled"` | The project has no mid-roll steps, or no pre-roll steps for a break at 0 (for example, they were removed after you prepared it). A pre-roll without pre-roll steps returns 422 when you prepare it. |
| `reason: "steps_exhausted"` | The list ran out of steps that can be asked. On `/next`, `context.last_reason` keeps the reason of the last step evaluated. |
| `reason: "steps_changed"` on `/next` | The project's lists were edited after `/request` and the step in `after_step` is no longer the one that was asked. `steps_left` is 0. |
| Other reasons on `/next` | If the content of the break is blocked, or the video or its analysis changed, `/next` answers the same reason `/request` would give. |
| `covered_by_contextual`, `no_linked_campaigns`, `profile_unavailable`, `no_scene_at_preroll`, `iadserver_unavailable`, `iadserver_refused` | Reasons in `context.skipped_steps`. An iADServer step that fails, is refused or does not answer is skipped in the same call, with `iadserver_unavailable` or `iadserver_refused`; it never answers 409. Around an iADServer step, 409 only means another call for the same opportunity got there first. |

A scene blocked by Content Safety stops every step: nothing is asked. Any answer with `eligible: false`, from `/request` or `/next`, ends the break: resume the content. A diagnostic test records only the first request of each break.

If the request response is lost after consumption, the server does not issue the tag a second time. Resume the program and let the next eligible break proceed. For SpringServe SSAI, use an airing signal. [Advertising providers](https://docs.interactivelayers.com/ad-providers.md) · [End-to-end recipes](https://docs.interactivelayers.com/recipes.md)

## Graphics and Buy next to your app's breaks

If your app plays its own breaks with this API and has the IL SDK, it can also show the scene graphics (**Super**, **L**, **Overlay 300×250** where the platform allows it), the product with **Buy** in the scene, and **Buy** during an iADServer ad. Your backend keeps requesting the breaks; the SDK draws around them. [Native apps](https://docs.interactivelayers.com/player-sdk.md#native-app-ads)

1. Create the playback with `"graphics": true` in `POST /v1/vod/playbacks`. The response echoes `"graphics": true`; with `"graphics": false` it answers `false`, and a playback created without the field has no such key.
2. From your backend, read `GET /v1/vod/playbacks/{playback_id}/plan` with a key that has read scope and pass the body to the app unchanged. It is the project's ad plan with `cuts: []` (you request the breaks through the API), the scenes, and `commerce` with a grant for that playback's session. `commerce.session` is always the same for that playback.
3. The app attaches the plan to the SDK and reports its breaks and ads: the positions with `setBreaks` before they arrive, then `breakStarted`, `adStarted`, `adEnded` and `breakEnded` (on the web and Samsung Tizen, `setBreakAd` and `clearBreakAd` for each ad). Each platform guide has the code: [Media3](https://docs.interactivelayers.com/media3.md) · [Roku](https://docs.interactivelayers.com/roku.md) · [AVPlayer](https://docs.interactivelayers.com/avplayer.md) · [Samsung Tizen](https://docs.interactivelayers.com/tizen.md) · [Web](https://docs.interactivelayers.com/player-sdk.md#host-breaks-web).
4. Request each break with `/request` and `/next` as usual.

`GET …/plan` answers `204` when there is nothing to draw: AdRouter on, analysis not finished, server-side insertion, playback ended, video changed since the playback started, or a plan with no scenes and no product. It may schedule a plan build and never touches the playback's opportunities or steps. A `version: 2` plan expires soon: read it again before `expires_at`. The scene and product windows are the project plan's: they keep clear of the breaks IL would place, not of the ones your app plays. That is why the SDK applies `scenes.pacing.cut_clearance_seconds` only around the breaks the app reports.

In a playback with `graphics: true` that walks steps (`"routing": "steps"`), an iADServer step with an **iADServer video tag**, whose iADServer connection still exists, answers with that step's permanent tag, also when the step is `contextual`. The tag carries the playback's session in `sid` and a `correlator` of its own for that break:

```json theme={null}
{
  "eligible": true,
  "reason": "requested",
  "provider": "iadserver",
  "ad_tag_url": "https://ads.iadserver.com/gampad/ads?tag=<tag>&output=vast&vid=<asset_id>&cue_seconds=58&sid=<commerce.session>&correlator=<16 digits>",
  "step": 0,
  "steps_left": 1,
  "kind": "contextual",
  "connection_id": "default",
  "ad_profile_id": "default",
  "context": {"skipped_steps": []}
}
```

On a `contextual` step, iADServer chooses with its own evaluation of the context, as in the web plan. If the player fetches the same URL again (a retry, or a prefetch followed by playback), iADServer returns the same delivery instead of reserving another one. Only deliveries requested this way can carry **Buy** during the ad. An iADServer step without a tag, a Google Ad Manager step and any playback without `graphics` answer exactly as before. If the tag returns no ad, continue with `/next` and `{"after_step": <step>}`.

`commerce.break_url`, the product route during an ad, is in the plan only when the playback has `graphics: true`, walks the saved steps, does not use AdRouter, the scene product is on, and the project saved at least one iADServer step with a tag. Without it there is no **Buy** during breaks; everything else works the same. The SDK names the break by its position, `cut=at-<milliseconds>` (`at-0` for the pre-roll).

What your app must do:

* **Report the breaks.** The SDK cannot know an ad is on screen unless the app says so. Without reports, graphics follow content time, can end up over a break, and there is no **Buy**.
* **Attach with `commerce.session`.** Use the plan's `commerce.session` as the session when you attach the SDK. With another session there is no **Buy** during breaks.
* **Fetch `ad_tag_url` exactly as given.** Do not add, change or remove `sid` or `correlator`.

**What was tested.** **Buy** during a break through this API was verified against a real iADServer in automated contract tests, not with a real app. The state of each platform is in [Native apps](https://docs.interactivelayers.com/player-sdk.md#native-app-ads).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.