Custom checkout
Collect ads on your site. Pay on AdsRoster.
Use this when you want your own booking UI. AdsRoster still reserves inventory and opens a Bachs hosted checkout. You never handle card data.
When to use it
- Default: link empty spots to
spot.bookingUrl(hosted AdsRoster checkout). - Custom form: you collect creative + contact on your domain, then call
createAdCheckoutand redirect.
Prerequisites: embed/delivery working, and Bachs connected for that environment (Settings & payments).
Required fields
spaceId: from delivery (spot.id)brand,title,targetUrlemail,firstName,lastName
startDate (YYYY-MM-DD, UTC midnight) and purchasedDays define a window of purchasedDays × 24h. Price prorates from the spot's listed bundle (price / durationDays on delivery).
Optional: description, whatsapp, imageUrl.
Image upload
Use uploadAdAsset(publicKey, file) to POST to /api/public/assets (CORS enabled). Defaults to production AdsRoster; pass a third baseUrl argument only when pointing at a non-production host. Limits: PNG, JPEG, or WebP up to 2 MB. AdsRoster re-encodes to WebP.
Or skip upload and pass any public https:// image URL as imageUrl.
Example
import { createAdCheckout, uploadAdAsset } from "adsroster";
const publicKey = process.env.NEXT_PUBLIC_ADSROSTER_PUBLIC_KEY!;
// Optional: upload from the buyer's device (defaults to production AdsRoster)
const { url: imageUrl } = await uploadAdAsset(publicKey, file);
const { url } = await createAdCheckout(publicKey, {
spaceId: spot.id,
brand: "Acme",
email: "hello@example.com",
firstName: "Ada",
lastName: "Okonkwo",
title: "Discover Acme",
description: "A short pitch",
targetUrl: "https://example.com",
imageUrl, // or any public https image URL
startDate: "2026-10-01",
purchasedDays: 7,
// whatsapp: "+234…", // optional
});
window.location.assign(url);On success you get { id, url }. Send the buyer to url. Payment is confirmed only after Bachs delivers a signed webhook, not when they return from checkout.
Common errors
- Publisher has not connected a payment provider: connect Bachs in that environment.
- Spot not found for this integration key:
spaceIdmust belong to the same site/environment as the public key. - Validation errors for names, email, or URL: match the field rules above.