Signed URLs
POST /api/v1/image-urls — browser-safe URLs billed once at creation.
Signed URLs let a browser, an email or a CMS load an image without ever seeing your API key. Your backend creates them; anyone holding the URL can open it until it expires. On a plan, each URL counts its image as one vehicle image of the month when it is created (nothing more if the account already received that image this month), and no credits, however many times it is opened within its TTL.
Create URLs
/api/v1/image-urls| Parameter | Type | Description |
|---|---|---|
imagesrequired | ImageRequest[] (1–50) | Each item takes the same fields as GET /api/v1/images/car: make, model, year (required), view, color, size, width, height, fit, background, framing, trim, padding, shadow, format. Both dimensions give an exact width×height canvas (fit decides how); format: "auto" makes the URL negotiate WebP or PNG on every load. A single object is also accepted as the whole body. |
ttl_seconds | integer 1–604,800 | How long the URLs stay valid. Maximum seven days. Sent, each URL expires exactly then. Left out, a URL lasts the default, or on a plan may be the image's hosted URL, valid to the end of the month; expires_at says when. Send it whenever a URL's life must be bounded.Default: 3600 |
max_uses | integer 0–1000 | Cap on redemptions per URL. 0 means unlimited within the TTL; 1 makes a single-use link.Default: 0 |
renew | boolean | Auto-renew: keep the URLs valid past expires_at, renewing for each further window of ttl_seconds in which a URL is loaded (on a plan, the image counts once for the month the window lands in). Requires max_uses: 0. See auto-renewing URLs.Default: false |
renew_days | integer 1–365 | How long a renewable URL keeps renewing, from creation. Only with renew: true.Default: 365 |
market | country code | The market of sale for every image that names none of its own (an image object may carry market too), such as AU. Each URL's appearance says which appearance it serves: the default one for every market today. Not part of the URL, and it changes neither what is counted nor what is charged.Default: the account's default, or none |
curl --fail-with-body \
-X POST https://carimage.dev/api/v1/image-urls \
-H "Authorization: Bearer $CAR_IMAGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"images":[{"make":"porsche","model":"911","year":2024,"view":"front-3-4","color":"red"}],"ttl_seconds":3600}'{
"data": [
{
"id": "3f0c2a7e-1c1e-4c2a-9c39-4f1f0a4b2d10",
"url": "https://carimage.dev/api/v1/delivery/eyJhbGciOi…",
"expires_at": "2026-09-02T18:00:00.000Z",
"max_uses": 0,
"renews_until": null,
"vehicle": {
"make": "porsche",
"model": "911",
"year": 2024,
"view": "front-3-4",
"color": "red",
"format": "png"
}
}
],
"billing": {
"charged_on": "creation",
"credits_charged": 0,
"vehicle_images": {
"used": 413,
"included": 2500
},
"renewal": null
},
"request_id": "req_01j9x…"
}The echoed vehicle carries the delivery options you set: width, height, fit (only with a box), background, trim, padding and shadow (a framing preset is echoed as the trim and padding it stands for), so a caller can tell one URL from another without decoding the token.
Display a signed URL in HTML or React
A signed delivery URL works as an ordinary image source in HTML and React. No browser SDK is needed. Your server or build step creates it with POST /api/v1/image-urls; only the returned data[0].url reaches the page. Look the vehicle up first and store its vehicle id.
curl --fail-with-body \
-X POST https://carimage.dev/api/v1/image-urls \
-H "Authorization: Bearer $CAR_IMAGE_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: listing-911-hero-v1" \
-d '{"images":[{"vehicle":"veh_78qtwrgh37bkr","view":"front-3-4","width":600,"height":400,"trim":true,"format":"auto"}],"ttl_seconds":604800}'<!-- Replace SIGNED_DELIVERY_URL with the complete data[0].url from your server. -->
<img
src="SIGNED_DELIVERY_URL"
alt="2024 Porsche 911, front three-quarter view"
width="600" height="400"
loading="lazy" decoding="async"
style="max-width: 100%; height: auto;"
>// Pass the complete data[0].url from your server as src.
// Works in React, including Vite apps and Next.js Client Components.
export function CarImage({ src, alt }: { src: string; alt: string }) {
return (
<img
src={src} alt={alt}
width={600} height={400}
loading="lazy" decoding="async"
style={{ maxWidth: "100%", height: "auto" }}
/>
);
}
// deliveryUrl is the signed URL your server returned and stored.
<CarImage src={deliveryUrl} alt="2024 Porsche 911, front three-quarter view" />Keep the API key on the server. Reuse the URL; do not create one during React client rendering or in a browser effect. Creating a URL counts its vehicle image once, like any delivery of it that month; repeated loads are free until expires_at. This example requests a seven-day lifetime. Replace it before expiry, or choose auto-renewal for longer-lived pages (a renewal counts the image once for the month it lands in). Set image options when creating the URL; use the returned URL unchanged.
In Next.js the whole loop is one Server Component you can copy from the React guide, which also covers caching and placeholders. For static HTML, follow Pages without a backend.
Retries are safe: Idempotency-Key
URLs are billed when they are created, so a retry after a dropped connection would normally create and bill a second batch. Send an Idempotency-Key header (1–255 characters: letters, digits, ., _, : or -) and the same key with the same body within 24 hours replays the original response — same status, same body — with Idempotent-Replayed: true and no second charge. Keys are scoped to your account and this route; a 5xx, a 402 and a 429 are never stored, so a retry after a server error, an upgrade or the Retry-After wait runs the request again.
- Same key, different body:
422 Idempotency-Key reused. Send a new key for a new request. - Same key while the first request is still running:
409 Request in progresswithRetry-After: 2.
curl --fail-with-body \
-X POST https://carimage.dev/api/v1/image-urls \
-H "Authorization: Bearer $CAR_IMAGE_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: listing-8812-hero" \
-d '{"images":[{"make":"porsche","model":"911","year":2024,"width":600,"height":400,"trim":true}]}'
# run it twice: the second answer is the first one, with Idempotent-Replayed: true| Header | Example | Meaning |
|---|---|---|
Idempotency-Key | listing-8812-hero | Request header. Any string unique to this request: an order id, a UUID, a content hash. |
Idempotent-Replayed | true | Response header on a replay. Status and body are the original's; nothing more was counted or charged. |
Retry-After | 2 | On a 409: seconds to wait before retrying the same key. |
The SDK (@meterapp/car-image-sdk 1.4.0) sends a generated key on every createImageUrls call unless you pass idempotencyKey, so its own retries are always safe; the CLI (@meterapp/car-image 1.3.0) takes car-image url --idempotency-key <key>; the MCP tool create_car_image_urls takes idempotency_key and answers a retry with idempotent_replayed: true.
Redeem a URL
/api/v1/delivery/{token}Redemption needs no key and is not billed. Drop the URL straight into an <img>:
<img
src="https://carimage.dev/api/v1/delivery/eyJhbGciOi…"
alt="2024 Porsche 911, red, front three-quarter"
width="1024" height="1024" loading="lazy"
/>| Header | Example | Meaning |
|---|---|---|
Cache-Control | public, max-age=300, s-maxage=3421, must-revalidate | Unlimited-use URLs are publicly cacheable: CDNs hold the bytes for the remaining lifetime (up to a day), browsers revalidate within five minutes, and every repeat is free. Use-capped URLs are private, no-store. |
ETag | "9f2a…c41d" | Same stable tag as the keyed endpoint. |
X-Image-Width / X-Image-Height | 600 / 400 | The delivered canvas: exactly width×height for a contain or cover box, otherwise what the render produced (a trimmed car follows its own aspect ratio). |
Vary | Accept | Only on URLs created with format: "auto": WebP for clients that accept it, PNG for the rest, negotiated on every load. |
X-Image-Source | cache | cache (the image was ready) or generated (prepared for this request). |
Restrict URLs to your sites
An unlimited-use URL is public for its lifetime: anyone who copies it from your page can embed it elsewhere until it expires, served from the image you counted at creation. To keep that to your own sites, give the key that creates the URLs a list of allowed origins on its card in the dashboard: hostnames such as example.com, or *.example.com for every subdomain and the apex. A URL created by such a key answers 403 with "code": "origin_not_allowed" to a browser whose Referer or Origin header names another site.
- Requests with no
RefererorOriginpass. Email clients, PDF viewers, curl and browsers with a strict referrer policy send neither, so a renewable URL in an email keeps working. - Hygiene, not identity. Both headers are set by the client, so this stops casual hotlinking and a URL pasted into another site, not a determined copier. The token is still the secret; use
max_usesand a short TTL for anything sensitive. - Per key, checked at redemption. The list is read when the URL is loaded, so editing it applies to URLs already created, and a key with an empty list allows every origin. Keys used only from your own servers need no list.
Auto-renewing URLs for email, CMS pages and documents
A page is re-rendered on every visit, so a seven-day URL is easy to refresh. An email, a PDF or a CMS page nobody re-publishes is rendered once and opened whenever the reader gets to it. For those surfaces, create them with renew: true: the URL is created and counted like any other, and when it is loaded after expires_at the first load in each new window of ttl_seconds renews it, until renews_until (default and maximum 365 days). On a plan a renewal counts the image once for the month it lands in, like any delivery of it, so a URL opened every week of a month is still one vehicle image that month.
- Only windows in which the URL is actually opened renew. Windows nobody opens count nothing. Accounts still on the credit meter (they paid before 2026-10-25) pay one credit per opened window, at most one per image per week with the seven-day maximum TTL.
- Counted once per window. The reference
renew:<id>:<window>is unique, so fifty opens in a week, or two mail proxies racing on the first, count once. - Same caching as the first window. Renewed windows answer with the same public
Cache-Control, bounded by the window end. - Allowance used up: 402, not 403. A renewal in a month whose vehicle images are used up answers
402(plan_image_limit) and the URL resumes on its next load once the allowance resets or the plan grows; on the credit meter it is402 Insufficient credits. Revoking the key still ends the URL with 403. - Not with use caps.
renewrequiresmax_uses: 0.
curl --fail-with-body \
-X POST https://carimage.dev/api/v1/image-urls \
-H "Authorization: Bearer $CAR_IMAGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"images":[{"make":"porsche","model":"911","year":2024,"width":480}],"ttl_seconds":604800,"renew":true}'{
"data": [
{
"id": "3f0c2a7e-1c1e-4c2a-9c39-4f1f0a4b2d10",
"url": "https://carimage.dev/api/v1/delivery/eyJhbGciOi…",
"expires_at": "2026-09-21T09:00:00.000Z",
"max_uses": 0,
"renews_until": "2027-09-14T09:00:00.000Z",
"vehicle": {
"make": "porsche",
"model": "911",
"year": 2024,
"view": "front-3-4",
"color": "silver",
"width": 480,
"format": "png"
}
}
],
"billing": {
"charged_on": "creation",
"credits_charged": 0,
"vehicle_images": {
"used": 413,
"included": 2500
},
"renewal": {
"window_seconds": 604800,
"until": "2027-09-14T09:00:00.000Z"
}
},
"request_id": "req_01j9x…"
}Campaign tracking: one set of URLs per send
Tag a mint with the campaign or send it is for, and how many pieces (emails, mail pieces, impressions) each URL will appear in. campaign is your own label, up to 100 characters; pieces is a good-faith estimate of how many pieces this URL will appear in, 1 to 10,000,000. They are for your own logging and documentation, campaign reporting, or Enterprise usage reporting, and they change nothing else: the same images, the same count and the same charge.
- Per image, with a default. Set them on each image of the batch: a send to 100,000 owners shows each car in a different number of pieces (the Camry URL in 3,200, the F-150 URL in 5,100). Set at the top of the body, beside
images, they apply to every image that names none of its own. - Request new URLs for each send. Each send gets its own URLs, never the URLs of an earlier send, so each URL carries exactly one send's piece count and its loads can be compared with it.
- Echoed and sealed in. Each URL in
datarepeats its owncampaignandpieces, and they are sealed into it, so each load is logged under that URL's send and count. The URL itself reveals neither. At the top,pieces(andX-Pieces) is the mint's total, the sum over its URLs, andcampaign(andX-Campaign) the label they share, when they share one. A send larger than one batch is several mints; each URL carries its own count, so nothing has to be split. - Read them back.
GET /api/v1/account/campaigns?from=2026-11-01&to=2026-11-30totals pieces and requests by campaign, with the URL loads logged under each, and by vehicle, with the campaigns that used it: which campaigns showed a given car, and how many pieces went out with it. - Enterprise usage reporting. An agreement priced per piece is invoiced from the pieces your requests declared each month, so send
pieceswith every send. - A malformed value is a free 400 that names the field. Hosted URLs (below) are one stable URL per image shared by every page, so they take no campaign; tag the signed URLs a send uses instead.
curl --fail-with-body \
-X POST https://carimage.dev/api/v1/image-urls \
-H "Authorization: Bearer $CAR_IMAGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"images":[{"make":"toyota","model":"camry","year":2024,"view":"side","width":600,"pieces":3200},{"make":"ford","model":"f-150","year":2024,"view":"side","width":600,"pieces":5100}],"campaign":"Owners mailer Nov","ttl_seconds":604800,"renew":true}'{
"data": [
{
"id": "8a51c0d2-6b0e-4f7e-9a8e-1d9f5e2c4b70",
"url": "https://carimage.dev/api/v1/delivery/eyJhbGciOi…",
"expires_at": "2026-12-04T09:00:00.000Z",
"max_uses": 0,
"renews_until": "2027-11-27T09:00:00.000Z",
"vehicle": {
"make": "toyota",
"model": "camry",
"year": 2024,
"view": "side",
"color": "silver",
"width": 600,
"format": "png"
},
"campaign": "Owners mailer Nov",
"pieces": 3200
},
{
"id": "c3f9e1a4-2d7b-4c8e-8f10-6a5b4d3c2e19",
"url": "https://carimage.dev/api/v1/delivery/eyJhbGciOi…",
"expires_at": "2026-12-04T09:00:00.000Z",
"max_uses": 0,
"renews_until": "2027-11-27T09:00:00.000Z",
"vehicle": {
"make": "ford",
"model": "f-150",
"year": 2024,
"view": "side",
"color": "silver",
"width": 600,
"format": "png"
},
"campaign": "Owners mailer Nov",
"pieces": 5100
}
],
"billing": {
"charged_on": "creation",
"credits_charged": 0,
"vehicle_images": {
"used": 415,
"included": 2500
},
"renewal": {
"window_seconds": 604800,
"until": "2027-11-27T09:00:00.000Z"
}
},
"campaign": "Owners mailer Nov",
"pieces": 8300,
"request_id": "req_01j9x…"
}Hosted URLs: one stable URL per image, served from our CDN
A hosted URL names one image and never changes, so our CDN keeps it and every page that shows the image shares the same copy. There is no key in the page and no API call when it loads. Ask for it once and store it with your vehicle:
/api/v1/hosted-urlscurl --fail-with-body -X POST https://carimage.dev/api/v1/hosted-urls \
-H "Authorization: Bearer $CAR_IMAGE_API_KEY" \
-d '{"images":[{"vehicle":"veh_395yw8tn73ff8","view":"side","color":"red","width":600,"format":"auto"}]}'The answer holds one url per image, in request order (up to 100 a call), signed for the key that asked. Asking again for the same image returns the same URL. Nothing is counted when you ask: the image counts once, the first time it is loaded in a calendar month, exactly as described below. The URLs stop when the key is revoked or its signing secret is rotated or deleted.
A hosted URL never expires, but it serves its image only while the account behind it can pay for that month's first load: within the plan's monthly allowance, or, on the credit meter, while the account has credits. When a plan ends, its allowance and included credits end with it, so a first load the account can no longer pay for answers 402 and shows no image; the same URL works again once the account can pay. To keep showing images without a plan, serve your own stored copies where your license allows it.
To build the URLs without calling us at all, sign them on your own server:
A signed URL costs an API call per image. An account-signed URL costs none: your server builds the URL and signs it locally with your key's signing secret, so a catalog page with five hundred cars renders without a single request to us. The URL never expires unless you add exp, so our CDN keeps it, and on a plan each image counts once per calendar month as a vehicle image, the first time the CDN fetches it in the month. Every later fetch that month, from any edge location, at any size or after a redeploy, is free; the month after, the first fetch counts again. (On the credit meter of accounts that paid before 2026-10-25 it is 1 credit per image per month.)
- Make a signing secret on the key's card in the dashboard (Signing secret), or with the key itself:
POST /api/v1/signing-secrets. It is shown once; keep it on your server with the key id it belongs to. - Sign each URL on your server with the SDK's
carImageUrl, or the React<CarImage>server component, or any HMAC-SHA256 library. - Put the URL in an
<img>. The page holds no key and no secret.
/api/v1/signing-secretscurl --fail-with-body -X POST https://carimage.dev/api/v1/signing-secrets \
-H "Authorization: Bearer $CAR_IMAGE_API_KEY" \
-d '{"previous_valid_seconds":86400}'{
"data": {
"key_id": "0b7c5c1e-4f7a-4b55-9d4e-2a1f3c6d8e90",
"signing_secret": "imgsig_…",
"id": "5d0e9a8c-…",
"prefix": "imgsig_Hq3v",
"created_at": "2026-10-22T17:00:00.000Z",
"expires_at": null,
"previous_expires_at": null
}
}/i/{vehicle_id}/{view}.{png|webp|jpg|auto}?…&k={key_id}&sig={hex}| Parameter | Type | Description |
|---|---|---|
vehicle_idrequired | path | The vehicle's id ( veh_…) from the catalog. |
viewrequired | path | One of the nine views, then the format: png, webp, jpg or auto (WebP where the browser accepts it). |
color, w, h, fit, background, framing, trim, padding, shadow | query | The same options, spellings and defaults as GET /api/v1/images/car. |
krequired | uuid | The API key's id. Not the key: the key never appears in a URL. |
exp | unix seconds | Optional. The URL answers 403 after this time. |
sigrequired | 64 hex characters | HMAC-SHA256 of the signed message, lowercase hex. |
import { carImageUrl } from "@meterapp/car-image-sdk";
const src = await carImageUrl(
{ vehicle: "veh_395yw8tn73ff8", view: "side", color: "red", width: 600, format: "auto" },
{ keyId: process.env.CAR_IMAGE_KEY_ID!, signingSecret: process.env.CAR_IMAGE_SIGNING_SECRET! }
);
// https://carimage.dev/i/veh_395yw8tn73ff8/side.auto?color=red&k=…&w=600&sig=…import { CarImage } from "@meterapp/car-image-sdk/react";
// Signs on the server while the page renders; reads CAR_IMAGE_KEY_ID and CAR_IMAGE_SIGNING_SECRET.
<CarImage vehicle="veh_395yw8tn73ff8" view="side" color="red" width={600} format="auto" alt="2024 Toyota Camry, side" />The signed message is the path, a ?, then every query parameter except sig, k and exp included, sorted by name and form-encoded (URLSearchParams in JavaScript, urlencode in Python). The signature is its HMAC-SHA256 under the signing secret, in lowercase hex, appended as &sig=:
import hashlib, hmac, os, urllib.parse
path = "/i/veh_395yw8tn73ff8/side.webp"
query = urllib.parse.urlencode(sorted({"color": "red", "w": "600", "k": os.environ["CAR_IMAGE_KEY_ID"]}.items()))
sig = hmac.new(os.environ["CAR_IMAGE_SIGNING_SECRET"].encode(), f"{path}?{query}".encode(), hashlib.sha256).hexdigest()
src = f"https://carimage.dev{path}?{query}&sig={sig}"- What one image is. The variant delivered: vehicle, view, paint, size, fit, background, trim, padding, shadow and format (
autois one format whichever encoding a browser gets). Parameter order, spellings, tracking tags andexpdo not make another image; another size or paint does, as on every billed route. - Caching.
Cache-Control: public, up to a day in the CDN and an hour in the browser (never pastexp), with anETagandVary: Acceptonauto. A CDN hit never reaches us and costs nothing. - Not rendered yet? The first load prepares it, like a keyed request, and is counted the same, one vehicle image; that can take half a minute when the angle was never prepared. A failed first load gives the count back.
- Rotation.
POST /api/v1/signing-secretsagain (or the dashboard) makes a new secret; the previous one keeps verifying forprevious_valid_seconds(default a day, at most a week,0for none) so you can deploy the new one first.DELETEstops every secret of the key at once;GETlists the live ones without their values. - Revocation. Revoking the key or its secrets stops its URLs at the origin at once and everywhere within the CDN's day. The key's allowed origins apply too.
- A leaked secret drains slowly. Each key may cause 300 origin fetches a minute; past that the URLs answer
429with"code": "signed_image_rate_limited"andRetry-After. Rotate a secret you think leaked. - Errors are free.
403(invalid_signature,signature_expired,key_revoked,origin_not_allowed,signed_urls_not_enabled),400for an option the API cannot read, and402(plan_image_limit) when a new image of the month does not fit the plan; the image resumes when the allowance resets or the plan grows.
Lifecycle and errors
403with"code": "delivery_url_expired"— the URL ran out. Create a new one, or create URLs that stay in a page with"renew": true. Itsreissuefield is that request, ready to send:POST /api/v1/image-urlswith the same image,"renew": trueand"max_uses": 0(billed like any other)."delivery_url_invalid"means the token is truncated or was changed (copy the wholeurl); a revoked key also answers403. Create a new URL.403with"code": "origin_not_allowed"— the key that created it restricts origins and the page loading the URL is not on its list. See Restrict URLs to your sites.410— the URL hit itsmax_usescap. Create a new URL.402— a renewable URL entered a new window in a month whose allowance is used up (plan_image_limit; on the credit meter, an empty balance). The URL resumes on its next load once it fits.502— the image could not be prepared on first delivery. What creation counted is given back (on the credit meter, the credit is refunded); create a new URL before retrying.503withgeneration_at_capacity— new renders reached the day's capacity. What creation counted is given back; create a new URL afterreset_at(Retry-After).413— the JSON body exceeded 64 KiB. Split the batch; each call takes up to 50 images.409/422— anIdempotency-Keyreused while its request is still running, or with a different body. See safe retries.