Retrieve and Delete Discounts

Learn how to retrieve and delete a discount created for a ticket to an event.

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

organization_id

String

Required

ID of the organization to list the discounts for

scope

String

Required

Scope of the discounts to retrieve; possible values are event, multi_events, and user

code_filter

String

Optional

Retrieve discounts by approximate match of text

code

String

Optional

Retrieve discounts with an exact match of the code provided

page_size

Number

Optional

Number of discount objects to return per page

type

String

Optional

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

ticket_group_id

String

Optional

Retrieve the ticket with the exact match provided ticket_group_id

event_id

String

Optional

Retrieve the discount with an exact match of event_id

order_by

String

Optional

Retrieve the discounts in the specific order; possible orders are code_asc, code_desc, discount_type_asc, discount_type_desc, start_asc, and start_desc

Note: The event_id is necessary when using the scope=event in the filter parameters. We can remove event_id from the filter criteria if we aren’t using scope=event.

Let’s see an example of how to retrieve the discounts list of an event:

Press + to interact
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 call
listDiscounts();
  • Line 1: We define the endpoint URL with {ORGANIZATION_ID} as the URL parameter and filter parameters scope and event_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 functions printResponse and printError 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.

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 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 call
retrieveTickets();
  • 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 functions printResponse and printError 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}'}
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 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 call
deleteDiscount();
  • 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 functions printResponse and printError print the respective objects.
  • Line 23: We invoke the deleteDiscount function.