Skip to main content

Swapping

Swapping tickets​

After checking the validity of the barcode as shown in the previous section, the ticket for which the barcode was issued can be swapped. The swap of a ticket is contained within a single endpoint. For this, you need the following information:

  • barcode: the original issued barcode of the ticket.
  • firstname: the first name of the resale customer.
  • lastname: the last name of the resale customer.
  • email: the email of the resale customer.

Use this information to create a POST request to https://api.openticket.tech/ticketswap/swap. The following code block shows some examples of such a request.

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $accessToken"
],
CURLOPT_POSTFIELDS => [
"ticket" => [
"barcode" => "TTZ2PM9NGRJXAUTWHHW"
],
"customer" => [
"firstname" => "John",
"lastname" => "Appleseed",
"email" => "john.appleseed@example.com"
]
],
CURLOPT_URL => "https://api.openticket.tech/ticketswap/swap"
]);

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

echo $response;
This request results in the following response
{
"valid": true,
"barcode": "THYWNZYQC7RT3B1",
"retrievable_after": 0,
"pdf": "vnxx752bzs4qqpsejpjuj69xi3sdqm3fw34w8qny6szuxdw8h7qa5qyqeageynj54kpoa3c884ujh3ri97nv2m6f8d3fiekyyrup7op8fby86wdodqyt5tmbq4bokhw9"
}
note

The ​OpenTicket system will not swap a ticket when the provided barcode is invalid.

Fetching PDFs​

After swapping a ticket, a new PDF with the reissued barcode will be generated for the resale customer. The pdf field in the swap response lists the location of the PDF in the ​OpenTicket system. To fetch the newly generated PDF, make a GET request to https://api.openticket.tech/ticketswap/pdf/:pdf. The following code block shows some examples of such a request.

$curl = curl_init();

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

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

echo $response;

The response to this request is a 202 ACCEPTED if the PDF is still being generated. Otherwise, the ​OpenTicket system will redirect you to the contents of the PDF.