Retrieve and Delete Discounts
Learn how to retrieve and delete a discount created for a ticket to an event.
We'll cover the following
List discounts by organization
We can view the discounts and the details of a specific event. Let’s say, for example, that we want to view the discount on a specific event.
The following URL utilizes the GET
request method to retrieve the list of discounts:
https://www.eventbriteapi.com/v3/organizations/{organization_id}/discounts?scope={scope_value}
We can append different parameters with the above URL to retrieve the list of discounts. The table below shows the different values that we can use to filter the list of discounts. It returns a paginated JSON object of discounts.
Object | Type | Category | Description |
| String | Required | ID of the organization to list the discounts for |
| String | Required | Scope of the discounts to retrieve; possible values are |
| String | Optional | Retrieve discounts by approximate match of text |
| String | Optional | Retrieve discounts with an exact match of the |
| Number | Optional | Number of discount objects to return per page |
| String | Optional | Type of discount; possible values are |
| String | Optional | Retrieve the ticket with the exact match provided |
| String | Optional | Retrieve the discount with an exact match of |
| String | Optional | Retrieve the discounts in the specific order; possible orders are |
Note: The
event_id
is necessary when using thescope=event
in the filter parameters. We can removeevent_id
from the filter criteria if we aren’t usingscope=event
.
Let’s see an example of how to retrieve the discounts list of an event:
const endpointUrl = new URL('https://www.eventbriteapi.com/v3/organizations/{{ORGANIZATION_ID}}/discounts?scope=event&event_id={{EVENT_ID}}');const headerParameters = {'Authorization': 'Bearer {{PRIVATE_TOKEN}}'};const options = {method: 'GET',headers: headerParameters};async function listDiscounts() {try {const response = await fetch(endpointUrl, options);printResponse(response);} catch (error) {printError(error);}}// Calling function to make API calllistDiscounts();
- Line 1: We define the endpoint URL with
{ORGANIZATION_ID}
as the URL parameter and filter parametersscope
andevent_id
. - Line 12–19: We create a function,
listDiscounts
, to make an API call using fetch and to handle any exception if it occurs. The custom functionsprintResponse
andprintError
print the respective objects. - Line 22: We invoke the
listDiscounts
function.
Retrieve a specific discount
If we want to retrieve only one specific discount detail, then we can use the following URL, which utilizes the GET
request method to call the API:
https://www.eventbriteapi.com/v3/discounts/{discount_id}/
Only one input parameter, {discount_id}
, is required with the URL. It returns the JSON object with all details of the discount.
const endpointUrl = new URL('https://www.eventbriteapi.com/v3/discounts/{{DISCOUNT_ID}}/');const headerParameters = {'Authorization': 'Bearer {{PRIVATE_TOKEN}}','Content-Type': 'application/json'};const options = {method: 'GET',headers: headerParameters,};async function retrieveTickets() {try {const response = await fetch(endpointUrl, options);printResponse(response);} catch (error) {printError(error);}}// Calling function to make API callretrieveTickets();
- Line 1: We define the endpoint URL with
{DISCOUNT_ID}
as the URL parameter. - Line 13–20: We create a function,
retrieveTickets
, to make an API call using fetch and to handle any exception if it occurs. The custom functionsprintResponse
andprintError
print the respective objects. - Line 23: We invoke the
retrieveTickets
function.
Delete a specific discount
If we want to delete a discount on a ticket, then we can use the following URL, which utilizes the DELETE
request method to call the API:
https://www.eventbriteapi.com/v3/discounts/{discount_id}/
Only one input parameter, {discount_id}
, is required with the URL. If all goes well, it returns the JSON object with two attributes:
{'deleted': True, 'discount_id': '{discount_id}'}
const endpointUrl = new URL('https://www.eventbriteapi.com/v3/discounts/{{DISCOUNT_ID}}/');const headerParameters = {'Authorization': 'Bearer {{PRIVATE_TOKEN}}','Content-Type': 'application/json'};const options = {method: 'GET',headers: headerParameters,};async function deleteDiscount() {try {const response = await fetch(endpointUrl, options);printResponse(response);} catch (error) {printError(error);}}// Calling function to make API calldeleteDiscount();
- Line 1: We define the endpoint URL with
{DISCOUNT_ID}
as the URL parameter. - Line 13–20: We create a function,
deleteDiscount
, to make an API call using fetch and to handle any exception if it occurs. The custom functionsprintResponse
andprintError
print the respective objects. - Line 23: We invoke the
deleteDiscount
function.