Configuration options

Every option you can pass to configure, and every item field.

Pass options to the configure command:

teak('configure', {
  apiKey: 'pk_...',                                      // required
  sandbox: true,
  currency: 'USD',
  locale: 'en_US',
  sessionId: '3f1c9a2e-8b4d-4e6f-9a0b-1c2d3e4f5a6b',     // optional: your own session ID
  persist: true,
  source: 'general',                                     // only if your Teak integration contact asks
  items: [                                               // required
    {
      name: 'Summer Fest - General Admission',
      referenceNumber: 'ITEM-1',
      productTypes: ['general-admission'],
      cost: 120.0,
      event: {
        name: 'Summer Fest',
        location: 'Austin, TX',
        startDatetime: '2026-07-18T18:00:00-05:00',
        endDatetime: '2026-07-18T23:00:00-05:00',
      },
      metadata: { ticketType: 'GA' },                    // only if your Teak integration contact asks
    },
  ],
  loadedCb: (context) => {},
  optInCb: (context) => {},
  optOutCb: (context) => {},
  updatedCb: (context) => {},
  onErrorCb: (sessionId) => {},
});

This example uses every option and item field. Only apiKey and items are required; each one is described below.

Call configure again at any time to update the widget, for example when the cart changes. Each call can change any option. Always pass the full list of items, not only the ones that changed.

Options

OptionTypeRequiredDefaultDescription
apiKeystringYesYour public key (pk_...).
itemsarrayYesThe items in the cart. See Items.
sandboxbooleanfalsetrue to use the Teak sandbox. Use sandbox keys with it.
currencystringUSDISO 4217 code for item costs and the protection price. Must be a currency enabled for your account.
localestringThe browser's languageThe language and region for the widget's text, for example en_US. See Locales.
sessionIdstringCreated by the widgetYour own ID for the session, as a UUID. See Session ID.
persistbooleanfalsetrue to remember the customer's choice in the browser tab and restore it when the widget loads on another page. To make the customer choose again, send clearSession.
sourcestringThe configuration variant to load: general or mobile. Only needed if your Teak integration contact asks you to set it.
loadedCbfunctionCalled when the widget has loaded. See Callbacks and events.
optInCbfunctionCalled when the customer adds protection.
optOutCbfunctionCalled when the customer declines protection.
updatedCbfunctionCalled when the widget has re-priced after a configure call.
onErrorCbfunctionCalled with the session ID when the widget fails and removes itself. See Errors.

Options not listed here have no effect in the TeakOS Widget. An unrecognized option is ignored, with a message in the browser console.

Items

Pass one item for each thing the customer is buying. Two tickets are two items.

FieldTypeRequiredDescription
namestringYesThe item's name, as the customer sees it.
referenceNumberstringYesYour ID for the item. It comes back in webhooks as reference_number, so you can match contracts to your items.
productTypesstring[]Yes, unless a widget element has an idProduct type identifier from your inventory system. Teak maps these values to protection products during onboarding and account setup, so you can send the same product labels you use internally. Work with your Teak integration contact to define these values during onboarding. See Product types.
costnumber or numeric stringYesThe price of one item, in currency, including its share of taxes and fees (see below). Protection is priced from it.
eventobjectYesThe event the item is for.
event.locationstringYesWhere the event takes place.
event.namestringRecommendedThe event's name.
event.startDatetimestringRecommendedWhen the event starts, as an ISO 8601 date-time.
event.endDatetimestringRecommendedWhen the event ends, as an ISO 8601 date-time.
metadataobjectExtra details Teak uses to choose the right protection for the item, for example a ticket type. Only send it if your Teak integration contact asks you to, using the keys they give you.

If name, referenceNumber, or event.location is missing, the widget doesn't render, and the browser console says which field is missing: see E4026 and E4027. Without a product type Teak has mapped, Teak can't quote the item.

Taxes and fees. Include taxes and fees in each item's cost, split across items in proportion to their price. For example, two $50.00 tickets with $5.00 tax and a $10.00 fee are each 57.50. This way, an approved refund request returns everything the customer paid for the item. Don't include the protection price itself.

Free items. Leave items that cost $0.00 out of items. They can't be protected, and a cost of 0 stops the widget from rendering.

Product types

Product types let you offer different refund protection for each kind of product you sell. For example, general admission tickets can have one protection offer, VIP packages another, and parking a third.

A product type is how your inventory system labels a product, for example general-admission, vip, or parking. During onboarding, your Teak integration contact works with you to list your product types and decide the refund protection for each one. Teak then maps each product type to its protection, so you send the same labels you use internally, and each item is quoted for the protection its product type maps to.

Items in the same cart can have different product types, and each is quoted for its own protection.

Every item needs a product type. Set it in one of two ways:

  • On each item, with productTypes. Use this when items in the same cart need different products.

    items: [
      {
        name: 'Summer Fest - General Admission',
        referenceNumber: 'ITEM-1',
        productTypes: ['general-admission'],   // your inventory system's label for this product
        cost: 120.0,
        event: { location: 'Austin, TX' },
      },
    ],
  • On the widget element, with its id. Items without their own productTypes use the id of every widget element on the page.

    <teak-widget id="general-admission"></teak-widget>

An item's own productTypes take precedence over element ids.

If you send a product type Teak hasn't mapped for your account, the widget shows no offer for it, without an error or a console message. When you add a new kind of product to your inventory, ask your Teak integration contact to map it before you send it. See A product type isn't mapped.

Session ID

The widget creates a session ID when it loads. To use your own instead, pass a UUID as sessionId in configure, for example one you create with crypto.randomUUID(). preload doesn't take it.

teak('configure', {
  apiKey: 'pk_...',
  sessionId: '3f1c9a2e-8b4d-4e6f-9a0b-1c2d3e4f5a6b',   // your UUID for this checkout
  items: [ /* ... */ ],
});

Pass your own session ID to:

  • Match the session to your records. The ID you pass is the session ID you submit, and it becomes the Teak order ID. You can store it with your cart from the start, and find the same session in your logs and in Teak.
  • Continue a session on another page or device. Pass the same sessionId in configure there, and the widget carries on with the same session.

teak.get('token') returns the ID you passed, so you submit the order as usual. To switch to a different session, call configure again with a different sessionId.

Use a new UUID for each purchase

Once an order is submitted, its session is closed. If you pass a session ID that's already been submitted, the widget fails when the customer makes their choice. Create a new UUID for each checkout.

sessionId must be a UUID in its standard form: 32 hexadecimal characters in groups of 8-4-4-4-12, for example 3f1c9a2e-8b4d-4e6f-9a0b-1c2d3e4f5a6b. Uppercase letters are accepted. If it isn't valid, the widget logs E4014 and ignores it: the rest of your configure call still applies, on the session the widget already has. That's a new session, or the one stored in the browser, the same as when you leave sessionId out. Checkout isn't affected.

Locales

LocaleLanguage
en_US, en_CA, en_GB, en_AUEnglish
es_ES, es_MXSpanish
fr_FR, fr_CAFrench
de_DEGerman
it_ITItalian
nl_NLDutch
pt_BR, pt_PTPortuguese
sv_SESwedish

A language code on its own maps to a default region: en to en_US, es to es_ES, fr to fr_FR, de to de_DE, it to it_IT, nl to nl_NL, pt to pt_BR, and sv to sv_SE.

Next steps

With the widget configured:


Did this page help you?