Ads on content

Attach VAST URL or Dacast VOD (vod-id) pre-roll, mid-roll, and post-roll ads to VOD and live channels via the API.

Ads on VOD and live channels

Attach ads to a VOD or live channel with /v2/{resource_type}/{id}/ads. Each slot can use either:

  • a VAST tag URL (url) - your ad server or a public test tag, or
  • a Dacast VOD as the creative (vod-id) - another VOD already on your account

Works on resource_type vod and channel.

📘

All examples use https://developer.dacast.com as the API host. Authenticate with X-Api-Key and send X-Format: default. JSON request bodies must include Content-Type: application/json.

Endpoints

ActionReferenceMethod
List adsList ads on a contentGET
Set ad scheduleCreate ads on contentPOST
Add adsAdd ads to contentPUT
Clear adsRemove ads from contentDELETE

Path pattern: /v2/{resource_type}/{id}/ads where resource_type is vod or channel and id is the content UUID.

Ad slots

ad-typeWhen it plays
pre-rollBefore playback starts
mid-rollDuring playback - requires timestamp
post-rollAfter playback ends

Each ad item in the ads array needs:

  • ad-type - one of the values above
  • either url (HTTPS VAST tag) or vod-id (UUID of a VOD on your account used as the ad creative) - not both for the same slot
  • timestamp - integer seconds from the start of the content (mid-roll only). Example: 120 = two minutes in

There is no per-ad id and no endpoint to delete or edit a single slot. The API works on the whole ad schedule for that content:

  • POST - send the full ads array you want afterward. Whatever was configured before is replaced by that list (including an empty list if you only need to drop one slot - resend the remaining items).
  • PUT - add the items in the body to what is already there.
  • DELETE - remove the entire schedule (ads becomes []). There is no delete-one-slot call.

Set the ad schedule with a VAST URL (POST)

POST sets the ad schedule to exactly the ads array you send. Send every slot you still want - omit a slot by leaving it out of the array.

curl -X POST "https://developer.dacast.com/v2/vod/YOUR_CONTENT_ID/ads" \
  -H "X-Api-Key: insertYourApiKeyHere" \
  -H "X-Format: default" \
  -H "Content-Type: application/json" \
  -d "{\"ads\":[{\"ad-type\":\"pre-roll\",\"url\":\"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&correlator=\"},{\"ad-type\":\"mid-roll\",\"url\":\"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&correlator=\",\"timestamp\":120},{\"ad-type\":\"post-roll\",\"url\":\"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&correlator=\"}]}"

Success: 200 { "message": "ok" }.

For a live channel, use /v2/channel/{id}/ads instead of /v2/vod/{id}/ads. The same body shape applies. You can send multiple mid-roll entries with different timestamp values in one request.


Set the ad schedule with a Dacast VOD (vod-id)

Use vod-id when the creative is another VOD already uploaded to your account (no external VAST server). Send the creative VOD UUID; do not send url for that slot - the API creates a custom ad tag and returns it on list as url (https://ads.dacast.com/…).

curl -X POST "https://developer.dacast.com/v2/vod/YOUR_CONTENT_ID/ads" \
  -H "X-Api-Key: insertYourApiKeyHere" \
  -H "X-Format: default" \
  -H "Content-Type: application/json" \
  -d "{\"ads\":[{\"ad-type\":\"pre-roll\",\"vod-id\":\"YOUR_CREATIVE_VOD_ID\"},{\"ad-type\":\"mid-roll\",\"vod-id\":\"YOUR_CREATIVE_VOD_ID\",\"timestamp\":120},{\"ad-type\":\"post-roll\",\"vod-id\":\"YOUR_CREATIVE_VOD_ID\"}]}"

Success: 200 { "message": "ok" }. Confirm with GET - each item includes vod-id and a generated url.

You can mix VAST url slots and vod-id slots in the same ads array.


List ads

curl "https://developer.dacast.com/v2/vod/YOUR_CONTENT_ID/ads" \
  -H "X-Api-Key: insertYourApiKeyHere" \
  -H "X-Format: default"

VAST-style response:

{
  "ads": [
    {
      "ad-type": "pre-roll",
      "url": "https://your-vast-tag.example/vast.xml"
    },
    {
      "ad-type": "mid-roll",
      "url": "https://your-vast-tag.example/vast.xml",
      "timestamp": 120
    }
  ],
  "IsDefault": false
}

When a slot was created with vod-id, list includes that vod-id and a generated url on ads.dacast.com. When no ads are configured, ads is an empty array.


Add ads (PUT)

PUT adds the items in your request to the current schedule. Existing slots stay unless you change them with POST.

curl -X PUT "https://developer.dacast.com/v2/vod/YOUR_CONTENT_ID/ads" \
  -H "X-Api-Key: insertYourApiKeyHere" \
  -H "X-Format: default" \
  -H "Content-Type: application/json" \
  -d "{\"ads\":[{\"ad-type\":\"post-roll\",\"url\":\"https://your-vast-tag.example/vast.xml\"}]}"

The same item shape applies for vod-id creatives:

{ "ads": [{ "ad-type": "post-roll", "vod-id": "YOUR_CREATIVE_VOD_ID" }] }

Success: 200 with a JSON array of all ads on the content after the add.

To rewrite the whole schedule, use POST instead of PUT.


Clear ads (DELETE)

curl -X DELETE "https://developer.dacast.com/v2/vod/YOUR_CONTENT_ID/ads" \
  -H "X-Api-Key: insertYourApiKeyHere" \
  -H "X-Format: default"

Success: 204 with an empty body.


Test VAST tag while integrating

While building your integration, you can point url at a public sample tag instead of your own ad server. Google publishes IMA sample tags for development: IMA sample tags (Single Inline Linear).

Example tag (same URL as in the VAST replace example above):

https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&correlator=

Use your production VAST URL when you go live. For Dacast VOD creatives, pass an uploaded VOD id as vod-id instead of an external tag.


Verify in the player

After configuring ads, open the content in the Dacast player (embed or share link). See Embed codes to fetch the iframe snippet for a VOD, channel, or playlist.

🚧

If ads appear in the dashboard but not in the player, check browser ad blockers and privacy extensions first - they often block VAST / ad requests even when the API configuration is correct.


Quick reference

GoalCall
Set the full schedulePOST …/ads with every slot you want
Add another slotPUT …/ads
Read current scheduleGET …/ads
Clear the scheduleDELETE …/ads
Creative sourceurl (VAST) or vod-id (Dacast VOD)