Skip to main content

API

Everything the web and the CLI do goes through one HTTP/JSON API. You can call it directly from a script or an integration. This page describes the general conventions, not each endpoint. The full contract of each endpoint is the OpenAPI 3.0 specification of the release. Today the server does not serve it over HTTP: the file is openapi3.json in the backend's api/ folder, in the source code at that release. The official way to publish it has not been decided.

Address and identifiers​

  • The root is https://<your team's API name>/v1. Most endpoints are under /v1/workspaces/{workspace_id}/..., and project endpoints under /v1/workspaces/{workspace_id}/projects/{project_id}/....
  • workspace_id and project_id are UUIDs. Specs, change requests and implementation specs can be addressed by UUID or by ref, for example PAY-R-12, PAY-CR-45, PAY-WS-14 or PAY-WS-14@ready-1 (a Ready milestone).
  • Field names in JSON use snake_case.
  • GET /v1/meta is public, needs no sign-in, and gives the versions and the sign-in address (see CLI and server compatibility). GET /healthz is public too.

Authentication​

Every other call needs Authorization: Bearer <access token>. The token is an OIDC token issued by your team's sign-in service. There are three ways to get a token:

  • A person's sign-in, through the web or tmspec auth login.
  • An API key (tms_...), created on the web. Exchange the key for a 15-minute token with client_credentials at the sign-in service's /token endpoint, sending the key in the form's client_secret field. The token holds only the key's permissions.
  • A token issued by another system, if your team has one.

The real permission is the person's role intersected with the token's scopes (Roles and permissions). Each resource has allowed_actions listing exactly what you can do, so a client does not have to work it out.

Conditional writes​

A write to an existing resource needs an If-Match header carrying the ETag you read:

SituationReturns
If-Match missing428
The resource changed since you read it412, with the current ETag

This step protects you from overwriting someone else's change; after a 412, read again and redo.

A POST that creates takes an Idempotency-Key header (1 to 255 printable characters): sending the same key with the same content again returns the first result without doing it twice, while the same key with different content is 409 idempotency_key_reused. That lets you retry safely after a network error. Some POSTs require a key.

Reading​

  • GET returns an ETag; send If-None-Match back to receive 304 when nothing changed.
  • Cursor pagination. A long list returns one page with next_cursor; send cursor=<that value> to get the next page, and limit to change the page size. There is no offset. A wrong cursor is 422 invalid_cursor.
  • Sets with a hard limit (the Area tree, the diff of a change request) are returned at once, without pagination.

Errors​

Errors are application/problem+json:

{
"status": 422,
"code": "validation_failed",
"detail": "…",
"errors": [{"location": "body.title", "value": ""}]
}

code is for machines and is stable across releases; detail is for people and may change. errors is present when the error is in the data sent, with a location such as body.<field> or query.<parameter>.

StatusUsual meaning
401Not signed in, or the token expired
403Role not enough (forbidden) or the key lacks a scope (scope_missing, the scope name is in errors)
404Not found, or you are not allowed to see it; the two cases are identical
405The method does not exist on this path
409Conflict with the current state: base_moved, invalid_step, idempotency_key_reused...
412 / 428If-Match wrong or missing
422The data was rejected
429Too many calls; wait according to the Retry-After header
5xxA server-side error; retry for GET or for a POST with an Idempotency-Key

API compatibility​

The API version (api_version) follows SemVer. Adding a field, an endpoint, an optional parameter or an enum value does not break compatibility; a client should tolerate fields and values it does not know yet. Removing or renaming a field, changing a type, or adding a required parameter is a breaking change and comes only with a new major version. A client generated from the OpenAPI specification tolerates additive changes.

Calling it with the CLI​

If you are signed in, tmspec api calls an endpoint that has no command of its own, with the same credential:

tmspec api GET /v1/workspaces --field limit=5
tmspec api PATCH /v1/workspaces/<id>/projects/<id>/implementation-specs/PAY-WS-14 --input draft.json --header 'If-Match: "3"'
cat body.json | tmspec api POST /v1/workspaces/<id>/projects/<id>/areas --input - --idempotency-key 7f3a
  • The path starts with /v1/ and is relative to the host in use. A full URL is accepted only when it is that very host.
  • --field key=value becomes a query parameter with GET, or a JSON object used as the body with other methods. --input file (or - for stdin) sends the file as the body unchanged.
  • The token is sent only to the host in use; a redirect to another host is not followed.
  • A result of 400 or above exits with the matching exit code, the error goes to stderr and stdout stays empty.