Create and Update Discount

Learn to create and update the discount on tickets for an event using Eventbrite API.

Eventbrite API allows the organization owner to create discounts on multiple tickets against 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 a discount

To create a discount on the ticket(s) for event(s) the following URL is used, which uses the POST method:

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 on tickets for an event are as follows:

Object

Type

Description

discount.type

string

This is the type of the discount, and its possible values are access, hold, public, and coded.

discount.code

string

This is the code that will be used by the customer to get a discount.

discount.amount_off

decimal

This object is the fixed amount discount and ranges from 0.01 to 99999.99.

discount.percent_off

decimal

This is the percentage discount which ranges from 1.00% to 100.00%.

discount.event_id

string

This object is the event ID for which the discount will be used.

discount.ticket_class_ids

array

This object provides the IDs of the ticket class to which we want to apply the discount.

discount.quantity_available

number

This value indicates how many times the discount can be used.

discount.start_date

string

This object indicates the start date of the discount when it is purchasable.

discount.start_date_relative

number

This object indicates the time in seconds after which the discount is online.

discount.end_date

string

This object indicates the end date of the discount.

discount.end_date_relative

number

This object indicates the time in seconds before the event starts, when the discount sale will stop.

discount.ticket_group_id

string

This object indicates the ID of the ticket group to which the discount will be usable.

discount.hold_ids

array

This object provides the list of hold ids that can be unlocked by this discount.

Response parameters

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

Object

Type

Description

discount.id

string

This object indicates the ID of the discount created.

discount.quantity_sold

number

This object provides the total number of tickets sold.

Note: The event should be paid to create a discount on it. Create an event with a paid ticket and publish it. Then we can make a discount for an event.

Let’s add a discount to a ticket for an event. In the example below, the code added is educative5 to give a discount of 55 units of amount_off.

Press + to interact
import requests
import json
url = 'https://www.eventbriteapi.com/v3/organizations/{{ORGANIZATION_ID}}/discounts/'
headers = {
'Authorization': 'Bearer {{PRIVATE_TOKEN}}',
'Content-Type': 'application/json'
}
values = json.dumps({
"discount": {
"type": "public",
"code": "educative5",
"amount_off": "5",
"event_id": "{{EVENT_ID}}",
"ticket_class_ids": ["{{TICKET_CLASS_ID}}"],
"quantity_available": 5
}
})
response = requests.request("POST", url, headers=headers, data=values).json()
print(json.dumps(response, indent=4))

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

We can see the discount code on the checkout screen. In the first slide above, we can see two tickets, one with “Full Price” and the second with the discount of educative5. As 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.

Update discount

We can update the discount list that has been created earlier using the discount ID endpoint. The following URL uses the POST 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 we’ve used to create a discount, and it returns the updated JSON object of the discount.

Press + to interact
import requests
import json
url = 'https://www.eventbriteapi.com/v3/discounts/{{DISCOUNT_ID}}/'
headers = {
'Authorization': 'Bearer {{PRIVATE_TOKEN}}',
'Content-Type': 'application/json'
}
values = json.dumps({
"discount": {
"code": "educative10",
"amount_off": "10"
}
})
response = requests.request("POST", url, headers=headers, data=values).json()
print(json.dumps(response, indent=4))