Skip to content
Documentation menu
SDKWebJavaScript SDK

Methods and options

Methods and options of the Sidekick browser client.

Client options

create()
const ads = Sidekick.create({
platformId: "plt_example",
onError: (error) => console.error(error.message)
});
ParameterTypeDescription
platformIdrequiredstringPublic platform ID.
baseUrlstringHTTPS API origin without a path. Defaults to https://sidekick-ads.com.
visitorIdstringVisitor ID, 16–128 characters. The SDK generates and persists it when omitted.
storagestringlocal persists the ID in the browser; memory retains it for the client lifetime. Defaults to local.
timeoutMsnumberRequest timeout, 100–30,000 ms. Defaults to 8,000.
appearanceobjectAppearance for all cards
onErrorfunctionRequest and media error callback.

Required fields.

Methods

MethodDescription
create({ platformId, … })Creates a client.
requestAd({ target, requestId, … })Requests and renders an ad. Returns Promise<{filled, fromCache?}>.
fetchAd({ requestId, … })Returns Promise<ad | null> for custom rendering.
trackView(ad)Custom rendering: confirms the view once at least half of the card has been on screen for at least one second. The impression is paid only then.
interact(ad, action)Returns Promise<ad | null> with the next consent or quiz scene.
setAppearance(options)Updates appearance without requesting a new ad.
setScreenActive(active)Controls media playback on the screen.
unmount(target)Removes the card from its container, retaining the client cache.
dispose()Cancels requests and releases client resources.

Request options

ParameterTypeDescription
targetrequiredHTMLElementCard container. Required for requestAd().
requestIdrequiredstringAd slot ID within a message, 1–128 characters. Reuse it on rerenders.
placementstringPlacement name. Defaults to chat.
languageCodestringAd language. Defaults to the page language or en.
acceptFormatsstring[]Accepted formats; defaults to all six.
contextobjectContext: conversation, article, feed or static.
test / testFormatboolean / stringTest mode and test ad format.
appearanceobjectPer-card appearance in requestAd().
onFill / onNoFillfunctionrequestAd() result callbacks.

Required fields.

Context fields →

Results and errors

requestAd() returns filled: true when the card is accepted for rendering, or filled: false on no-fill or request failure. fromCache: true indicates a cached result. The SDK confirms the view separately once the card is visible.

Request errors are passed to onError. fetchAd() returns null on failure. Invalid create() options throw an exception.

The cache belongs to one client and does not survive a page reload. A repeated HTTP request is a new issuance. The SDK does not automatically retry network failures.