Find a user's banners by name
action=get-user-banners-by-name
2 side effects
MCP: always on
Finds the banners and banner sets of an end user that have exactly this name.
MCP tool:
user_find_banners_by_name.
Use with AI
The name must match exactly. The list also has the banners inside banner sets.
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.
Parameters
Every request also has the
common parameters
client_id, t, signature and
action.
| Name | Description | Allowed 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-42 | At most 255 characters |
banner_name
Required
text |
The exact name to find.
Example: Summer sale |
Response
| Field | Type | Description |
|---|---|---|
code |
integer | 200 when the call worked. Every answer comes with HTTP 200, errors too, so read this field. |
data[].bannerHash |
string | The hash of the banner or banner set. |
data[].name |
string | The name of the banner or banner set. |
data[].image |
string | A preview image. For a banner set, the image of its first banner. |
data[].dateCreated |
integer | When the item was made, as a Unix timestamp. |
data[].dateLastUpdate |
integer | When the item last changed, as a Unix timestamp. |
data[].width |
integer | The width in pixels. null for a banner set. |
data[].height |
integer | The height in pixels. null for a banner set. |
data[].type |
string | banner for a single banner, bannerset for a banner set. |
data[].bannerType |
string | html5 for a single banner, set for a banner set. |
Example
{
"code": 200,
"data": [
{
"bannerHash": "bduny9j1",
"image": "https://cdn.example.com/banners/bduny9j1/images/png",
"type": "banner",
"dateCreated": 1793300000,
"dateLastUpdate": 1793361000,
"bannerType": "html5",
"width": 300,
"height": 250,
"name": "Summer sale"
}
]
}
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. |
| 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=get-user-banners-by-name&banner_name=Summer%20sale&client_id=YOUR_CLIENT_ID&identifier=user-42&t=1793361600&signature=1b026abf658c726feeec20c455c96786dcf79b92'
Node
import { createHmac } from 'node:crypto';
const params = {
"action": "get-user-banners-by-name",
"banner_name": "Summer sale",
"client_id": "YOUR_CLIENT_ID",
"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' => 'get-user-banners-by-name',
'banner_name' => 'Summer sale',
'client_id' => 'YOUR_CLIENT_ID',
'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": "get-user-banners-by-name",
"banner_name": "Summer sale",
"client_id": "YOUR_CLIENT_ID",
"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())