Discounts
View as Markdown

Create a coupon

Needs the catalog:write scope, or a full-access key. About scopes

POST
/api/v1/coupons

Authorization

Authorization
Required
Bearer <token>

An API key: gpy_test_… or gpy_live_… (or an agent key, agk_…).

In: header

Request Body

application/jsonOptional

name
Required
string

Minimum length: 1Maximum length: 100

percent_offAny properties in string, number

Exactly one of percent_off / amount_off_cents.

amount_off_centsstring

Fixed amount off; needs currency.

Pattern: "^\\d+$"

currencystring

Value in: "USD" | "AUD" | "CAD" | "GBP" | "EUR" | "INR" | "NPR"

duration
Required
string

Value in: "once" | "repeating" | "forever"

duration_in_periodsinteger

applies_to_plan_idsarray<string>

max_redemptionsinteger

redeem_bystring

Format: "date-time"

activeboolean

Header Parameters

Idempotency-Keystring

A unique value for this operation, chosen by you. A retry with the same key and the same body returns the first response instead of running again. The same key with a different body answers 409 idempotency_key_reused; a key whose first request is still running answers 409 idempotency_in_progress.

curl -X POST "https://globalymint.com/api/v1/coupons" \
  -H "Idempotency-Key: order-8842-charge" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "string",
    "percent_off": "string",
    "amount_off_cents": "1999",
    "currency": "USD",
    "duration": "once",
    "duration_in_periods": 1,
    "applies_to_plan_ids": [
      "3fa85f64-5717-4562-b3fc-2c963f66afa6"
    ],
    "max_redemptions": 1,
    "redeem_by": "2019-08-24T14:15:22Z",
    "active": true
  }'

The coupon.

{
  "data": {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "name": "string",
    "percent_off": "20",
    "amount_off_cents": "1999",
    "currency": "USD",
    "duration": "once",
    "duration_in_periods": 0,
    "applies_to_plan_ids": [
      "3fa85f64-5717-4562-b3fc-2c963f66afa6"
    ],
    "max_redemptions": 0,
    "times_redeemed": 0,
    "redeem_by": "2019-08-24T14:15:22Z",
    "active": true,
    "created_at": "2019-08-24T14:15:22Z",
    "updated_at": "2019-08-24T14:15:22Z"
  },
  "_agent": {
    "summary": "string",
    "status": "ok",
    "next_actions": [
      "string"
    ],
    "warnings": [
      "string"
    ]
  },
  "api_version": "2026-07-01"
}