Get the export links of a banner
action=get-banner-urls
3 side effects
MCP: always on
Lists the export links of one banner and the status of each export.
MCP tool:
banner_get_urls.
Use with AI
The answer has nine entries in a fixed order: jpg, png, html5, mp4, animated-gif, optimized-animated-gif, pdf, pdf-print and amp. Each entry has a link and a status.
Use this action to see when an export that you started is ready. Call it slowly, for example every 10 seconds, because each call signs in the owner of the banner.
jpg and png show pending until they exist. html5 shows done when its zip is ready, and pending before that. For the other types, done means ready. Before that, the status is none or pending, and none does not always mean that no export runs.
The banner must be a published, active, single HTML5 banner of your white label.
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.
- If the HTML5 zip does not exist yet, each call queues a build of it.
Parameters
Every request also has the
common parameters
client_id, t, signature and
action.
| Name | Description | Allowed values |
|---|---|---|
banner_hash
Required
hash |
The hash of a published single HTML5 banner of your white label.
Example: bduny9j1 | |
ad_network
Optional
whole number |
If you send an ad network id, the answer is the ad network zip of get-banner-url-for-adtag-network instead. On this path, the API does not test the id.
Example: 1 |
Response
| Field | Type | Description |
|---|---|---|
code |
integer | 200 when the call worked. Every answer comes with HTTP 200, errors too, so read this field. |
data[].type |
string | The export type: jpg, png, html5, mp4, animated-gif, optimized-animated-gif, pdf, pdf-print or amp. |
data[].url |
string | The file link. The API adds ?t= and a time to every link, also to a link that already has a query. While the html5 zip is not ready, this link has no address before ?t=. |
data[].status |
string | none, pending or done. Only done means that the file is ready. |
Example
{
"code": 200,
"data": [
{
"type": "jpg",
"url": "https://cdn.example.com/banners/bduny9j1/images/jpg?t=1793361600123",
"status": "done"
},
{
"type": "png",
"url": "https://cdn.example.com/banners/bduny9j1/images/png?t=1793361600123",
"status": "done"
},
{
"type": "html5",
"url": "https://cdn.example.com/exports/final/0f3c9a7d2b6e4f1a8c5d7e9b0a1c2d3e?type=html5&download_type=html5&hash=bduny9j1&name=Summer%20sale?t=1793361600456",
"status": "done"
},
{
"type": "mp4",
"url": "https://cdn.example.com/banners/bduny9j1/mp4?t=1793361600789",
"status": "none"
},
{
"type": "animated-gif",
"url": "https://cdn.example.com/banners/bduny9j1/gif?t=1793361600789",
"status": "none"
},
{
"type": "optimized-animated-gif",
"url": "https://cdn.example.com/banners/bduny9j1/gif_optimized?t=1793361600789",
"status": "none"
},
{
"type": "pdf",
"url": "https://cdn.example.com/banners/bduny9j1/pdf?t=1793361600789",
"status": "none"
},
{
"type": "pdf-print",
"url": "https://cdn.example.com/banners/bduny9j1/pdf_print?t=1793361600789",
"status": "none"
},
{
"type": "amp",
"url": "https://cdn.example.com/banners/bduny9j1/amp.zip?t=1793361600789",
"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.
| Code | Meaning | What 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>" | A required parameter is missing. The message names it. A missing or unknown action also gives this code, with the name action. | 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. |
| 521 Internal server error | The API failed while it handled the request. A value of the wrong form also gives this code. Examples are an unknown export type, an unknown category_type, and data that is not a JSON array of name and value pairs. | 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 not published, is not active, is not a single HTML5 banner, or is not in your white label. The answer has message instead of data. | 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. |
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=get-banner-urls&banner_hash=bduny9j1&client_id=YOUR_CLIENT_ID&t=1793361600&signature=fd4e226273267e446e294389608597c927b37f83'
Node
import { createHmac } from 'node:crypto';
const params = {
"action": "get-banner-urls",
"banner_hash": "bduny9j1",
"client_id": "YOUR_CLIENT_ID"
};
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' => 'get-banner-urls',
'banner_hash' => 'bduny9j1',
'client_id' => 'YOUR_CLIENT_ID',
];
$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": "get-banner-urls",
"banner_hash": "bduny9j1",
"client_id": "YOUR_CLIENT_ID"
}
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())