Coupons

Validate a coupon against a cart (preview the discount)

POST
/v1/coupons/validate

Authorization

selectkey<token>

API key para requisições autenticadas. Envie sua chave no cabeçalho selectkey (sandbox sk_test_…, produção sk_live_…).

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/v1/coupons/validate" \  -H "Content-Type: application/json" \  -d '{    "code": "string",    "amount": 5000,    "itemCount": 0,    "itemIds": [      "id_0a1b2c3d4e5f60718293"    ],    "customerId": "cus_0a1b2c3d4e5f60718293"  }'
{
  "valid": true,
  "reason": "string",
  "code": "string",
  "discount": {
    "type": "percentage",
    "value": 5000,
    "percentage": 0
  },
  "originalAmount": 5000,
  "chargedAmount": 5000
}
{
  "error": {
    "status": "Bad Request",
    "statusCode": 400,
    "category": "validation",
    "code": "invalidParameters",
    "message": "Validation errors occurred.",
    "resource": "server"
  }
}
{
  "error": {
    "status": "Unauthorized",
    "statusCode": 401,
    "category": "authentication",
    "code": "unauthorized",
    "message": "Authentication is required to access this resource.",
    "resource": "server"
  }
}
{
  "error": {
    "status": "Forbidden",
    "statusCode": 403,
    "category": "authorization",
    "code": "forbidden",
    "message": "You do not have permission to perform this action.",
    "resource": "server"
  }
}
{
  "error": {
    "status": "Internal Server Error",
    "statusCode": 500,
    "category": "server",
    "code": "serverError",
    "message": "An unexpected error occurred. Please try again later.",
    "resource": "server",
    "details": "If the problem persists, contact support with the correlationId from the response headers."
  }
}