Meet Toki Operator

Docs/Wallet SDK

Customer

The signed-in customer: profile, sign-out, birthday, marketing consent, addresses and Apple Wallet pass.

The customer is the shopper signed in to Toki in this browser, the one the wallet shows. Toki signs customers in automatically when it can, for example with their store account. Addresses and marketing consent live on the customer's account in your Shopify store, so changes show up in your Shopify admin too.

isSignedIn#

tokiWallet.isSignedIn()→ Promise<boolean>

Returns whether a customer is signed in to Toki in this browser.

Resolves true for a signed-in customer and false for guests. If you've turned off Auto-join users to the rewards program, it resolves true once the signed-in customer has joined.

Toki signs customers in automatically right after the SDK loads, so check again when tokiWalletUserAuthenticated fires: Toki dispatches it once it has confirmed the customer, on every page load and right after they sign in.

Returns

Promise<boolean>
Example
const signedIn = await tokiWallet.isSignedIn()
document.querySelector("#join-rewards").hidden = signedIn
Result
true

getCustomer#

tokiWallet.getCustomer()→ Promise<Customer>

Returns the signed-in customer's profile.

Names are empty strings when Toki doesn't have them, and dates are ISO 8601 date-times.

Returns

Promise<Customer>
  • idstring

    The customer's Toki ID.

  • customerIdstring | null

    The customer's Shopify customer ID, a numeric ID rather than a GID; null if their Toki account isn't linked to a customer in this store.

  • memberNumbernumber | null

    The customer's number in your program: Toki numbers members 1, 2, 3… in the order they join. null if they don't have one.

  • emailstring | null

    null if the customer has no email address.

  • phoneNumberstring | null
  • namestring

    The full name, usually firstName and lastName joined with a space.

  • firstNamestring
  • lastNamestring
  • birthdayobject | null

    null if Toki doesn't have the customer's birthday.

    3 fields
    • daynumber

      Day of the month, 1–31.

    • monthnumber

      1 for January to 12 for December.

    • yearnumber | null

      null when the customer gave only the day and month.

  • avatarUrlstring | null

    The customer's profile photo, for display; null if they haven't added one.

  • avatarUrlSmallstring | null

    A version of the photo for small spaces, such as a header avatar.

  • avatarUrlOriginalstring | null

    The photo as the customer uploaded it.

  • createdAtstring

    When the customer was added to this store, for example by their first order or sign-in.

  • firstActivityAtstring | null

    When the customer joined your program in this store, usually by first signing in to their wallet; null if they haven't joined.

Example
const customer = await tokiWallet.getCustomer()
document.querySelector("#greeting").textContent =
  "Hi, " + (customer.firstName || "there")
Result
{
  "id": "4f0c2a8e-91d3-4b6a-a1f2-7c5e9d3b8a10",
  "customerId": "7212345678901",
  "memberNumber": 1834,
  "email": "anna@example.com",
  "phoneNumber": "+14155550123",
  "name": "Anna Smith",
  "firstName": "Anna",
  "lastName": "Smith",
  "birthday": {
    "day": 12,
    "month": 4,
    "year": 1990
  },
  "avatarUrl": null,
  "avatarUrlSmall": null,
  "avatarUrlOriginal": null,
  "createdAt": "2025-03-14T09:26:53.589Z",
  "firstActivityAt": "2025-03-14T09:27:02.114Z"
}

signOut#

tokiWallet.signOut()→ Promise<void>

Signs the customer out of Toki in this browser.

The wallet switches to its signed-out view. Reload the page afterwards so Toki's blocks refresh too, or send the customer to /account/logout to sign them out of their store account as well.

Returns

Promise<void>

Nothing, once it's done.

Example
await tokiWallet.signOut()
window.location.reload()

setBirthday#

tokiWallet.setBirthday({ day, month, year? })→ Promise<void>

Saves the customer's birthday.

Without year, Toki saves the day and month only. If you have a Birthday activity, the customer gets its reward when it's due, right away if it's due today.

Rejects when the date doesn't exist, such as April 31.

Options

one object
  • daynumberRequired

    Day of the month, 1–31.

  • monthnumberRequired

    1 for January to 12 for December.

  • yearnumber

    The year, such as 1990.

Returns

Promise<void>

Nothing, once it's done.

Example
await tokiWallet.setBirthday({
  day: 12,
  month: 4,
  year: 1990,
})
// Without the year:
await tokiWallet.setBirthday({ day: 12, month: 4 })

getMarketingConsent#

tokiWallet.getMarketingConsent()→ Promise<MarketingConsent>

Returns whether the customer receives your marketing emails and texts.

Toki reads the consent from the customer's account in your Shopify store. If their Toki account isn't linked to a customer in your store, every flag is false and both records are null. Shopify stores only.

Returns

Promise<MarketingConsent>
  • hasEmailboolean

    Whether the customer's account in your store has an email address.

  • hasPhoneboolean

    Whether it has a phone number.

  • emailSubscribedboolean

    true when the email marketing state is SUBSCRIBED.

  • smsSubscribedboolean

    true when the SMS marketing state is SUBSCRIBED.

  • emailMarketingConsentobject | null

    Shopify's email consent record; null without an email address.

    3 fields
    • marketingState"SUBSCRIBED" | "NOT_SUBSCRIBED" | "PENDING" | "UNSUBSCRIBED" | "REDACTED" | "INVALID"

      PENDING means the customer hasn't confirmed a double opt-in yet.

    • marketingOptInLevel"SINGLE_OPT_IN" | "CONFIRMED_OPT_IN" | "UNKNOWN" | null
    • consentUpdatedAtstring | null

      When the consent last changed, as an ISO 8601 date-time.

  • smsMarketingConsentobject | null

    Shopify's SMS consent record; null without a phone number.

    4 fields
    • marketingState"SUBSCRIBED" | "NOT_SUBSCRIBED" | "PENDING" | "UNSUBSCRIBED" | "REDACTED"
    • marketingOptInLevel"SINGLE_OPT_IN" | "CONFIRMED_OPT_IN" | "UNKNOWN"
    • consentUpdatedAtstring | null

      When the consent last changed, as an ISO 8601 date-time.

    • consentCollectedFrom"SHOPIFY" | "OTHER" | null

      Where the consent was collected.

Example
const { emailSubscribed, hasPhone, smsSubscribed } =
  await tokiWallet.getMarketingConsent()
Result
{
  "hasEmail": true,
  "hasPhone": false,
  "emailSubscribed": true,
  "smsSubscribed": false,
  "emailMarketingConsent": {
    "marketingState": "SUBSCRIBED",
    "marketingOptInLevel": "SINGLE_OPT_IN",
    "consentUpdatedAt": "2026-03-02T14:05:11Z"
  },
  "smsMarketingConsent": null
}

updateMarketingConsent#

tokiWallet.updateMarketingConsent({ emailSubscribed?, smsSubscribed? })→ Promise<MarketingConsent>

Subscribes the customer to your marketing emails or texts, or unsubscribes them.

Toki updates the consent on the customer's account in your Shopify store: true subscribes them right away, as a single opt-in, and false unsubscribes them. Pass at least one option; a channel you leave out stays as it is.

Email consent needs an email address on the customer's account, and SMS consent a phone number, so check hasEmail and hasPhone from getMarketingConsent() first. Shopify stores only.

Options

one object
  • emailSubscribedboolean

    true subscribes the customer to email marketing; false unsubscribes them.

  • smsSubscribedboolean

    true subscribes the customer to SMS marketing; false unsubscribes them.

Returns

Promise<MarketingConsent>

The consent after the change, as getMarketingConsent() returns it.

  • hasEmailboolean

    Whether the customer's account in your store has an email address.

  • hasPhoneboolean

    Whether it has a phone number.

  • emailSubscribedboolean

    true when the email marketing state is SUBSCRIBED.

  • smsSubscribedboolean

    true when the SMS marketing state is SUBSCRIBED.

  • emailMarketingConsentobject | null

    Shopify's email consent record; null without an email address.

    3 fields
    • marketingState"SUBSCRIBED" | "NOT_SUBSCRIBED" | "PENDING" | "UNSUBSCRIBED" | "REDACTED" | "INVALID"

      PENDING means the customer hasn't confirmed a double opt-in yet.

    • marketingOptInLevel"SINGLE_OPT_IN" | "CONFIRMED_OPT_IN" | "UNKNOWN" | null
    • consentUpdatedAtstring | null

      When the consent last changed, as an ISO 8601 date-time.

  • smsMarketingConsentobject | null

    Shopify's SMS consent record; null without a phone number.

    4 fields
    • marketingState"SUBSCRIBED" | "NOT_SUBSCRIBED" | "PENDING" | "UNSUBSCRIBED" | "REDACTED"
    • marketingOptInLevel"SINGLE_OPT_IN" | "CONFIRMED_OPT_IN" | "UNKNOWN"
    • consentUpdatedAtstring | null

      When the consent last changed, as an ISO 8601 date-time.

    • consentCollectedFrom"SHOPIFY" | "OTHER" | null

      Where the consent was collected.

Example
const consent = await tokiWallet.updateMarketingConsent({
  emailSubscribed: true,
})
Result
{
  "hasEmail": true,
  "hasPhone": false,
  "emailSubscribed": true,
  "smsSubscribed": false,
  "emailMarketingConsent": {
    "marketingState": "SUBSCRIBED",
    "marketingOptInLevel": "SINGLE_OPT_IN",
    "consentUpdatedAt": "2026-10-28T16:42:07Z"
  },
  "smsMarketingConsent": null
}

getAddresses#

tokiWallet.getAddresses()→ Promise<{ addresses: Address[] }>

Lists the customer's addresses in your Shopify store.

These are the addresses saved on the customer's account in your store, the ones they can choose at checkout. Resolves an empty list when the customer has no saved addresses. Shopify stores only.

Returns

Promise<{ addresses: Address[] }>
  • addressesAddress[]

    Text fields are empty or null when not set.

    11 fields per item
    • idstring

      Shopify's numeric address ID, as a string. Pass it to saveAddress() and deleteAddress().

    • firstNamestring | null
    • lastNamestring | null
    • address1string | null

      Street address.

    • address2string | null

      Apartment, suite or unit.

    • citystring | null
    • countrystring | null

      Country name, such as "Canada".

    • provincestring | null

      Province or state name, such as "Ontario".

    • zipstring | null

      ZIP or postal code.

    • phonestring | null
    • isDefaultboolean

      Whether it's the customer's default address.

Example
const { addresses } = await tokiWallet.getAddresses()
const defaultAddress = addresses.find(
  (address) => address.isDefault,
)
Result
{
  "addresses": [
    {
      "id": "8123456789012",
      "firstName": "Anna",
      "lastName": "Smith",
      "address1": "151 O'Connor St",
      "address2": "Apt 4",
      "city": "Ottawa",
      "country": "Canada",
      "province": "Ontario",
      "zip": "K2P 2L8",
      "phone": "+16135551111",
      "isDefault": true
    }
  ]
}

saveAddress#

tokiWallet.saveAddress({ firstName, lastName, address1, city, province, country, zip, … })→ Promise<void>

Adds an address to the customer's account in your Shopify store, or updates one.

Without id, it adds a new address; with the id of one of the customer's addresses, it updates that address. Shopify checks the address, and the promise rejects with its message, such as Country is invalid, when it doesn't accept it. Shopify stores only.

Options

one object
  • idstring

    The address to update, from getAddresses(). Leave it out to add an address.

  • firstNamestringRequired
  • lastNamestringRequired
  • address1stringRequired

    Street address.

  • address2string

    Apartment, suite or unit.

  • citystringRequired
  • provincestringRequired

    Province or state name, such as "Ontario".

  • countrystringRequired

    Country name, such as "Canada".

  • zipstringRequired

    ZIP or postal code.

  • phonestring
  • isDefaultboolean

    true makes it the customer's default address.

Returns

Promise<void>

Nothing, once it's done.

Example
await tokiWallet.saveAddress({
  firstName: "Anna",
  lastName: "Smith",
  address1: "151 O'Connor St",
  address2: "Apt 4",
  city: "Ottawa",
  province: "Ontario",
  country: "Canada",
  zip: "K2P 2L8",
  isDefault: true,
})

deleteAddress#

tokiWallet.deleteAddress(addressId)→ Promise<void>

Deletes one of the customer's addresses from their account in your Shopify store.

Shopify stores only.

Arguments

  • addressIdstringRequired

    The address's id, from getAddresses().

Returns

Promise<void>

Nothing, once it's done.

Example
await tokiWallet.deleteAddress("8123456789012")