Update a banner with data

action=edit-banner-with-data 5 side effects MCP: always on

Overwrites the fields of an existing banner with new values.

MCP tool: dynamic_update_banner. Use with AI

The banner changes in place, and its hash stays the same. Use this action to update a banner that is already in use, for example with a new price. No editor opens.

The banner can belong to any user of your white label. Values match layers by name. One value changes every layer with that name inside a slide, and layers without a value keep their content.

Side effects

  • The API signs in the end user with this identifier. If the identifier is new, the API first creates that user.
  • This sign-in serves this one request: it ends no other session of the user, so an open editor keeps working.
  • Overwrites the banner with the new values. The API has no action that undoes this.
  • Sets the click-through URL and the click tag of the banner from this request. If you leave out banner_url, the banner loses its click-through URL, and the click tag turns off.
  • Resets every export of the banner. The API starts the image and HTML5 exports again. The other export types go back to none until you start them again.

Parameters

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

NameDescriptionAllowed values
identifier Required user identifier The key of the end user in your own system, for example a user id or an email address. It has at most 255 characters. A new identifier can contain only letters, digits, spaces and @ # $ & . - _ /. Example: user-42At most 255 characters
name Optional text The display name of the end user. The API uses it only when it creates the user. If you leave it out, the display name is the identifier. A new display name can contain only letters, digits, spaces and @ # $ & . - _ /. Example: Anna Smith
banner_hash Required hash The hash of the banner to change. It must be a single HTML5 banner of your white label. Example: bduny9j1
banner_url Optional URL The click-through URL of the banner. If you leave it out, the API removes the click-through URL of the banner. Example: https://www.example.com/summer-sale
use_as_clicktag Optional true or false If true, the banner uses banner_url as its click tag. Any other value, or no value, turns the click tag off. Example: truetrue or false
data Required JSON A JSON array of objects with name and value. Each name is a field name from the field list. Each value is a string: the new text, or the URL of the new file. Send [] to change only banner_url and use_as_clicktag. The whole request URL must fit the limit of the web server, which is about 8 KB by default. This limit was not tested. Example: [{"name":"Headline","value":"50% off today"},{"name":"Product photo","value":"https://cdn.example.com/p/123.png"}]

Response

FieldTypeDescription
code integer200 when the call worked. Every answer comes with HTTP 200, errors too, so read this field.
data.hash stringThe hash of the changed banner.

Example

{
  "code": 200,
  "data": {
    "hash": "bduny9j1"
  }
}

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>" 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.
500 <the text of the failure> The sign-in step inside the API failed. The message has the details.Try again in a few minutes. If it keeps happening, contact Bannersnack support and send them the message.
521 Internal server error data is missing, is not valid JSON, or has an item without a name or a value.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 For most failures, this action answers {"type":"error","code":"Banner not found","data":"531"}, with the code and the message swapped. Causes include a missing source, two layers with the same name on one slide of the source, and a failed save.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.
540 Invalid user name. <the characters that it can contain> The display name in name has a character that is not allowed. The API makes this test only when it creates the user.Use only letters, digits, spaces and @ # $ & . - _ / in name.
541 Invalid user identifier. <the characters that it can contain> The identifier has a character that is not allowed. The API makes this test only when it creates the user.Use only letters, digits, spaces and @ # $ & . - _ / in identifier.

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=edit-banner-with-data&banner_hash=bduny9j1&client_id=YOUR_CLIENT_ID&data=%5B%7B%22name%22%3A%22Headline%22%2C%22value%22%3A%2250%25%20off%20today%22%7D%2C%7B%22name%22%3A%22Product%20photo%22%2C%22value%22%3A%22https%3A%2F%2Fcdn.example.com%2Fp%2F123.png%22%7D%5D&identifier=user-42&t=1793361600&signature=d9a3b9e443b692817f0b0d3d417f63b346b08dd6'
Node
import { createHmac } from 'node:crypto';

const params = {
    "action": "edit-banner-with-data",
    "banner_hash": "bduny9j1",
    "client_id": "YOUR_CLIENT_ID",
    "data": "[{\"name\":\"Headline\",\"value\":\"50% off today\"},{\"name\":\"Product photo\",\"value\":\"https://cdn.example.com/p/123.png\"}]",
    "identifier": "user-42"
};
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' => 'edit-banner-with-data',
    'banner_hash' => 'bduny9j1',
    'client_id' => 'YOUR_CLIENT_ID',
    'data' => '[{"name":"Headline","value":"50% off today"},{"name":"Product photo","value":"https://cdn.example.com/p/123.png"}]',
    'identifier' => 'user-42',
];
$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": "edit-banner-with-data",
    "banner_hash": "bduny9j1",
    "client_id": "YOUR_CLIENT_ID",
    "data": "[{\"name\":\"Headline\",\"value\":\"50% off today\"},{\"name\":\"Product photo\",\"value\":\"https://cdn.example.com/p/123.png\"}]",
    "identifier": "user-42"
}
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())