Ads on content

Attach VAST pre-roll, mid-roll, and post-roll ads to VOD and live channels via the API.

Ads on VOD and live channels

Attach VAST ad tags to a VOD or live channel with /v2/{resource_type}/{id}/ads. The player loads the url you configure (a VAST tag endpoint). 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
  • url - HTTPS VAST tag URL (your ad server or a test tag while integrating)
  • 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 (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.

Use this when you want the final schedule in one call (for example pre-roll + one or more mid-rolls + post-roll).

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.


List ads

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

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 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\"}]}"

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 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.


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 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