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.weeztix.com/event/:eventGUID/ticket. See the following
code blocks for examples of such requests and the expected response to the requests.
- PHP
- GO
- Node
- Shell
$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.weeztix.com/event/$eventGUID/ticket"
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
payloadBuf := new(bytes.Buffer)
json.NewEncoder(payloadBuf).Encode({
"name": "Gold circle",
"vat_percentage": "21"
})
req, _ := http.NewRequest("PUT", "https://api.weeztix.com/event/" + eventGUID + "/ticket", bytes.NewBuffer(body))
req.Header.Add("Authorization", "Bearer " + accessToken)
resp, _ := http.DefaultClient.Do(req)
respBody, _ := io.ReadAll(resp.Body)
fmt.Println(string(respBody))
const options = {
"method": "POST",
"headers": {
"Authorization": `Bearer ${accessToken}`,
"Content-Type": "application/json"
},
"body": JSON.stringify({
"name": "Gold circle",
"vat_percentage": "21"
})
};
fetch(`https://api.weeztix.com/event/${eventGUID}/ticket`, options)
.then(response => response.json())
.then(response => console.log(response))
curl -X POST \
-H "Authorization: Bearer $accessToken" \
-F "name=Gold circle" \
-F "vat_percentage=21" \
"https://api.weeztix.com/event/$eventGUID/ticket"
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.weeztix.com/ticket/:GUID. You can also make
a GET request to https://api.weeztix.com/ticket to list all ticket
resources currently stored in the Weeztix system.
Use the deprecated https://api.weeztix.com/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.weeztix.com/event/:GUID/ticket. See the following code blocks
for examples of such requests and the expected response to the requests.
- PHP
- GO
- Node
- Shell
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $accessToken"
],
CURLOPT_URL => "https://api.weeztix.com/event/$eventGUID/ticket"
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
req, _ := http.NewRequest("PUT", "https://api.weeztix.com/event/" + eventGUID + "/ticket", bytes.NewBuffer(body))
req.Header.Add("Authorization", "Bearer " + accessToken)
resp, _ := http.DefaultClient.Do(req)
respBody, _ := io.ReadAll(resp.Body)
fmt.Println(string(respBody))
const options = {
"method": "GET",
"headers": {
"Authorization": `Bearer ${accessToken}`
}
};
fetch(`https://api.weeztix.com/event/${eventGUID}/ticket`, options)
.then(response => response.json())
.then(response => console.log(response))
curl -X GET \
-H "Authorization: Bearer $accessToken" \
"https://api.weeztix.com/event/$eventGUID/ticket"
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.weeztix.com/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.
- PHP
- GO
- Node
- Shell
$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.weeztix.com/ticket/$GUID"
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
payloadBuf := new(bytes.Buffer)
json.NewEncoder(payloadBuf).Encode({
"description": "Front row seats in the Hertog Jan Zaal",
"swappable": false
})
req, _ := http.NewRequest("PUT", "https://api.weeztix.com/ticket/" + GUID, bytes.NewBuffer(body))
req.Header.Add("Authorization", "Bearer " + accessToken)
resp, _ := http.DefaultClient.Do(req)
respBody, _ := io.ReadAll(resp.Body)
fmt.Println(string(respBody))
const options = {
"method": "PUT",
"headers": {
"Authorization": `Bearer ${accessToken}`,
"Content-Type": "application/json"
},
"body": JSON.stringify({
"description": "Front row seats in the Hertog Jan Zaal",
"swappable": false
})
};
fetch(`https://api.weeztix.com/ticket/${GUID}`, options)
.then(response => response.json())
.then(response => console.log(response))
curl -X PUT \
-H "Authorization: Bearer $accessToken" \
-d "description=Front%20row%20seats%20in%20the%20Hertog%20Jan%20Zaal" \
-d "swappable=false" \
"https://api.weeztix.com/ticket/$GUID"
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
}