tokenId, right in the buyer’s browser. This token is what you send in
creditCard.token when creating a transaction — so the card number
never passes through your server, reducing your PCI scope.
Why use the SDK
When the buyer enters the card data at checkout, the SDK sends the number (PAN), the CVV, and the expiry date directly from the browser to the vault and to the PSPs — never to your backend. What your server receives is only an opaquetokenId: a string that is meaningful only within Z2Pay and
that, on its own, reveals nothing about the card.
No card data on your server
The PAN/CVV go from the browser directly to the vault. You only ever see the
tokenId.Disposable token
The
tokenId is temporary and expires automatically (24h TTL).Installation
You can load the SDK via a<script> tag (CDN) or install it as a dependency via npm.
Configuration
Create aTokenizer instance passing the configuration below.
Public identifier of your company. It is safe to expose it on the frontend.
Base URL of the Z2Pay API. Use
https://api.sandbox.z2pay.com in the sandbox and the production URL
(see Environments) in production.Optional. Maximum time, in milliseconds, for tokenization. Default:
15000 (15s).Tokenize a card
CallcreateCardToken with the card data. The SDK returns a { tokenId } object.
Card number (PAN), digits only. Never reaches your server.
Cardholder name, as printed on the card.
Cardholder’s CPF or CNPJ, digits only.
Card security code (CVV).
Expiry in the
MM/YYYY format (e.g. 12/2030). The MM/YY format is also accepted.Response
createCardToken resolves with an object containing the opaque tokenId.
Opaque, temporary token. Use it in
creditCard.token in the
POST /transactions. Expires in 24h.The prefix and exact format of the
tokenId are defined internally — treat the value as an opaque
string and do not attempt to parse it.Using the token in a transaction
With thetokenId in hand, create the transaction on your backend by providing it in
creditCard.token:
This example illustrates how the token is used. The exact fields for creating a transaction are
documented on the Transactions page. Values are always integers in
cents (
19900 = R$ 199.00).How it works under the hood
When you callcreateCardToken, the SDK — running in the buyer’s browser — sends the sensitive data
(PAN, CVV) directly to Z2Pay’s secure vault and to its PSPs, in parallel, and exchanges
everything for a single opaque tokenId. The card data never passes through your backend; you
only receive the tokenId. All communication with the vault, the PSPs, and the tokenization service
is handled by the SDK — you don’t need to orchestrate any of it by hand.
Common errors
Failed to generate any tokens: no PSP or vault was able to tokenize the card. Common causes: invalid card data or no PSP configured for the company. Check thecompanyIdand the data provided.Timeout: tokenization exceeded thetimeout(default 15s). This usually indicates a slow network on the buyer’s side.- Network / API error: if the call to the Z2Pay API fails, the SDK throws an
Errorwith the status and the response body. See Errors for the API error format.
See also
Transactions
Use the
tokenId when creating a card transaction.Cards
Saved cards and persistent tokenization.
Test cards (sandbox)
Card numbers for testing in the sandbox environment.
Environments
Sandbox and production URLs.

