Link Search Menu Expand Document

How To: Create a Ticket via API

This guide walks through the three steps required to create a ticket programmatically using the Tikting REST API.

Steps:

  1. Authenticate — obtain a JWT token
  2. Fetch App Metadata — retrieve system IDs (sites, departments, priorities, etc.)
  3. Register the Ticket — submit the ticket creation request

Prerequisites

Requirement Details
Base URL Your Tikting instance URL, e.g. https://your-tikting-host
Credentials A valid username and password with the Tickets.Create permission
Content-Type application/json for Step 1 · multipart/form-data for Step 3

Step 1: Authenticate

Obtain a Bearer token by posting your credentials. The token is valid for 7 days.

Request

POST https://your-tikting-host/api/Users/authenticate
Content-Type: application/json
{
  "Email": "your.username",
  "Password": "your_password",
  "RememberMe": false,
  "Domain": ""
}

Note: Domain is only required for LDAP/Active Directory accounts. Leave it empty for local accounts.

Response (200 OK)

{
  "Id": "a1b2c3d4-...",
  "Username": "your.username",
  "FirstName": "John",
  "LastName": "Doe",
  "Avatar": "https://your-tikting-host/avatars/a1b2c3d4.jpg",
  "UserSettings": { ... },
  "Token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

What to save

Value Where to use
Token Add as Authorization: Bearer <Token> header in all subsequent requests

Error Cases

Status Cause Fix
401 Unauthorized Wrong username or password Verify credentials
401 Unauthorized Account locked out Wait for lockout to expire or contact admin

Step 2: Fetch App Metadata

Retrieve the system’s lookup data to obtain valid IDs for site, department, priority, status, category, etc. These IDs are required when registering a ticket.

Request

GET https://your-tikting-host/api/TicketsApi/appmetadata
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

Response (200 OK)

{
  "groups": [
    { "id": 1, "group": "Network Team" },
    { "id": 2, "group": "Hardware Support" }
  ],
  "levels": [
    { "id": 1, "title": "Level 1" },
    { "id": 2, "title": "Level 2" }
  ],
  "priorities": [
    { "id": 1, "priority": "Low" },
    { "id": 2, "priority": "Medium" },
    { "id": 3, "priority": "High" },
    { "id": 4, "priority": "Critical" }
  ],
  "categories": [
    { "id": 10, "name": "Hardware" },
    { "id": 11, "name": "Software" },
    { "id": 12, "name": "Network" }
  ],
  "status": [
    { "id": 1, "status": "Open",     "statusType": 1 },
    { "id": 2, "status": "Pending",  "statusType": 2 },
    { "id": 3, "status": "Resolved", "statusType": 3 },
    { "id": 4, "status": "Closed",   "statusType": 4 }
  ],
  "clients": [
    { "id": 1, "name": "Acme Corp" }
  ],
  "sites": [
    { "id": 1, "title": "Head Office" },
    { "id": 2, "title": "Branch Office" }
  ],
  "departments": [
    { "id": 1, "title": "IT Department" },
    { "id": 2, "title": "Finance" },
    { "id": 3, "title": "HR" }
  ]
}

What to save

Pick the IDs that match your ticket’s context:

Field Pick from Example
SiteId sites 1 → “Head Office”
DepartmentId departments 1 → “IT Department”
TicketStatusId status 1 → “Open”
TicketPriorityId priorities 3 → “High”
TicketCategoryId categories 11 → “Software”
GroupId groups 1 → “Network Team” (optional)
TierLevelId levels 1 → “Level 1” (optional)

Step 3: Register the Ticket

Use the IDs collected in Step 2 to submit the ticket. This endpoint uses multipart/form-data.

Permission required: The authenticated user must have the Tickets.Create permission.

Request

POST https://your-tikting-host/api/TicketsApi/register
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Content-Type: multipart/form-data

Form Fields

Field Value Notes
Title Laptop screen is broken Required · max 255 chars
Description The screen cracked after a fall. Needs replacement. Required
CreatorId a1b2c3d4-... Required · User ID of the requester (from Step 1 Id, or another user’s ID)
SiteId 1 Required · from Step 2
DepartmentId 1 Required · from Step 2
TicketStatusId 1 Required · use “Open” status ID from Step 2
TicketType 1 Required · 1 = Ticket
TicketPriorityId 3 Optional · from Step 2
TicketCategoryId 10 Optional · from Step 2
GroupId 1 Optional · from Step 2
TierLevelId 1 Optional · from Step 2
Uploads (file) Optional · attach files

Example using curl

curl -X POST https://your-tikting-host/api/TicketsApi/register \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -F "Title=Laptop screen is broken" \
  -F "Description=The screen cracked after a fall. Needs replacement." \
  -F "CreatorId=a1b2c3d4-e5f6-7890-abcd-ef1234567890" \
  -F "SiteId=1" \
  -F "DepartmentId=1" \
  -F "TicketStatusId=1" \
  -F "TicketType=1" \
  -F "TicketPriorityId=3" \
  -F "TicketCategoryId=10"

Example using JavaScript (fetch)

const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."; // from Step 1

const form = new FormData();
form.append("Title",           "Laptop screen is broken");
form.append("Description",     "The screen cracked after a fall. Needs replacement.");
form.append("CreatorId",       "a1b2c3d4-e5f6-7890-abcd-ef1234567890"); // requester user ID
form.append("SiteId",          "1");
form.append("DepartmentId",    "1");
form.append("TicketStatusId",  "1");
form.append("TicketType",      "1");
form.append("TicketPriorityId","3");
form.append("TicketCategoryId","10");

const response = await fetch("https://your-tikting-host/api/TicketsApi/register", {
  method: "POST",
  headers: { "Authorization": `Bearer ${token}` },
  body: form
});

if (response.status === 201) {
  const ticket = await response.json();
  console.log("Ticket created! ID:", ticket.Id);
} else {
  console.error("Failed:", response.status, await response.text());
}

Example using C# (HttpClient)

var token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."; // from Step 1

using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", token);

var form = new MultipartFormDataContent
{
    { new StringContent("Laptop screen is broken"),                              "Title"             },
    { new StringContent("The screen cracked after a fall. Needs replacement."), "Description"       },
    { new StringContent("a1b2c3d4-e5f6-7890-abcd-ef1234567890"),                "CreatorId"         },
    { new StringContent("1"),                                                    "SiteId"            },
    { new StringContent("1"),                                                    "DepartmentId"      },
    { new StringContent("1"),                                                    "TicketStatusId"    },
    { new StringContent("1"),                                                    "TicketType"        },
    { new StringContent("3"),                                                    "TicketPriorityId"  },
    { new StringContent("10"),                                                   "TicketCategoryId"  }
};

var response = await client.PostAsync(
    "https://your-tikting-host/api/TicketsApi/register", form);

if (response.StatusCode == HttpStatusCode.Created)
{
    var body = await response.Content.ReadAsStringAsync();
    Console.WriteLine($"Ticket created: {body}");
}

Response (201 Created)

{
  "id": 1042,
  "title": "Laptop screen is broken",
  "description": "The screen cracked after a fall. Needs replacement.",
  "siteId": 1,
  "departmentId": 1,
  "ticketStatusId": 1,
  "ticketPriorityId": 3,
  ...
}

The response also includes a Location header pointing to the new ticket:

Location: https://your-tikting-host/api/TicketsApi/1042

Use this URL (or the returned id) to fetch, update, or track the ticket going forward.

Error Cases

Status Cause Fix
400 Bad Request Missing required field (Title, Description, CreatorId, SiteId, DepartmentId, TicketStatusId, TicketType) Include all required fields
400 Bad Request CreatorId does not match any user in the system Use a valid user ID
400 Bad Request Invalid SiteId or DepartmentId Use IDs from the metadata response
400 Bad Request (no Tickets.Create claim) Authenticated user lacks the create permission Use an account with the correct role/permission
401 Unauthorized Token missing or expired Re-authenticate (Step 1) and retry

Complete Flow Summary

┌─────────────────────────────────────────────────────────────┐
│  Step 1 — Authenticate                                      │
│  POST /api/Users/authenticate                               │
│  Body: { Email, Password }                                  │
│  ► Save: Token                                              │
└────────────────────────────┬────────────────────────────────┘
                             │ Bearer Token
                             ▼
┌─────────────────────────────────────────────────────────────┐
│  Step 2 — App Metadata                                      │
│  GET /api/TicketsApi/appmetadata                            │
│  Header: Authorization: Bearer <Token>                      │
│  ► Save: SiteId, DepartmentId, TicketStatusId,              │
│          TicketPriorityId, TicketCategoryId, etc.           │
└────────────────────────────┬────────────────────────────────┘
                             │ Bearer Token + IDs
                             ▼
┌─────────────────────────────────────────────────────────────┐
│  Step 3 — Register Ticket                                   │
│  POST /api/TicketsApi/register                              │
│  Header: Authorization: Bearer <Token>                      │
│  Body (multipart/form-data):                                │
│    Title, Description, CreatorId,                           │
│    SiteId, DepartmentId, TicketStatusId,                    │
│    TicketType, + optional fields                            │
│  ► Response: 201 Created + Ticket ID                        │
└─────────────────────────────────────────────────────────────┘

See Also