Start a banner export

action=start-banner-export 4 side effects MCP: always on

Queues an export of one banner, for example an MP4 video, a PDF or an ad tag.

MCP tool: banner_start_export. Use with AI

The API queues the export and answers at once. The answer {"code":200,"data":{"status":"Done"}} means that the export is queued, not that it is finished. To get the file, call get-banner-urls until the status of this type is done. While the export runs, that status can be none or pending.

Each type needs a permission of your white label: MP4 and GIF export, PDF export, or ad tag embed download. AMP needs no permission. Without the permission, the API answers 514.

The ad tag types need the id of an ad network in ad_network. Without it, the API answers 520 with the message Missing mandatory parameter "network_id". The message says network_id, but the request parameter is ad_network. An unknown network gives 553. An ad tag export publishes the hosted ad tag of the banner. To download a zip for an ad network, call get-banner-url-for-adtag-network. That zip is HTML5 only. There is no MRAID zip.

After each save of the banner, the API resets every export, AMP included. Start the export again after a change.

The API also exports a draft or deleted banner, but get-banner-urls does not read back the result for such a banner.

Side effects

  • The API signs in the owner of the banner.
  • This sign-in serves this one request: it ends no other session of the user, so an open editor keeps working.
  • Queues an export job for the banner. Each call queues a new job.
  • For an ad tag type, the export publishes the hosted ad tag of the banner for that ad network.

Parameters

Every request also has the common parameters client_id, t, signature and action.

NameDescriptionAllowed values
banner_hash Required hash The hash of the single banner to export. Example: bduny9j1
type Required one value from a list The export type: mp4, animated-gif, optimized-animated-gif, pdf, pdf-print, amp, ad-tag-html5, ad-tag-mraid. The API also accepts the upper-case names with underscores, for example ANIMATED_GIF or PDF_PRINT, in any letter case. Example: mp4mp4, animated-gif, optimized-animated-gif, pdf, pdf-print, amp, ad-tag-html5 or ad-tag-mraid
ad_network Optional whole number The id of the ad network, from get-adtag-networks. The ad tag types need it. If it is missing, the error message names network_id. Example: 1

Response

FieldTypeDescription
code integer200 when the call worked. Every answer comes with HTTP 200, errors too, so read this field.
data.status stringDone when the API queued the export. It does not mean that the export is finished.

Example

{
  "code": 200,
  "data": {
    "status": "Done"
  }
}

Errors

The error code is in the code field. The errors guide explains the answer shapes and the codes that come as text.

CodeMeaningWhat to do
510 The request has expired The time in t is more than one hour away from the clock of the API server. The API accepts a request from one hour before t until one hour after t. A missing t gives the same code.When you sign the request, set t to the current Unix time in seconds. Make sure that the clock of your server is correct. Sign the request again if it is older than one hour. Send every parameter in the query string, because the API does not read a POST body.
512 Client id not found The API does not know this client id.Make sure that client_id is the client id of your API credentials, with no extra spaces.
513 Invalid signature The signature does not match the parameters and your secret key.Sign with the secret key of your white label, not with the client id. Use every query parameter except signature. Sort the names in byte order. Join each name and its value with no separator. Compute the HMAC-SHA1 of the result as 40 lowercase hex characters. Sign the values before URL encoding.
515 Disabled domain Your white label is not active.Contact Bannersnack support.
520 Missing mandatory parameter "<name>" banner_hash or type is missing, or an ad tag type has no ad_network. For the missing ad network, the message names network_id.Add the parameter that the message names. If the message names network_id, Ad Network Id or Ad Network ID, send the id in ad_network. If it names Adtag type, send adtag_type.
514 Bad Request Your white label does not have the permission for this export type.Ask Bannersnack support to allow the export for your white label. MP4 and both GIF types need the MP4 and GIF export. PDF and print PDF need the PDF export. The ad tag types need the ad tag embed download. AMP needs no permission.
521 Internal server error type is not a known export type.Make sure that every value matches this reference, then try again. If the values are right, try again in a few minutes.
531 Banner not found The banner does not exist, is a banner set, or its owner is not in your white label.Make sure that the hash is right. Make sure that it is a banner or a banner set, as the action needs. Read the rules of the action. For a generation action, give each layer on a slide of the source its own name.
534 Identifier not found The owner of the banner is not a user of your white label.Make sure that the banner belongs to a user of your white label.
553 Invalid Ad Network ID No ad network has the id in ad_network.Get the ids with get-adtag-networks.

Code examples

These examples send the required parameters with example values. Replace YOUR_CLIENT_ID with your client id. The Node, PHP and Python examples sign the request themselves. They read your secret key from the environment variable BANNERSNACK_SECRET_KEY.

The cURL example shows the form of a signed request. It has an example signature and an old t, so the API refuses it. Use Try it to get a cURL command that is signed with your own key.

cURL
curl -sS 'https://enterprise.bannersnack.com/wapi/2.0/?action=start-banner-export&banner_hash=bduny9j1&client_id=YOUR_CLIENT_ID&t=1793361600&type=mp4&signature=1fee2621b6ddae94d51ae0b5a5e14da66589e458'
Node
import { createHmac } from 'node:crypto';

const params = {
    "action": "start-banner-export",
    "banner_hash": "bduny9j1",
    "client_id": "YOUR_CLIENT_ID",
    "type": "mp4"
};
params.t = String(Math.floor(Date.now() / 1000));

const data = Object.keys(params).sort().map(key => key + params[key]).join('');
params.signature = createHmac('sha1', process.env.BANNERSNACK_SECRET_KEY).update(data).digest('hex');

const url = "https://enterprise.bannersnack.com/wapi/2.0/" + '?' + new URLSearchParams(params);
const response = await fetch(url);
console.log(await response.json());
PHP
<?php
$params = [
    'action' => 'start-banner-export',
    'banner_hash' => 'bduny9j1',
    'client_id' => 'YOUR_CLIENT_ID',
    'type' => 'mp4',
];
$params['t'] = (string) time();

ksort($params);
$data = '';
foreach ($params as $key => $value) {
    $data .= $key . $value;
}
$params['signature'] = hash_hmac('sha1', $data, getenv('BANNERSNACK_SECRET_KEY'));

$url = 'https://enterprise.bannersnack.com/wapi/2.0/' . '?' . http_build_query($params, '', '&', PHP_QUERY_RFC3986);
echo file_get_contents($url), PHP_EOL;
Python
import hashlib, hmac, os, time, urllib.parse, urllib.request

params = {
    "action": "start-banner-export",
    "banner_hash": "bduny9j1",
    "client_id": "YOUR_CLIENT_ID",
    "type": "mp4"
}
params["t"] = str(int(time.time()))

data = "".join(key + params[key] for key in sorted(params))
secret = os.environ["BANNERSNACK_SECRET_KEY"].encode()
params["signature"] = hmac.new(secret, data.encode(), hashlib.sha1).hexdigest()

url = "https://enterprise.bannersnack.com/wapi/2.0/" + "?" + urllib.parse.urlencode(params, quote_via=urllib.parse.quote)
with urllib.request.urlopen(url) as response:
    print(response.read().decode())