Tickets

Create tickets

Basic ticket

If a ticket is created by a user you can run the following code:

<?php
use Deskpro\API\DeskproClient;
use Deskpro\API\Exception\APIException;

include (__DIR__ . '/vendor/autoload.php');

$client = new DeskproClient('http://deskpro.company.com');

$client->setAuthKey(1, 'dev-admin-code');

try {
    $payload = [
        'agent' => 1,
        'person' => 'joe@deskprodemo.com',
        'subject' => 'Test ticket',
        'message' => [
            'message' => 'Test message'
        ]
    ];
    $resp = $client->post('/tickets', $payload);
    print_r($resp->getData());
    print_r($resp->getMeta());
} catch (APIException $e) {
    echo $e->getMessage();
}

Checking if the user exists

If you are unsure the user that creates the ticket exists in Deskpro, you can run this code to check for it and create it otherwise:

Ticket with custom fields

To fill custom fields you need to know the field ID and its value ID in case of a choice input. Those IDs can be found in the admin section by clicking the cog icon then Show IDs

Ticket with labels

Ticket with CC's

Ticket with attachments

To post a message with an attachment, you need:

  • First to post the attachment and create a blob.

  • Then create the ticket

  • And finally add a message to this ticket with the attachement

Get Tickets

Tickets from a user

Update a ticket

Modify a ticket

Add a reply to a ticket

Last updated