Create ticket


Create ticket with HTTP POST request.

POST

/tickets/

Data
Type
Description
description (required)
string
Ticket description
status (default = draft)
string
One of: draft, active, closed, archived
custom_id (unique)
string
Optional field to set custom id
participants (read only)
array of integers
Ids of related client users
due_date / closed_at
datetime
curl -X POST \
  https://<your_app_subdomain>.user.com/api/public/tickets/ \
  -H 'Authorization: Token <your_64_char_api_key>' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "New Ticket",
    "custom_id": "new-ticket",
    "description": "Example from REST API",
    "status": "draft",
    "due_date": "2020-11-25T00:00:00Z",
    "assigned_to": 1,
    "person": 123,
    "company": 134,
    "participants": [1, 2, 3],
    "priority": 1
}'

Response

{
    "id": 53,
    "attributes": [],
    "status_history": [
        {
            "entered_at": "2019-12-20T12:23:38.718116+00:00",
            "status": "draft"
        }
    ],
    "created_at": "2019-12-20T12:28:55.123270Z",
    "updated_at": "2019-12-20T12:28:55.123355Z",
    "serialized_attributes": [],
    "custom_id": "my custom id",
    "status": "draft",
    "token": "some-token",
    "name": "my ticket",
    "description": "my description",
    "due_date": "2019-12-20T12:25:05.555624Z",
    "closed_at": "2019-12-20T12:25:05.555624Z",
    "attachments": null,
    "assigned_to": 1,
    "person": null,
    "company": 1,
    "priority": 1,
    "participants": []
}
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://<your_app_subdomain>.user.com/api/public/tickets/",
  "method": "POST",
  "headers": {
    "authorization": "Token <your_64_char_api_key>",
    "content-type": "application/json"
  },
  "data": "{
    "name": "New Ticket",
    "custom_id": "new-ticket",
    "description": "Example from REST API",
    "status": "draft",
    "due_date": "2020-11-25T00:00:00Z",
    "assigned_to": 1,
    "person": 123,
    "company": 134,
    "participants": [1, 2, 3],
    "priority": 1
  }"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var data = JSON.stringify({
        "name": "New Ticket",
        "custom_id": "new-ticket",
        "description": "Example from REST API",
        "status": "draft",
        "due_date": "2020-11-25T00:00:00Z",
        "assigned_to": 1,
        "person": 123,
        "company": 134,
        "participants": [1, 2, 3],
        "priority": 1
    }"

});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://<your_app_subdomain>.user.com/api/public/tickets/");
xhr.setRequestHeader("authorization", "Token <your_64_char_api_key>");
xhr.setRequestHeader("content-type", "application/json");

xhr.send(data);
var request = require("request");

var options = { method: 'POST',
  url: 'https://<your_app_subdomain>.user.com/api/public/tickets/',
  headers: {
    'content-type': 'application/json',
    authorization: 'Token <your_64_char_api_key>'
  },
  form: {
    "name": "New Ticket",
    "custom_id": "new-ticket",
    "description": "Example from REST API",
    "status": "draft",
    "due_date": "2020-11-25T00:00:00Z",
    "assigned_to": 1,
    "person": 123,
    "company": 134,
    "participants": [1, 2, 3],
    "priority": 1
  }"
  json: true };
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_PORT => "8000",
  CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/tickets/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\n\t\"name\": \"my ticket\",\n\t\"custom_id\": \"my custom id\",\n\t\"status\": \"draft\",\n\t\"token\": \"some-token\",\n\t\"description\": \"my description\",\n\t\"due_date\": \"2019-12-20T12:25:05.555624Z\",\n\t\"closed_at\": \"2019-12-20T12:25:05.555624Z\",\n\t\"priority\": 1,\n\t\"assigned_to\": 1,\n\t\"company\": 1\n}",  CURLOPT_HTTPHEADER => array(
    "Authorization: Token <your_64_char_api_key>",
    "Content-Type: application/json",
    "Postman-Token: 4536e8ad-8801-4f25-80bb-aaa1343642ee",
    "cache-control: no-cache"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import requests

url = "https://<your_app_subdomain>.user.com/api/public/tickets/"

payload = "{
    "name": "New Ticket",
    "custom_id": "new-ticket",
    "description": "Example from REST API",
    "status": "draft",
    "due_date": "2020-11-25T00:00:00Z",
    "assigned_to": 1,
    "person": 123,
    "company": 134,
    "participants": [1, 2, 3],
    "priority": 1
}"
headers = {
    'Authorization': "Token YxMAaMr0ly4VtE5nvQdzxtALSLnHDWtUuvx4FI54oWnQEgJmJ088kktucqMAmfwD",
    'Content-Type': "application/json",
    'cache-control': "no-cache",
    'Postman-Token': "c82439d4-21c5-4e5d-9747-fa1a7525667c"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)