Create and Update Discounts

Learn how to create and update the ticket discounts for an event using the Eventbrite API.

The Eventbrite API allows the organization owner to create discounts on multiple tickets for one or more events. These discounts can appear on the event’s listing and during the checkout process or only during the checkout process.

Eventbrite provides four types of discounts:

  • Public discounts: These discounts are only used for one event and are shown publically.
  • Coded discounts: A secret code is used by the order owner to get a discount.
  • Access code: It shows the hidden tickets using a secret code and may or may not contain the discount.
  • Hold discounts: This discount is used for the seats on hold.

Create discount

To create a discount for a ticket (or tickets) for an event (or events) the following URL is used, which utilizes the POST request method to call the API:

https://www.eventbriteapi.com/v3/organizations/{organization_id}/discounts/

The URL requires the {organization_id}.

Request parameters

Some important input parameters to create a discount for tickets to an event are as follows:

Object

Type

Description

discount.type

String

Type of discount; possible values are: access, hold, public, and coded

discount.code

String

Code that will be used by the customer to get the discount

discount.amount_off

Float

Fixed amount discount that ranges from 0.01 to 99999.99

discount.percent_off

Float

Percentage discount that ranges from 1.00% to 100.00%

discount.event_id

String

Event ID for which the discount will be used

discount.ticket_class_ids

String [ ]

IDs of the ticket class on which we want to apply the discount

discount.quantity_available

Integer

Indicates how many times the discount can be used

discount.start_date

String

Start date of the discount when it is purchaseable

discount.start_date_relative

Integer

Time in seconds after which the discount is online

discount.end_date

String

End date of the discount

discount.end_date_relative

Integer

Time in seconds before the event starts (when the discount sale will stop)

discount.ticket_group_id

String

ID of the ticket group on which the discount will be usable

discount.hold_ids

String [ ]

List of hold IDs that can be uncloked by this discount

The event should be paid to create a discount on it. Let's create a paid ticket for the event we have already created.

Press + to interact
const endpointUrl = new URL('https://www.eventbriteapi.com/v3/events/{{EVENT_ID}}/ticket_classes/');
const headerParameters = {
'Authorization': 'Bearer {{PRIVATE_TOKEN}}',
'Content-Type': 'application/json'
};
const bodyParameters = JSON.stringify({
"ticket_class": {
"name": "Sample paid ticket",
"free": "False",
"cost": "USD,2000",
"capacity": "100",
"minimum_quantity": "1",
"maximum_quantity": "10",
"sales_channels": ["online", "atd"],
"delivery_methods": ["electronic"]
}
});
const options = {
method: 'POST',
headers: headerParameters,
body: bodyParameters,
};
async function createTicket() {
try {
const response = await fetch(endpointUrl, options);
printResponse(response);
} catch (error) {
printError(error);
}
}
// Calling function to make API call
createTicket();

After the paid ticket has been created, let's add a discount to it.

Press + to interact
const endpointUrl = new URL('https://www.eventbriteapi.com/v3/organizations/{{ORGANIZATION_ID}}/discounts/');
const headerParameters = {
'Authorization': 'Bearer {{PRIVATE_TOKEN}}',
'Content-Type': 'application/json'
};
const bodyParameters = JSON.stringify({
"discount": {
"type": "public",
"code": "educative5",
"amount_off": "5",
"event_id": "{{EVENT_ID}}",
"ticket_class_ids": ["{{TICKET_CLASS_ID}}"],
"quantity_available": 5
}
});
const options = {
method: 'POST',
headers: headerParameters,
body: bodyParameters,
};
async function createDiscount() {
try {
const response = await fetch(endpointUrl, options);
printResponse(response);
} catch (error) {
printError(error);
}
}
// Calling function to make API call
createDiscount();
  • Line 1: We define the endpoint URL with {ORGANIZATION_ID} as the URL parameter.
  • Line 8–17: We set the bodyParameters with the discount object details.
  • Line 25–32: We create a function, createDiscount, to make an API call using fetch and to handle any exception if it occurs. The custom functions printResponse and printError print the respective objects.
  • Line 35: We invoke the createDiscount function.

We can see the created discount on the checkout screen as shown:

The discount code we added can be seen on the checkout screen. In the first slide above, we can see two tickets, one with “Full Price” and the second with the “educative5” discount. Because we have added 55 units of amount off on the original price, the “Discount: -$10” can be seen in the second slide for two tickets.

Response fields

The output of the above API call is a JSON object with all the details of the discount object created. It returns two extra attributes for discount, which are as follows:

Object

Type

Description

id

String

ID of the discount created

quantity_sold

Number

Total number of tickets sold

Update discount

The already created discounts can be updated using the discount ID. The following URL utilizes the POST request method to update the discount:

https://www.eventbriteapi.com/v3/discounts/{discount_id}/

The URL requires the {discount_id}. All other input parameters are the same as the ones we have used to create a discount, and it returns the updated JSON object of the discount.

Press + to interact
const endpointUrl = new URL('https://www.eventbriteapi.com/v3/discounts/{{DISCOUNT_ID}}/');
const headerParameters = {
'Authorization': 'Bearer {{PRIVATE_TOKEN}}',
'Content-Type': 'application/json'
};
const bodyParameters = JSON.stringify({
"discount": {
"code": "educative10",
"amount_off": "10"
}
});
const options = {
method: 'POST',
headers: headerParameters,
body: bodyParameters,
};
async function updateDiscount() {
try {
const response = await fetch(endpointUrl, options);
printResponse(response);
} catch (error) {
printError(error);
}
}
// Calling function to make API call
updateDiscount();
  • Line 1: We define the endpoint URL with {DISCOUNT_ID} as the URL parameter.
  • Line 8–13: We set the bodyParameters with the updated values of the discount.
  • Line 21–28: We create a function, updateDiscount, to make an API call using fetch and to handle any exception if it occurs. The custom functions printResponse and printError print the respective objects.
  • Line 31: We invoke the updateDiscount function.