Open ticket

Open a new ticket


Endpoint


Method URI
POST https://apiv2.keliweb.it/api/v2/keliweb/open-ticket

Request Parameters


Parameter Type Description Required
HTTP headers: Authorization string Bearer + the token to access APIs Required
deptid integer The department to open the ticket in Required
subject string The subject of the ticket Required
message string The message of the ticket Required
contactid integer If applicable, the Contact ID to create the ticket for (only if $clientid is passed). Optional
name string The name of the person opening the ticket (if not a client) Optional
email string The email address of the person opening the ticket (if not a client) Optional
serviceid integer The service to associate the ticket with (only one of $serviceid or $domainid) Optional
domainid integer The domain to associate the ticket with (only one of $serviceid or $domainid) Optional
markdown boolean Should markdown be used on the ticket output Optional
customfields string Base64 encoded serialized array of custom field values Optional
attachments array Optional base64 json encoded array of file attachments. Can be the direct output of a multipart-form-data form submission ($_FILES superglobal in PHP) or an array of arrays consisting of both a filename and data keys (see example below). Optional

Response Parameters


Parameter Type Description
result string The result of the operation: success or error

Example Request (PHP Curl)

            

                    $curl = curl_init();
                    
                    curl_setopt_array($curl, array(
                      CURLOPT_URL => "https://apiv2.keliweb.it/api/v2/keliweb/open-ticket",
                      CURLOPT_RETURNTRANSFER => true,
                      CURLOPT_ENCODING => "",
                      CURLOPT_MAXREDIRS => 10,
                      CURLOPT_TIMEOUT => 0,response
                      CURLOPT_FOLLOWLOCATIOresponseN => false,
                      CURLOPT_HTTP_VERSION response=> CURL_HTTP_VERSION_1_1,
                      CURLOPT_CUSTOMREQUEST => "POST",
                      CURLOPT_POSTFIELDS =>
                        http_build_query(
                                array(
                                    'deptid'      => '1',
                                    'subject'     => 'This is a sample ticket',
                                    'message'     => 'This is a **sample** ticket message',
                                    'clientid'    => '1',
                                    'priority'    => 'Medium',
                                    'markdown'    => true,
                                    'attachments' => base64_encode(json_encode([['name' => 'sample_text_file.txt', 'data' => base64_encode('This is a sample text file contents')]]))
                                )
                            ),
                      CURLOPT_HTTPHEADER => array(
                        "Content-Type: multipart/form-data",
                        "X-Requested-With: XMLHttpRequest",
                        "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NhMmNlNkNjNhMmU2MmUxIzZDRkODY5MS1mMDMzLTQ1MWMtYjU-3EHc",
                      ),
                    ));
                    
                    $response = curl_exec($curl);
                    $err = curl_error($curl);
                    
                    curl_close($curl);
                    
                    if ($err) {
                      echo "cURL Error #:" . $err;
                    } else {
                      echo $response;
                    }

            
        

Example Request (jQuery AJAX)

            
                    var form = new FormData();
                    form.append("deptid", "1");
                    form.append("subject", "This is a sample ticket");
                    form.append("message", "This is a **sample** ticket message");
                    form.append("clientid", "1");
                    form.append("priority", "Medium");
                    form.append("markdown", true);
                    form.append("attachments", "[]");

                    var settings = {
                        "async": true,
                        "crossDomain": true,
                        "url": "https://apiv2.keliweb.it/api/v2/keliweb/open-ticket",
                        "method": "POST",
                        "headers": {
                            "Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImNjMDEwYWVlYmUzMjMxMmZlZjBiNzRjYTBhMmNlNDc2MjNjNhMMTA1MzJjODk1In0",
                            "cache-control": "no-cache",
                        },
                        "processData": false,
                        "contentType": false,
                        "mimeType": "multipart/form-data",
                        "data": form
                    }

                    $.ajax(settings).done(function (response) {
                        console.log(response);
                    });
            
        

Example Response (JSON payload)

            
                {
                    "result": "success",
                    "id"    : "1",
                    "tid"   : "516757",
                    "c"     : "KPqH7yG3"
                }