Add labels to a test
Requires the Flag tests permission.
Applies each named label to the test by hand. A name with no label in the organization creates the label, colored #6366F1 with no description; an admin can change both in the web app’s organization settings. A label already applied by hand is left as it is. A label a monitor applies gets a user source beside the monitor’s.
Answers the test’s labels after the change, in the shape of Test.labels, read in the same transaction as the write.
A label changes no status, so this sends no webhook and does not reconcile the test.
The labels filter of GET /v2/tests reads a copy of the assignments that lags by a minute or two, so a test can be missing from (or still in) a label’s results that long after this answers. The labels on each test, here and on every read, are current.
The change is recorded as made by the person whose token made the call. An API token is recorded as no one: its source reads user: null.
Idempotency-Key is not honored. The change is idempotent by state, so a request whose outcome is unknown (a 504 or a dropped connection) is safe to send again.
A test in another organization is reported as 404, not 403.
Authorizations
An API key, sent as Authorization: Bearer <key>. An organization admin creates one in the Trunk app under Settings → Developer → API Keys and chooses the permissions it holds. A key with none can read merge queues but change nothing in them. Permissions cover merge queues and test-result uploads, including the quarantine lookups a CI run makes before it uploads; any key can call the other Flaky Tests and Dynamic CI endpoints, including their writes.