Integrators#

This chapter is for whoever writes something that talks to the tracker: a script, a dashboard, a CI job, a bot, or a language model.

In short: the API is MantisBT’s. It has the same paths, the same JSON, the same status lines and the same headers. A script written against MantisBT 2.28’s REST API runs against locust unchanged, and that is the point.

Four things are locust’s own, and they are marked where they appear:

  • extra fields on the issue JSON, for features that MantisBT does not have (estimates, deadlines, the compliance roles, work packages, meetings);

  • a few routes on MantisBT’s own paths, where MantisBT’s API cannot do what its pages do, and routes below an issue for what the compliance process does to it;

  • collections of its own under /api/rest, for the features that it added: meetings, templates, the clock, timesheets, work packages and the plan. MantisBT serves no such paths, so nothing that it serves changes, and a MantisBT client notices nothing. They use the same base URL and the same token as the rest of the API;

  • a separate namespace, /api/ai, for language models.

Every route of both namespaces, except three that MantisBT’s own pages use, is described in a served OpenAPI document:

$ curl https://bugs.example.org/api/rest/openapi.json

It needs no token, because it documents routes and shows no data. A test makes sure that every route has its description in the document. The three routes that are left out on purpose are /api/rest/internal/autocomplete, /api/rest/internal/config_display and /api/rest/pages/issues/view/{id}.

Getting in#

The API tokens page

Figure 35 API Tokens in the account pages: one token per client, shown once.#

Every request carries an API token in the Authorization header: the token itself, with no scheme word in front of it.

$ curl -H "Authorization: $TOKEN" https://bugs.example.org/api/rest/users/me

A user creates tokens on the API Tokens tab of their account pages. The token is shown once, when it is created; after that, only its name and the day it was last used are shown. Revoking a token takes effect at once.

A token acts as the user it belongs to, with that user’s access everywhere: there is no scope, no separate permission system, and nothing that a token can do and its owner cannot. An administrator can also create a token for another user (POST /api/rest/users/{user_id}/token). An installation that allows anonymous browsing also answers read requests that carry no token, with the anonymous user’s access.

Two base paths work, and they are the same API:

  • https://host/api/rest/..., with MantisBT’s rewrite rule;

  • https://host/api/rest/index.php/..., without it.

The pages of MantisBT have moved: they have lost their .php, and old links to them answer 308. The API has not moved, on purpose.

Conventions#

JSON

Written as PHP’s json_encode() writes it, down to the escaping, because some clients compare bytes or hash bodies.

ETags

GET /api/rest/issues and GET /api/rest/issues/{id} carry an ETag, and so does the answer to a PATCH of an issue. Sending the tag back in If-None-Match gets 304 Not Modified with no body. Use it for polling: it is far cheaper on both sides than fetching the list again. Sending it in If-Match with a PATCH or DELETE of an issue makes the request answer 412 instead of writing, if the issue has changed in the meantime.

Status lines

MantisBT’s, with its reason phrases.

Errors

{"message": "...", "code": N, "localized": "..."}: MantisBT’s shape, with MantisBT’s error numbers, on MantisBT’s routes. locust’s own collections answer {"message": "..."}. A path that is no route answers an HTML 404 page, and a method that the route does not take answers an HTML 405 with Allow. /api/ai uses a different shape, which leads with a slug (below), on purpose: the two namespaces make different promises.

Paging

page and page_size on /api/rest/issues and /api/rest/projects/{id}/users. The other lists answer in full.

Rate limits

An installation may limit requests per client address and per token. Over the limit, the answer is 429, in plain text, with Retry-After. A client that respects that header will never notice anything else.

The routes#

Issues#

GET /api/rest/issues#

A page of issues. Query parameters: project_id, filter_id (a saved filter, or MantisBT’s standard ones such as assigned), page, page_size, and MantisBT’s select to narrow the fields returned.

GET /api/rest/issues/(int: id)#

One issue, with its notes, attachments, relationships, tags, monitors, custom fields and history, as far as the viewer may see them.

POST /api/rest/issues#

Files one. summary, description, project and category at least.

PATCH /api/rest/issues/(int: id)#

Changes it: only the fields that you send.

DELETE /api/rest/issues/(int: id)#

Deletes it, if your account may.

Notes, files, tags, monitors and relationships belong to an issue:

  • POST   /api/rest/issues/{id}/notes, PATCH/PUT /api/rest/issues/{id}/notes/{note_id} and DELETE /api/rest/issues/{id}/notes/{note_id}

  • GET/POST /api/rest/issues/{id}/files and GET /api/rest/issues/{id}/files/{file_id}

  • POST   /api/rest/issues/{id}/tags and DELETE /api/rest/issues/{id}/tags/{tag_id}

  • GET/POST /api/rest/issues/{id}/monitors and DELETE /api/rest/issues/{id}/monitors/{user_id}

  • POST   /api/rest/issues/{id}/relationships and DELETE /api/rest/issues/{id}/relationships/{relationship_id}

Three of those are locust’s own. MantisBT’s own routing table answers 405 or 404 there, which leaves a client no way to do what its pages do:

GET /api/rest/issues/(int: id)/monitors#

Who is watching, under show_monitor_list_threshold, as in the issue’s own JSON. A caller who may not see the list gets an empty one rather than a refusal, because a refusal would say that there is somebody to hide.

DELETE /api/rest/issues/(int: id)/monitors/(user_id)#

Ends somebody’s monitoring. Ending your own needs monitor_bug_threshold, and ending somebody else’s needs monitor_delete_others_bug_threshold. me stands for the caller, so a client need not know its own id. Repeating the request gives the same answer, as the page’s button does.

PATCH /api/rest/issues/(int: id)/notes/(note_id)#

Corrects a note: {"text": "..."}, {"view_state": {"name": "private"}}, or both. PUT is the same route. What the correction replaced stays in the record as a revision. That is why this route exists: deleting the note and adding another loses its number, its date and its place in the history. Editing your own note needs bugnote_user_edit_threshold, and editing somebody else’s needs update_bugnote_threshold, exactly as on the page. A request that names neither field answers 400, rather than quietly changing nothing.

Projects#

GET, POST, PATCH and DELETE on /api/rest/projects and /api/rest/projects/{id}, plus:

  • /projects/{id}/versions and /projects/{id}/versions/{version_id} (GET, POST, PATCH, DELETE)

  • POST /projects/{id}/subprojects, and PATCH and DELETE on /projects/{id}/subprojects/{subproject_id}

  • /projects/{id}/users (GET, POST, PUT) and /projects/{id}/users/{user_id}: PATCH or PUT changes a member’s level in place, which is locust’s own (MantisBT answers 405), and DELETE takes them out. A PATCH of somebody who is not a member answers 404, because granting membership is what the POST is for, and nobody hands out a level above their own.

  • /projects/{id}/handlers: who may be assigned issues here

Users#

  • GET /api/rest/users/me: who this token belongs to, and what that account may do. It is the first call a client should make.

  • GET /api/rest/users/{id}, GET /api/rest/users/username/{name}

  • POST, PATCH and DELETE on users, and PUT /api/rest/users/{id}/reset, for accounts that may administer

  • POST /api/rest/users/me/token and DELETE /api/rest/users/me/token/{token_id} for your own tokens, and POST /api/rest/users/{user_id}/token and DELETE /api/rest/users/{user_id}/token/{token_id} for somebody else’s

The rest#

  • GET /api/rest/config and PATCH /api/rest/config: the configuration options that a client may read or set

  • GET /api/rest/filters, GET /api/rest/filters/{id} and DELETE /api/rest/filters/{id}: saved filters

  • GET /api/rest/lang: the tracker’s own strings, for a client that wants to show them

  • GET /api/rest/pages/issues/view/{id}: everything that the issue page needs, in one response

  • /api/rest/internal/autocomplete and /api/rest/internal/config_display: what MantisBT’s own pages use

locust’s own collections#

Every one of these endpoints uses the permission check of its page, because a rule that holds on the page and not in the API is not a rule.

Meetings#

A jour fixe is a standing appointment, and a meeting is one appointment. Jour fixes are the management’s (manage_project_threshold). Calling a meeting needs meeting_create_threshold, and running one is for its responsible person or a manager. A private meeting is visible only to its invitees, to whoever called it or runs it, and to the project’s managers, so a meeting that you may not see answers 404 rather than 403.

Jour fixes:

  • GET /api/rest/jour_fixes?project_id=N: the project’s jour fixes, with their schedules and the occurrences that are due

  • GET, PATCH and DELETE on /api/rest/jour_fixes/{id}. The delete is refused once the jour fixe has made a meeting: switch it off instead.

  • POST /api/rest/jour_fixes: defines one. The schedule reads as the page’s form does: frequency_unit (hour, day, week, month, quarter, year), every_n, offset as a duration (2d 14h is Wednesday at two, in a week that starts on Monday), spawn_ahead, spawn_from, time_zone and duration_minutes.

  • POST /api/rest/jour_fixes/{id}/invitees: {"invitees": [1, 2]} replaces them.

  • POST /api/rest/jour_fixes/{id}/templates: the templates that are filed with every meeting. A template that a periodic task files is refused (see Templates and periodic tasks).

  • POST /api/rest/jour_fixes/{id}/spawn: {"occurrence": "..."} makes that occurrence’s meeting now, with its invitees, its standing agenda and its templates’ issues. A second call makes no second meeting, and a time that the schedule does not name makes none at all.

Meetings:

  • GET /api/rest/meetings?project_id=N and GET /api/rest/meetings/{id}. The single meeting carries its agenda, its minutes and its outcomes.

  • POST /api/rest/meetings: calls one, and you become its responsible person.

  • PATCH /api/rest/meetings/{id}: the appointment. A field that the patch leaves out keeps its value.

  • POST /api/rest/meetings/{id}/agreement: agrees the agenda (the page’s Finish the schedule), which sends the invitation with the calendar entry.

  • POST .../reopen, .../skip and .../close: the other three changes of state. Skipping carries the agenda on to the next meeting. Closing makes the meeting final, and every write to a closed meeting answers 409.

  • POST .../hand_over: {"responsible_id": N}

  • POST .../invitees: replaces them. On an agreed meeting, the people taken off get the cancellation.

  • POST .../items: {"issue_id": N} or {"body": "..."}. Whoever runs the meeting puts the item straight on the agenda, and anybody else proposes it.

  • PATCH .../items/{item_id}: {"state": "agenda" | "rejected" | "deferred", "reason": "..."}. A deferred item goes on the next meeting of the series.

  • DELETE .../items/{item_id}: for whoever proposed the item, or whoever runs the meeting

  • POST .../notes and PATCH .../notes/{note_id}: the minutes

$ curl -H "Authorization: $TOKEN" -H "Content-Type: application/json" \
    -d '{"project_id": 1, "title": "Triage",
         "starts_at": "2026-11-11 14:00", "time_zone": "Europe/Zurich",
         "duration_minutes": 60, "invitees": [2, 3]}' \
    https://bugs.example.org/api/rest/meetings

A calendar program can subscribe to meetings without a token: /meetings.ics?username=NAME&key=KEY, with the key of the user’s RSS links, is the user’s meetings, and /meeting.ics?id=N is one meeting.

Templates and periodic tasks#

A template is a named issue tree with one root, filled in in advance. A periodic task is a schedule that names exactly one template. Any developer of the project may write a template (manage_template_threshold); filing one also needs the right to report an issue; and a schedule is the management’s.

Templates:

  • GET /api/rest/templates?project_id=N: the project’s templates, each with the periodic tasks and jour fixes that file it

  • GET /api/rest/templates/{id}: one template, with its whole tree and every issue that it has filed, by hand and on a schedule alike

  • POST /api/rest/templates: {"project_id": N, "name": "...", "summary": "..."}. The summary is the root issue’s, because a template without a root could never be filed.

  • PATCH and DELETE on /api/rest/templates/{id}. The delete keeps the issues that the template filed, which stop naming a template, and it is refused while a periodic task or a jour fixe files the template.

  • POST /api/rest/templates/{id}/clone: {"name": "..."}, tree and all. The original is untouched.

  • POST /api/rest/templates/{id}/instantiate: files the tree now, with you as the reporter of every issue, and answers with the new issues.

  • POST /api/rest/templates/{id}/nodes, and PATCH and DELETE on /nodes/{node_id}: the issues that the template will file. The fields are those of the node’s page, read by the same code, so a custom field that is mandatory on a report is mandatory here. status is the state that the issue starts in, and it cannot be closed or beyond. deadline is a duration from the occurrence (3d). A template has one root, so every other node names a parent_id in the same template and outside its own subtree: a POST without one is refused, and a PATCH that leaves it out keeps it. DELETE removes the one node and moves its children up to its parent, and the root cannot be deleted. meta makes the root a release, under the report form’s rule, and only the root. Instantiating such a template is refused with 403 for a caller who may not file a meta issue.

  • POST /api/rest/templates/{id}/nodes/{node_id}/make_root: the node becomes the root, and the old root becomes its child, carrying everything else with it.

Periodic tasks:

  • GET /api/rest/periodic_tasks?project_id=N and GET /api/rest/periodic_tasks/{id}

  • POST /api/rest/periodic_tasks: template_id names what the task files, and the schedule reads as a jour fixe’s does.

  • PATCH and DELETE on /api/rest/periodic_tasks/{id}. Deleting a task leaves its issues where they are; they stop naming a schedule and keep saying which template they came from.

  • POST /api/rest/periodic_tasks/{id}/spawn: files what is due on the schedule, or one named occurrence. A second call files nothing twice.

  • GET /api/rest/periodic_tasks/{id}/occurrences: what is coming and what has been filed

  • DELETE /api/rest/periodic_tasks/{id}/occurrences: {"issue_id": [N, ...]} withdraws those issues, which closes the future ones that nobody has touched, and deletes nothing.

Two periodic tasks may file the same template. A template cannot be filed both by a periodic task and on a jour fixe’s agenda: pointing a periodic task at a template that a jour fixe puts on its agenda answers 409, and the jour fixe’s route refuses the other way round.

The clock#

A run is somebody’s clock while they work. A record is what a finished run booked, per day, once its owner has confirmed it. The clock’s requests write time as decimal hours ("1.5"), also in the two fields whose names say minutes: minutes_<run id> of the confirmation and minutes of a correction.

  • GET /api/rest/time_runs: the viewer’s own runs, and nobody else’s, because a clock is a statement about one person’s work

  • POST /api/rest/time_runs: {"issue_id": N} measures work on an issue, and which step it is follows from the issue’s state, so the request does not say. {"project_id": N, "kind": "activity", "type_id": N} measures an activity of the project, and {"project_id": N, "kind": "work", "work_package": N} (the package is optional) measures working time that is neither. Starting a second run ends the first.

  • POST /api/rest/time_runs/{id}/stop: your own run, and only the one that is running

  • POST /api/rest/time_records/confirm: {"run": [N, ...]}. With nothing else in the request, each run is confirmed as it was measured. minutes_<run id>, in hours, may lower it, which is what “I forgot to stop” means. A run of more than eight hours needs long_<run id>, because the process expects a stop and a resume in between.

    rows says what the measured time was for, with one object per allocation per day: {"run": N, "day": "2026-03-04", "issue_id": N, "work_package": N, "hours": 1.5}. The day may be left out for a run that touched one day only, and issue_id or work_package may be left out for a row that names none. A bug must be one that you may update, in a project that runs the process; a package must be one that you may book to in that bug’s project; and a day’s rows may not add up to more than the clock measured on that day (409), because a re-allocation divides a measurement and never adds to one. The share_<run id>_<package id> fields that an earlier version took for the percentages are no longer read: the hours are stated in the rows instead.

  • GET /api/rest/time_records: confirmed records, with user_id, year, month and project_id

  • POST /api/rest/time_records/{id}/correction: {"minutes": "0.25", "reason": "..."}, in hours, so this is a quarter of an hour. Only a manager of the project that the hours belong to may correct them, never without a reason, and the correction is appended rather than edited in.

  • GET and POST on /api/rest/projects/{id}/activities, and PATCH /api/rest/projects/{id}/activities/{activity_id}: the kinds of run that are not about an issue. Switching one off stops it being offered and keeps the hours booked to it.

In a project that sets Classify before working, starting a run on an issue that nobody has classified answers 409 and says so, because a run needs a work package.

Timesheets#

  • GET /api/rest/timesheets/{year}/{month}: one person’s month, with the cells, the days, the working week, what has been declared and how far each declaration reaches. user_id asks for somebody else’s month, project_id narrows it to one project, and detail=1 asks for the issues behind each cell.

  • GET /api/rest/timesheets/{year}/{month}/export: the same workbook that the page’s export produces, byte for byte. shape is declaration (the default) or grid.

  • POST /api/rest/timesheets/{year}/{month}/declaration: {"kind": "submitted"} from the person whose sheet it is, or {"kind": "approved", "user_id": N} from a manager or an administrator. Nobody approves their own, and nobody approves where the installation has switched off the manager’s view (timesheet_manager_view), as on the page.

Your own sheet is always readable. Somebody else’s needs the right to report on the time of their projects, and an installation that allows the manager’s view at all; a works agreement may draw the line exactly there. An administrator reads the whole sheet, with the issues behind each cell, without asking. Anybody else who asks for the issues behind a cell of somebody else’s sheet is recorded in the audit log and on the owner’s own sheet.

Work packages#

A work package is the contract or the grant that hours are charged to: one name that an auditor and a developer read the same way. Keeping packages is the management’s. A package is as confidential as the contract that it names, so reading one that you may not manage answers 404. Changing such a package, or its members, answers 403.

  • GET and POST on /api/rest/projects/{id}/work_packages

  • GET and PATCH on /api/rest/work_packages/{id}. budget is in hours, and starts_on and ends_on are days. A package that is switched off has a retain_years of at least one. If the request gives none, the package keeps the figure that it had, or five years if it had none, because switching a package off must never become a quiet way to delete a project’s hours.

  • DELETE /api/rest/work_packages/{id}: for an administrator only, and only once the package is off and the years for which its records had to be kept have passed. It is one of the two operations that delete records from a sheet of a past month; the other is locust retain.

  • POST /api/rest/work_packages/{id}/members: {"user_id": N} engages somebody, so that they may book to the package. A package whose list of members is empty may be booked to by every member of the project. Somebody who is not a member of the project is refused.

  • DELETE /api/rest/work_packages/{id}/members/{user_id}: takes them off. The hours that they booked stay: the list says who may book from now on, not who ever did.

  • GET /api/rest/work_packages/{id}/report: the funder’s periodic report, with the schedule, the addresses that it goes to, the periods that are not settled and what has been sent.

Which issues are on which package is a field of the issue (work_packages on PATCH /api/rest/issues/{id}), and the issue’s own thresholds decide it.

The plan#

The three planning tabs (Gantt, Resources and Priorities) are three views of one schedule, computed from one query, and these three paths answer with what each view shows. A dashboard outside the tracker therefore sees what the tab sees. All three take project_id, and they answer 409 where the project does not estimate, because then there is no plan to draw.

  • GET /api/rest/plan/gantt: the work laid out from today. issues with their estimates, and one stretches entry for each step of each issue, with from, to, minutes, the step (implementation, control, release, deployment, verification, communication) and whose calendar it came out of. A step that nobody is named for carries no person, just as the page draws it in a lane of its own.

  • GET /api/rest/plan/resources: for each person and ISO week, planned_minutes against available_minutes. Only the people whom the project can plan against are included: an administrator account is not planned against, so none appears here.

  • GET /api/rest/plan/priorities: what to do next and why, for user_id or for the caller. Each entry has its rank and its reasons, and each reason says what kind it is: answering, deadline (with days_left, work_days, whether the issue is estimated, and the issue the deadline comes from), blocks (how many people, and the soonest day they need it), late or ordinary. So a client can write the same sentence that the page writes.

Availability#

A calendar is how much time somebody has: the weekdays that they work, the days that differ, and the minutes of their day that one project has. Your own calendar is always yours to read and to write; somebody else’s is the business of the project’s management, through project_id.

  • GET /api/rest/users/me/availability and GET /api/rest/users/{id}/availability: weekdays (seven numbers of minutes, Monday first, absent where the person keeps the installation’s week), days (the days that differ, each with its kind and remark), may_edit, and, with project_id, is_member and project_hours.

  • PATCH on either:

    • {"weekdays": ["8", "8", "8", "8", "6", "0", "0"]} sets the working week in hours, and {"clear_weekdays": 1} gives it back to the installation’s week;

    • {"day": "2026-12-24", "day_hours": "0", "day_kind": "public_holiday", "remark": "..."} writes one day, and {"remove_day": "2026-12-24"} takes it off again;

    • {"project_hours": "4"} with project_id sets how much of the day that project has, which only somebody who manages the project may do.

    Hours are read exactly as the page’s own field reads them, so a value that is not a number of hours answers 400.

An entry for a day replaces the hours of the working week on that day. The project’s hours then cap the result: they never extend a day, so a day off stays off however the project divides the week.

The issue verbs that locust added#

These routes do three things to an issue that MantisBT’s issue endpoints have no field for: questions and taking a phase, which belong to the compliance process, and an estimate, which any project that estimates has. Each asks the same function that the page asks, and refuses with the same words. Each is a route below the issue, so for an issue that you may not read, these routes answer exactly what the issue’s own route answers. In a project that does not run the process, the routes of the questions answer 409.

  • GET /api/rest/issues/{id}/questions: who has been asked what, and what came back: the note that the question is, who was asked, the asker, when, and whether the question is still open. A question whose note is private, and which you may not see, is not listed at all, because listing it would announce that the note exists.

  • DELETE /api/rest/issues/{id}/questions/{question_id}: the asker takes a question back. It is marked as withdrawn and nothing is deleted. Somebody else’s question answers 403, and a question that is not on this issue answers 404.

  • POST /api/rest/issues/{id}/step: the caller takes the phase that the issue is in. Which role that is follows from the state, so the request does not say. It fills that one role and touches neither the status nor the handler, and a role that is already somebody’s answers 403.

  • PATCH /api/rest/issues/{id}/estimate: {"effort_estimate": "2.5"}, the hours that the plan is waiting for. An empty or zero estimate is refused (400). The route fills only an estimate that is still missing, so two clients that race each other do not overwrite one another.

Neither questions nor the notification list have a route of their own for writing. A question is put on the issue page, and its answer is the next note that the person who was asked writes on the issue (POST /api/rest/issues/{id}/notes). The notification list is the issue field notify (below).

$ curl -s -H "Authorization: $TOKEN" \
    "$BASE/api/rest/plan/priorities?project_id=1"
$ curl -s -X PATCH -H "Authorization: $TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"weekdays": ["8", "8", "8", "8", "6", "0", "0"]}' \
    "$BASE/api/rest/users/me/availability"
$ curl -s -X POST -H "Authorization: $TOKEN" \
    -H "Content-Type: application/json" -d '{}' \
    "$BASE/api/rest/issues/42/step"

locust’s own fields#

An issue’s JSON carries these in addition to MantisBT’s, each only where the project has the feature and the viewer may see it:

effort_estimate

Hours, where the project estimates.

due_date

The deadline, under MantisBT’s due_date_view_threshold, which locust, unlike MantisBT, does not set to “nobody” by default.

fast_track

Whether this issue takes the short way, where the project allows it.

meeting

Which meeting the issue came out of, where one did; notes likewise say which meeting they were written in. A PATCH does not change it.

template and occurrence

For an issue that a template filed: which template, and for which occurrence of its schedule.

In a project that runs the process, also:

implementer, reviewer, release_manager, deployer, verifier, communicator

The six roles (Release signed by and Deployed by on the pages are release_manager and deployer).

work_packages

An array of {"id": N, "name": "..."}: the contracts that the hours are charged to. A PATCH may name a package by id, by name or as a bare string, as it may name a version, and an empty list takes them all off. The single work_package of an earlier version is still understood, as a list of one. A package of another project, or one that has been switched off, is refused, except one that the issue already carries, which stays nameable after it has been switched off.

effort_actual

Hours, the sum of what the clock measured. Read-only.

meta

Whether the issue is a release. It is set when the issue is filed, and read-only afterwards.

dpa_required, dpa_informed, csirt_required, csirt_informed

The two authority questions and their ticks.

notify

The notification list. Sending notify replaces the list: an addressee that the request does not repeat is taken off.

triaged_by and questions

The first manager who moved the issue out of new or named somebody for a role, and the questions that were put on the issue.

Three read-only fields are refused rather than ignored: effort_actual, meta, and effective_due_date, which the issue page’s JSON carries (see Reading). A PATCH that gives one of them a value other than the one that the issue has answers 400, naming the field, and writes nothing else from that request either. Repeating the value that the issue already has passes, so a client may read an issue, change one field and send the whole object back.

The roles, the authority questions and the notification list can be set with PATCH. POST /api/rest/issues does not read them: a new issue gets its roles from its category’s teams and the project’s default communicator, as it does on the report form.

Three places where locust is stricter than MantisBT:

  • MantisBT writes a status that the project does not have, as the id it was given or as 0 for a name it cannot find. locust refuses such a status with 400, in every project.

  • MantisBT’s API never asks the project’s workflow which status may follow which, so a client can make a move that the pages refuse. locust refuses a move that the workflow does not allow with 400, in every project that has a workflow. The ways back to an earlier status and the fast-track move are allowed, as on the pages, and a meta issue moves only forward.

  • MantisBT’s issue update checks only that the caller may change a status at all, never which status, so set_status_threshold applies to its pages and not to its API. In a project that runs the process, the thresholds are the process’s own and hold for the pages and the API alike, so a PATCH that sets a status answers 403 where the page would refuse it. A project that does not run the process keeps MantisBT’s behaviour here.

Everything else is additive: a client that ignores unknown fields sees exactly MantisBT’s issue.

Other ways out#

Not everything needs the API:

  • Any filtered issue list exports as CSV or as an Excel workbook, with the columns that the account configured. The print view also offers a Word document, which holds every issue of the list with all its details.

  • The issues of a project, or of a saved filter (filter_id), are an RSS feed. The URL carries a key for each user, so treat it as a credential, and note that it changes when that user changes their password.

  • GET /healthz answers 200 and ok while the database answers. It needs no token and shows nothing; poll it from a load balancer.

Agents#

A language model that is pointed at a bug in a tracker usually has to work for its answer: the bug is a page of markup, the API that would hand it over as data needs a token that nobody can create without a browser, and nothing on the site says any of this. locust’s answer is an entrance that says clearly what is behind it, and that is not a second, laxer way into the data.

Reading#

The issue page also answers in JSON when asked, at its own URL: with Accept: application/json, or with ?format=json. The other pages answer with their HTML.

$ curl -H 'Accept: application/json' https://bugs.example.org/view?id=42

The shape is locust’s own, and deliberately slim: scalars where MantisBT’s REST API has objects ("status": "assigned" with "status_code": 50 beside it, a user as their username). Reading needs no token wherever reading the page needs none, and the visibility rules are the ones that the HTML obeys. Without a token, an agent sees exactly what an anonymous visitor sees, and no more.

GET /api/ai/issues/{id} is the same data under a stable path, and full=1 widens it to the REST API’s issue, for a client that wants everything.

GET /api/ai/issues is the REST API’s list of issues (GET /api/rest/issues), with the same parameters and the same shape, and three parameters more, so that an agent can look for an earlier report before it files another:

  • project: a project by its name, as the project menu shows it, or by its number.

  • status: a status by its name, or open for every status below the one at which an issue counts as resolved.

  • updated_since: the issues updated since a moment, as an ISO 8601 timestamp, or a date, which means its first second in UTC.

A value that the tracker cannot read is refused: an unknown project answers 404, and an unknown status or a moment that is not a timestamp answers 400. A search that ignored a filter would answer a different question without saying so.

Reading it as Markdown#

The issue page also answers in Markdown, to a client that asks for Markdown instead of HTML: with Accept: text/markdown, or with ?format=markdown (md is accepted too).

$ curl -H 'Accept: text/markdown' https://bugs.example.org/view?id=42
$ curl 'https://bugs.example.org/api/ai/issues/42?format=markdown'

What comes back is one document. It starts with a heading with the issue’s number and summary, and its fields as a list. Then come its description, its steps to reproduce, its additional information, its tags, its monitors, its custom fields, its relationships, its attachments and its notes, each note headed by who wrote it and when, and marked where it is private.

The texts are the texts that were typed. A description or a note that was written as Markdown, such as a list, a table or a fenced patch, arrives as that Markdown, not escaped and not wrapped in markup. Since this representation is for a reader of Markdown, the text is passed on as Markdown. Nothing is turned into a link, so #123 stays #123.

The document is rendered from the JSON above, which is why the two can never disagree about what you may see: a note that the JSON hides is not in the Markdown either, and an issue that you may not read answers exactly what it answers to a browser.

Discovery#

/llms.txt

Generated Markdown: what this tracker is, whether it can be read without a token, the policies (below), how to get a token, what can be read and what can be written, and every error slug. /.well-known/llms.txt redirects to it.

/.well-known/ai

A JSON description in the shape of the draft-aiendpoint-ai-discovery-00 Internet-Draft: the capabilities, the authentication, the rate limits and the meta data. The draft is an individual draft that no working group has adopted, and the document says which version it follows, so a client can tell what it is reading.

Every page also carries one comment in its <head> that points at /llms.txt.

Writing#

Writing needs an account, and an agent’s account is marked as one. /llms.txt states four policies in the second person, and the code enforces them:

  1. An agent may register its own account, but its username begins with bot- and its contact address is the human who runs it.

  2. An agent never deletes anything.

  3. An agent changes only what it wrote itself, and only as a correction, which stays in the record.

  4. An agent starts as a reporter. Its human may ask for it to be promoted to updater, which lets it set a status, a handler or a priority.

Two more rules hold without being policies: the human has to confirm the account before its token works, and everything that an agent does carries its name, which is marked as an agent’s wherever it appears. On /api/rest, a token of an agent’s account is refused, with the slug bot_restricted, on every route that deletes or withdraws something, skips or closes a meeting, resets a user or corrects booked hours.

POST /api/ai/signup#

username, email (the human’s), real_name and purpose. The human is mailed the username that was asked for, the real name and the purpose, with a link to allow the account and a link to reject it; a third link, later, switches the account off again. Rejecting removes the account and its token. Switching it off leaves what it wrote where it is.

GET /api/ai/me#

What this agent’s account is, and what it may do.

GET /api/ai/vocabulary#

What an agent chooses from when it files, with the caller’s visibility: the projects that it can see, each with the categories that it offers (inherited ones included), whether each category spans_components, and whether the caller may file there at all (may_file) and privately (may_file_private); the tags that the caller may view, with their descriptions; the severities, each with locust’s sentence on what it means; the view states; and patch_tag, the tag that marks a report with a patch, where a tag of the configured name exists.

POST /api/ai/issues/tree#

Files a whole tree in one transaction, all or nothing: {"request_id": "...", "issue": {...}}, where every node may carry children, nested as deep as the installation allows. A specification in one project with three implementations in three others, linked as its children, is one request.

A node may set what the update page can set, at the agent’s level in each project. It may not set the status: a new issue always starts in the project’s first status (new, unless the project says otherwise), and a request with any status at all is refused (status_not_new), rather than quietly corrected. An agent that got a 201 after asking for assigned would believe that it had assigned the issue.

/llms.txt says how to choose what goes into a tree, and the rules are the same on every tracker:

  • text for anything about strings, and trivial for a fix so obvious that it most likely needs no review. These two are the severities of the fast-track (Developers), so the choice also decides whether a change may skip the review.

  • A report that likely has serious security implications is at least major and private. An agent that may not file a private issue in the project files nothing and tells its human.

  • Work that needs a change in several components is a parent issue in a category that spans components, with one child for each component, each in that component’s category. This is a parent, not a meta issue: a meta issue is a release, which an agent never files.

  • Tags only where their description clearly fits, and the patch tag on a report that carries a patch.

None of this is enforced: the tracker cannot tell a security bug or a string from the text of a report. What is enforced stays as it is: the status, no meta issue and no new tag.

POST /api/ai/issues/(int: id)/notes#

Adds a note.

POST /api/ai/issues/(int: id)/files#

Attaches a file.

PATCH /api/ai/notes/(int: id)#

Corrects a note that the agent itself wrote.

Every write except the signup takes a ``request_id``. An agent that timed out retries, and a tree of twenty issues filed twice is the expensive mistake. So the tracker remembers the id with a hash of the request. A retry with the same id and the same body gets the first result instead of filing again: 200 with "replayed": true. The same id with a different body answers 409 (request_id_reused).

Errors on /api/ai lead with a slug, so that a program can branch on them without parsing prose:

{"error": "tree_too_large", "message": "...", "ref": "<node>", "field": "..."}

Every slug is listed in /llms.txt.

Limits#

An installation sets how big one tree may be (issues, depth, bytes), how long a confirmation link lives, and how long request ids are remembered. It can switch all of this off ([locust-ai] ENABLED = NO), which removes the discovery documents, the comment in each page and the JSON and Markdown answers, makes /api/ai answer 404 (disabled), and changes nothing else. Signup for agents can be refused separately.

What is deliberately not there: an agent cannot create tags, neither in a tree nor through POST /api/rest/issues/{id}/tags, because an agent attaches the tracker’s vocabulary and does not invent it. And there is no webhook and no stream of changes yet, so an agent that wants to know about changes polls, with If-None-Match on the list of issues, which is what its ETag is for.

A worked example#

Three of the issues assigned to you, the most recently updated first, as JSON:

$ curl -s -H "Authorization: $TOKEN" \
    'https://bugs.example.org/api/rest/issues?page_size=3&filter_id=assigned'

Add a note to issue 42:

$ curl -s -X POST -H "Authorization: $TOKEN" \
    -H 'Content-Type: application/json' \
    -d '{"text": "Reproduced on 1.2.3, log attached."}' \
    https://bugs.example.org/api/rest/issues/42/notes

Poll a list without downloading it twice:

import time

import requests

session = requests.Session()
session.headers["Authorization"] = TOKEN
etag = None
while True:
    headers = {"If-None-Match": etag} if etag else {}
    r = session.get(f"{BASE}/api/rest/issues?project_id=1", headers=headers)
    if r.status_code == 304:
        ...            # nothing changed
    else:
        etag = r.headers.get("ETag")
        handle(r.json()["issues"])
    time.sleep(60)