List, Cancel and Delete Events
Learn how to list, cancel, and delete an event using the Eventbrite API.
We'll cover the following
List events by organization
Events can be listed in different ways, and we will be listing events by organization_id
. The following URL utilizes the GET
request method to retrieve all the events organized by an organization:
https://www.eventbriteapi.com/v3/organizations/{organization_id}/events/
The {organiztion_id}
is the required input to list the events. It returns a paginated response with a list of events belonging to the provided {organization_id}
. Let’s list the events we have created previously.
const endpointUrl = new URL('https://www.eventbriteapi.com/v3/organizations/{{ORGANIZATION_ID}}/events/');const headerParameters = {'Authorization': 'Bearer {{PRIVATE_TOKEN}}'};const options = {method: 'GET',headers: headerParameters,};async function listEvents() {try {const response = await fetch(endpointUrl, options);printResponse(response);} catch (error) {printError(error);}}// Calling function to make API calllistEvents();
The above API call returns a list of events, and the events count can be seen under the attribute pagination.object_count
.
Cancel an event
The Eventbrite API also provides us with the ability to cancel an event. The event to be canceled should not have any pending or completed orders. The following URL utilizes the POST
request method to cancel an event:
https://www.eventbriteapi.com/v3/events/{event_id}/cancel/
The above API call requires {event_id}
to cancel an event and returns true
or false
as a response.
const endpointUrl = new URL('https://www.eventbriteapi.com/v3/events/{{EVENT_ID}}/cancel/');const headerParameters = {'Authorization': 'Bearer {{PRIVATE_TOKEN}}','Content-Type': 'application/json'};const options = {method: 'POST',headers: headerParameters};async function cancelEvent() {try {const response = await fetch(endpointUrl, options);printResponse(response);} catch (error) {printError(error);}}// Calling function to make API callcancelEvent();
Delete an event
We can also delete an event using the Eventbrite API. The event to be deleted should not have any pending or completed orders. The following URL utilizes the DELETE
request method to delete an event:
https://www.eventbriteapi.com/v3/events/{event_id}/
The above API call requires {event_id}
to delete an event and returns true
or false
as a response.
const endpointUrl = new URL('https://www.eventbriteapi.com/v3/events/{{EVENT_ID}}/');const headerParameters = {'Authorization': 'Bearer {{PRIVATE_TOKEN}}','Content-Type': 'application/json'};const options = {method: 'DELETE',headers: headerParameters};async function deleteEvent() {try {const response = await fetch(endpointUrl, options);printResponse(response);} catch (error) {printError(error);}}// Calling function to make API calldeleteEvent();