---
title: "Validate Code"
method: POST
path: "/api/v1/payments/validate-code"
tags: ["Payments"]
---

# Validate Code

`POST /api/v1/payments/validate-code`

## Request

- Base URL: `https://cryptodataapi.com`
- URL: `https://cryptodataapi.com/api/v1/payments/validate-code`
- Auth: none declared

Validate a discount code and return what the first payment costs per plan.

Codes apply to card and dashboard crypto checkout only — never to x402
purchases. A bounded code is "percent_off for duration_months months": a
monthly plan takes the full percentage on each of those months, and an
annual plan takes those months' share of it off the first year.

Public (checkout UIs call it pre-auth). Every anonymous failure mode returns
the identical `{"valid": false}` — unknown, inactive, expired, and exhausted
are indistinguishable, and email binding is never revealed here (it
surfaces only at pay time) — so codes can't be enumerated or probed.

With an `X-API-Key` header the answer is for that key's account: `prices`
and `duration_months` reflect the discounted months it has left, and a code
its email or wallet has already used up returns `valid: false` with
`reason: "already_used"`. The dashboard calls this right before an EVM
wallet transfer, which is sent before the server ever sees the payment.
Rate-limited per IP.

## Request body

- ValidateCodeRequest
  - `code` string, required

## Response `200`

Successful Response

- ValidateCodeResponse: Public validate response. Uniform {valid: false} for EVERY failure mode (unknown/inactive/expired/exhausted) so codes can't be enumerated; for_email is never exposed — binding surfaces only at pay time.
  - `valid` boolean, required
  - `percent_off` integer, nullable
  - `duration_months` integer, nullable
  - `prices` object, nullable
  - `reason` string, nullable

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/cryptodataapi/apis/crypto-data-api.md) · [All operations](https://skmtc.dev/cryptodataapi/apis/crypto-data-api/llms.txt) · [OpenAPI document](https://skmtc.dev/cryptodataapi/apis/crypto-data-api/revisions/8628b754ca81?raw)
