API¶
This page documents the HTTP API in Traq 3.9, based on the routes and controllers in the 3.9 source.
Traq has no separate API application. There are two groups of JSON endpoints:
- Dedicated endpoints under
/api/…that always return JSON. - Regular pages that also return JSON when you ask for it (the same URLs the web UI uses).
Warning
The API is currently being refactored to be RESTful. Endpoints, request formats and response shapes described here may change in a future release.
Note
Examples use https://traq.example.com. If Traq is installed in a
subdirectory, include it in the base URL. {project} in a path is the
project slug.
Authentication¶
Generate an API key from your User CP (/usercp, "Create API key"). Send it in
the X-API-Key header, optionally prefixed with Bearer:
curl -H "X-API-Key: YOUR_KEY" https://traq.example.com/api/auth
curl -H "X-API-Key: Bearer YOUR_KEY" https://traq.example.com/api/auth
Requests made with a valid key act as that user, with that user's group and project permissions. Without a key (or session cookie) you are the guest user, so public projects are readable without authentication.
Requests authenticated with an API key are treated as API requests. Some endpoints below return JSON for any JSON request, and some only for API requests. The latter are marked API key in the tables.
Requesting JSON¶
A regular (non-/api) URL returns JSON if any of these is true:
- The path ends in
.json, e.g./projects.json - The
Acceptheader is exactlyapplication/json - The request is authenticated with an API key
A few project pages (/{project}, the roadmap and milestone pages) only check
for the .json extension or an API key, not the Accept header.
Methods and request bodies¶
Routes are registered per HTTP method, so a path only answers the methods listed
for it; any other method returns 404. Reads are GET, creates are POST to
the collection, updates are PUT to the item and deletes are DELETE.
Request bodies are read from PHP's $_POST, so send form-encoded
(application/x-www-form-urlencoded or multipart/form-data) data. Query
string parameters are also accepted by most actions.
Sending PUT
PHP doesn't fill $_POST for a real PUT request, so the body would be
ignored. To update something, send a POST with an extra _method=PUT
field, the same way the web forms do:
curl -X POST -H "X-API-Key: KEY" \
-d "_method=PUT" -d "name=Backend" \
https://traq.example.com/traq/settings/components/3
DELETE requests don't need a body, so a real DELETE works (or POST
with _method=DELETE).
Two endpoints read a raw JSON body instead:
POST /api/search and POST /{project}/tickets/{id}/related-tickets.
Responses and errors¶
- JSON responses use
Content-Type: application/json. - The keys
password,login_hash,api_keyandprivate_keyare stripped from every JSON response. - Validation failures when creating a ticket return
422with{"errors": …}. - Permission failures return
403({"error": "…"}) when the request hasAccept: application/json, otherwise an HTML error page. Some legacy paths return401HTML. - A missing project returns
404; a project you can'tviewreturns403. - Dates are
YYYY-MM-DD HH:MM:SSstrings as stored in the database. - Many write endpoints redirect instead of returning JSON unless the request is an API request, as noted below.
Dedicated /api endpoints¶
All are GET except search, and all return JSON. Endpoints with a project slug
require the view permission for that project.
| Endpoint | Description |
|---|---|
/api/auth |
Current user, or false if not authenticated |
/api/auth/{project} |
Same, plus the user's permissions in that project |
/api/types |
All ticket types |
/api/types/{id} |
One ticket type |
/api/statuses |
All ticket statuses |
/api/priorities |
All ticket priorities |
/api/{project}/components |
Project components |
/api/{project}/custom-fields |
Project custom fields |
/api/{project}/members |
Project members and roles |
POST /api/search |
Search tickets and milestones (JSON body) |
GET /api/auth¶
{
"id": 1,
"username": "jack",
"name": "Jack",
"group_id": 1,
"locale": "enUS",
"group": { "id": "1", "name": "Admin", "is_admin": true },
"permissions": {}
}
permissions is only populated on /api/auth/{project}, and only contains
permissions that are granted, as { "action": true }. Returns false when
there is no authenticated user.
Types, statuses, priorities¶
// /api/types
[{ "id": 1, "name": "Defect", "bullet": "-", "changelog": 1, "template": "" }]
// /api/statuses
[{ "id": 1, "name": "New", "status": 1, "changelog": true }]
// /api/priorities
[{ "id": 1, "name": "Highest" }]
For statuses, status is the status type: 0 closed, 1 open, 2 started.
GET /api/{project}/components¶
[{ "id": 1, "name": "Core", "project_id": 1 }]
GET /api/{project}/custom-fields¶
[{
"id": 3,
"name": "Browser",
"slug": "browser",
"type": "select",
"is_required": false,
"min_length": 0,
"max_length": 255,
"multiple": false,
"regex": null,
"values": ["Firefox", "Chrome"],
"default_value": null,
"ticket_type_ids": [1]
}]
values is an array for select fields. ticket_type_ids contains 0 when
the field applies to all ticket types. See Custom Fields.
GET /api/{project}/members¶
[{ "id": 2, "username": "sam", "name": "Sam", "role": "Developer" }]
POST /api/search¶
Body is raw JSON.
| Field | Type | Description |
|---|---|---|
query |
string | Required. Matched with LIKE %query% against ticket summaries and milestone names |
project |
string | Optional project slug to limit the search |
Results are limited to 25 tickets and 25 milestones, only from projects the user can view.
curl -X POST -H "X-API-Key: KEY" -d '{"query":"crash","project":"traq"}' \
https://traq.example.com/api/search
{
"tickets": [
{ "ticket_id": 12, "summary": "Crash on save", "project": { "name": "Traq", "slug": "traq" } }
],
"milestones": [
{ "name": "3.9", "codename": null, "slug": "3.9", "project": { "name": "Traq", "slug": "traq" } }
]
}
Projects and milestones¶
| Method | Path | Returns |
|---|---|---|
| GET | /projects |
Array of all projects |
| GET | /{project}.json |
The project |
| GET | /{project}/roadmap.json |
Array of milestones (default: active ones) |
| GET | /{project}/roadmap/{completed\|all\|cancelled}.json |
Filtered milestones |
| GET | /{project}/milestone/{slug}.json |
One milestone |
/projects needs .json, Accept: application/json or an API key to return
JSON. The others need .json or an API key.
Project fields: id, name, slug, codename, info, enable_wiki,
default_ticket_type_id, default_ticket_sorting, displayorder.
Milestone fields: id, name, slug, codename, info, changelog, due,
completed_on, status, is_locked, project_id, displayorder. Milestone
status is 1 active, 2 completed, 0 cancelled.
Tickets¶
| Method | Path | Purpose |
|---|---|---|
| GET | /{project}/tickets |
List tickets |
| POST | /{project}/tickets |
Create a ticket |
| GET | /{project}/tickets/{id} |
View a ticket |
| POST / PUT | /{project}/tickets/{id} |
Update a ticket |
| DELETE | /{project}/tickets/{id} |
Delete a ticket |
| POST | /{project}/tickets/{id}/edit |
Edit the description |
| POST | /{project}/tickets/{id}/move |
Move to another project |
| POST | /{project}/tickets/mass-actions |
Update many tickets |
| GET, POST | /{project}/tickets/{id}/vote |
Vote |
| GET, POST | /{project}/tickets/{id}/related-tickets |
Read / replace related tickets |
| POST | /{project}/tickets/{id}/tasks/{task_id} |
Toggle a task |
| DELETE | /{project}/tickets/{id}/history/{history_id} |
Delete a history entry |
GET /{project}/tickets¶
Requires view_tickets. Returns a page of tickets.
{
"page": 1,
"total_pages": 3,
"tickets": [
{
"ticket_id": 12,
"summary": "Crash on save",
"user_id": 2,
"assigned_to_id": null,
"votes": 0,
"created_at": "2026-01-01 12:00:00",
"updated_at": null,
"is_closed": 0,
"owner": "Sam",
"assignee": null,
"type": "Defect",
"milestone": "3.9",
"milestone_slug": "3.9",
"version": null,
"version_slug": null,
"component": "Core",
"status": "New",
"status_id": 1,
"priority": "Normal",
"priority_id": 3,
"severity": "Normal",
"severity_id": 4,
"project_id": 1,
"project_slug": "traq"
}
]
}
Custom fields are added to each ticket under their slug. Page size is the
tickets_per_page setting.
Query parameters
| Parameter | Description |
|---|---|
page |
Page number (default 1) |
order_by |
field.direction, e.g. created_at.desc. Defaults to the project's default sorting |
| any filter field | Filter, see below |
Sortable fields: ticket_id, summary, votes, created_at, updated_at,
owner (or user), assigned_to, milestone, component, type, status,
priority, severity, plus custom field slugs. Direction is asc or desc.
Filterable fields:
| Field | Matching |
|---|---|
q |
Search ticket summary and ticket ID (contains) |
summary, description, owner |
Contains |
milestone, version |
Exact, by slug |
status, type, component, priority, severity, assigned_to |
Exact, by name |
status_type |
Status type: 0 closed, 1 open, 2 started |
| custom field slugs | Contains |
Multiple values are comma separated (status=New,Open); prefix the value with
! to negate (type=!Task). * is a wildcard in "contains" filters. For
status the special values allopen, allclosed and allstarted match by
status type. Unknown parameters are ignored.
curl -H "X-API-Key: KEY" \
"https://traq.example.com/traq/tickets?status=allopen&milestone=3.9&order_by=updated_at.desc"
POST /{project}/tickets¶
Creates a ticket. Requires create_tickets. For API requests it returns
{"ticket": {…}}. A failed validation returns 422 with {"errors": …} for
any JSON request. Without an API key a successful create redirects to the new
ticket.
Form fields:
| Field | Notes |
|---|---|
summary |
Required |
description |
Ticket body |
type |
Type ID (default 1) |
milestone, version, component, assigned_to |
IDs; 0 for none |
severity (default 4), priority (default 3), status (default 1) |
IDs |
tasks |
JSON-encoded array of {"task": "…", "completed": false} |
time_proposed, time_worked |
Strings |
custom_fields[{field_id}] |
Custom field values, keyed by field ID |
Each property beyond summary, description and type requires the matching
ticket_properties_set_* permission, otherwise it is ignored. Non-admin users
are subject to the ticket creation delay.
GET /{project}/tickets/{ticket_id}¶
Requires view_tickets.
{
"ticket": { "id": 12, "ticket_id": 12, "summary": "…", "body": "…", "type": {"id": 1, "name": "Defect"}, "…": "…" },
"attachments": [ { "id": 1, "name": "log.txt", "type": "text/plain", "size": 120, "user_id": 2, "ticket_id": 5, "created_at": "…" } ],
"ticketHistory": [ { "id": 1, "user_id": 2, "ticket_id": 5, "changes": [], "comment": "…", "created_at": "…" } ]
}
Ticket objects have project, user, assigned_to, milestone, version,
component, status, priority, severity and type expanded to
{id, name} objects (users also include username), plus votes, tasks,
extra, time_proposed, time_worked, is_closed, created_at,
updated_at. Attachment contents are not included.
POST /{project}/tickets/{ticket_id}¶
Updates a ticket (PUT also works, see Sending PUT).
Requires update_tickets. Any JSON request returns {"ticket": {…}}, otherwise
it redirects to the ticket.
Fields: summary, type, milestone, version, component, severity,
priority, status, assigned_to, tasks, time_proposed, time_worked,
custom_fields[…], comment, and a file upload attachment.
Each property needs the matching ticket_properties_change_* permission;
omitted fields keep their current value. Attachments need add_attachments.
DELETE /{project}/tickets/{ticket_id}¶
Requires delete_tickets. Redirects to the ticket list; no JSON body is returned.
POST /{project}/tickets/{ticket_id}/edit¶
Replaces the ticket description with the body field. Requires
edit_ticket_description. Redirects; no JSON body is returned.
POST /{project}/tickets/{ticket_id}/move¶
Requires move_tickets and create_tickets in the destination project. API
requests must be POST (a GET returns 400 {"error": "POST required"}).
| Field | Description |
|---|---|
project_id |
Destination project ID |
milestone_id, version_id, component_id, assigned_to_id |
Optional values in the destination project |
Returns {"success": true, "project": "new-slug", "ticket_id": 7}.
POST /{project}/tickets/mass-actions¶
Requires update_tickets and perform_mass_actions. Fields: tickets (array
of ticket IDs, or JSON string), type, milestone, version, component,
severity, priority, status, assigned_to (value -1 or omitted means
"don't change"), and comment. Returns {"success": true} for .json and API
requests, otherwise redirects.
Votes¶
GET or POST /{project}/tickets/{ticket_id}/vote casts a vote for the
current user. Requires vote_on_tickets. You can't vote on your own ticket.
For JSON requests it returns {"votes": 3} on success, or
{"error": "…"} if you have already voted.
Related tickets¶
Both methods require ticket_properties_change_related_tickets.
GET /{project}/tickets/{ticket_id}/related-tickets:
{ "related_tickets": [], "relation_types": [{ "id": 1, "name": "Relates to", "inverse_type_id": 1 }] }
POST with a JSON body {"related_tickets": [{"ticket_id": 3, "relation_type_id": 2}]}
replaces the set of related tickets (existing relations missing from the list
are removed) and returns the same structure as GET.
Built-in relation types: 1 Relates to, 2 Blocks, 3 Is Blocked By, 4 Duplicates, 5 Is Duplicated By, 6 Contains, 7 Is Contained By.
Tasks¶
POST /{project}/tickets/{ticket_id}/tasks/{task_id} toggles a task's
completed state. Needs ticket_properties_complete_tasks. Returns
{"success": true}, or {"success": false} if you lack permission.
Ticket history and attachments¶
| Method | Path | Notes |
|---|---|---|
| DELETE | /{project}/tickets/{id}/history/{history_id} |
Needs delete_ticket_history. {"success": true} for JSON requests, otherwise redirects |
| GET | /attachments/{id}/{filename} |
Downloads an attachment (not JSON) |
| DELETE | /attachments/{id}/{filename} |
{"success": true} for JSON requests, otherwise redirects. 500 on failure |
Editing a history entry (GET/POST …/history/{history_id}/edit) is a web form
only.
Timeline¶
DELETE /{project}/timeline/{event_id} removes a timeline event. Needs
delete_timeline_events (otherwise 403 {"success": false}). Returns
{"success": true} for JSON requests, otherwise redirects.
Wiki¶
| Method | Path | Returns |
|---|---|---|
| GET | /{project}/wiki |
{"page": {…}} (main page) |
| GET | /{project}/wiki/_pages |
{"pages": […]} |
| GET | /{project}/wiki/{slug} |
{"page": {…}} |
| GET | /{project}/wiki/{slug}/_revisions |
{"page": {…}, "revisions": […]} |
| GET | /{project}/wiki/{slug}/_revisions/{n} |
{"page": {…}, "revision": {…}} |
| POST | /{project}/wiki |
Create. Fields title, slug, body. Returns {"page": {…}} |
| PUT | /{project}/wiki/{slug} |
Update. Fields title, slug, body. Returns {"page": {…}} |
| DELETE | /{project}/wiki/{slug} |
Delete. Returns {"success": true} |
Creating, editing and deleting pages require create_wiki_page,
edit_wiki_page and delete_wiki_page. Reading only needs access to the
project. Without a JSON request, create and update redirect to the page and
delete redirects to the wiki.
Page fields: id, project_id, title, slug, main, revision_id.
Revision fields: id, wiki_page_id, revision, content, user_id,
created_at, updated_at. See Wiki.
Project settings¶
These endpoints manage a project and need the project_settings permission.
Unless noted, the JSON response is only returned for API key requests; web
requests redirect. Updates are PUT (send POST with _method=PUT).
| Method | Path | Fields | Returns |
|---|---|---|---|
| POST | /{project}/settings |
name, slug, codename, info, displayorder, default_ticket_type_id, default_ticket_sorting, enable_wiki |
{"project": {…}} (API key) |
Milestones¶
| Method | Path | Fields | Returns |
|---|---|---|---|
| GET | /{project}/settings/milestones |
{"milestones": […]} (any JSON request) |
|
| POST | /{project}/settings/milestones |
name, slug, codename, info, due, displayorder |
{"milestone": {…}} |
| PUT | /{project}/settings/milestones/{id} |
same, plus status (0, 1, 2) |
{"milestone": {…}} |
| DELETE | /{project}/settings/milestones/{id} |
milestone: ID to move its tickets to |
{"success": true} |
Components¶
| Method | Path | Fields | Returns |
|---|---|---|---|
| GET | /{project}/settings/components |
{"components": […]} (any JSON request) |
|
| POST | /{project}/settings/components |
name |
{"component": {…}} |
| PUT | /{project}/settings/components/{id} |
name |
{"component": {…}} |
| DELETE | /{project}/settings/components/{id} |
{"success": true} |
Custom fields¶
| Method | Path | Fields | Returns |
|---|---|---|---|
| GET | /{project}/settings/custom_fields |
{"customFields": […]} (any JSON request) |
|
| POST | /{project}/settings/custom_fields |
name, slug, type, values, multiple, default_value, regex, min_length, max_length, is_required, ticket_type_ids[] |
{"success": true, "field": {…}} |
| PUT | /{project}/settings/custom_fields/{id} |
same | {"field": {…}}, or {"success": false, "errors": …} |
| DELETE | /{project}/settings/custom_fields/{id} |
{"success": true} |
See Custom Fields for what the fields mean.
Members¶
| Method | Path | Fields | Returns |
|---|---|---|---|
| GET | /{project}/settings/members |
{"members": […]} (any JSON request) |
|
| POST | /{project}/settings/members |
username, role (role ID) |
Redirects (no JSON on success) |
| PUT | /{project}/settings/members |
role[{membership_id}]={role_id} |
Redirects |
| DELETE | /{project}/settings/members/{user_id} |
{"success": true} or {"success": false} |
Note the delete path takes the user ID, not the membership ID.
Admin¶
These need an admin user. Updates are PUT (send POST with _method=PUT).
The JSON column says whether any JSON request works or an API key is
required; otherwise the web redirect is returned.
Ticket types, statuses and priorities¶
| Method | Path | Fields | Returns |
|---|---|---|---|
| GET | /admin/tickets/types |
{"types": […]} |
|
| POST | /admin/tickets/types |
name, bullet, changelog, template |
{"type": {…}} |
| PUT | /admin/tickets/types/{id} |
name (required), bullet, changelog, template |
{"type": {…}} |
| DELETE | /admin/tickets/types/{id} |
{"success": true} |
|
| GET | /admin/tickets/statuses |
{"statuses": […]} |
|
| POST | /admin/tickets/statuses |
name, status (0 closed, 1 open, 2 started), changelog |
{"status": {…}} |
| PUT | /admin/tickets/statuses/{id} |
same, all optional | {"status": {…}} |
| DELETE | /admin/tickets/statuses/{id} |
{"success": true} |
|
| GET | /admin/priorities |
{"priorities": […]} |
|
| POST | /admin/priorities |
name |
{"priority": {…}} |
| PUT | /admin/priorities/{id} |
name |
{"priority": {…}} |
| DELETE | /admin/priorities/{id} |
{"success": true} |
All of the above return JSON for any JSON request.
Severities, groups and project roles¶
The list endpoints return JSON for any JSON request. Create, update and delete need an API key.
| Method | Path | Fields | Returns |
|---|---|---|---|
| GET | /admin/severities |
{"severities": […]} |
|
| POST | /admin/severities |
name |
{"severity": {…}} |
| PUT | /admin/severities/{id} |
name |
{"severity": {…}} |
| DELETE | /admin/severities/{id} |
{"success": true} |
|
| GET | /admin/groups |
{"groups": […]} |
|
| POST | /admin/groups |
name |
{"group": {…}} |
| PUT | /admin/groups/{id} |
name |
{"group": {…}} |
| DELETE | /admin/groups/{id} |
{"success": true} |
|
| GET | /admin/roles |
[…] (a bare array) |
|
| POST | /admin/roles |
name, assignable, project (project ID, 0 for all) |
{"role": {…}} |
| PUT | /admin/roles/{id} |
same | {"role": {…}} |
| DELETE | /admin/roles/{id} |
{"success": true} |
Projects¶
| Method | Path | Fields | Returns |
|---|---|---|---|
| GET | /admin/projects |
[…] (a bare array, any JSON request) |
|
| POST | /admin/projects |
name, slug, codename, info, enable_wiki, default_ticket_type_id, default_ticket_sorting, displayorder |
{"project": {…}} (API key) |
| DELETE | /admin/projects/{id} |
{"success": true} (API key) |
Update a project with POST /{project}/settings (see above).
Users¶
| Method | Path | Fields | Returns |
|---|---|---|---|
| GET | /admin/users |
{"users": […]} (any JSON request) |
|
| POST | /admin/users |
username, name, password, email, group_id (default 2) |
{"user": {…}} (any JSON request) |
| PUT | /admin/users/{id} |
same, all optional | {"user": {…}} (API key) |
| DELETE | /admin/users/{id} |
{"success": true} (any JSON request) |
Your account¶
POST /usercp updates the logged-in user's profile with name, email,
locale and watch_created_tickets. For JSON requests it returns
{"user": {…}}. Needs a logged-in user.
GET /usercp/create_api_key generates a new API key (replacing any existing one)
and redirects to the User CP. The key isn't returned in the response; read it
from the User CP page.
Other JSON endpoints¶
| Method | Path | Notes |
|---|---|---|
| GET | /_ajax/autocomplete/username?term=ab |
Usernames starting with term (* is a wildcard) |
Not JSON¶
These exist but return HTML or redirects, so they aren't useful as API calls:
login, registration and password reset, subscribing to projects, milestones and
tickets (POST/DELETE on the …/subscribe and …/unsubscribe paths), the
permissions pages, admin settings and plugins, ticket voters, ticket task forms,
and ticket description and history editing forms.
Caveats¶
- Traq 3.9 is in development, so details here may change before release.
- JSON support is per-action. Endpoints not listed above return HTML regardless
of the
.jsonextension. - Many actions still use browser-style conventions (form-encoded bodies, redirects on success when not using an API key).