DiscountCodes
Create DiscountCode
Create a new DiscountCode record.
POST
Create DiscountCode
A DiscountCode is a code operators share with customers to take a percentage or a fixed amount off a price. Each code belongs to a location, and a code owned by a network parent location can also be redeemed at every location in that network. Set either DiscountPercentage or DiscountAmount, not both; if both are set the fixed amount is used and it is capped at the item price. The DiscountPricePlans, DiscountBookings, DiscountProducts and DiscountEvents flags choose which kinds of purchase the code pays for, and the matching Tariffs, ResourceTypes, Products and EventCategories lists narrow each one to specific items, where an empty list means every item of that kind is allowed. On update each list replaces the whole collection, so send the complete intended set of IDs. Availability is further limited by Active, the validity window (ValidFrom/ValidTo), the portal publish window (PublishFrom/PublishTo), usage caps (MaxUses, MaxUsesPerUser) and audience (OnlyForContacts, OnlyForMembers). ExpirationType and ExpiresIn set how long a customer keeps the discount once they claim it. Claiming a code creates a CoworkerDiscountCode linking it to that customer; set ReferralDiscount when the discount should reward the referring customer instead of the person redeeming it.
Authentication
This endpoint requires OAuth2 authentication. Include a valid bearer token in the
Authorization header.
The authenticated user must be a full unrestricted administrator or have the DiscountCode-Create role.Enums
eDiscountExpirePeriod
eDiscountExpirePeriod
Request Body
Required Fields
integer
required
ID of the location this discount code is available at. If the location is a network parent, the code can also be redeemed at every location in that network.
string
required
The code customers type to claim the discount; must be unique within the location. Typically a short alphanumeric string such as SUMMER25.
string
required
Short text shown to the customer when they enter a valid code, for example 20% off your first month. Required, and translatable per language.
Optional Fields
boolean
Whether the code can be redeemed at all. When false the code is ignored everywhere, regardless of its validity or publish dates.
string
UTC date and time from which the code can be redeemed on the members portal, website and app. Leave empty to publish immediately.
string
UTC date and time after which the code can no longer be redeemed on the members portal, website and app. Leave empty for no publish end date.
number
Percentage taken off the price, entered as a whole number so 10 means 10% off. Set either this or DiscountAmount, not both; when both are set DiscountAmount wins.
number
Fixed amount taken off the price, in the location currency. Capped at the item price so the result is never negative. Set either this or DiscountPercentage, not both; when both are set this one wins.
boolean
Whether the discount is granted to the referring customer instead of the person redeeming it. When true, sign-up fails unless the new customer arrived through a referral link, and the discount stops applying if the referrer becomes inactive. To reward both sides, add a second non-referral code using the same Code value.
boolean
Whether the code can be used to pay for plans. When false the code never applies to a plan, whatever Tariffs contains.
integer[]
List of plan (tariff) IDs the discount is restricted to. Leave empty to allow any plan. Only has an effect while DiscountPricePlans is true.
boolean
Whether the code can be used to pay for bookings. When false the code never applies to a booking, whatever ResourceTypes contains.
integer[]
List of resource type IDs the discount is restricted to. Leave empty to allow any resource type. Only has an effect while DiscountBookings is true, and once the list is set a booking with no resource is excluded.
boolean
Whether the code can be used to pay for products. When false the code never applies to a product, whatever Products contains.
integer[]
List of product IDs the discount is restricted to. Leave empty to allow any product. Only has an effect while DiscountProducts is true.
boolean
Whether the code can be used to pay for event tickets. When false the code never applies to an event, whatever EventCategories contains.
integer[]
List of event category IDs the discount is restricted to. Leave empty to allow any event. Only has an effect while DiscountEvents is true, and an event matches when it belongs to at least one listed category.
integer
Maximum number of times one customer may redeem this code. Leave empty for no per-customer limit.
integer
Maximum number of redemptions across all customers, after which the code stops working. Leave empty for no overall limit.
boolean
Whether the code is restricted to contacts, meaning customers with no active contract. Mutually exclusive with OnlyForMembers; leave both false to allow every customer.
boolean
Whether the code is restricted to members, meaning customers with at least one active contract. Mutually exclusive with OnlyForContacts; leave both false to allow every customer.
string
UTC date and time from which the discount applies. Leave empty for no start date. For bookings this is compared against the booking start time rather than the moment of redemption.
string
UTC date and time after which the discount no longer applies. Leave empty for no end date. For bookings this is compared against the booking end time rather than the moment of redemption.
integer
Unit used together with ExpiresIn to work out when a claimed code stops working for that customer: Day, Week, Month or Year. See
eDiscountExpirePeriod? enum above.integer
How many ExpirationType periods a customer keeps the discount for after claiming it, so 3 with ExpirationType Month expires it three months after the customer claims the code. Leave empty so the discount never expires on its own.
Code Examples
Response
200
integer
HTTP status code.
200 on success.string
A human-readable message confirming the creation.
object
Contains the
Id of the newly created record.boolean
true if the discountcode was created successfully.array
null on success.Example Response
400
string
A summary of the validation error(s), in the format
PropertyName: error message.any
null on validation failure.object[]
Array of validation errors.
boolean
false when the request fails validation.Example Response