apyhub
DATA VALIDATION · FINANCE

Validate Payment Card API

What it does

Card Number Validator checks whether a payment card number is structurally valid, identifies the card network, and returns a masked representation for safer handling.

Send a card_number in the request body. The value can include spaces or dashes; those are ignored during validation. The response includes valid, luhn_valid, and length_valid so you can see whether the number passes the checksum and length checks. You also get network, iin, length, last4, formatted, and masked when they can be derived, plus an optional note for additional context.

Use Card Number Validator when you need to clean up user-entered payment data before storing it, flag obvious typos in checkout forms, or label card numbers by network in admin and support workflows. The masked and last-four outputs are useful when you want to display or log card details without exposing the full number.

This service is for validation and normalization only. It does not perform authorization, issuer lookup, or account verification.

POST
Validate a card number - Luhn + network detection + masking.
http://localhost:8080/creightonnick0/validate-card-number
QUICKSTARTGUIDE

Quickstart

Validate a card number by sending it in the request body.

curl -X POST "http://localhost:8080/creightonnick0/validate-card-number" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"card_number":"4242 4242 4242 4242"}'

What you'll get back

Returns a JSON object with these top-level fields, when available: iin (string), note (string), last4 (string), valid (boolean), length (integer), masked (string), network (string), formatted (string), luhn_valid (boolean), and length_valid (boolean).

{
  "iin": "424242",
  "note": "Valid card number",
  "last4": "4242",
  "valid": true,
  "length": 16,
  "masked": "4242 42XX XXXX 4242",
  "network": "Visa",
  "formatted": "4242 4242 4242 4242",
  "luhn_valid": true,
  "length_valid": true
}
TRY ITLIVE · 10 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
The card number (spaces and dashes are ignored)

About this endpoint

What it does

Validates a card number using the Luhn algorithm, detects the card network, and returns normalized/masked card-number details. The request sends a card number in the body; the response returns validation and formatting fields for that number.

Request Body

ParameterTypeMandatoryDescription
card_numberStringYesThe card number. Spaces and dashes are ignored.

Response

Returns a JSON object with iin, note, last4, valid, length, masked, network, formatted, luhn_valid, and length_valid fields. The response is a single JSON object containing these top-level fields.

ParameterTypeMandatoryDescription
iinStringNoThe card IIN/BIN value.
noteStringNoA textual note.
last4StringNoThe last 4 digits of the card number.
validBooleanNoWhether the card number is valid.
lengthIntegerNoThe card number length.
maskedStringNoA masked version of the card number.
networkStringNoThe detected card network.
formattedStringNoThe formatted card number.
luhn_validBooleanNoWhether the number passes the Luhn check.
length_validBooleanNoWhether the number length is valid.

Body

Name
Type
Description
bodyREQUIRED
object
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.