Create a coupon

Creates a coupon. A coupon has either an amountOff and currency or percentOff. The coupon created will be automatically synchronized with Stripe if you have a connected stripe account. If you are not connected the endpoint will throw an error. In addition to Checkout Page rate limits, Stripe rate limits apply when creating coupons.

POST/v1/coupons/

Authorization

api_key_auth
AuthorizationBearer <token>

API key authentication. Use "Bearer YOUR_API_KEY" format.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

  • labelstringrequired

    Internal name for the coupon.

    min 1 characters

  • codestringrequired

    The coupon code a customer enters.

    min 1 characters · ^[A-Za-z0-9_-]+$

  • amountOffnumber

    A positive integer representing the amount to subtract from an invoice total, in the smallest currency unit of currency (for example 500 USD is $5.00 and 500 JPY is ¥500). Required if percentOff is not passed.

    1 to 99999999

  • currencystring

    Three-letter ISO code for the currency of the amountOff parameter. Required when amountOff is set, and not allowed when percentOff is set.

    aedaudbrlcadchfclpczkdkk
  • durationstringrequired
    oncerepeatingforever
  • durationInMonthsinteger

    A positive integer representing the number of months the coupon applies for. Required when duration === repeating, and not allowed when duration is once or forever.

    more than 0

  • percentOffnumber

    A positive float larger than 0, and smaller or equal to 100, that represents the discount the coupon will apply (required if amountOff is not passed).

    1 to 100

  • appliesToSetupFeeboolean

    When enabled, applies this coupon discount to the setup fee.

  • appliesToTicketFeesboolean

    When enabled, applies this coupon discount to ticket-level fees on event pages as well as the ticket prices. Defaults to false, which leaves ticket fees undiscounted.

  • Where the coupon works and what it discounts, one rule per page. A coupon works on a page when any of its rules names that page, and on each page the rules are combined with OR (an event cannot mix tickets and ticketsAndAddOns rules). Omit rules (and pageIds), or send an empty list, for a coupon that discounts the whole order on every checkout page and event.

  • maxRedemptionsnumber

    The total amount of times this coupon can be used. Doesn't limit a single customer from redeeming multiple times.

    min 0

  • redeemBystring

    The ISO datetime that this coupon must be used before.

    date-time

Returns

Coupon created successfully

    • idstring

      Unique identifier for the object.

    • labelstring

      Internal name for the coupon.

    • codestring

      The coupon code a customer enters.

    • amountOff?number, nullable

      Flat discount amount in the specified currency. Only set if percentOff is not used.

    • currency?string

      Three-letter ISO code for the currency (required when amountOff is set). Examples: usd, eur, gbp.

    • percentOff?number, nullable

      Percentage discount (0-100) applied to payments using this coupon. Example: 50 applies 50% off ($100 payment becomes $50). Only set if amountOff is not used.

    • appliesToSetupFee?boolean

      When enabled, applies this coupon discount to the setup fee.

    • appliesToTicketFees?boolean

      When enabled, applies this coupon discount to ticket-level fees on event pages as well as the ticket prices.

    • durationstring

      How long the discount applies: once (single payment), repeating (specified months), or forever (all future payments).

      oncerepeatingforever
    • durationInMonths?number

      If duration is repeating, the number of months the coupon applies. Null if coupon duration is forever or once.

    • redeemBy?string

      The ISO datetime that this coupon must be used before.

      date-time

    • maxRedemptions?number

      Maximum number of times this coupon can be redeemed globally. A single customer may redeem it multiple times.

    • timesRedeemednumber

      The number of times this coupon has been redeemed.

    • deletedboolean

      If true, this coupon will be soft deleted. It is no longer usable but data is retained.

    • sellerIdstring
    • Where the coupon works and what it discounts, one rule per page. A coupon works on a page when any of its rules names that page, and on each page the rules are combined with OR (an event cannot mix tickets and ticketsAndAddOns rules). Omit rules (and pageIds), or send an empty list, for a coupon that discounts the whole order on every checkout page and event.

    • stripeCouponId?string

      The unique identifier of the stripe coupon that was created with this coupon.

    • createdAtstring

      date-time

    • updatedAtstring

      date-time

Bad request - Invalid request parameters

  • statusstring

    Indicates the request failed.

    error
  • typestring

    Machine-readable error category.

  • messagestring

    Human-readable error message.

  • Optional validation details for invalid requests.

Unauthorized - Missing or invalid API key

  • statusstring

    Indicates the request failed.

    error
  • typestring

    Machine-readable error category.

  • messagestring

    Human-readable error message.

  • Optional validation details for invalid requests.

Forbidden - Insufficient permissions or validation error

  • statusstring

    Indicates the request failed.

    error
  • typestring

    Machine-readable error category.

  • messagestring

    Human-readable error message.

  • Optional validation details for invalid requests.

Conflict - Coupon code already exists

  • statusstring

    Indicates the request failed.

    error
  • typestring

    Machine-readable error category.

  • messagestring

    Human-readable error message.

  • Optional validation details for invalid requests.

Rate Limit Exceeded - Please try again later.

  • messagestring

    Human-readable error message.

Internal server error

  • statusstring

    Indicates the request failed.

    error
  • typestring

    Machine-readable error category.

  • messagestring

    Human-readable error message.

  • Optional validation details for invalid requests.

import { createCheckoutPageClient } from '@checkoutpage/sdk';const checkoutpage = createCheckoutPageClient({  apiKey: process.env.CHECKOUTPAGE_API_KEY!,});const response = await checkoutpage.coupons.create({  label: 'Free shipping within US',  code: '10Off',  duration: 'once',});
{
  "data": {
    "id": "string",
    "label": "Free shipping within US",
    "code": "10Off",
    "amountOff": 0,
    "currency": "string",
    "percentOff": 0,
    "appliesToSetupFee": true,
    "appliesToTicketFees": true,
    "duration": "once",
    "durationInMonths": 0,
    "redeemBy": "2019-08-24T14:15:22Z",
    "maxRedemptions": 0,
    "timesRedeemed": 0,
    "deleted": false,
    "sellerId": "string",
    "rules": [
      {
        "pageId": "string",
        "appliesTo": "prices",
        "priceIds": [
          "string"
        ],
        "ticketTypeIds": [
          "string"
        ],
        "bumpProductIds": [
          "string"
        ]
      }
    ],
    "stripeCouponId": "string",
    "createdAt": "2019-08-24T14:15:22Z",
    "updatedAt": "2019-08-24T14:15:22Z"
  }
}
{
  "status": "error",
  "type": "ValidationError",
  "message": "Bad request - Invalid body: Field 'email' must be a valid email address",
  "errors": [
    {
      "param": "email",
      "message": "must be a valid email address"
    }
  ]
}
{
  "status": "error",
  "type": "error",
  "message": "Missing or invalid API key"
}
{
  "status": "error",
  "type": "error",
  "message": "Insufficient permissions requires: BOOKINGS_WRITE"
}
{
  "status": "error",
  "type": "error",
  "message": "Conflict - Coupon code already exists"
}
{
  "message": "API key rate limit exceeded. Please try again later."
}
{
  "status": "error",
  "type": "error",
  "message": "Internal server error"
}