Endpoint
Authentication
| Header | Required | Value |
|---|---|---|
X-API-Key | Yes | Your API key (bun_...) |
Content-Type | Yes | application/json |
Overview
Validate credit and debit card numbers using the Luhn algorithm and identify the card network (Visa, Mastercard, Amex, etc.) and card type. Use this API to provide instant feedback on payment forms before processing a charge, reducing failed transactions and improving checkout UX.Use cases
- Validate card numbers client-side before calling your payment gateway
- Display the correct card network logo in checkout forms
- Reduce fraud by catching obviously invalid numbers early
- Enforce card type restrictions (e.g. credit only, no prepaid)
Details
Accepts card numbers with or without spaces and dashes. Validation uses the Luhn algorithm; it confirms the number is structurally valid, not that the account exists or has funds. Never log or store raw card numbers.Request body
| Field | Type | Required | Description |
|---|---|---|---|
number | string | Yes | Credit card number (spaces and dashes are ignored) |
Example
Response
200 OK
| Field | Type | Description |
|---|---|---|
valid | boolean | true if both Luhn check and length are valid |
luhn_valid | boolean | Whether the number passes the Luhn algorithm |
length_valid | boolean | Whether the digit count matches the expected length for the detected brand |
brand | string | Card brand: Visa, Mastercard, Amex, Discover, Diners, JCB, Elo, Hipercard, or Unknown |
digits | number | Number of digits in the card number |
masked | string | Card number with middle digits replaced by asterisks (e.g. 4111 **** **** 1111) |

