Skip to main content
POST
/
api
/
cards
/
create
Create Card Token
curl --request POST \
  --url https://api.example.com/api/cards/create \
  --header 'Content-Type: application/json' \
  --data '
{
  "number": "<string>",
  "exp_month": "<string>",
  "exp_year": "<string>",
  "cvc": "<string>"
}
'
{
  "status": true,
  "message": "<string>",
  "data": {
    "token_id": "<string>",
    "card_id": "<string>",
    "card_brand": "<string>",
    "card_last4": "<string>"
  }
}
Never store raw card data on your servers. This endpoint creates a secure token through Stripe that represents the card information.
Creates a token representing a credit card. The token can then be used to attach the card to a customer or make a payment. This approach ensures PCI compliance by never storing sensitive card data on your servers.

Request Body

number
string
required
The card number, as a string without any separators.For testing, use Stripe test card: 4242424242424242
exp_month
string
required
The card’s expiration month (1-12).Example: "12"
exp_year
string
required
The card’s expiration year as a 4-digit number.Example: "2026"
cvc
string
required
The card’s CVC/CVV security code.Example: "123"

Response

status
boolean
Indicates if the request was successful (true) or failed (false).
message
string
Human-readable message describing the result.Example: "Tarjeta tokenizada correctamente"
data
object
The tokenized card data.

Example Request

curl -X POST https://your-api.com/api/cards/create \
  -H "Content-Type: application/json" \
  -d '{
    "number": "4242424242424242",
    "exp_month": "12",
    "exp_year": "2026",
    "cvc": "123"
  }'

Example Response

{
  "status": true,
  "message": "Tarjeta tokenizada correctamente",
  "data": {
    "token_id": "tok_1QRs9eKZ4xUzN2TP9vQqWXYZ",
    "card_id": "card_1QRs9eKZ4xUzN2TPabcdefgh",
    "card_brand": "Visa",
    "card_last4": "4242"
  }
}

Error Codes

CodeDescription
incorrect_numberThe card number is incorrect
invalid_expiry_monthThe expiration month is invalid
invalid_expiry_yearThe expiration year is invalid
invalid_cvcThe CVC/CVV code is invalid
card_declinedThe card was declined by the issuer
Test Cards: Use Stripe’s test card numbers for development:
  • Success: 4242424242424242
  • Declined: 4000000000000002
  • Insufficient funds: 4000000000009995
See Stripe’s test cards documentation for more.

Build docs developers (and LLMs) love