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 usehttps://developer.dacast.comas the API host. Authenticate withX-Api-Keyand sendX-Format: default. JSON request bodies must includeContent-Type: application/json.
Endpoints
| Action | Reference | Method |
|---|---|---|
| List ads | List ads on a content | GET |
| Set ad schedule | Create ads on content | POST |
| Add ads | Add ads to content | PUT |
| Clear ads | Remove ads from content | DELETE |
Path pattern: /v2/{resource_type}/{id}/ads where resource_type is vod or channel and id is the content UUID.
Ad slots
ad-type | When it plays |
|---|---|
pre-roll | Before playback starts |
mid-roll | During playback - requires timestamp |
post-roll | After playback ends |
Each ad item in the ads array needs:
ad-type- one of the values aboveurl- 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 fulladsarray 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 (adsbecomes[]). There is no delete-one-slot call.
Set the ad schedule (POST)
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)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)
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
| Goal | Call |
|---|---|
| Set the full schedule | POST …/ads with every slot you want |
| Add another slot | PUT …/ads |
| Read current schedule | GET …/ads |
| Clear the schedule | DELETE …/ads |
Updated about 6 hours ago
