TrieOH
PayssageProvidersMercado Pago

Card Tokens

Create Mercado Pago card tokens in test and production environments.

A card token is a temporary, single-use representation of a card, created from card and cardholder information. It replaces the raw card number everywhere — including inside TrieOH: the Univents checkout tokenizes cards in the browser with @mercadopago/sdk-js and sends only the token to the backend. This page documents the raw Mercado Pago API for reference and debugging.

Test and production environments

EnvironmentCredentialsCard and cardholder dataTransactions
TestMercado Pago test credentials (MP_TEST_ACCESS_TOKEN, MP_TEST_PUBLIC_KEY)Mercado Pago test cards and test payer dataSimulated; no real charge
ProductionMercado Pago production credentialsReal card and cardholder dataReal payment; the cardholder may be charged

In production, use production credentials and real card and cardholder data. The test values shown below are only for test mode.

See the official Mercado Pago documentation for credentials and test cards.


Create card token

Creates a temporary token from card and cardholder information.

POST https://api.mercadopago.com/v1/card_tokens

Authentication

Send the Mercado Pago Access Token for the selected environment as a Bearer token.

Authorization: Bearer ACCESS_TOKEN

Headers

HeaderTypeRequiredDescription
AuthorizationstringYesBearer Access Token for the current environment.
Content-TypestringYesMust be application/json.

Request body

FieldTypeRequiredDescription
card_numberstringYesCard number.
expiration_yearstringYesExpiration year.
expiration_monthstringYesExpiration month.
security_codestringYesSecurity code.
cardholderobjectYesCardholder information.
cardholder.namestringYesCardholder name.
cardholder.identificationobjectYesCardholder identification document.
cardholder.identification.typestringYesIdentification type (e.g. CPF, CNPJ).
cardholder.identification.numberstringYesIdentification number.

Test request

Set a test Access Token in your shell:

export MERCADO_PAGO_ACCESS_TOKEN="replace-with-test-access-token"

Create a card token using Mercado Pago test data:

curl --request POST \
  --url https://api.mercadopago.com/v1/card_tokens \
  --header "Authorization: Bearer ${MERCADO_PAGO_ACCESS_TOKEN}" \
  --header "Content-Type: application/json" \
  --data '{
    "card_number": "5031433215406351",
    "expiration_year": "2030",
    "expiration_month": "11",
    "security_code": "123",
    "cardholder": {
      "name": "APRO",
      "identification": {
        "type": "CPF",
        "number": "12345678909"
      }
    }
  }'

Production request

The endpoint and request structure are the same in production. Replace the test Access Token and all test values with production credentials and real card and cardholder data.

export MERCADO_PAGO_ACCESS_TOKEN="replace-with-production-access-token"

In TrieOH (the frontend way)

The raw API above is what the Mercado Pago SDK wraps. In our frontends (see Univents checkout) the flow is:

  1. Load the SDK: loadMercadoPago() from @mercadopago/sdk-js.
  2. Create the instance with the seller's public key (from the event's payssage_public_key): new window.MercadoPago(publicKey, { locale: "pt-BR" }).
  3. Mount mp.cardForm({ iframe: true, … }) — card number, expiry, and CVV live in Mercado Pago iframes and never touch your DOM state.
  4. On submit, getCardFormData() returns { token, issuerId, paymentMethodId, installments, identificationNumber, identificationType, cardholderEmail }.
  5. Send { card_token, payment_method_id, installments, issuer_id, payer: { email, identification: { type, number } } } to the checkout endpoint (Payssage intent).

Never send raw card numbers to TrieOH backends — only the token. Cards charge synchronously at checkout; Pix returns a QR code instead.

On this page