Skip to main content

Creating tickets

Creating tickets​

You can use the resources set up in the previous section to create a ticket. For this, you need the following information:

  • eventGUID: GUID of the event for which the ticket will be created.
  • name: the name for the ticket.
  • vat_percentage: the vat percentage that must apply to the ticket.

You can add more details to the event later, as will be described in updating a ticket. First, use the required information to create a POST request to https://api.openticket.tech/event/:eventGUID/ticket. See the following code blocks for examples of such requests and the expected response to the requests.

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $accessToken"
],
CURLOPT_POSTFIELDS => [
"name" => "Gold circle",
"vat_percentage" => "21"
],
CURLOPT_URL => "https://api.openticket.tech/event/$eventGUID/ticket"
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
This request results in the following response
{
"increment": 1,
"min_orderable_amount_per_order": 1,
"max_orderable_amount_per_order": 20,
"availability_margin": 0,
"percentage_service_costs_in_ticket": 0,
"swappable": true,
"name": "Gold circle",
"vat_percentage": 21,
"event_id": "68096ad5-2eb7-45fb-977d-931b3485fe30",
"company_id": "d0a3f370-cd43-11ed-9c9c-bbcffde24a48",
"guid": "1b3760ca-c999-4b24-8e51-ea4ab4552957",
"updated_at": "2023-10-02T13:19:32+02:00",
"created_at": "2023-10-02T13:19:32+02:00",
"status": null,
"seated": false,
"include_service_cost_in_price": false,
"reserved_count": 0,
"pending_count": 0
}

A ticket is created through the /event endpoint, and not the /ticket endpoint. This is the case as a ticket can only be created if there is an event for which it can be created.

Getting tickets​

After you created a ticket, you can retrieve the information stored in this resource. To do this, make a GET request to https://api.openticket.tech/ticket/:GUID. You can also make a GET request to https://api.openticket.tech/ticket to list all ticket resources currently stored in the ​OpenTicket system.

caution

Use the deprecated https://api.openticket.tech/ticket endpoint with caution.

A better way to retrieve all ticket resources is through the event they belong to. For this, you need the following information:

  • eventGUID: the GUID of an event.

Use the required information to create a GET request to https://api.openticket.tech/event/:GUID/ticket. See the following code blocks for examples of such requests and the expected response to the requests.

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $accessToken"
],
CURLOPT_URL => "https://api.openticket.tech/event/$eventGUID/ticket"
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
This request results in the following response
[
{
"guid": "1b3760ca-c999-4b24-8e51-ea4ab4552957",
"company_id": "d0a3f370-cd43-11ed-9c9c-bbcffde24a48",
"event_id": "68096ad5-2eb7-45fb-977d-931b3485fe30",
"name": "Gold circle",
"description": null,
"min_price": null,
"vat_percentage": 21,
"late_personalization": false,
"status_overrule": "auto",
"barcode_type": "generate",
"class": null,
"available_stock": 0,
"sold_count": 0,
"scanned_count": 0,
"increment": 1,
"available_from": null,
"available_until": null,
"availability_margin": 0,
"min_orderable_amount_per_order": 1,
"max_orderable_amount_per_order": 20,
"percentage_service_costs_in_ticket": 0,
"seats_category_key": null,
"available_in_cashr": false,
"hide_without_coupon": false,
"combines_products": true,
"swappable": true,
"created_at": "2023-10-02T13:19:32+02:00",
"updated_at": "2023-10-02T13:19:32+02:00",
"deleted_at": null,
"status": "available",
"seated": false,
"include_service_cost_in_price": false,
"reserved_count": 0,
"pending_count": 0
}
]

Updating a ticket​

The response of the GET-request shows that the created ticket still contains a lot of undefined information. However, as opposed to event resources where only a small amount of the information was relevant, a ticket has a lot of fields that provide essential information or heavily influence how users interact with tickets. It is useful to refer to the API reference to see what all these fields entail.

To update a ticket, you need to following information:

  • GUID: the GUID of the ticket.

Use the required information to make a PUT request to https://api.openticket.tech/ticket/:GUID. This request should contain a payload containing the information that should be updated. Any information that can be associated with a ticket but that is not contained in the payload is left unchanged. See the following code blocks for examples of such requests and the expected response to the requests. In these example requests, the description and swappable of a ticket are updated.

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $accessToken"
],
CURLOPT_POSTFIELDS => http_build_query([
"description" => "Front row seats in the Hertog Jan Zaal",
"swappable" => false
]),
CURLOPT_URL => "https://api.openticket.tech/ticket/$GUID"
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
This request results in the following response
{
"guid": "1b3760ca-c999-4b24-8e51-ea4ab4552957",
"company_id": "d0a3f370-cd43-11ed-9c9c-bbcffde24a48",
"event_id": "68096ad5-2eb7-45fb-977d-931b3485fe30",
"name": "Gold circle",
"description": "Front row seats in the Hertog Jan Zaal",
"min_price": null,
"vat_percentage": 21,
"late_personalization": false,
"status_overrule": "auto",
"barcode_type": "generate",
"class": null,
"available_stock": 0,
"sold_count": 0,
"scanned_count": 0,
"increment": 1,
"available_from": null,
"available_until": null,
"availability_margin": 0,
"min_orderable_amount_per_order": 1,
"max_orderable_amount_per_order": 20,
"percentage_service_costs_in_ticket": 0,
"seats_category_key": null,
"available_in_cashr": false,
"hide_without_coupon": false,
"combines_products": true,
"swappable": true,
"created_at": "2023-10-02T13:19:32+02:00",
"updated_at": "2023-10-02T13:21:06+02:00",
"deleted_at": null,
"status": "available",
"seated": false,
"include_service_cost_in_price": false,
"reserved_count": 0,
"pending_count": 0
}