diff --git a/api/authentication.mdx b/api/authentication.mdx index 356f2eec..a365745f 100644 --- a/api/authentication.mdx +++ b/api/authentication.mdx @@ -36,7 +36,7 @@ Keys start with `trunk_v2_`, so you can add that prefix to your secret scanner. Permissions are the scopes of an API key. A key without permissions can still: - Read your organization's merge queues, pull requests, and repositories. So a dashboard or a Prometheus scrape needs no permissions. -- Call every Flaky Tests endpoint in this reference, including writes, such as creating a test collection or a ticket. +- Read Flaky Tests collections, tests, monitors, and detection events, and create a test collection. Each permission adds writes: @@ -48,6 +48,12 @@ Each permission adds writes: | **Merge PRs with direct to queue** | Send a pull request to the queue before branch protection is satisfied. The queue's own tests still run and still gate the merge. | A submit that sends `direct: true`; a queue-entry update that sends `direct` | | **Update Merge Queue settings** | Change queue settings; pause, resume, or drain a queue; and create or delete queues. | [Create](/api/mergequeues/create-a-merge-queue), [delete](/api/mergequeues/delete-a-merge-queue), [update configuration](/api/mergequeues/update-a-merge-queues-configuration), [switch modes](/api/mergequeues/switch-a-merge-queues-mode), [pause](/api/mergequeues/pause-a-merge-queue), [resume](/api/mergequeues/resume-a-merge-queue), [drain](/api/mergequeues/drain-a-merge-queue) | | **Upload test results** (Flaky Tests) | Upload test results from CI, including looking up which tests are quarantined before the upload. | Test-results uploads through the API. The Trunk Analytics CLI and `trunk-io/analytics-uploader` don't use it yet | +| **Quarantine tests** (Flaky Tests) | Always or never quarantine a test whatever its monitors decided, or clear that override, for one test or many at once. | [One test](/api/tests/set-a-tests-quarantine-override), [many tests](/api/tests/set-quarantine-overrides-on-many-tests) | +| **Flag tests** (Flaky Tests) | Mark a test flaky by hand or clear that mark, and add or remove a test's labels. | [Mark flaky](/api/tests/mark-a-test-flaky), [clear the mark](/api/tests/clear-a-tests-flaky-mark), [add labels](/api/tests/add-labels-to-a-test), [remove labels](/api/tests/remove-labels-from-a-test) | +| **Manage monitors** (Flaky Tests) | Create monitors and change their settings, including turning a monitor off for every test. | [Create](/api/testcollections/create-a-monitor), [edit](/api/monitors/edit-a-monitor) | +| **Mute monitors** (Flaky Tests) | Mute or unmute a monitor for one test or for many at once. | [Mute one test](/api/monitortests/mute-a-monitor-for-one-test), [unmute one test](/api/monitortests/unmute-a-monitor-for-one-test), [mute many](/api/monitortests/mute-a-monitor-for-many-tests), [unmute many](/api/monitortests/unmute-a-monitor-for-many-tests) | +| **Link tickets** (Flaky Tests) | Link an existing ticket in the connected ticketing provider to a test, or unlink it. | [Link](/api/tests/link-a-ticket-to-a-test), [unlink](/api/tests/unlink-a-tests-ticket) | +| **Create tickets** (Flaky Tests) | File a new ticket for a test in the connected ticketing provider and link it to the test. | [Create a ticket](/api/tests/create-a-ticket-for-a-test) | A request's permissions come from its body as well as its endpoint. For example, a submit that sets a priority needs both **Merge and cancel PRs** and **Set priority on PRs**. If the key doesn't have a permission that the request needs, the API returns `403 INSUFFICIENT_PERMISSIONS` and changes nothing. diff --git a/docs.json b/docs.json index be085adf..898a21f6 100644 --- a/docs.json +++ b/docs.json @@ -862,7 +862,52 @@ "GET /v2/tests/{testId}/status-history", "GET /v2/tests/{testId}/test-runs", "POST /v2/tests/{testId}/ticket", - "POST /v2/tests/{testId}/create-ticket" + "POST /v2/tests/{testId}/create-ticket", + "GET /v2/tests/{testId}/ticket", + "DELETE /v2/tests/{testId}/ticket", + "POST /v2/tests/{testId}/quarantine", + "POST /v2/tests/quarantine", + "POST /v2/tests/{testId}/mark-flaky", + "POST /v2/tests/{testId}/unmark-flaky", + "POST /v2/tests/{testId}/add-labels", + "POST /v2/tests/{testId}/remove-labels" + ] + }, + { + "group": "Monitors", + "openapi": { + "source": "/openapi-v2.json", + "directory": "/api" + }, + "pages": [ + "GET /v2/monitors", + "GET /v2/monitors/{monitorId}", + "POST /v2/test-collections/{id}/monitors", + "PATCH /v2/monitors/{monitorId}" + ] + }, + { + "group": "Monitored tests", + "openapi": { + "source": "/openapi-v2.json", + "directory": "/api" + }, + "pages": [ + "GET /v2/monitors/{monitorId}/tests", + "POST /v2/monitors/{monitorId}/tests/{testId}/mute", + "POST /v2/monitors/{monitorId}/tests/{testId}/unmute", + "POST /v2/monitors/{monitorId}/tests/mute", + "POST /v2/monitors/{monitorId}/tests/unmute" + ] + }, + { + "group": "Detection events", + "openapi": { + "source": "/openapi-v2.json", + "directory": "/api" + }, + "pages": [ + "GET /v2/detection-events" ] }, { diff --git a/openapi-v2.json b/openapi-v2.json index c1ab7c67..9c62962b 100644 --- a/openapi-v2.json +++ b/openapi-v2.json @@ -68,10 +68,6 @@ "name": "tests", "x-group": "Tests" }, - { - "name": "testInvestigations", - "x-group": "Test Investigations" - }, { "name": "testUploads", "x-group": "Test Uploads" @@ -79,6 +75,14 @@ { "name": "detectionEvents", "x-group": "Detection Events" + }, + { + "name": "monitors", + "x-group": "Monitors" + }, + { + "name": "monitorTests", + "x-group": "Monitor Tests" } ], "components": { @@ -362,6 +366,14 @@ "testBranchConstructionMode": { "$ref": "#/components/schemas/TestBranchConstructionMode" }, + "failedTestRunTeardown": { + "$ref": "#/components/schemas/FailedTestRunTeardown" + }, + "maxHoldMinutes": { + "type": "integer", + "description": "How long a re-run of failed checks (`POST /v2/pull-requests/{id}/rerun-failed-checks`) keeps its pull request in `pendingFailure` waiting for the re-run to start; `rerun.until` is the request time plus this. From 1 to 60. Applies while `failedTestRunTeardown` is `keepForRerun`. A change applies to later re-runs; a hold already in progress keeps its `rerun.until`.", + "example": 30 + }, "enqueueingLabel": { "type": "string", "description": "The label that submits a pull request to this queue when `areLabelCommandsEnabled` is true. May not collide with a Trunk-reserved `trunk-*` state label.", @@ -392,6 +404,8 @@ "mergeMethod", "isMergeMethodOverrideEnabled", "testBranchConstructionMode", + "failedTestRunTeardown", + "maxHoldMinutes", "enqueueingLabel" ], "description": "A queue's full configuration. `requiredStatuses` (what must pass) is a merge-protection control rather than a tuning knob, so treat write access to this object as security-relevant." @@ -441,6 +455,12 @@ "description": "How the queue turns the temporary branch it builds into the `trunk-merge` branch CI runs on. `renameTempBranch` renames the ref. `pushNewBranchFromTemp` creates the final ref at the temporary branch's head commit and deletes the temporary ref, which needs no rename permission — use it when an organization- or enterprise-level ruleset targets these branches, since GitHub's rename restriction is the one rule an exempt bypass actor cannot lift.", "example": "renameTempBranch" }, + "FailedTestRunTeardown": { + "type": "string", + "enum": ["tearDown", "keepForRerun"], + "description": "What the queue does with a failed verification run's testing branch and CI. `tearDown` deletes them when the run fails. `keepForRerun` keeps them while the entry waits in `pendingFailure`, so its failed checks can be re-run on the same run (`POST /v2/pull-requests/{id}/rerun-failed-checks`); they are torn down once the entry stops waiting, including runs kept before a switch back to `tearDown`. Switching to `tearDown` also ends any re-run hold already in progress.", + "example": "tearDown" + }, "ErrorResponse": { "type": "object", "properties": { @@ -478,6 +498,7 @@ "UPSTREAM_ERROR", "VERIFICATION_RUN_NOT_FOUND", "PR_NOT_FOUND", + "IMPACTED_TARGETS_NOT_FOUND", "REPOSITORY_NOT_FOUND", "IMPACTED_TARGETS_UNSUPPORTED", "QUEUE_ALREADY_EXISTS", @@ -505,7 +526,9 @@ "TEST_COLLECTION_NOT_FOUND", "TEST_NOT_FOUND", "TEST_UPLOAD_NOT_FOUND", - "INVESTIGATION_NOT_FOUND", + "MONITOR_NOT_FOUND", + "MONITOR_LIMIT_EXCEEDED", + "MONITOR_NOT_ACTIVE", "OUT_OF_RANGE", "TEST_UNAVAILABLE", "TICKETING_NOT_CONFIGURED", @@ -1286,7 +1309,7 @@ "stackNeedsRebase", "other" ], - "description": "Why the pull request is not mergeable. `behind`, `pending`, and `awaitingCheck` resolve without author action (Trunk updates the branch; GitHub is still computing; a required check is still running); the rest need the author to act. `stackNeedsRebase` means a PR in the middle of this GitHub stack was pushed to without rebasing the ones above it. `other` is a block Trunk could not attribute to a specific rule.", + "description": "Why the pull request is not mergeable. `behind`, `pending`, and `awaitingCheck` resolve without author action (Trunk updates the branch; GitHub is still computing; a required check is still running); the rest need the author to act. `stackNeedsRebase` means a PR in the middle of this GitHub stack was pushed to without rebasing the ones above it. `other` is any other block; its `message` names a ruleset rule when Trunk has one.", "example": "reviewRequired" }, "PullRequestCi": { @@ -1617,6 +1640,17 @@ "enum": ["renameTempBranch", "pushNewBranchFromTemp"], "description": "One of `renameTempBranch` or `pushNewBranchFromTemp`. See the `TestBranchConstructionMode` schema." }, + "failedTestRunTeardown": { + "type": "string", + "enum": ["tearDown", "keepForRerun"], + "description": "One of `tearDown` or `keepForRerun`. See the `FailedTestRunTeardown` schema." + }, + "maxHoldMinutes": { + "type": "integer", + "minimum": 1, + "maximum": 60, + "description": "How long a re-run of failed checks (`POST /v2/pull-requests/{id}/rerun-failed-checks`) keeps its pull request in `pendingFailure` waiting for the re-run to start; `rerun.until` is the request time plus this. From 1 to 60. Applies while `failedTestRunTeardown` is `keepForRerun`. A change applies to later re-runs; a hold already in progress keeps its `rerun.until`." + }, "enqueueingLabel": { "type": "string", "minLength": 1, @@ -2025,6 +2059,42 @@ ], "description": "The impacted targets of a set of commits on a verification run." }, + "PullRequestImpactedTargets": { + "type": "object", + "properties": { + "sha": { + "type": "string", + "description": "The pull request's head commit, which is the commit the targets were uploaded for. A squash merge does not move it.", + "example": "9c58bf40e5c1a2b3d4e5f60718293a4b5c6d7e8f" + }, + "impactsAllTargets": { + "type": "boolean", + "description": "True when any commit in this set uploaded `impactsAllTargets: true`, which makes the explicit lists of the others moot.", + "example": false + }, + "impactedTargets": { + "type": "array", + "items": { + "type": "string" + }, + "maxItems": 100000, + "description": "The union of the commits' uploaded targets, sorted and deduplicated. Empty when `impactsAllTargets` is true, and also when every upload was an explicit empty list — the commits impact nothing. Truncated to the first 100,000 targets; `totalImpactedTargets` says whether it was.", + "example": ["//lib/db", "//svc/api"] + }, + "totalImpactedTargets": { + "type": "integer", + "description": "The size of the union before truncation. 0 when `impactsAllTargets` is true.", + "example": 2 + } + }, + "required": [ + "sha", + "impactsAllTargets", + "impactedTargets", + "totalImpactedTargets" + ], + "description": "The impacted targets most recently uploaded for a pull request's head commit (`PUT /impacted-targets`): a set of one commit." + }, "VerificationRunList": { "type": "object", "properties": { @@ -2100,7 +2170,7 @@ }, "reason": { "type": ["string", "null"], - "description": "Why the entry entered this state. `null` for `testing` and `pendingFailure`, which carry no reason.\n\nThe values below are the vocabulary in use today, grouped by the state they accompany. **This is an open set** — it is the engine's own vocabulary and new values may appear within v2, so match on the values you care about and treat anything else as unclassified rather than failing closed.\n\n**Why an entry is waiting (`notReady`)** — `USER_REQUESTED`, `TRUNK_ADMIN_REQUESTED`, `API_REQUESTED`, `PR_PUSHED_TO` (a push to the pull request sent it back to wait on the new commit).\n\n**Why an entry (re)entered the line (`pending`)** — these are what distinguish a restart's cause:\n\n| Value | Meaning |\n| --- | --- |\n| `TESTS_RESTARTED_BY_USER` | A person restarted the tests. |\n| `TESTS_RESTARTED_BY_API_REQUEST` | Restarted through the API — e.g. `pullRequests.restartTests`. |\n| `MERGE_ITEM_NOW_READY` | A readiness condition became satisfied. |\n| `MANUAL_PUSH_TO_TARGET_BRANCH` | Someone pushed to the target branch, invalidating the tested state. |\n| `PREREQUISITE_MERGE_ITEM_FAILED` | An entry ahead of this one failed, so this one must re-test. |\n| `PREREQUISITE_MERGE_ITEM_CANCELLED` | An entry ahead was removed. |\n| `PREREQUISITE_MERGE_ITEM_MANUALLY_MERGED` | An entry ahead was merged outside the queue. |\n| `SKIP_THE_LINE_INTERRUPTED` | A higher-priority entry preempted this one. |\n| `BISECTION_REQUIRED` | A batch failed and the engine is bisecting to find the culprit. |\n| `BISECTION_TEST_RUN_PASSED` | A bisection run cleared this entry. |\n\n**Why verification passed (`testsPassed`)** — `TEST_RUN_PASSED`, `SUCCESSOR_TEST_RUN_PASSED`, `PASSED_BY_OPTIMIZATION`.\n\n**Why an entry failed (`failed`)** — `TEST_RUN_REQUIRED_STATUS_FAILED`, `TEST_RUN_TIMEOUT`, `TEST_RUN_FAILED_BY_OPTIMIZATION`, `START_TEST_RUN_MERGE_CONFLICT`, `START_TEST_RUN_RETRY_EXHAUSTED`, `START_TEST_RUN_DRAFT_PRS_NOT_ALLOWED`, `START_TEST_RUN_PERMISSIONS_BLOCK_TEST_BRANCH`, `START_TEST_RUN_NO_REQUIRED_STATUSES`, `START_TEST_RUN_CONFIG_NOT_FOUND`, `START_TEST_RUN_CONFIG_PARSING_FAILURE`, `START_TEST_RUN_CONFIG_BAD_VERSION`, `START_TEST_RUN_CONFIG_BAD_REQUIRED_STATUSES`, `START_TEST_RUN_CONFIG_MISSING_REQUIRED_STATUSES`, `START_TEST_RUN_INVALID_EVENT`, `PR_UPDATED_AT_MERGE_TIME`, `GITHUB_API_MERGE_PR_FAILED`, `GITHUB_API_DIRECT_MERGE_PR_FAILED`, `GITHUB_API_BRANCH_PROTECTION_UNMET`, `GITHUB_API_MERGE_ALREADY_IN_PROGRESS`, `GITHUB_API_RATE_LIMIT_EXCEEDED`, `GITHUB_API_REPEATED_SERVER_ERRORS`, `MERGE_METHOD_NOT_ALLOWED`.\n\n**Why an entry was removed (`cancelled`)** — `USER_REQUESTED`, `TRUNK_ADMIN_REQUESTED`, `PR_CLOSED`, `PR_MERGED_INTO_OTHER_BRANCH`, `PR_PUSHED_TO` (older entries only; a push now returns an entry to `notReady`), `PR_BASE_BRANCH_CHANGED`, `PR_CONVERTED_TO_DRAFT`, `NOT_READY_TIMEOUT_EXPIRED`, `STACKED_PR_MEMBER_PUSHED_TO`, `STACKED_PR_MEMBER_CLOSED`, `STACKED_PR_MEMBER_MERGED`, `STACKED_PR_MEMBER_BASE_BRANCH_CHANGED`, `STACKED_PR_STACK_CHANGED`, `STACKED_PR_GROUP_CANCELLED_AT_MERGE_TIME`.\n\n**Why an entry merged (`merged`)** — `MERGE_GRAPH_MERGE`, `MERGE_GRAPH_DIRECT_MERGE`, `MANUAL_MERGE`.", + "description": "Why the entry entered this state. `null` for `testing` and `pendingFailure`, which carry no reason.\n\nThe values below are the vocabulary in use today, grouped by the state they accompany. **This is an open set** — it is the engine's own vocabulary and new values may appear within v2, so match on the values you care about and treat anything else as unclassified rather than failing closed.\n\n**Why an entry is waiting (`notReady`)** — `USER_REQUESTED`, `TRUNK_ADMIN_REQUESTED`, `API_REQUESTED`, `PR_PUSHED_TO` (a push to the pull request sent it back to wait on the new commit).\n\n**Why an entry (re)entered the line (`pending`)** — these are what distinguish a restart's cause:\n\n| Value | Meaning |\n| --- | --- |\n| `TESTS_RESTARTED_BY_USER` | A person restarted the tests. |\n| `TESTS_RESTARTED_BY_API_REQUEST` | Restarted through the API — e.g. `pullRequests.restartTests`. |\n| `MERGE_ITEM_NOW_READY` | A readiness condition became satisfied. |\n| `MANUAL_PUSH_TO_TARGET_BRANCH` | Someone pushed to the target branch, invalidating the tested state. |\n| `PREREQUISITE_MERGE_ITEM_FAILED` | An entry ahead of this one failed, so this one must re-test. |\n| `PREREQUISITE_MERGE_ITEM_CANCELLED` | An entry ahead was removed. |\n| `PREREQUISITE_MERGE_ITEM_MANUALLY_MERGED` | An entry ahead was merged outside the queue. |\n| `SKIP_THE_LINE_INTERRUPTED` | A higher-priority entry preempted this one. |\n| `BISECTION_REQUIRED` | A batch failed and the engine is bisecting to find the culprit. |\n| `BISECTION_TEST_RUN_PASSED` | A bisection run cleared this entry. |\n\n**Why verification passed (`testsPassed`)** — `TEST_RUN_PASSED`, `SUCCESSOR_TEST_RUN_PASSED`, `PASSED_BY_OPTIMIZATION`.\n\n**Why an entry failed (`failed`)** — `TEST_RUN_REQUIRED_STATUS_FAILED`, `TEST_RUN_TIMEOUT`, `TEST_RUN_FAILED_BY_OPTIMIZATION`, `START_TEST_RUN_MERGE_CONFLICT`, `START_TEST_RUN_RETRY_EXHAUSTED`, `START_TEST_RUN_DRAFT_PRS_NOT_ALLOWED`, `START_TEST_RUN_PERMISSIONS_BLOCK_TEST_BRANCH`, `START_TEST_RUN_NO_REQUIRED_STATUSES`, `START_TEST_RUN_CONFIG_NOT_FOUND`, `START_TEST_RUN_CONFIG_PARSING_FAILURE`, `START_TEST_RUN_CONFIG_BAD_VERSION`, `START_TEST_RUN_CONFIG_BAD_REQUIRED_STATUSES`, `START_TEST_RUN_CONFIG_MISSING_REQUIRED_STATUSES`, `START_TEST_RUN_INVALID_EVENT`, `PR_UPDATED_AT_MERGE_TIME`, `GITHUB_API_MERGE_PR_FAILED`, `GITHUB_API_DIRECT_MERGE_PR_FAILED`, `GITHUB_API_BRANCH_PROTECTION_UNMET`, `GITHUB_API_MERGE_ALREADY_IN_PROGRESS`, `GITHUB_API_RATE_LIMIT_EXCEEDED`, `GITHUB_API_REPEATED_SERVER_ERRORS`, `MERGE_METHOD_NOT_ALLOWED`, `GITHUB_STACK_MERGE_STUCK_PENDING`.\n\n**Why an entry was removed (`cancelled`)** — `USER_REQUESTED`, `TRUNK_ADMIN_REQUESTED`, `PR_CLOSED`, `PR_MERGED_INTO_OTHER_BRANCH`, `PR_PUSHED_TO` (older entries only; a push now returns an entry to `notReady`), `PR_BASE_BRANCH_CHANGED`, `PR_CONVERTED_TO_DRAFT`, `NOT_READY_TIMEOUT_EXPIRED`, `STACKED_PR_MEMBER_PUSHED_TO`, `STACKED_PR_MEMBER_CLOSED`, `STACKED_PR_MEMBER_MERGED`, `STACKED_PR_MEMBER_BASE_BRANCH_CHANGED`, `STACKED_PR_STACK_CHANGED`, `STACKED_PR_GROUP_CANCELLED_AT_MERGE_TIME`.\n\n**Why an entry merged (`merged`)** — `MERGE_GRAPH_MERGE`, `MERGE_GRAPH_DIRECT_MERGE`, `MANUAL_MERGE`.", "example": "TEST_RUN_REQUIRED_STATUS_FAILED" }, "verificationRunId": { @@ -2911,6 +2981,17 @@ }, "maxItems": 64, "description": "The audit trail behind `summary`, abstentions included." + }, + "variations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/VariationVerdict" + }, + "maxItems": 256, + "description": "One verdict per matrix variation, for a job decided per variation. Informational: act on `run` and `prune`, never on these." + }, + "prune": { + "$ref": "#/components/schemas/Prune" } }, "required": ["jobKey", "run", "summary", "signals"] @@ -2969,6 +3050,100 @@ "description": "One signal's contribution. `MUST_RUN` and `NEVER_RUN` are hard verdicts (a single one decides, with `MUST_RUN` winning a tie); `VOTE_RUN` and `VOTE_NO_RUN` are weighted votes. `INCOMPLETE` means the signal applies but lacks evidence — two of them fail the job safe to running. `ABSTAIN` means the signal does not apply at all and is excluded from the tally entirely, which is what makes it different from `INCOMPLETE`.", "example": "VOTE_NO_RUN" }, + "VariationVerdict": { + "type": "object", + "properties": { + "match": { + "type": "object", + "additionalProperties": {}, + "description": "The variation's matrix values, each as typed JSON. Informational: a number may lose how it was written (`3.10` reads as `3.1`), so never build a matrix output from it; set `prune` instead.", + "example": { + "os": "macos-14", + "node": 20 + } + }, + "group": { + "type": "object", + "additionalProperties": {}, + "description": "The values of `match` on the job's variation dimensions: the decision group whose verdict this variation took, and what to label this variation by. Empty when the variation sets none of them. Variations in one group can still differ in `run`, because a variation that cannot be pruned runs while its group skips, so combine variations into one line only when both `group` and `run` match.", + "example": { + "os": "macos-14" + } + }, + "run": { + "type": "boolean", + "description": "Whether this variation's legs should run.", + "example": false + }, + "summary": { + "type": "string", + "description": "One-line rationale for this variation's verdict, safe to show to a user.", + "example": "The job should skip because no changed file has ever broken it." + } + }, + "required": ["match", "run", "summary"] + }, + "Prune": { + "type": "object", + "properties": { + "exclude": { + "type": "string", + "description": "Set as the `-exclude` output, unchanged, for a matrix declared with axes and wired as `exclude: ${{ fromJSON( || '[...your own excludes...]') }}`. A JSON array: your own `exclude` entries first, then one entry per pruned leg. Do not parse or re-encode it: GitHub matches `exclude` by JSON type.", + "example": "[{\"os\":\"macos-14\",\"node\":20}]" + }, + "matrix": { + "type": "string", + "description": "Set as the `-matrix` output, unchanged, for a matrix written as `matrix: ${{ fromJSON( || '{\"include\":[...]}') }}`. A JSON object `{\"include\": [...]}` holding the rows that run, each exactly as written in your literal, so leg names do not change.", + "example": "{\"include\":[{\"lane\":\"parallel\",\"shard\":1}]}" + }, + "include": { + "type": "string", + "description": "Set as the `-include` output, unchanged, for a matrix wired as `include: ${{ fromJSON( || '[...]') }}`. The same rows as `matrix`, as a bare JSON array.", + "example": "[{\"lane\":\"parallel\",\"shard\":1}]" + }, + "dropSetup": { + "type": "array", + "items": { + "type": "integer", + "minimum": 0 + }, + "maxItems": 50, + "description": "For a Buildkite matrix with no dimension names (`matrix: [a, b]` or `setup: [a, b]`): the positions in the step's setup list to delete, counted from 0 in the list you sent in `matrixBlocks`, ascending. Delete them from the step you upload; never every position.", + "example": [1] + }, + "adjustments": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PruneAdjustment" + }, + "maxItems": 12, + "description": "For a Buildkite matrix with named dimensions: entries to append, unchanged, to the step's `matrix.adjustments`. Each skips one variation. With your own adjustments, the step never has more than Buildkite's limit of 12." + } + }, + "description": "Present only when some legs of this matrix job are skipped and others run. Each field is the exact text for one output; a client sets it unchanged. When every leg is skipped, `run` is false and `prune` is absent." + }, + "PruneAdjustment": { + "type": "object", + "properties": { + "with": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "The variation's value for each named dimension, as strings. Buildkite matches these against your `setup` values by their string form.", + "example": { + "os": "macos", + "arch": "arm64" + } + }, + "skip": { + "type": "string", + "description": "The reason Buildkite shows for the skipped variation. It starts with `Trunk Dynamic CI:`.", + "example": "Trunk Dynamic CI: no changed file has broken this variation." + } + }, + "required": ["with", "skip"] + }, "PlanNotice": { "type": "object", "properties": { @@ -3076,6 +3251,31 @@ "type": "string", "description": "From `github.workflow_ref`; identifies the workflow whose jobs are in scope.", "example": ".github/workflows/ci.yaml" + }, + "workflowFileSha": { + "type": "string", + "pattern": "^[0-9a-f]{40}([0-9a-f]{24})?$", + "description": "The git blob sha of the workflow file at `commitSha` (`git rev-parse :`). Matrix jobs are pruned only against the parsed version of exactly this file; without it, a matrix job is decided as a whole.", + "example": "51d537a714c0f1c8a4e92b13d5f0e6a7c2b9d8e1" + }, + "matrixRows": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "For matrix jobs whose rows a planner job builds at run time (`fromJSON`): each job's rows array, by job key, as the exact JSON text the planner emitted. Send the text unchanged; Trunk returns the rows it keeps in the same text. A job is pruned per variation only when its rows are sent and they are its whole matrix. Send at most 64 jobs, 64 KiB and 256 rows per job, and 256 KiB in all; a job over its limits is decided as a whole.", + "example": { + "tests": "[{\"suite\":\"api\",\"shard\":1},{\"suite\":\"web\",\"shard\":1}]" + } + }, + "matrixRowsOmitted": { + "type": "array", + "items": { + "type": "string" + }, + "maxItems": 64, + "description": "Job keys whose rows you left out of `matrixRows` for size. Informational: those jobs are decided as a whole.", + "example": ["bin-packed"] } }, "required": [ @@ -3327,6 +3527,14 @@ "maxLength": 200, "description": "`BUILDKITE_PIPELINE_SLUG` on an agent.", "example": "widgets-pr" + }, + "matrixBlocks": { + "type": "object", + "additionalProperties": {}, + "description": "Each keyed matrix step's `matrix:` block, by step key, as `buildkite-agent pipeline upload --dry-run` renders it with environment variables resolved. Matrix steps are pruned per variation only when their block is sent; a step left out is decided as a whole. Send at most 64 KiB of blocks; Trunk ignores a larger map.", + "example": { + "build-image": ["amd64", "arm64"] + } } }, "required": [ @@ -3532,13 +3740,13 @@ }, "required": ["scope"] }, - "TestCollectionList": { + "PathsFilterWithJobsList": { "type": "object", "properties": { "data": { "type": "array", "items": { - "$ref": "#/components/schemas/TestCollection" + "$ref": "#/components/schemas/PathsFilterWithJobs" }, "maxItems": 100 }, @@ -3560,809 +3768,600 @@ }, "required": ["data", "nextCursor", "hasMore"] }, - "TestCollection": { + "PathsFilterWithJobs": { "type": "object", "properties": { - "id": { + "pathsFilterId": { "type": "string", - "description": "The collection's id.", - "example": "aB3xY9kQ" + "example": "e8f1c2a4-5b6d-4e7f-8a9b-0c1d2e3f4a5b" }, "name": { - "type": "string", - "example": "Backend integration tests" - }, - "description": { "type": ["string", "null"], - "example": "Owned by the platform team." - }, - "testCount": { - "type": "integer", - "description": "Distinct tests seen in this collection. Reflects ingested uploads, so a brand-new collection reports 0 until its first upload is processed. `GET /v2/test-collections/{id}` may serve a value up to a minute old.", - "example": 1284 + "description": "Null for an unnamed filter, which the web app shows as Custom.", + "example": "web" }, - "quarantineEnabled": { - "type": "boolean", - "description": "Whether quarantining is turned on for this collection. False until configured.", - "example": true + "rules": { + "$ref": "#/components/schemas/PathsFilterRules" }, - "autoQuarantineEnabled": { - "type": "boolean", - "description": "Whether flaky tests are quarantined automatically. False until configured.", - "example": false + "jobs": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PathsFilterJob" + }, + "maxItems": 10000, + "description": "The jobs the filter gates. A job the web app gave one filter for pull requests and another for the merge queue is listed under both." }, "createdAt": { "type": "string", "format": "date-time", - "example": "2026-01-14T09:12:00.000Z" + "example": "2026-10-26T20:31:04.512Z" }, "updatedAt": { "type": "string", "format": "date-time", - "example": "2026-07-20T16:44:10.000Z" + "example": "2026-10-26T20:31:04.512Z" } }, "required": [ - "id", + "pathsFilterId", "name", - "description", - "testCount", - "quarantineEnabled", - "autoQuarantineEnabled", + "rules", + "jobs", "createdAt", "updatedAt" ] }, - "CreateTestCollectionRequest": { + "PathsFilterRules": { "type": "object", "properties": { - "name": { - "type": "string", - "minLength": 1, - "maxLength": 100, - "description": "Display name. Leading and trailing whitespace is trimmed.", - "example": "Backend integration tests" + "include": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PathsFilterRule" + }, + "minItems": 1, + "maxItems": 64, + "description": "A changed file counts when some `include` rule matches it and no `exclude` rule does.", + "example": [ + { + "glob": "web/**" + } + ] }, - "description": { - "type": "string", - "maxLength": 500, - "example": "Owned by the platform team." + "exclude": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PathsFilterRule" + }, + "maxItems": 64, + "example": [ + { + "glob": "web/**/*.md" + } + ] } }, - "required": ["name"], - "description": "Fields for a new test collection." + "required": ["include", "exclude"], + "additionalProperties": false }, - "QuarantineStatus": { + "PathsFilterRule": { "type": "object", "properties": { - "testCollectionUuid": { - "type": "string", - "format": "uuid", - "description": "The collection's internal UUID, which a test's `testId` is computed from. Use it only for that: everywhere else a collection is addressed by its `id`.", - "example": "204b6c93-1c51-4e0f-a13c-e07b9bc60688" - }, - "repositoryId": { + "glob": { "type": "string", - "format": "uuid", - "description": "The repository the tests are stored under. The nil UUID for an upload without a repository, or for a repository Trunk does not know.", - "example": "7a1f0e3d-2b4c-4d5e-8f90-123456789abc" - }, - "quarantineEnabled": { - "type": "boolean", - "description": "Whether quarantining is on for the collection. When it is off, no test is quarantined.", - "example": true + "minLength": 1, + "maxLength": 256, + "description": "A picomatch glob, matched with `dot: true` against the repository-relative path. May not begin with `!` or `(`.", + "example": "web/**" }, - "tests": { + "changeTypes": { "type": "array", "items": { - "$ref": "#/components/schemas/QuarantineStatusTest" + "$ref": "#/components/schemas/ChangeType" }, - "maxItems": 2000, - "description": "One entry per requested identifier, in request order. Empty when none were sent. The whole quarantined set is `POST /v2/test-collections/{id}/all-quarantined-tests`." + "minItems": 1, + "maxItems": 6, + "description": "Match only these kinds of change. Absent matches any.", + "example": ["added", "modified"] } }, - "required": [ - "testCollectionUuid", - "repositoryId", - "quarantineEnabled", - "tests" - ] + "required": ["glob"], + "additionalProperties": false }, - "QuarantineStatusTest": { + "ChangeType": { + "type": "string", + "enum": [ + "added", + "copied", + "deleted", + "modified", + "renamed", + "unmerged" + ], + "description": "A kind of file change, as `dorny/paths-filter` names them.", + "example": "modified" + }, + "PathsFilterJob": { "type": "object", "properties": { - "clientTestId": { + "workflowPath": { "type": ["string", "null"], - "description": "The identifier's `id`, echoed so the caller can match it.", - "example": "88e5353c-190c-5dce-9d06-0e66c3e062b1" + "description": "The workflow file's path. Null if Trunk has not seen one.", + "example": ".github/workflows/ci.yaml" }, - "testId": { + "jobKey": { "type": ["string", "null"], - "format": "uuid", - "description": "The test's id, as `GET /v2/tests/{testId}` takes it. Always present when the identifier had an `id`. Without one, present only when the identifier matched a quarantined test by name.", - "example": "bfeebcf4-72d1-887d-8bcd-788d0dec7f97" + "description": "The job's key under `jobs:`. Null means the job is reachable only by `jobId`.", + "example": "web-unit" }, - "quarantined": { - "type": "boolean", - "description": "Whether the test is quarantined, so its failure should not fail the run.", - "example": true + "jobId": { + "type": "string", + "example": "3c4d0b17-8e2a-4f6c-9d1b-7a5e3c2f1d0e" } }, - "required": ["clientTestId", "testId", "quarantined"] + "required": ["workflowPath", "jobKey", "jobId"] }, - "QuarantineStatusRequest": { + "SetPathsFiltersResult": { "type": "object", "properties": { - "repo": { - "type": ["object", "null"], - "properties": { - "host": { - "type": "string", - "minLength": 1, - "example": "github.com" - }, - "owner": { - "type": "string", - "minLength": 1, - "example": "acme" - }, - "name": { - "type": "string", - "minLength": 1, - "example": "web" - } + "filters": { + "type": "array", + "items": { + "$ref": "#/components/schemas/WrittenFilter" }, - "required": ["host", "owner", "name"], - "description": "The repository the tests ran in, as the CLI reads it from git. `null` for an upload made without a repository (`--no-repo`)." + "maxItems": 100, + "description": "One per `filters` entry, leaving out an entry none of whose jobs resolved." }, - "testIdentifiers": { + "jobs": { "type": "array", "items": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "The CLI's id for the test, in UUID form. When present, the test is matched by it alone.", - "example": "88e5353c-190c-5dce-9d06-0e66c3e062b1" - }, - "name": { - "type": "string", - "description": "Required without `id`.", - "example": "renders the checkout total" - }, - "parentName": { - "type": "string", - "description": "Required without `id`.", - "example": "CheckoutSuite" - }, - "className": { - "type": "string", - "description": "Narrows a match by name. Ignored when `id` is present or when empty.", - "example": "CheckoutSuiteTest" - } - }, - "description": "A test, by `id`, or by `name` and `parentName` when it has no `id`. Sending only `id` keeps the request small.", - "anyOf": [ - { - "required": ["id"] - }, - { - "required": ["name", "parentName"] - } - ] + "$ref": "#/components/schemas/WrittenJob" }, - "maxItems": 2000, - "description": "The tests to report on, usually the run's failures. Each one gets an entry in `tests`, in this order." + "maxItems": 500, + "description": "One per job named, in request order. A job named by `jobId` is reported by its path and key." } }, - "required": ["repo"], - "description": "The repository and the tests to look up." + "required": ["filters", "jobs"] }, - "QuarantinedTestList": { + "WrittenFilter": { "type": "object", "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/QuarantinedTest" - }, - "maxItems": 25000 + "pathsFilterId": { + "type": "string", + "example": "e8f1c2a4-5b6d-4e7f-8a9b-0c1d2e3f4a5b" }, - "nextCursor": { + "name": { "type": ["string", "null"], - "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", - "example": "AQEKZm9vYmFy" + "description": "The stored name, which an existing named filter keeps.", + "example": "web" }, - "hasMore": { - "type": "boolean", - "description": "True when another page is available.", - "example": true + "status": { + "$ref": "#/components/schemas/WrittenFilterStatus" }, - "total": { + "jobCount": { "type": "integer", - "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", - "example": 1247 - }, - "testCollectionUuid": { - "type": "string", - "format": "uuid", - "description": "The collection's internal UUID, which a test's `testId` is computed from. Use it only for that: everywhere else a collection is addressed by its `id`.", - "example": "204b6c93-1c51-4e0f-a13c-e07b9bc60688" - }, - "repositoryId": { - "type": "string", - "format": "uuid", - "description": "The repository the tests are stored under. The nil UUID for an upload without a repository, or for a repository Trunk does not know.", - "example": "7a1f0e3d-2b4c-4d5e-8f90-123456789abc" - }, - "quarantineEnabled": { - "type": "boolean", - "description": "Whether quarantining is on for the collection. When it is off, no test is quarantined.", - "example": true + "description": "Distinct jobs on the filter after the write.", + "example": 1 } }, - "required": [ - "data", - "nextCursor", - "hasMore", - "testCollectionUuid", - "repositoryId", - "quarantineEnabled" - ] + "required": ["pathsFilterId", "name", "status", "jobCount"] }, - "QuarantinedTest": { + "WrittenFilterStatus": { + "type": "string", + "enum": ["new", "existing"], + "description": "Whether the request created the filter or found it by its rules.", + "example": "new" + }, + "WrittenJob": { "type": "object", "properties": { - "testId": { - "type": "string", - "format": "uuid", - "description": "The test's id, as `GET /v2/tests/{testId}` takes it. A test runner computes the same id for each test it runs from the list's `testCollectionUuid` and `repositoryId` and its own test id (`gen_test_case_guid`), then checks it against this list.", - "example": "bfeebcf4-72d1-887d-8bcd-788d0dec7f97" + "workflowPath": { + "type": ["string", "null"], + "example": ".github/workflows/ci.yaml" + }, + "jobKey": { + "type": ["string", "null"], + "example": "web-unit" + }, + "status": { + "$ref": "#/components/schemas/WrittenJobStatus" + }, + "jobIds": { + "type": "array", + "items": { + "type": "string" + }, + "maxItems": 500, + "description": "Every job the name matched; one name can match more than one. Empty for `unresolved`.", + "example": ["3c4d0b17-8e2a-4f6c-9d1b-7a5e3c2f1d0e"] } }, - "required": ["testId"] + "required": ["workflowPath", "jobKey", "status", "jobIds"] }, - "AllQuarantinedTestsRequest": { + "WrittenJobStatus": { + "type": "string", + "enum": ["set", "unchanged", "cleared", "unresolved"], + "description": "`set`: the job now has the filter. `unchanged`: nothing was written. `cleared`: its filter was removed. `unresolved`: Trunk has not seen the job run, so nothing was written; send the request again after it runs.", + "example": "set" + }, + "SetPathsFiltersRequest": { "type": "object", "properties": { "repo": { - "type": ["object", "null"], - "properties": { - "host": { - "type": "string", - "minLength": 1, - "example": "github.com" - }, - "owner": { - "type": "string", - "minLength": 1, - "example": "acme" - }, - "name": { - "type": "string", - "minLength": 1, - "example": "web" - } + "$ref": "#/components/schemas/PlanRepo" + }, + "overwrite": { + "type": "boolean", + "default": false, + "description": "Replace a different filter already on a job. Without it, such a job fails the request with `PATHS_FILTER_CONFLICT`.", + "example": false + }, + "filters": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PathsFilterEntry" }, - "required": ["host", "owner", "name"], - "description": "The repository the tests ran in, as the CLI reads it from git. `null` for an upload made without a repository (`--no-repo`)." + "maxItems": 100 + }, + "clear": { + "type": "array", + "items": { + "$ref": "#/components/schemas/JobRef" + }, + "maxItems": 500, + "description": "Jobs to remove the paths filter from." } }, "required": ["repo"], - "description": "The repository whose quarantined tests to list." + "additionalProperties": false }, - "Test": { - "allOf": [ - { - "$ref": "#/components/schemas/TestSummary" - }, - { - "type": "object", - "properties": { - "quarantineOverride": { - "anyOf": [ - { - "$ref": "#/components/schemas/QuarantineOverride" - }, - { - "type": "null" - } - ], - "description": "The override currently in effect on this test, or null if none is." - }, - "activeMonitors": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ActiveMonitor" - }, - "maxItems": 100, - "description": "The monitors currently classifying this test." - }, - "firstSeenAt": { - "type": ["string", "null"], - "format": "date-time", - "description": "When the test was first ingested. Null for tests last seen before Trunk began recording this, which is not backfilled.", - "example": "2026-05-20T08:00:00.000Z" - }, - "lastFailureAt": { - "type": ["string", "null"], - "format": "date-time", - "description": "The most recent failing run Trunk still holds metrics for. Null if the test has never failed within that window.", - "example": "2026-06-10T12:30:00.000Z" - } - }, - "required": [ - "quarantineOverride", - "activeMonitors", - "firstSeenAt", - "lastFailureAt" - ] - } - ] - }, - "TestStatus": { - "type": "string", - "enum": ["healthy", "flaky", "broken"], - "description": "A test's current composite status, reconciled across every active monitor.", - "example": "flaky" - }, - "QuarantineState": { - "type": "string", - "enum": ["quarantined", "notQuarantined"], - "description": "Whether the test is currently quarantined, derived from its status, the collection's quarantine settings and any override.", - "example": "notQuarantined" - }, - "Label": { + "PathsFilterEntry": { "type": "object", "properties": { - "id": { - "type": "string", - "example": "2b3c4d5e-6f70-4a1b-8c9d-0e1f2a3b4c5d" - }, "name": { - "type": "string", - "example": "slow-on-prs" + "type": ["string", "null"], + "maxLength": 80, + "description": "Trimmed; blank or absent is unnamed. Names a new filter, or an existing unnamed one with the same rules; an existing name is kept.", + "example": "web" }, - "description": { - "type": "string", - "example": "Tests that only get slow on pull-request runs." + "rules": { + "$ref": "#/components/schemas/PathsFilterRulesInput" }, - "assignedAt": { - "type": "string", - "format": "date-time", - "description": "The earliest of `sources[].assignedAt`. Exact when a user applied the label; see `MonitorLabelSource.assignedAt` for when a monitor did.", - "example": "2026-05-01T00:00:00.000Z" + "jobs": { + "type": "array", + "items": { + "$ref": "#/components/schemas/JobRef" + }, + "minItems": 1, + "maxItems": 500 + } + }, + "required": ["rules", "jobs"], + "additionalProperties": false + }, + "PathsFilterRulesInput": { + "type": "object", + "properties": { + "include": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PathsFilterRule" + }, + "minItems": 1, + "maxItems": 64, + "example": [ + { + "glob": "web/**" + } + ] }, - "sources": { + "exclude": { "type": "array", "items": { - "$ref": "#/components/schemas/LabelSource" + "$ref": "#/components/schemas/PathsFilterRule" }, - "maxItems": 100, - "description": "Everything that put this label on the test. More than one entry means several sources applied the same label independently; removing it clears them all." + "maxItems": 64, + "description": "Defaults to none.", + "example": [ + { + "glob": "web/**/*.md" + } + ] } }, - "required": ["id", "name", "description", "assignedAt", "sources"], - "description": "A label on a test, folded across its sources — one entry per label, never one per assignment." + "required": ["include"], + "additionalProperties": false }, - "LabelSource": { - "oneOf": [ + "JobRef": { + "anyOf": [ { - "$ref": "#/components/schemas/UserLabelSource" + "$ref": "#/components/schemas/JobRefByName" }, { - "$ref": "#/components/schemas/MonitorLabelSource" + "$ref": "#/components/schemas/JobRefById" } ], - "discriminator": { - "propertyName": "type", - "mapping": { - "user": "#/components/schemas/UserLabelSource", - "monitor": "#/components/schemas/MonitorLabelSource" - } - }, - "description": "Something that put a label on a test. A `user` source carries no monitor fields and a `monitor` source carries no user." + "description": "A job, as `{ workflowPath, jobKey }` or as `{ jobId }`." }, - "UserLabelSource": { + "JobRefByName": { "type": "object", "properties": { - "type": { + "workflowPath": { "type": "string", - "enum": ["user"] - }, - "user": { - "anyOf": [ - { - "$ref": "#/components/schemas/LabelUser" - }, - { - "type": "null" - } - ], - "description": "Who applied the label. Null when an API token did — a token resolves to no user." + "minLength": 1, + "description": "The workflow file's repository-relative path, exactly.", + "example": ".github/workflows/ci.yaml" }, - "assignedAt": { + "jobKey": { "type": "string", - "format": "date-time", - "description": "When the user applied the label.", - "example": "2026-06-01T00:00:00.000Z" + "minLength": 1, + "description": "The job's key under `jobs:` in that file.", + "example": "web-unit" } }, - "required": ["type", "user", "assignedAt"], - "description": "A label applied by hand." + "required": ["workflowPath", "jobKey"], + "additionalProperties": false }, - "LabelUser": { + "JobRefById": { "type": "object", "properties": { - "id": { + "jobId": { "type": "string", - "example": "6f708192-a3b4-4c5d-8e9f-0a1b2c3d4e5f" + "format": "uuid", + "description": "A job's id from `dynamicCi.listPathsFilters` or `dynamicCi.listPrJobs`. A `workflowPath` or `jobKey` sent beside it must name the same job.", + "example": "3c4f8e21-6a1d-4b7e-9f02-5d8c1a2b3e4f" }, - "name": { + "workflowPath": { "type": ["string", "null"], - "description": "Null only if the user record could not be resolved; the id still identifies them.", - "example": "Ada Lovelace" + "minLength": 1, + "description": "The workflow file's repository-relative path, exactly.", + "example": ".github/workflows/ci.yaml" + }, + "jobKey": { + "type": ["string", "null"], + "minLength": 1, + "description": "The job's key under `jobs:` in that file.", + "example": "web-unit" } }, - "required": ["id", "name"], - "description": "The person who applied a label." + "required": ["jobId"], + "additionalProperties": false }, - "MonitorLabelSource": { + "TestCollectionList": { "type": "object", "properties": { - "type": { - "type": "string", - "enum": ["monitor"] + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TestCollection" + }, + "maxItems": 100 }, - "monitorId": { - "type": "string", - "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" + "nextCursor": { + "type": ["string", "null"], + "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", + "example": "AQEKZm9vYmFy" }, - "monitorType": { - "$ref": "#/components/schemas/LabelingMonitorType" + "hasMore": { + "type": "boolean", + "description": "True when another page is available.", + "example": true }, - "assignedAt": { - "type": "string", - "format": "date-time", - "description": "The monitor has applied this label since at least this time. Muting the monitor, then unmuting it, and editing its label action all re-create the assignment, so this can be later than the first time it applied the label.", - "example": "2026-06-01T00:00:00.000Z" + "total": { + "type": "integer", + "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", + "example": 1247 } }, - "required": ["type", "monitorId", "monitorType", "assignedAt"], - "description": "A label applied by a monitor." - }, - "LabelingMonitorType": { - "type": "string", - "enum": [ - "failureRate", - "passOnRetry", - "failureCount", - "newTest", - "skippedTest", - "slowTest", - "timeoutInflation" - ], - "description": "A monitor type that can apply a label.", - "example": "failureRate" + "required": ["data", "nextCursor", "hasMore"] }, - "TicketSummary": { + "TestCollection": { "type": "object", "properties": { "id": { "type": "string", - "description": "Trunk's id for the linked ticket.", - "example": "5d4c3b2a-1f0e-4a1b-8c9d-0e1f2a3b4c5d" - }, - "provider": { - "$ref": "#/components/schemas/TicketProvider" + "description": "The collection's id.", + "example": "aB3xY9kQ" }, - "key": { + "name": { "type": "string", - "description": "The provider's human-readable key. Mutable on some providers (a Jira issue moved between projects gets a new one).", - "example": "TRUNK-1234" + "example": "Backend integration tests" }, - "url": { - "type": "string", - "format": "uri", - "example": "https://acme.atlassian.net/browse/TRUNK-1234" - }, - "status": { - "type": "string", - "description": "The provider's status name, as last synced.", - "example": "In Progress" - }, - "deletedAt": { + "description": { "type": ["string", "null"], - "format": "date-time", - "description": "When Trunk found that the ticketing provider no longer has this ticket; null while it exists. A deleted ticket stays linked until it is unlinked, and its `status` is the last one synced.", - "example": "2026-10-01T09:00:00.000Z" - } - }, - "required": ["id", "provider", "key", "url", "status", "deletedAt"], - "description": "The ticket linked to a test, as Trunk last synced it. Reading a test never calls the ticketing provider." - }, - "TicketProvider": { - "type": "string", - "enum": ["jiraCloud", "linear", "asana", "jiraDataCenter"], - "description": "The ticketing system a ticket lives in.", - "example": "jiraCloud" - }, - "TestMetrics": { - "type": "object", - "properties": { - "failureRate": { - "type": "number", - "description": "Failing runs over total runs in the period, 0 to 1.", - "example": 0.25 - }, - "prsImpacted": { - "type": "integer", - "description": "Distinct pull requests that saw this test fail while it was unhealthy and not quarantined.", - "example": 3 + "example": "Owned by the platform team." }, - "runCount": { + "testCount": { "type": "integer", - "example": 40 + "description": "Distinct tests seen in this collection. Reflects ingested uploads, so a brand-new collection reports 0 until its first upload is processed. `GET /v2/test-collections/{id}` may serve a value up to a minute old.", + "example": 1284 }, - "failureCount": { - "type": "integer", - "example": 10 + "quarantineEnabled": { + "type": "boolean", + "description": "Whether quarantining is turned on for this collection. False until configured.", + "example": true }, - "durationP95Ms": { - "type": ["integer", "null"], - "description": "95th-percentile duration in milliseconds. Null when nothing measurable ran in the period — skipped runs are not measured.", - "example": 1200 + "autoQuarantineEnabled": { + "type": "boolean", + "description": "Whether flaky tests are quarantined automatically. False until configured.", + "example": false }, - "lastRunAt": { - "type": ["string", "null"], + "createdAt": { + "type": "string", "format": "date-time", - "example": "2026-06-02T10:00:00.000Z" + "example": "2026-01-14T09:12:00.000Z" }, - "lastFailureAt": { - "type": ["string", "null"], + "updatedAt": { + "type": "string", "format": "date-time", - "description": "Within the period, unlike the test's own field.", - "example": "2026-06-01T10:00:00.000Z" + "example": "2026-07-20T16:44:10.000Z" } }, "required": [ - "failureRate", - "prsImpacted", - "runCount", - "failureCount", - "durationP95Ms", - "lastRunAt", - "lastFailureAt" + "id", + "name", + "description", + "testCount", + "quarantineEnabled", + "autoQuarantineEnabled", + "createdAt", + "updatedAt" ] }, - "QuarantineOverride": { + "CreateTestCollectionRequest": { "type": "object", "properties": { - "mode": { - "$ref": "#/components/schemas/QuarantineMode" - }, - "reason": { - "type": ["string", "null"], - "example": "flaky in CI" - }, - "createdAt": { + "name": { "type": "string", - "format": "date-time", - "example": "2026-06-05T00:00:00.000Z" - } - }, - "required": ["mode", "reason", "createdAt"] - }, - "QuarantineMode": { - "type": "string", - "enum": ["alwaysQuarantine", "neverQuarantine"], - "description": "A per-test quarantine override.", - "example": "alwaysQuarantine" - }, - "ActiveMonitor": { - "type": "object", - "properties": { - "monitorId": { - "type": ["string", "null"], - "description": "Null for `manual`, which has no monitor resource.", - "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" - }, - "monitorType": { - "$ref": "#/components/schemas/ActiveMonitorType" + "minLength": 1, + "maxLength": 100, + "description": "Display name. Leading and trailing whitespace is trimmed.", + "example": "Backend integration tests" }, - "activeSince": { + "description": { "type": "string", - "format": "date-time", - "description": "The monitor has been active on this test since at least this time.", - "example": "2026-06-05T00:00:00.000Z" + "maxLength": 500, + "example": "Owned by the platform team." } }, - "required": ["monitorId", "monitorType", "activeSince"], - "description": "A monitor watching this test. Includes types that never affect its status." - }, - "ActiveMonitorType": { - "type": "string", - "enum": [ - "failureRate", - "passOnRetry", - "failureCount", - "newTest", - "skippedTest", - "slowTest", - "timeoutInflation", - "manual" - ], - "description": "A monitor type that can be active on a test. `manual` is the 'flag as flaky' mark, which has no addressable monitor resource and always reports a null `monitorId`.", - "example": "failureRate" + "required": ["name"], + "description": "Fields for a new test collection." }, - "TestSummary": { + "QuarantineStatus": { "type": "object", "properties": { - "id": { - "type": "string", - "description": "The test's globally unique id. Stable across repos and collections, and safe to store.", - "example": "bfeebcf4-0000-8000-8000-000000000001" - }, - "testCollectionId": { + "testCollectionUuid": { "type": "string", - "description": "The owning collection's id.", - "example": "aB3xY9kQ" + "format": "uuid", + "description": "The collection's internal UUID, which a test's `testId` is computed from. Use it only for that: everywhere else a collection is addressed by its `id`.", + "example": "204b6c93-1c51-4e0f-a13c-e07b9bc60688" }, "repositoryId": { "type": "string", - "description": "The repository the test was uploaded for. Resolve with `GET /v2/repositories/{id}`. Uploads made without a repository carry the nil UUID, which names no repository and does not resolve.", - "example": "7a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" - }, - "name": { - "type": "string", - "example": "suite::test_case_name" - }, - "parentName": { - "type": "string", - "example": "Foo" - }, - "className": { - "type": "string", - "example": "FooSuite" - }, - "file": { - "type": "string", - "example": "src/foo.test.ts" - }, - "target": { - "type": "string", - "description": "The build target that ran the test, when one was reported.", - "example": "//src:foo_test" - }, - "variant": { - "type": "string", - "example": "" + "format": "uuid", + "description": "The repository the tests are stored under. The nil UUID for an upload without a repository, or for a repository Trunk does not know.", + "example": "7a1f0e3d-2b4c-4d5e-8f90-123456789abc" }, - "crossVariantId": { - "type": ["string", "null"], - "description": "Groups the same test across variants, when it has any.", - "example": "5d4c3b2a-1f0e-4a1b-8c9d-0e1f2a3b4c5d" + "quarantineEnabled": { + "type": "boolean", + "description": "Whether quarantining is on for the collection. When it is off, no test is quarantined.", + "example": true }, - "codeowners": { + "tests": { "type": "array", "items": { - "type": "string" + "$ref": "#/components/schemas/QuarantineStatusTest" }, - "maxItems": 1000, - "example": ["@team-a"] - }, - "status": { - "$ref": "#/components/schemas/TestStatus" - }, - "statusSince": { + "maxItems": 2000, + "description": "One entry per requested identifier, in request order. Empty when none were sent. The whole quarantined set is `POST /v2/test-collections/{id}/all-quarantined-tests`." + } + }, + "required": [ + "testCollectionUuid", + "repositoryId", + "quarantineEnabled", + "tests" + ] + }, + "QuarantineStatusTest": { + "type": "object", + "properties": { + "clientTestId": { "type": ["string", "null"], - "format": "date-time", - "description": "When `status` last changed — how long the test has been in its current state. Null for a test no monitor has ever classified.", - "example": "2026-06-01T10:00:00.000Z" - }, - "quarantineState": { - "$ref": "#/components/schemas/QuarantineState" + "description": "The identifier's `id`, echoed so the caller can match it.", + "example": "88e5353c-190c-5dce-9d06-0e66c3e062b1" }, - "quarantinedSince": { + "testId": { "type": ["string", "null"], - "format": "date-time", - "description": "When the test's current quarantine began, as far as Trunk records it. Null exactly when `quarantineState` is `notQuarantined`. For a test quarantined by an `alwaysQuarantine` override, the time that override was set. For a test quarantined automatically, the later of `statusSince` and the last time an override on it was cleared. Changes to the collection's quarantine settings are not recorded per test, so this can be earlier than when quarantining was turned on for the collection.", - "example": "2026-06-01T10:00:00.000Z" - }, - "labels": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Label" - }, - "maxItems": 100 - }, - "url": { - "type": "string", - "format": "uri", - "description": "The test's page in the Trunk web app.", - "example": "https://app.trunk.io/acme/flaky-tests/collections/aB3xY9kQ/tests/bfeebcf4-0000-8000-8000-000000000001" + "format": "uuid", + "description": "The test's id, as `GET /v2/tests/{testId}` takes it. Always present when the identifier had an `id`. Without one, present only when the identifier matched a quarantined test by name.", + "example": "bfeebcf4-72d1-887d-8bcd-788d0dec7f97" }, - "ticket": { - "anyOf": [ - { - "$ref": "#/components/schemas/TicketSummary" - }, - { - "type": "null" - } - ], - "description": "The ticket currently linked to this test, as Trunk last synced it, or null if none is linked." - }, - "metrics": { - "anyOf": [ - { - "$ref": "#/components/schemas/TestMetrics" - }, - { - "type": "null" - } - ], - "description": "Returned only when `include=metrics` is set. Null when the test had no runs in `period`." + "quarantined": { + "type": "boolean", + "description": "Whether the test is quarantined, so its failure should not fail the run.", + "example": true } }, - "required": [ - "id", - "testCollectionId", - "repositoryId", - "name", - "parentName", - "className", - "file", - "target", - "variant", - "crossVariantId", - "codeowners", - "status", - "statusSince", - "quarantineState", - "quarantinedSince", - "labels", - "url", - "ticket" - ] + "required": ["clientTestId", "testId", "quarantined"] }, - "TestList": { + "QuarantineStatusRequest": { "type": "object", "properties": { - "data": { + "repo": { + "type": ["object", "null"], + "properties": { + "host": { + "type": "string", + "minLength": 1, + "example": "github.com" + }, + "owner": { + "type": "string", + "minLength": 1, + "example": "acme" + }, + "name": { + "type": "string", + "minLength": 1, + "example": "web" + } + }, + "required": ["host", "owner", "name"], + "description": "The repository the tests ran in, as the CLI reads it from git. `null` for an upload made without a repository (`--no-repo`)." + }, + "testIdentifiers": { "type": "array", "items": { - "$ref": "#/components/schemas/TestSummary" + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The CLI's id for the test, in UUID form. When present, the test is matched by it alone.", + "example": "88e5353c-190c-5dce-9d06-0e66c3e062b1" + }, + "name": { + "type": "string", + "description": "Required without `id`.", + "example": "renders the checkout total" + }, + "parentName": { + "type": "string", + "description": "Required without `id`.", + "example": "CheckoutSuite" + }, + "className": { + "type": "string", + "description": "Narrows a match by name. Ignored when `id` is present or when empty.", + "example": "CheckoutSuiteTest" + } + }, + "description": "A test, by `id`, or by `name` and `parentName` when it has no `id`. Sending only `id` keeps the request small.", + "anyOf": [ + { + "required": ["id"] + }, + { + "required": ["name", "parentName"] + } + ] }, - "maxItems": 100 - }, - "nextCursor": { - "type": ["string", "null"], - "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", - "example": "AQEKZm9vYmFy" - }, - "hasMore": { - "type": "boolean", - "description": "True when another page is available.", - "example": true - }, - "total": { - "type": "integer", - "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", - "example": 1247 + "maxItems": 2000, + "description": "The tests to report on, usually the run's failures. Each one gets an entry in `tests`, in this order." } }, - "required": ["data", "nextCursor", "hasMore"] + "required": ["repo"], + "description": "The repository and the tests to look up." }, - "StatusHistoryEntryList": { + "QuarantinedTestList": { "type": "object", "properties": { "data": { "type": "array", "items": { - "$ref": "#/components/schemas/StatusHistoryEntry" + "$ref": "#/components/schemas/QuarantinedTest" }, - "maxItems": 100 + "maxItems": 25000 }, "nextCursor": { "type": ["string", "null"], @@ -4378,333 +4377,280 @@ "type": "integer", "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", "example": 1247 - } - }, - "required": ["data", "nextCursor", "hasMore"] - }, - "StatusHistoryEntry": { - "type": "object", - "properties": { - "id": { - "type": "string", - "example": "5a7fef9e-c8cd-8eed-8a87-9494bdf96bed" - }, - "fromStatus": { - "$ref": "#/components/schemas/TestStatus" - }, - "toStatus": { - "$ref": "#/components/schemas/TestStatus" }, - "activeMonitors": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ClassifyingMonitor" - }, - "maxItems": 100, - "description": "The monitors active immediately after the transition, recorded at the time rather than resolved on read — so a monitor deleted since still appears." + "testCollectionUuid": { + "type": "string", + "format": "uuid", + "description": "The collection's internal UUID, which a test's `testId` is computed from. Use it only for that: everywhere else a collection is addressed by its `id`.", + "example": "204b6c93-1c51-4e0f-a13c-e07b9bc60688" }, - "startedAt": { + "repositoryId": { "type": "string", - "format": "date-time", - "description": "When this status began — the moment of the transition, and the start of the period the row describes.", - "example": "2026-06-02T10:00:00.000Z" + "format": "uuid", + "description": "The repository the tests are stored under. The nil UUID for an upload without a repository, or for a repository Trunk does not know.", + "example": "7a1f0e3d-2b4c-4d5e-8f90-123456789abc" + }, + "quarantineEnabled": { + "type": "boolean", + "description": "Whether quarantining is on for the collection. When it is off, no test is quarantined.", + "example": true } }, "required": [ - "id", - "fromStatus", - "toStatus", - "activeMonitors", - "startedAt" + "data", + "nextCursor", + "hasMore", + "testCollectionUuid", + "repositoryId", + "quarantineEnabled" ] }, - "ClassifyingMonitor": { + "QuarantinedTest": { "type": "object", "properties": { - "monitorId": { - "type": ["string", "null"], - "description": "Null for `manual`, which has no monitor resource.", - "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" - }, - "monitorType": { - "$ref": "#/components/schemas/ClassifyingMonitorType" + "testId": { + "type": "string", + "format": "uuid", + "description": "The test's id, as `GET /v2/tests/{testId}` takes it. A test runner computes the same id for each test it runs from the list's `testCollectionUuid` and `repositoryId` and its own test id (`gen_test_case_guid`), then checks it against this list.", + "example": "bfeebcf4-72d1-887d-8bcd-788d0dec7f97" } }, - "required": ["monitorId", "monitorType"], - "description": "A monitor that was classifying this test at the moment of the transition." - }, - "ClassifyingMonitorType": { - "type": "string", - "enum": ["failureRate", "passOnRetry", "failureCount", "manual"], - "description": "A monitor type that can classify a test's status. Narrower than `ActiveMonitorType`: the lifecycle and performance monitors watch a test without ever changing its status.", - "example": "failureRate" + "required": ["testId"] }, - "TestRunList": { + "AllQuarantinedTestsRequest": { "type": "object", "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TestRun" + "repo": { + "type": ["object", "null"], + "properties": { + "host": { + "type": "string", + "minLength": 1, + "example": "github.com" + }, + "owner": { + "type": "string", + "minLength": 1, + "example": "acme" + }, + "name": { + "type": "string", + "minLength": 1, + "example": "web" + } }, - "maxItems": 100 - }, - "nextCursor": { - "type": ["string", "null"], - "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", - "example": "AQEKZm9vYmFy" - }, - "hasMore": { - "type": "boolean", - "description": "True when another page is available.", - "example": true - }, - "total": { - "type": "integer", - "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", - "example": 1247 + "required": ["host", "owner", "name"], + "description": "The repository the tests ran in, as the CLI reads it from git. `null` for an upload made without a repository (`--no-repo`)." } }, - "required": ["data", "nextCursor", "hasMore"] + "required": ["repo"], + "description": "The repository whose quarantined tests to list." }, - "TestRun": { - "type": "object", - "properties": { - "id": { - "type": "string", - "example": "1f9ddce9-b5f5-5676-8eef-770e11cf761f" - }, - "conclusion": { - "$ref": "#/components/schemas/Conclusion" + "Test": { + "allOf": [ + { + "$ref": "#/components/schemas/TestSummary" }, - "branch": { + { + "type": "object", + "properties": { + "quarantineOverride": { + "anyOf": [ + { + "$ref": "#/components/schemas/QuarantineOverride" + }, + { + "type": "null" + } + ], + "description": "The override currently in effect on this test, or null if none is." + }, + "activeMonitors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ActiveMonitor" + }, + "maxItems": 100, + "description": "The monitors currently classifying this test." + }, + "manualFlag": { + "anyOf": [ + { + "$ref": "#/components/schemas/ManualFlag" + }, + { + "type": "null" + } + ], + "description": "The test's flaky mark set by hand, or null if it has none. While it is set, `activeMonitors` also lists a `manual` entry. The mark is not a status override: a monitor classifying the test as broken still wins `status`." + }, + "firstSeenAt": { + "type": ["string", "null"], + "format": "date-time", + "description": "When the test was first ingested. Null for tests last seen before Trunk began recording this, which is not backfilled.", + "example": "2026-05-20T08:00:00.000Z" + }, + "lastFailureAt": { + "type": ["string", "null"], + "format": "date-time", + "description": "The most recent failing run Trunk still holds metrics for. Null if the test has never failed within that window.", + "example": "2026-06-10T12:30:00.000Z" + } + }, + "required": [ + "quarantineOverride", + "activeMonitors", + "manualFlag", + "firstSeenAt", + "lastFailureAt" + ] + } + ] + }, + "TestStatus": { + "type": "string", + "enum": ["healthy", "flaky", "broken"], + "description": "A test's current composite status, reconciled across every active monitor.", + "example": "flaky" + }, + "QuarantineState": { + "type": "string", + "enum": ["quarantined", "notQuarantined"], + "description": "Whether the test is currently quarantined, derived from its status, the collection's quarantine settings and any override.", + "example": "notQuarantined" + }, + "Label": { + "type": "object", + "properties": { + "id": { "type": "string", - "example": "main" - }, - "isPullRequest": { - "type": "boolean", - "description": "True when the run happened on a pull-request branch.", - "example": false + "example": "2b3c4d5e-6f70-4a1b-8c9d-0e1f2a3b4c5d" }, - "sha": { + "name": { "type": "string", - "example": "9c58bf40e5c1a2b3d4e5f60718293a4b5c6d7e8f" - }, - "quarantineState": { - "$ref": "#/components/schemas/QuarantineState" + "example": "slow-on-prs" }, - "statusAtRunTime": { - "$ref": "#/components/schemas/TestStatus" + "description": { + "type": "string", + "example": "Tests that only get slow on pull-request runs." }, - "startedAt": { + "color": { "type": "string", - "format": "date-time", - "example": "2026-06-02T10:00:00.000Z" + "description": "The label's hex color, as the web app shows it. A label created by `POST /v2/tests/{testId}/add-labels` starts as `#6366F1`.", + "example": "#6366F1" }, - "endedAt": { + "assignedAt": { "type": "string", "format": "date-time", - "example": "2026-06-02T10:00:03.500Z" - }, - "pullRequest": { - "anyOf": [ - { - "$ref": "#/components/schemas/TestRunPullRequest" - }, - { - "type": "null" - } - ], - "description": "Null for a run that was not on a pull request." - }, - "buildUrl": { - "type": ["string", "null"], - "description": "Link to the CI job run that reported this test run. Null for older runs: Trunk keeps uploads for less time than it keeps runs.", - "example": "https://github.com/acme/widgets/actions/runs/1" - }, - "workflow": { - "type": ["string", "null"], - "description": "The CI workflow the run came from.", - "example": "CI" + "description": "The earliest of `sources[].assignedAt`. Exact when a user applied the label; see `MonitorLabelSource.assignedAt` for when a monitor did.", + "example": "2026-05-01T00:00:00.000Z" }, - "jobName": { - "type": ["string", "null"], - "description": "The name of the CI job within that workflow.", - "example": "unit" + "sources": { + "type": "array", + "items": { + "$ref": "#/components/schemas/LabelSource" + }, + "maxItems": 100, + "description": "Everything that put this label on the test. More than one entry means several sources applied the same label independently. `POST /v2/tests/{testId}/remove-labels` removes only the `user` source; a `monitor` source stays until the monitor stops applying the label." } }, "required": [ "id", - "conclusion", - "branch", - "isPullRequest", - "sha", - "quarantineState", - "statusAtRunTime", - "startedAt", - "endedAt", - "pullRequest", - "buildUrl", - "workflow", - "jobName" - ] + "name", + "description", + "color", + "assignedAt", + "sources" + ], + "description": "A label on a test, folded across its sources — one entry per label, never one per assignment." }, - "Conclusion": { - "type": "string", - "enum": ["success", "failure", "skipped"], - "description": "How a single test run finished.", - "example": "failure" + "LabelSource": { + "oneOf": [ + { + "$ref": "#/components/schemas/UserLabelSource" + }, + { + "$ref": "#/components/schemas/MonitorLabelSource" + } + ], + "discriminator": { + "propertyName": "type", + "mapping": { + "user": "#/components/schemas/UserLabelSource", + "monitor": "#/components/schemas/MonitorLabelSource" + } + }, + "description": "Something that put a label on a test. A `user` source carries no monitor fields and a `monitor` source carries no user." }, - "TestRunPullRequest": { + "UserLabelSource": { "type": "object", "properties": { - "number": { - "type": "integer", - "example": 4901 + "type": { + "type": "string", + "enum": ["user"] }, - "url": { + "user": { + "anyOf": [ + { + "$ref": "#/components/schemas/LabelUser" + }, + { + "type": "null" + } + ], + "description": "Who applied the label. Null when an API token did, since a token resolves to no user, or when that user has since been deleted." + }, + "assignedAt": { "type": "string", - "description": "The pull request's URL, when Trunk has it.", - "example": "https://github.com/acme/widgets/pull/4901" + "format": "date-time", + "description": "When the label was applied.", + "example": "2026-06-01T00:00:00.000Z" } }, - "required": ["number"] + "required": ["type", "user", "assignedAt"], + "description": "A label applied by hand: in the web app, or through `POST /v2/tests/{testId}/add-labels`." }, - "DetectionEventList": { + "LabelUser": { "type": "object", "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/DetectionEvent" - }, - "maxItems": 100 + "id": { + "type": "string", + "example": "6f708192-a3b4-4c5d-8e9f-0a1b2c3d4e5f" }, - "nextCursor": { + "name": { "type": ["string", "null"], - "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", - "example": "AQEKZm9vYmFy" - }, - "hasMore": { - "type": "boolean", - "description": "True when another page is available.", - "example": true - }, - "total": { - "type": "integer", - "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", - "example": 1247 + "description": "Null only if the user record could not be resolved; the id still identifies them.", + "example": "Ada Lovelace" } }, - "required": ["data", "nextCursor", "hasMore"] + "required": ["id", "name"], + "description": "The person who applied a label." }, - "DetectionEvent": { + "MonitorLabelSource": { "type": "object", "properties": { - "id": { - "type": "string", - "example": "5d6e7f80-91a2-4b3c-8d4e-5f6071829304" - }, - "testCollectionId": { + "type": { "type": "string", - "description": "The id of the test collection the test belongs to.", - "example": "aB3xY9kQ" + "enum": ["monitor"] }, "monitorId": { "type": "string", "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" }, "monitorType": { - "$ref": "#/components/schemas/MonitorType" - }, - "monitorStatus": { - "$ref": "#/components/schemas/MonitorStatus" + "$ref": "#/components/schemas/LabelingMonitorType" }, - "testId": { - "type": "string", - "description": "The test's globally unique id.", - "example": "bfeebcf4-0000-8000-8000-000000000001" - }, - "classification": { - "anyOf": [ - { - "$ref": "#/components/schemas/TestStatus" - }, - { - "type": "null" - } - ], - "description": "The status the event's classify action names. Null when the event has no classify action, or when its classify action names a status this API does not report; `isClassificationEvent` is still `true` then." - }, - "isClassificationEvent": { - "type": "boolean", - "description": "True when the event carries a classify action. It does not mean the test's status changed: several monitors can be active on one test, and `/tests/{testId}/status-history` records the changes.", - "example": true - }, - "deactivationReason": { - "anyOf": [ - { - "$ref": "#/components/schemas/DeactivationReason" - }, - { - "type": "null" - } - ], - "description": "Set when the monitor became inactive because it was disabled or deleted. Null for a detection, and for a test that recovered." - }, - "detectedAt": { + "assignedAt": { "type": "string", "format": "date-time", - "example": "2026-06-02T10:00:00.000Z" - }, - "monitorKey": { - "type": ["string", "null"], - "description": "The detection pipeline's key for the event. Null for an event that a change to the monitor caused.", - "example": "7a1f0e3d-2b4c-4d5e-8f90-123456789abc:9c8b7a6f-5e4d-4c3b-8a2f-1b2c3d4e5f60:1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d:recovered" - }, - "sha": { - "type": ["string", "null"], - "description": "The commit the detection was made on, when it has one.", - "example": "9c58bf40e5c1a2b3d4e5f60718293a4b5c6d7e8f" - }, - "actions": { - "type": "array", - "items": { - "$ref": "#/components/schemas/DetectionEventAction" - }, - "maxItems": 100, - "description": "The actions the monitor was configured to take when the event was recorded." - }, - "actor": { - "anyOf": [ - { - "$ref": "#/components/schemas/DetectionEventActor" - }, - { - "type": "null" - } - ], - "description": "The person who disabled or deleted the monitor. Null for an event the detection pipeline made, and for a change made with an API token." + "description": "The monitor has applied this label since at least this time. Muting the monitor, then unmuting it, and editing its label action all re-create the assignment, so this can be later than the first time it applied the label.", + "example": "2026-06-01T00:00:00.000Z" } }, - "required": [ - "id", - "testCollectionId", - "monitorId", - "monitorType", - "monitorStatus", - "testId", - "classification", - "isClassificationEvent", - "deactivationReason", - "detectedAt", - "monitorKey", - "sha", - "actions", - "actor" - ] + "required": ["type", "monitorId", "monitorType", "assignedAt"], + "description": "A label applied by a monitor." }, - "MonitorType": { + "LabelingMonitorType": { "type": "string", "enum": [ "failureRate", @@ -4715,880 +4661,828 @@ "slowTest", "timeoutInflation" ], - "description": "A monitor's type. The 'flag as flaky' mark is not a monitor, so `manual` is not one of them.", + "description": "A monitor type that can apply a label.", "example": "failureRate" }, - "MonitorStatus": { - "type": "string", - "enum": ["active", "inactive"], - "description": "A monitor's verdict on one test: `active` when it detected the condition it watches for, `inactive` when the test recovered or the monitor stopped watching.", - "example": "active" - }, - "DeactivationReason": { - "type": "string", - "enum": ["monitorDisabled", "monitorDeleted"], - "description": "Why a monitor stopped being active on a test because of a change to the monitor itself.", - "example": "monitorDisabled" - }, - "DetectionEventAction": { - "oneOf": [ - { - "$ref": "#/components/schemas/DetectionEventClassifyAction" - }, - { - "$ref": "#/components/schemas/DetectionEventLabelAction" - } - ], - "discriminator": { - "propertyName": "type", - "mapping": { - "classify": "#/components/schemas/DetectionEventClassifyAction", - "label": "#/components/schemas/DetectionEventLabelAction" - } - }, - "description": "An action the monitor was configured to take, recorded with the event." - }, - "DetectionEventClassifyAction": { + "TicketSummary": { "type": "object", "properties": { - "type": { + "id": { "type": "string", - "enum": ["classify"] + "description": "Trunk's id for the linked ticket.", + "example": "5d4c3b2a-1f0e-4a1b-8c9d-0e1f2a3b4c5d" }, - "classification": { - "$ref": "#/components/schemas/TestStatus" - } - }, - "required": ["type", "classification"], - "description": "The monitor classified the test." - }, - "DetectionEventLabelAction": { - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": ["label"] + "provider": { + "$ref": "#/components/schemas/TicketProvider" }, - "labels": { - "type": "array", - "items": { - "$ref": "#/components/schemas/DetectionEventLabel" - }, - "maxItems": 100 - } - }, - "required": ["type", "labels"], - "description": "The monitor applied labels to the test, or removed them." - }, - "DetectionEventLabel": { - "type": "object", - "properties": { - "name": { + "key": { "type": "string", - "example": "slow" + "description": "The provider's human-readable key. Mutable on some providers (a Jira issue moved between projects gets a new one).", + "example": "TRUNK-1234" }, - "color": { + "url": { "type": "string", - "example": "#f97316" - } - }, - "required": ["name", "color"], - "description": "A label as it was when the event was recorded." - }, - "DetectionEventActor": { - "type": "object", - "properties": { - "userId": { + "format": "uri", + "example": "https://acme.atlassian.net/browse/TRUNK-1234" + }, + "status": { "type": "string", - "example": "6f708192-a3b4-4c5d-8e9f-0a1b2c3d4e5f" + "description": "The provider's status name, as last synced.", + "example": "In Progress" }, - "displayName": { + "deletedAt": { "type": ["string", "null"], - "description": "Null only if the user record could not be found.", - "example": "Ada Lovelace" + "format": "date-time", + "description": "When Trunk found that the ticketing provider no longer has this ticket; null while it exists. A deleted ticket stays linked until it is unlinked, and its `status` is the last one synced.", + "example": "2026-10-01T09:00:00.000Z" } }, - "required": ["userId", "displayName"], - "description": "The person whose change to the monitor caused the event." + "required": ["id", "provider", "key", "url", "status", "deletedAt"], + "description": "The ticket linked to a test, as Trunk last synced it. Reading a test never calls the ticketing provider." }, - "InvestigationSummaryList": { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/InvestigationSummary" - }, - "maxItems": 100 - }, - "nextCursor": { - "type": ["string", "null"], - "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", - "example": "AQEKZm9vYmFy" - }, - "hasMore": { - "type": "boolean", - "description": "True when another page is available.", - "example": true - }, - "total": { - "type": "integer", - "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", - "example": 1247 - } - }, - "required": ["data", "nextCursor", "hasMore"] + "TicketProvider": { + "type": "string", + "enum": ["jiraCloud", "linear", "asana", "jiraDataCenter"], + "description": "The ticketing system a ticket lives in.", + "example": "jiraCloud" }, - "InvestigationSummary": { + "TestMetrics": { "type": "object", "properties": { - "id": { - "type": "string", - "example": "5a7fef9e-c8cd-4eed-8a87-9494bdf96bed" - }, - "testId": { - "type": "string", - "description": "The investigated test's globally unique id.", - "example": "bfeebcf4-0000-8000-8000-000000000001" - }, - "status": { - "$ref": "#/components/schemas/InvestigationStatus" - }, - "triggerType": { - "$ref": "#/components/schemas/InvestigationTriggerType" + "failureRate": { + "type": "number", + "description": "Failing runs over total runs in the period, 0 to 1.", + "example": 0.25 }, - "detectionEventId": { - "type": ["string", "null"], - "description": "The detection that started an `automatic` investigation.", - "example": "6b8f0aaf-d9de-4ffe-9b98-a5a5ceca7cfe" + "prsImpacted": { + "type": "integer", + "description": "Distinct pull requests that saw this test fail while it was unhealthy and not quarantined.", + "example": 3 }, - "factCount": { + "runCount": { "type": "integer", - "example": 4 + "example": 40 }, - "overallConfidence": { - "type": ["number", "null"], - "description": "The model's confidence in the summary, from 0 to 1. Null unless `completed`.", - "example": 0.75 + "failureCount": { + "type": "integer", + "example": 10 }, - "markdownSummary": { - "type": ["string", "null"], - "description": "The investigation's conclusion, in Markdown. Null unless `completed`.", - "example": "The test is flaky because it races the cache warm-up introduced in [this commit](https://github.com/acme/widgets/commit/9c58bf40e5c1)." + "durationP95Ms": { + "type": ["integer", "null"], + "description": "95th-percentile duration in milliseconds. Null when nothing measurable ran in the period — skipped runs are not measured.", + "example": 1200 }, - "errorMessage": { + "lastRunAt": { "type": ["string", "null"], - "description": "Why a `failed` or `skipped` investigation did not complete.", - "example": "The monthly investigation limit for this collection was reached" - }, - "actor": { - "anyOf": [ - { - "$ref": "#/components/schemas/InvestigationActor" - }, - { - "type": "null" - } - ], - "description": "Who started a `manual` or `mcp` investigation. Null for an `automatic` one." - }, - "createdAt": { - "type": "string", "format": "date-time", - "example": "2026-06-02T10:00:00.123Z" + "example": "2026-06-02T10:00:00.000Z" }, - "updatedAt": { - "type": "string", + "lastFailureAt": { + "type": ["string", "null"], "format": "date-time", - "example": "2026-06-02T10:01:30.000Z" + "description": "Within the period, unlike the test's own field.", + "example": "2026-06-01T10:00:00.000Z" } }, "required": [ - "id", - "testId", - "status", - "triggerType", - "detectionEventId", - "factCount", - "overallConfidence", - "markdownSummary", - "errorMessage", - "actor", - "createdAt", - "updatedAt" + "failureRate", + "prsImpacted", + "runCount", + "failureCount", + "durationP95Ms", + "lastRunAt", + "lastFailureAt" ] }, - "InvestigationStatus": { + "QuarantineOverride": { + "type": "object", + "properties": { + "mode": { + "$ref": "#/components/schemas/QuarantineMode" + }, + "reason": { + "type": ["string", "null"], + "example": "flaky in CI" + }, + "createdAt": { + "type": "string", + "format": "date-time", + "example": "2026-06-05T00:00:00.000Z" + } + }, + "required": ["mode", "reason", "createdAt"] + }, + "QuarantineMode": { "type": "string", - "enum": ["completed", "failed", "skipped"], - "description": "`completed` produced a summary; `failed` errored; `skipped` was declined, for example by a monthly cap.", - "example": "completed" + "enum": ["alwaysQuarantine", "neverQuarantine"], + "description": "A per-test quarantine override.", + "example": "alwaysQuarantine" + }, + "ActiveMonitor": { + "type": "object", + "properties": { + "monitorId": { + "type": ["string", "null"], + "description": "Null for `manual`, which has no monitor resource.", + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" + }, + "monitorType": { + "$ref": "#/components/schemas/ActiveMonitorType" + }, + "activeSince": { + "type": "string", + "format": "date-time", + "description": "The monitor has been active on this test since at least this time.", + "example": "2026-06-05T00:00:00.000Z" + } + }, + "required": ["monitorId", "monitorType", "activeSince"], + "description": "A monitor watching this test. Includes types that never affect its status." }, - "InvestigationTriggerType": { + "ActiveMonitorType": { "type": "string", - "enum": ["manual", "automatic", "mcp"], - "description": "`manual` from the web app, `automatic` from a detection, `mcp` from the MCP server.", - "example": "automatic" + "enum": [ + "failureRate", + "passOnRetry", + "failureCount", + "newTest", + "skippedTest", + "slowTest", + "timeoutInflation", + "manual" + ], + "description": "A monitor type that can be active on a test. `manual` is the 'flag as flaky' mark, which has no addressable monitor resource and always reports a null `monitorId`.", + "example": "failureRate" }, - "InvestigationActor": { + "ManualFlag": { "type": "object", "properties": { - "userId": { + "markedAt": { "type": "string", - "example": "6f708192-a3b4-4c5d-8e9f-0a1b2c3d4e5f" - }, - "displayName": { - "type": ["string", "null"], - "description": "Null when the user no longer exists.", - "example": "Ada Lovelace" + "format": "date-time", + "description": "When the mark was last set. Marking a test that is already marked does not move it.", + "example": "2026-06-07T00:00:00.000Z" } }, - "required": ["userId", "displayName"] + "required": ["markedAt"], + "description": "A flaky mark set by hand, in the web app or with `POST /v2/tests/{testId}/mark-flaky`." }, - "Investigation": { + "TestSummary": { "type": "object", "properties": { "id": { "type": "string", - "example": "5a7fef9e-c8cd-4eed-8a87-9494bdf96bed" + "description": "The test's globally unique id. Stable across repos and collections, and safe to store.", + "example": "bfeebcf4-0000-8000-8000-000000000001" }, - "testId": { + "testCollectionId": { "type": "string", - "description": "The investigated test's globally unique id.", - "example": "bfeebcf4-0000-8000-8000-000000000001" + "description": "The owning collection's id.", + "example": "aB3xY9kQ" }, - "status": { - "$ref": "#/components/schemas/InvestigationStatus" + "repositoryId": { + "type": "string", + "description": "The repository the test was uploaded for. Resolve with `GET /v2/repositories/{id}`. Uploads made without a repository carry the nil UUID, which names no repository and does not resolve.", + "example": "7a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" + }, + "name": { + "type": "string", + "example": "suite::test_case_name" + }, + "parentName": { + "type": "string", + "example": "Foo" + }, + "className": { + "type": "string", + "example": "FooSuite" + }, + "file": { + "type": "string", + "example": "src/foo.test.ts" + }, + "target": { + "type": "string", + "description": "The build target that ran the test, when one was reported.", + "example": "//src:foo_test" }, - "triggerType": { - "$ref": "#/components/schemas/InvestigationTriggerType" + "variant": { + "type": "string", + "example": "" }, - "detectionEventId": { + "crossVariantId": { "type": ["string", "null"], - "description": "The detection that started an `automatic` investigation.", - "example": "6b8f0aaf-d9de-4ffe-9b98-a5a5ceca7cfe" + "description": "Groups the same test across variants, when it has any.", + "example": "5d4c3b2a-1f0e-4a1b-8c9d-0e1f2a3b4c5d" }, - "factCount": { - "type": "integer", - "example": 4 + "codeowners": { + "type": "array", + "items": { + "type": "string" + }, + "maxItems": 1000, + "example": ["@team-a"] }, - "overallConfidence": { - "type": ["number", "null"], - "description": "The model's confidence in the summary, from 0 to 1. Null unless `completed`.", - "example": 0.75 + "status": { + "$ref": "#/components/schemas/TestStatus" }, - "markdownSummary": { + "statusSince": { "type": ["string", "null"], - "description": "The investigation's conclusion, in Markdown. Null unless `completed`.", - "example": "The test is flaky because it races the cache warm-up introduced in [this commit](https://github.com/acme/widgets/commit/9c58bf40e5c1)." + "format": "date-time", + "description": "When `status` last changed — how long the test has been in its current state. Null for a test no monitor has ever classified.", + "example": "2026-06-01T10:00:00.000Z" + }, + "quarantineState": { + "$ref": "#/components/schemas/QuarantineState" }, - "errorMessage": { + "quarantinedSince": { "type": ["string", "null"], - "description": "Why a `failed` or `skipped` investigation did not complete.", - "example": "The monthly investigation limit for this collection was reached" + "format": "date-time", + "description": "When the test's current quarantine began, as far as Trunk records it. Null exactly when `quarantineState` is `notQuarantined`. For a test quarantined by an `alwaysQuarantine` override, the time that override was set. For a test quarantined automatically, the later of `statusSince` and the last time an override on it was cleared. Changes to the collection's quarantine settings are not recorded per test, so this can be earlier than when quarantining was turned on for the collection.", + "example": "2026-06-01T10:00:00.000Z" }, - "actor": { + "labels": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Label" + }, + "maxItems": 100 + }, + "url": { + "type": "string", + "format": "uri", + "description": "The test's page in the Trunk web app.", + "example": "https://app.trunk.io/acme/flaky-tests/collections/aB3xY9kQ/tests/bfeebcf4-0000-8000-8000-000000000001" + }, + "ticket": { "anyOf": [ { - "$ref": "#/components/schemas/InvestigationActor" + "$ref": "#/components/schemas/TicketSummary" }, { "type": "null" } ], - "description": "Who started a `manual` or `mcp` investigation. Null for an `automatic` one." - }, - "createdAt": { - "type": "string", - "format": "date-time", - "example": "2026-06-02T10:00:00.123Z" - }, - "updatedAt": { - "type": "string", - "format": "date-time", - "example": "2026-06-02T10:01:30.000Z" - }, - "facts": { - "type": "array", - "items": { - "$ref": "#/components/schemas/InvestigationFact" - }, - "maxItems": 100, - "description": "Ordered by impact, then confidence, highest first." + "description": "The ticket currently linked to this test, as Trunk last synced it, or null if none is linked." }, - "snapshotFailureTestRunIds": { - "type": "array", - "items": { - "type": "string" - }, - "maxItems": 1000, - "description": "The failing runs the investigation was started from." + "metrics": { + "anyOf": [ + { + "$ref": "#/components/schemas/TestMetrics" + }, + { + "type": "null" + } + ], + "description": "Returned only when `include=metrics` is set. Null when the test had no runs in `period`." } }, "required": [ "id", - "testId", + "testCollectionId", + "repositoryId", + "name", + "parentName", + "className", + "file", + "target", + "variant", + "crossVariantId", + "codeowners", "status", - "triggerType", - "detectionEventId", - "factCount", - "overallConfidence", - "markdownSummary", - "errorMessage", - "actor", - "createdAt", - "updatedAt", - "facts", - "snapshotFailureTestRunIds" + "statusSince", + "quarantineState", + "quarantinedSince", + "labels", + "url", + "ticket" ] }, - "InvestigationFact": { + "TestList": { "type": "object", "properties": { - "type": { - "type": "string", - "description": "What the fact is about, such as `ciLogs`, `gitBlame`, `failureMode`, `testPurpose` or `environmentConfig`. New types may be added.", - "example": "gitBlame" - }, - "content": { - "type": "string", - "description": "Markdown. Cited evidence is linked inline where it has a URL.", - "example": "The assertion began failing after [this commit](https://github.com/acme/widgets/commit/9c58bf40e5c1)." - }, - "confidence": { - "type": "number", - "description": "The model's confidence in the fact, from 0 to 1.", - "example": 0.8 - }, - "impact": { - "type": "number", - "description": "How much the fact explains the flakiness, from 0 to 1.", - "example": 0.7 - }, - "citations": { + "data": { "type": "array", "items": { - "$ref": "#/components/schemas/InvestigationCitation" + "$ref": "#/components/schemas/TestSummary" }, "maxItems": 100 + }, + "nextCursor": { + "type": ["string", "null"], + "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", + "example": "AQEKZm9vYmFy" + }, + "hasMore": { + "type": "boolean", + "description": "True when another page is available.", + "example": true + }, + "total": { + "type": "integer", + "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", + "example": 1247 } }, - "required": ["type", "content", "confidence", "impact", "citations"] + "required": ["data", "nextCursor", "hasMore"] }, - "InvestigationCitation": { + "StatusHistoryEntryList": { "type": "object", "properties": { - "kind": { - "$ref": "#/components/schemas/InvestigationCitationKind" + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/StatusHistoryEntry" + }, + "maxItems": 100 }, - "url": { + "nextCursor": { "type": ["string", "null"], - "description": "Where the cited evidence is. Set for a commit or file on a GitHub repository; null otherwise.", - "example": "https://github.com/acme/widgets/commit/9c58bf40e5c1" + "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", + "example": "AQEKZm9vYmFy" }, - "testRunId": { - "type": ["string", "null"], - "description": "The cited run, for a `testRun` citation.", - "example": "1f9ddce9-b5f5-5676-8eef-770e11cf761f" + "hasMore": { + "type": "boolean", + "description": "True when another page is available.", + "example": true + }, + "total": { + "type": "integer", + "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", + "example": 1247 } }, - "required": ["kind", "url", "testRunId"] - }, - "InvestigationCitationKind": { - "type": "string", - "enum": ["testRun", "testCase", "upload", "commit", "file", "ciRun"], - "example": "commit" + "required": ["data", "nextCursor", "hasMore"] }, - "CreatedTestUpload": { + "StatusHistoryEntry": { "type": "object", "properties": { "id": { "type": "string", - "format": "uuid", - "description": "The upload's id. The bundle uploaded to `uploadUrl` must carry it, with `createdAt`.", - "example": "f47ac10b-58cc-4372-a567-0e02b2c3d479" - }, - "status": { - "type": "string", - "enum": ["awaitingData"], - "description": "The bundle has not been uploaded yet.", - "example": "awaitingData" - }, - "uploadUrl": { - "type": "string", - "format": "uri", - "description": "A pre-signed URL to `PUT` the bundle to, without Trunk credentials. It expires at `expiresAt`.", - "example": "https://bundles.s3.us-west-2.amazonaws.com/20261006/0d9c3de1-14a0-4f68-a44a-2fbbcf0dcb2f/a1b2c3/f47ac10b-58cc-4372-a567-0e02b2c3d479.tar.zst?X-Amz-Signature=3f1b8c9e" + "example": "5a7fef9e-c8cd-8eed-8a87-9494bdf96bed" }, - "expiresAt": { - "type": "string", - "format": "date-time", - "description": "When `uploadUrl` stops accepting the bundle: at most an hour after `createdAt`, and at least 15 minutes.", - "example": "2026-10-06T17:00:00.000Z" + "fromStatus": { + "$ref": "#/components/schemas/TestStatus" }, - "testCollectionUuid": { - "type": "string", - "format": "uuid", - "description": "The collection's internal UUID, which a test's `testId` is computed from (with `repositoryId` and the test's own id). Use it only for that: everywhere else a collection is addressed by its `id`.", - "example": "204b6c93-1c51-4e0f-a13c-e07b9bc60688" + "toStatus": { + "$ref": "#/components/schemas/TestStatus" }, - "repositoryId": { - "type": "string", - "format": "uuid", - "description": "The repository the tests are stored under. The nil UUID for an upload without a repository, or for a repository Trunk could not find or create.", - "example": "7a1f0e3d-2b4c-4d5e-8f90-123456789abc" + "activeMonitors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassifyingMonitor" + }, + "maxItems": 100, + "description": "The monitors active immediately after the transition, recorded at the time rather than resolved on read — so a monitor deleted since still appears." }, - "createdAt": { + "startedAt": { "type": "string", "format": "date-time", - "description": "When the upload was created.", - "example": "2026-10-06T16:00:00.000Z" + "description": "When this status began — the moment of the transition, and the start of the period the row describes.", + "example": "2026-06-02T10:00:00.000Z" } }, "required": [ "id", - "status", - "uploadUrl", - "expiresAt", - "testCollectionUuid", - "repositoryId", - "createdAt" - ], - "description": "A test-results upload, waiting for its bundle." + "fromStatus", + "toStatus", + "activeMonitors", + "startedAt" + ] }, - "CreateTestUploadRequest": { + "ClassifyingMonitor": { "type": "object", "properties": { - "repo": { - "type": ["object", "null"], - "properties": { - "host": { - "type": "string", - "minLength": 1, - "maxLength": 256, - "example": "github.com" - }, - "owner": { - "type": "string", - "minLength": 1, - "maxLength": 512, - "example": "acme" - }, - "name": { - "type": "string", - "minLength": 1, - "maxLength": 512, - "example": "web" - } - }, - "required": ["host", "owner", "name"], - "description": "The repository the tests ran in, as the CLI reads it from git. `null` for an upload made without a repository (`--no-repo`)." + "monitorId": { + "type": ["string", "null"], + "description": "Null for `manual`, which has no monitor resource.", + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" }, - "remoteUrls": { + "monitorType": { + "$ref": "#/components/schemas/ClassifyingMonitorType" + } + }, + "required": ["monitorId", "monitorType"], + "description": "A monitor that was classifying this test at the moment of the transition." + }, + "ClassifyingMonitorType": { + "type": "string", + "enum": ["failureRate", "passOnRetry", "failureCount", "manual"], + "description": "A monitor type that can classify a test's status. Narrower than `ActiveMonitorType`: the lifecycle and performance monitors watch a test without ever changing its status.", + "example": "failureRate" + }, + "TestRunList": { + "type": "object", + "properties": { + "data": { "type": "array", "items": { - "type": "string", - "minLength": 1, - "maxLength": 2048 + "$ref": "#/components/schemas/TestRun" }, - "maxItems": 20, - "description": "The repository's git remote URLs. When present and Trunk does not know the repository yet, it is created.", - "example": ["https://github.com/acme/web.git"] + "maxItems": 100 }, - "clientVersion": { - "type": "string", - "maxLength": 256, - "description": "The uploading client's version.", - "example": "0.12.3" + "nextCursor": { + "type": ["string", "null"], + "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", + "example": "AQEKZm9vYmFy" }, - "externalId": { - "type": "string", - "maxLength": 256, - "description": "The CI job's own id, used to match the upload to its GitHub Actions job.", - "example": "45829103344" + "hasMore": { + "type": "boolean", + "description": "True when another page is available.", + "example": true + }, + "total": { + "type": "integer", + "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", + "example": 1247 } }, - "required": ["repo"], - "description": "The repository the tests ran in, and the client uploading." + "required": ["data", "nextCursor", "hasMore"] }, - "TestUpload": { + "TestRun": { "type": "object", "properties": { "id": { "type": "string", - "format": "uuid", - "description": "The upload's id.", - "example": "f47ac10b-58cc-4372-a567-0e02b2c3d479" + "example": "1f9ddce9-b5f5-5676-8eef-770e11cf761f" }, - "testCollectionId": { - "type": "string", - "description": "The id of the test collection the upload belongs to.", - "example": "aB3xY9kQ" + "conclusion": { + "$ref": "#/components/schemas/Conclusion" }, - "repositoryId": { + "branch": { "type": "string", - "format": "uuid", - "description": "The repository the tests are stored under. The nil UUID for an upload without a repository.", - "example": "7a1f0e3d-2b4c-4d5e-8f90-123456789abc" - }, - "status": { - "$ref": "#/components/schemas/TestUploadStatus" + "example": "main" }, - "defects": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TestUploadDefect" - }, - "maxItems": 1000, - "description": "The problems ingestion found, oldest first. Empty until the bundle has been read. At most 1000; past that, every `invalid` defect is kept before any `suboptimal` one." + "isPullRequest": { + "type": "boolean", + "description": "True when the run happened on a pull-request branch.", + "example": false }, - "clientVersion": { + "sha": { "type": "string", - "description": "The version of the client that built the bundle, as ingestion read it from the bundle. Empty until the bundle has been read. It is not the `clientVersion` sent on the create.", - "example": "trunk-analytics-cli 0.12.3" + "example": "9c58bf40e5c1a2b3d4e5f60718293a4b5c6d7e8f" }, - "createdAt": { + "quarantineState": { + "$ref": "#/components/schemas/QuarantineState" + }, + "statusAtRunTime": { + "$ref": "#/components/schemas/TestStatus" + }, + "startedAt": { "type": "string", "format": "date-time", - "description": "When the upload was created.", - "example": "2026-10-06T16:00:00.000Z" + "example": "2026-06-02T10:00:00.000Z" }, - "updatedAt": { + "endedAt": { "type": "string", "format": "date-time", - "description": "The last time ingestion touched the upload. Each ingestion attempt moves it, even when `status` stays the same.", - "example": "2026-10-06T16:00:04.000Z" + "example": "2026-06-02T10:00:03.500Z" + }, + "pullRequest": { + "anyOf": [ + { + "$ref": "#/components/schemas/TestRunPullRequest" + }, + { + "type": "null" + } + ], + "description": "Null for a run that was not on a pull request." + }, + "buildUrl": { + "type": ["string", "null"], + "description": "Link to the CI job run that reported this test run. Null for older runs: Trunk keeps uploads for less time than it keeps runs.", + "example": "https://github.com/acme/widgets/actions/runs/1" + }, + "workflow": { + "type": ["string", "null"], + "description": "The CI workflow the run came from.", + "example": "CI" + }, + "jobName": { + "type": ["string", "null"], + "description": "The name of the CI job within that workflow.", + "example": "unit" } }, "required": [ "id", - "testCollectionId", - "repositoryId", - "status", - "defects", - "clientVersion", - "createdAt", - "updatedAt" - ], - "description": "A test-results upload: where it is, and what ingestion found." + "conclusion", + "branch", + "isPullRequest", + "sha", + "quarantineState", + "statusAtRunTime", + "startedAt", + "endedAt", + "pullRequest", + "buildUrl", + "workflow", + "jobName" + ] }, - "TestUploadStatus": { + "Conclusion": { "type": "string", - "enum": ["awaitingData", "received", "ingested", "skipped"], - "description": "Where an upload is. `awaitingData`: Trunk has not read the bundle. Past `expiresAt` on the create, it was never uploaded or could not be read. `received`: ingestion has started and not finished. Ingestion retries for about 10 minutes, so an upload still `received` with `updatedAt` more than 15 minutes old was not ingested and will not change. `ingested`: ingestion has recorded the upload. Its results and defects are written just after, so `defects` can still grow for a few seconds; each one moves `updatedAt`. If writing them fails, the upload stays `ingested` with its results incomplete. An `invalid` defect names a part of the bundle that was left out. `skipped`: it was read, but so many of its tests failed that Trunk treated the run as an infrastructure failure and stored no results.", - "example": "ingested" + "enum": ["success", "failure", "skipped"], + "description": "How a single test run finished.", + "example": "failure" }, - "TestUploadDefect": { + "TestRunPullRequest": { "type": "object", "properties": { - "type": { - "$ref": "#/components/schemas/TestUploadDefectType" - }, - "level": { - "$ref": "#/components/schemas/TestUploadDefectLevel" - }, - "source": { - "type": "string", - "description": "Where in the upload the defect is, such as a report path.", - "example": "reports/junit.xml" - }, - "message": { - "type": "string", - "description": "What is wrong.", - "example": "Test case `login` has no timestamp" - } - }, - "required": ["type", "level", "source", "message"], - "description": "A problem ingestion found in an upload." - }, - "TestUploadDefectType": { - "type": "string", - "enum": [ - "unspecified", - "junit", - "env", - "repo", - "bundleSize", - "reportLimit", - "meta", - "deprecatedCli" - ], - "description": "What part of the upload a defect is about.", - "example": "junit" - }, - "TestUploadDefectLevel": { - "type": "string", - "enum": ["suboptimal", "invalid"], - "description": "`invalid`: Trunk could not use the part of the bundle the defect names (`type`, `source`), and ingested the rest. `suboptimal`: that part was used, with less information than it could have had.", - "example": "suboptimal" - }, - "SetQuarantineRequest": { - "type": "object", - "properties": { - "mode": { - "$ref": "#/components/schemas/SetQuarantineMode" + "number": { + "type": "integer", + "example": 4901 }, - "reason": { + "url": { "type": "string", - "minLength": 1, - "maxLength": 1000, - "description": "Why the override was set, shown with it in the web app and on the test's `quarantineOverride`.", - "example": "Fails only on the Windows shard; tracked in TRUNK-1234." + "description": "The pull request's URL, when Trunk has it.", + "example": "https://github.com/acme/widgets/pull/4901" } }, - "required": ["mode"], - "additionalProperties": false, - "description": "The quarantine override to set on one test." - }, - "SetQuarantineMode": { - "type": "string", - "enum": ["alwaysQuarantine", "neverQuarantine", "clear"], - "description": "`alwaysQuarantine` quarantines the test whatever its status. `neverQuarantine` keeps it out of quarantine whatever its status. `clear` removes the override, so the collection's quarantine settings and the test's status decide again.", - "example": "neverQuarantine" + "required": ["number"] }, - "BulkResult": { + "DetectionEventList": { "type": "object", "properties": { - "results": { + "data": { "type": "array", "items": { - "$ref": "#/components/schemas/BulkResultItem" + "$ref": "#/components/schemas/DetectionEvent" }, - "maxItems": 100, - "description": "One entry per requested item, in request order." + "maxItems": 100 }, - "succeededCount": { - "type": "integer", - "example": 2 + "nextCursor": { + "type": ["string", "null"], + "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", + "example": "AQEKZm9vYmFy" }, - "unchangedCount": { - "type": "integer", - "example": 1 + "hasMore": { + "type": "boolean", + "description": "True when another page is available.", + "example": true }, - "failedCount": { + "total": { "type": "integer", - "example": 0 + "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", + "example": 1247 } }, - "required": [ - "results", - "succeededCount", - "unchangedCount", - "failedCount" - ], - "description": "The outcome of each item of a many-form request. A request that is refused as a whole answers a coded error instead, never a `BulkResult`." + "required": ["data", "nextCursor", "hasMore"] }, - "BulkResultItem": { + "DetectionEvent": { "type": "object", "properties": { + "id": { + "type": "string", + "example": "5d6e7f80-91a2-4b3c-8d4e-5f6071829304" + }, + "testCollectionId": { + "type": "string", + "description": "The id of the test collection the test belongs to.", + "example": "aB3xY9kQ" + }, + "monitorId": { + "type": "string", + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" + }, + "monitorType": { + "$ref": "#/components/schemas/MonitorType" + }, + "monitorStatus": { + "$ref": "#/components/schemas/MonitorStatus" + }, "testId": { "type": "string", + "description": "The test's globally unique id.", "example": "bfeebcf4-0000-8000-8000-000000000001" }, - "status": { - "$ref": "#/components/schemas/BulkItemStatus" + "classification": { + "anyOf": [ + { + "$ref": "#/components/schemas/TestStatus" + }, + { + "type": "null" + } + ], + "description": "The status the event's classify action names. Null when the event has no classify action, or when its classify action names a status this API does not report; `isClassificationEvent` is still `true` then." }, - "quarantineOverride": { + "isClassificationEvent": { + "type": "boolean", + "description": "True when the event carries a classify action. It does not mean the test's status changed: several monitors can be active on one test, and `/tests/{testId}/status-history` records the changes.", + "example": true + }, + "deactivationReason": { "anyOf": [ { - "$ref": "#/components/schemas/QuarantineOverride" + "$ref": "#/components/schemas/DeactivationReason" }, { "type": "null" } ], - "description": "Quarantine: the test's override after the call, null when none is in force. Absent on a failed item." + "description": "Set when the event comes from a change to the monitor: it was disabled or deleted, or its classify action changed. Null for a detection, and for a test that recovered." }, - "error": { - "$ref": "#/components/schemas/BulkItemError" - } - }, - "required": ["testId", "status"] - }, - "BulkItemStatus": { - "type": "string", - "enum": ["succeeded", "unchanged", "failed"], - "description": "`succeeded` changed the test. `unchanged` found it already in the requested state and wrote nothing. `failed` carries an `error` and changed nothing that stayed.", - "example": "succeeded" - }, - "BulkItemError": { - "type": "object", - "properties": { - "code": { + "detectedAt": { "type": "string", - "example": "TEST_NOT_FOUND" + "format": "date-time", + "example": "2026-06-02T10:00:00.000Z" }, - "message": { - "type": "string", - "example": "No test found with ID bfeebcf4-0000-8000-8000-000000000001" + "monitorKey": { + "type": ["string", "null"], + "description": "The detection pipeline's key for the event. Null for an event that a change to the monitor caused.", + "example": "7a1f0e3d-2b4c-4d5e-8f90-123456789abc:9c8b7a6f-5e4d-4c3b-8a2f-1b2c3d4e5f60:1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d:recovered" }, - "param": { - "type": "string", - "description": "The request field the error is about.", - "example": "items[2].testId" - } - }, - "required": ["code", "message", "param"] - }, - "SetQuarantineManyRequest": { - "type": "object", - "properties": { - "reason": { - "type": "string", - "minLength": 1, - "maxLength": 1000, - "description": "Why the override was set, shown with it in the web app and on the test's `quarantineOverride`.", - "example": "Fails only on the Windows shard; tracked in TRUNK-1234." + "sha": { + "type": ["string", "null"], + "description": "The commit the detection was made on, when it has one.", + "example": "9c58bf40e5c1a2b3d4e5f60718293a4b5c6d7e8f" }, - "items": { + "actions": { "type": "array", "items": { - "$ref": "#/components/schemas/SetQuarantineItem" + "$ref": "#/components/schemas/DetectionEventAction" }, - "minItems": 1, "maxItems": 100, - "description": "The tests to change, at most 100, each id once." - } - }, - "required": ["items"], - "additionalProperties": false, - "description": "Quarantine overrides to set on many tests, with one `reason` for all of them." - }, - "SetQuarantineItem": { - "type": "object", - "properties": { - "testId": { - "type": "string", - "minLength": 1, - "description": "The test's globally unique id.", - "example": "bfeebcf4-0000-8000-8000-000000000001" + "description": "The actions the monitor was configured to take when the event was recorded." }, - "mode": { - "$ref": "#/components/schemas/SetQuarantineMode" + "actor": { + "anyOf": [ + { + "$ref": "#/components/schemas/DetectionEventActor" + }, + { + "type": "null" + } + ], + "description": "The person who disabled or deleted the monitor, or changed its classify action. Null for an event the detection pipeline made, and for a change made with an API token." } }, - "required": ["testId", "mode"], - "additionalProperties": false + "required": [ + "id", + "testCollectionId", + "monitorId", + "monitorType", + "monitorStatus", + "testId", + "classification", + "isClassificationEvent", + "deactivationReason", + "detectedAt", + "monitorKey", + "sha", + "actions", + "actor" + ] }, - "Ticket": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "Trunk's id for the linked ticket.", - "example": "5d4c3b2a-1f0e-4a1b-8c9d-0e1f2a3b4c5d" - }, - "provider": { - "$ref": "#/components/schemas/TicketProvider" - }, - "key": { - "type": "string", - "description": "The provider's human-readable key. Mutable on some providers (a Jira issue moved between projects gets a new one).", - "example": "TRUNK-1234" - }, - "url": { - "type": "string", - "format": "uri", - "example": "https://acme.atlassian.net/browse/TRUNK-1234" - }, - "title": { - "type": "string", - "example": "[Flaky Test] suite::test_case_name" + "MonitorType": { + "type": "string", + "enum": [ + "failureRate", + "passOnRetry", + "failureCount", + "newTest", + "skippedTest", + "slowTest", + "timeoutInflation" + ], + "description": "A monitor's type. The 'flag as flaky' mark is not a monitor, so `manual` is not one of them.", + "example": "failureRate" + }, + "MonitorStatus": { + "type": "string", + "enum": ["active", "inactive"], + "description": "A monitor's verdict on one test: `active` when it detected the condition it watches for, `inactive` when the test recovered or the monitor stopped watching.", + "example": "active" + }, + "DeactivationReason": { + "type": "string", + "enum": ["monitorDisabled", "monitorDeleted", "classifyActionChanged"], + "description": "Why the event exists because of a change to the monitor itself. `monitorDisabled` and `monitorDeleted` are on an `inactive` event: the monitor stopped being active on the test. `classifyActionChanged` is on an `active` event: someone added, removed or changed the monitor's classify action while it was active on the test. That event is not a detection.", + "example": "monitorDisabled" + }, + "DetectionEventAction": { + "oneOf": [ + { + "$ref": "#/components/schemas/DetectionEventClassifyAction" }, - "status": { + { + "$ref": "#/components/schemas/DetectionEventLabelAction" + } + ], + "discriminator": { + "propertyName": "type", + "mapping": { + "classify": "#/components/schemas/DetectionEventClassifyAction", + "label": "#/components/schemas/DetectionEventLabelAction" + } + }, + "description": "An action the monitor was configured to take, recorded with the event." + }, + "DetectionEventClassifyAction": { + "type": "object", + "properties": { + "type": { "type": "string", - "description": "The provider's status name, as last synced.", - "example": "In Progress" - }, - "assignee": { - "type": ["string", "null"], - "description": "The provider's assignee display name; null when unassigned.", - "example": "Ada Lovelace" + "enum": ["classify"] }, - "syncedAt": { + "classification": { + "$ref": "#/components/schemas/TestStatus" + } + }, + "required": ["type", "classification"], + "description": "The monitor classified the test." + }, + "DetectionEventLabelAction": { + "type": "object", + "properties": { + "type": { "type": "string", - "format": "date-time", - "description": "When Trunk last read the ticket back from its provider.", - "example": "2026-09-15T14:45:01.000Z" + "enum": ["label"] }, - "deletedAt": { - "type": ["string", "null"], - "format": "date-time", - "description": "When Trunk found that the ticketing provider no longer has this ticket; null while it exists. A deleted ticket stays linked until it is unlinked, and its `status` is the last one synced.", - "example": "2026-10-01T09:00:00.000Z" + "labels": { + "type": "array", + "items": { + "$ref": "#/components/schemas/DetectionEventLabel" + }, + "maxItems": 100 } }, - "required": [ - "id", - "provider", - "key", - "url", - "title", - "status", - "assignee", - "syncedAt", - "deletedAt" - ] + "required": ["type", "labels"], + "description": "The monitor applied labels to the test, or removed them." }, - "LinkTicketRequest": { + "DetectionEventLabel": { "type": "object", "properties": { - "externalTicketId": { + "name": { "type": "string", - "minLength": 1, - "maxLength": 2048, - "description": "The ticket to link, as its provider key (`TRUNK-123`, a Linear identifier, an Asana task gid) or as its browser URL — either form is accepted.", - "example": "TRUNK-1234" + "example": "slow" }, - "integrationId": { + "color": { "type": "string", - "format": "uuid", - "description": "Which of the organization's ticketing connections the ticket lives on. Defaults to the collection's default connection.", - "example": "2b3c4d5e-6f70-4a1b-8c9d-0e1f2a3b4c5d" + "example": "#f97316" } }, - "required": ["externalTicketId"], - "description": "The ticket to link to a test in a test collection." + "required": ["name", "color"], + "description": "A label as it was when the event was recorded." }, - "CreateTicketRequest": { + "DetectionEventActor": { "type": "object", "properties": { - "title": { - "type": "string", - "minLength": 1, - "maxLength": 250, - "description": "The ticket's title. Defaults to the one the web app generates, such as `[Flaky Test] suite::test_case_name`.", - "example": "[Flaky Test] suite::test_case_name" - }, - "description": { + "userId": { "type": "string", - "description": "The ticket's body, in Markdown. Defaults to the one the web app generates: the test's location, failure rate, owners and most common failure reasons, with a link back to the test in Trunk.", - "example": "See all details on the [Trunk Test Detail page](https://app.trunk.io/acme/flaky-tests/collections/ab12cd34/tests/bfeebcf4-0000-8000-8000-000000000001)" - }, - "fields": { - "type": "object", - "additionalProperties": {}, - "description": "Provider fields to set on the ticket, keyed by the provider's field id (a Jira custom field id, `assignee`, a Linear project id), in the shape the provider takes. Merged over the default fields saved on the collection's ticketing connection; a field set here wins.", - "example": { - "assignee": "5b10ac8d82e05b22cc7d4ef5" - } + "example": "6f708192-a3b4-4c5d-8e9f-0a1b2c3d4e5f" }, - "replaceExisting": { - "type": "boolean", - "description": "Replace a ticket already linked to the test. When false or absent, a test that has a ticket is refused with `TEST_ALREADY_LINKED`.", - "example": false + "displayName": { + "type": ["string", "null"], + "description": "Null only if the user record could not be found.", + "example": "Ada Lovelace" + } + }, + "required": ["userId", "displayName"], + "description": "The person whose change to the monitor caused the event." + }, + "TestLabels": { + "type": "object", + "properties": { + "labels": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Label" + }, + "maxItems": 100 + } + }, + "required": ["labels"], + "description": "A test's labels, folded across their sources as on `Test.labels`." + }, + "TestLabelsRequest": { + "type": "object", + "properties": { + "labels": { + "type": "array", + "items": { + "type": "string", + "pattern": "^[a-zA-Z0-9_ -]{1,64}$", + "example": "needs-triage" + }, + "minItems": 1, + "maxItems": 50, + "description": "Label names, at most 50. A name listed twice counts once. Names match exactly, case included." } }, + "required": ["labels"], "additionalProperties": false, - "description": "The ticket to create for a test in a test collection." + "description": "The labels to add to a test, or to remove from it, by name." }, - "RepositoryList": { + "MonitorList": { "type": "object", "properties": { "data": { "type": "array", "items": { - "$ref": "#/components/schemas/Repository" + "$ref": "#/components/schemas/Monitor" }, "maxItems": 100 }, @@ -5610,1105 +5504,5047 @@ }, "required": ["data", "nextCursor", "hasMore"] }, - "Repository": { + "Monitor": { + "oneOf": [ + { + "$ref": "#/components/schemas/FailureRateMonitor" + }, + { + "$ref": "#/components/schemas/PassOnRetryMonitor" + }, + { + "$ref": "#/components/schemas/FailureCountMonitor" + }, + { + "$ref": "#/components/schemas/NewTestMonitor" + }, + { + "$ref": "#/components/schemas/SkippedTestMonitor" + }, + { + "$ref": "#/components/schemas/SlowTestMonitor" + }, + { + "$ref": "#/components/schemas/TimeoutInflationMonitor" + } + ], + "discriminator": { + "propertyName": "monitorType", + "mapping": { + "failureRate": "#/components/schemas/FailureRateMonitor", + "passOnRetry": "#/components/schemas/PassOnRetryMonitor", + "failureCount": "#/components/schemas/FailureCountMonitor", + "newTest": "#/components/schemas/NewTestMonitor", + "skippedTest": "#/components/schemas/SkippedTestMonitor", + "slowTest": "#/components/schemas/SlowTestMonitor", + "timeoutInflation": "#/components/schemas/TimeoutInflationMonitor" + } + }, + "description": "A monitor on one test collection. `config` holds the fields of its `monitorType`." + }, + "FailureRateMonitor": { "type": "object", "properties": { "id": { "type": "string", - "example": "7c9e6679-7425-40de-944b-e07fc1f90ae7" + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" }, - "provider": { - "$ref": "#/components/schemas/Provider" + "testCollectionId": { + "type": "string", + "description": "The id of the test collection the monitor belongs to.", + "example": "aB3xY9kQ" }, - "path": { + "name": { "type": "string", - "description": "The provider-side path, `owner/repo`.", - "example": "acme/widgets" + "example": "Broken on main" }, - "host": { - "type": ["string", "null"], - "description": "Null for a repository on the provider's default host.", - "example": "github.com" + "enabled": { + "type": "boolean", + "example": true }, - "url": { - "type": "string", - "example": "https://github.com/acme/widgets" + "activeTestCount": { + "type": "integer", + "description": "Tests the monitor is active on and has not muted.", + "example": 3 }, - "defaultBranch": { - "type": ["string", "null"], - "description": "Null until Trunk has synced it.", - "example": "main" + "mutedTestCount": { + "type": "integer", + "description": "Tests whose mute on this monitor is in force, whether or not the monitor is active on them.", + "example": 1 }, - "isPrivate": { - "type": ["boolean", "null"], - "description": "Null until Trunk has synced it.", - "example": true + "actions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MonitorAction" + }, + "maxItems": 100, + "description": "What the monitor does to a test it detects, oldest first. A label action is one entry per label. At most the first 100 are returned." }, "createdAt": { "type": "string", "format": "date-time", - "example": "2026-01-14T09:12:00.000Z" + "example": "2026-06-01T00:00:00.000Z" }, "updatedAt": { "type": "string", "format": "date-time", - "example": "2026-07-20T16:44:10.000Z" + "example": "2026-06-02T00:00:00.000Z" + }, + "monitorType": { + "type": "string", + "enum": ["failureRate"] + }, + "config": { + "$ref": "#/components/schemas/FailureRateMonitorConfig" } }, "required": [ "id", - "provider", - "path", - "host", - "url", - "defaultBranch", - "isPrivate", + "testCollectionId", + "name", + "enabled", + "activeTestCount", + "mutedTestCount", + "actions", "createdAt", - "updatedAt" + "updatedAt", + "monitorType", + "config" ] }, - "Provider": { - "type": "string", - "enum": ["github", "gitlab", "bitbucket", "unknown"], - "description": "The hosting provider. `unknown` is a repository Trunk has indexed without resolving a provider.", - "example": "github" + "MonitorAction": { + "type": "object", + "properties": { + "id": { + "type": "string", + "example": "3c4d5e6f-7081-4a1b-8c9d-0e1f2a3b4c5d" + }, + "actionType": { + "type": "string", + "enum": ["classify", "label"], + "description": "`classify` sets the test's status while the monitor is active on it; `label` applies labels.", + "example": "classify" + } + }, + "required": ["id", "actionType"], + "description": "Something the monitor does to a test it detects." }, - "CiJobRunList": { + "FailureRateMonitorConfig": { "type": "object", "properties": { - "data": { + "branches": { "type": "array", "items": { - "$ref": "#/components/schemas/CiJobRun" + "type": "string" }, - "maxItems": 100 - }, - "nextCursor": { - "type": ["string", "null"], - "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", - "example": "AQEKZm9vYmFy" + "maxItems": 100, + "description": "Branch name patterns the monitor watches. Empty, with `pullRequestOnly` false, watches every branch. At most the first 100 are returned.", + "example": ["main", "release/*"] }, - "hasMore": { + "pullRequestOnly": { "type": "boolean", - "description": "True when another page is available.", - "example": true + "description": "True when the monitor watches only pull-request runs; `branches` is then empty.", + "example": false }, - "total": { + "windowMinutes": { "type": "integer", - "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", - "example": 1247 + "description": "The window the rate is computed over.", + "example": 1440 + }, + "minSampleSize": { + "type": "integer", + "description": "Runs needed in the window before the monitor decides.", + "example": 10 + }, + "activationFailureThreshold": { + "type": "number", + "description": "The failure rate, 0 to 1, at or above which it detects.", + "example": 0.9 + }, + "resolutionFailureThreshold": { + "type": ["number", "null"], + "description": "The failure rate below which a detected test resolves. Null uses `activationFailureThreshold`.", + "example": 0.5 + }, + "staleAfterMinutes": { + "type": ["integer", "null"], + "description": "Resolves a test that has not run for this many minutes. Null keeps it active until it runs again.", + "example": 1440 } }, - "required": ["data", "nextCursor", "hasMore"] + "required": [ + "branches", + "pullRequestOnly", + "windowMinutes", + "minSampleSize", + "activationFailureThreshold", + "resolutionFailureThreshold", + "staleAfterMinutes" + ] }, - "CiJobRun": { + "PassOnRetryMonitor": { "type": "object", "properties": { "id": { "type": "string", - "description": "Opaque. Identifies the job's latest attempt.", - "example": "1a289f57705150d7~q1790685507000" + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" }, - "commitSha": { + "testCollectionId": { "type": "string", - "example": "a0de7a77e8d758a346f83ed19209a5a25814bb17" + "description": "The id of the test collection the monitor belongs to.", + "example": "aB3xY9kQ" }, "name": { "type": "string", - "example": "test (2/2)" - }, - "workflowName": { - "type": ["string", "null"], - "example": "CI" - }, - "workflowRunId": { - "type": ["string", "null"], - "description": "The `CiWorkflowRun.id` of the job's run.", - "example": "5e1d2c3b4a596877" + "example": "Broken on main" }, - "attempt": { - "type": "integer", - "example": 1 + "enabled": { + "type": "boolean", + "example": true }, - "attemptCount": { + "activeTestCount": { "type": "integer", - "description": "Every attempt of the job, the latest included.", - "example": 2 + "description": "Tests the monitor is active on and has not muted.", + "example": 3 }, - "failedAttemptCount": { + "mutedTestCount": { "type": "integer", + "description": "Tests whose mute on this monitor is in force, whether or not the monitor is active on them.", "example": 1 }, - "status": { - "$ref": "#/components/schemas/CiJobStatus" - }, - "conclusion": { - "anyOf": [ - { - "$ref": "#/components/schemas/CiConclusion" - }, - { - "type": "null" - } - ], - "description": "Set when `status` is `completed`." - }, - "required": { - "type": ["boolean", "null"], - "description": "Whether the job is a required check on the pull request's base branch or its merge queue. Null when the list is read by commit, with no pull request to say which branch.", - "example": true - }, - "queuedAt": { - "type": ["string", "null"], - "format": "date-time", - "example": "2026-09-29T12:37:00.000Z" - }, - "startedAt": { - "type": ["string", "null"], - "format": "date-time", - "example": "2026-09-29T12:38:27.000Z" + "actions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MonitorAction" + }, + "maxItems": 100, + "description": "What the monitor does to a test it detects, oldest first. A label action is one entry per label. At most the first 100 are returned." }, - "finishedAt": { - "type": ["string", "null"], + "createdAt": { + "type": "string", "format": "date-time", - "example": "2026-09-29T12:44:03.000Z" - }, - "queuedMs": { - "type": ["integer", "null"], - "example": 87000 - }, - "durationMs": { - "type": ["integer", "null"], - "example": 336000 + "example": "2026-06-01T00:00:00.000Z" }, "updatedAt": { "type": "string", "format": "date-time", - "example": "2026-09-29T12:44:03.000Z" + "example": "2026-06-02T00:00:00.000Z" }, - "url": { - "type": ["string", "null"], - "example": "https://github.com/acme/widgets/actions/runs/36498062451/job/1" + "monitorType": { + "type": "string", + "enum": ["passOnRetry"] }, - "failure": { - "anyOf": [ - { - "$ref": "#/components/schemas/CiJobFailure" - }, - { - "type": "null" - } - ], - "description": "Set when `conclusion` is `failure` or `timedOut`." + "config": { + "$ref": "#/components/schemas/PassOnRetryMonitorConfig" } }, "required": [ "id", - "commitSha", + "testCollectionId", "name", - "workflowName", - "workflowRunId", - "attempt", - "attemptCount", - "failedAttemptCount", - "status", - "conclusion", - "required", - "queuedAt", - "startedAt", - "finishedAt", - "queuedMs", - "durationMs", + "enabled", + "activeTestCount", + "mutedTestCount", + "actions", + "createdAt", "updatedAt", - "url", - "failure" - ], - "description": "The latest attempt of one CI job on a commit. Named apart from Dynamic CI's `CiJob`, which is a job's definition rather than a run of it. A job is a workflow run and a rendered job name, so each matrix leg is its own job." - }, - "CiJobStatus": { - "type": "string", - "enum": ["queued", "running", "completed", "abandoned"], - "description": "`abandoned` is a job whose queue or run never reported an end, past the 25-hour open-span cap.", - "example": "completed" - }, - "CiConclusion": { - "type": "string", - "enum": ["success", "failure", "timedOut", "cancelled", "skipped"], - "example": "failure" + "monitorType", + "config" + ] }, - "CiJobFailure": { + "PassOnRetryMonitorConfig": { "type": "object", "properties": { - "failingStep": { - "type": ["string", "null"], - "example": "Typecheck" + "branches": { + "type": "array", + "items": { + "type": "string" + }, + "maxItems": 100, + "description": "Branch name patterns the monitor watches. Empty, with `pullRequestOnly` false, watches every branch. At most the first 100 are returned.", + "example": ["main", "release/*"] }, - "analysis": { - "$ref": "#/components/schemas/CiFailureAnalysis" + "pullRequestOnly": { + "type": "boolean", + "description": "True when the monitor watches only pull-request runs; `branches` is then empty.", + "example": false }, - "logExcerpt": { - "anyOf": [ - { - "$ref": "#/components/schemas/CiLogExcerpt" - }, - { - "type": "null" - } - ] + "minPorCount": { + "type": "integer", + "description": "Passes on retry needed to detect.", + "example": 1 }, - "cluster": { - "anyOf": [ - { - "$ref": "#/components/schemas/CiFailureClusterRef" - }, - { - "type": "null" - } - ], - "description": "Other failures with the same cause. Null until the hourly clustering run assigns this one." + "windowMinutes": { + "type": ["integer", "null"], + "description": "The rolling window the passes on retry are counted over. Null counts only the runs each detection pass is given.", + "example": 10080 }, - "annotationCount": { + "resolveAfterMinutes": { "type": "integer", - "description": "Read them with `GET /v2/ci-jobs/{id}/annotations`.", - "example": 0 + "description": "Resolves a test with no pass on retry for this many minutes.", + "example": 10080 } }, "required": [ - "failingStep", - "analysis", - "logExcerpt", - "cluster", - "annotationCount" + "branches", + "pullRequestOnly", + "minPorCount", + "windowMinutes", + "resolveAfterMinutes" ] }, - "CiFailureAnalysis": { + "FailureCountMonitor": { "type": "object", "properties": { - "state": { - "$ref": "#/components/schemas/CiAnalysisState" + "id": { + "type": "string", + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" }, - "summaryShort": { - "type": ["string", "null"], - "example": "Frontend TypeScript checks failed" + "testCollectionId": { + "type": "string", + "description": "The id of the test collection the monitor belongs to.", + "example": "aB3xY9kQ" }, - "summary": { - "type": ["string", "null"], - "example": "Frontend TypeScript checks failed on a type mismatch" + "name": { + "type": "string", + "example": "Broken on main" }, - "rootCause": { - "type": ["string", "null"], - "example": "A string is passed where a number is expected." - } - }, - "required": ["state", "summaryShort", "summary", "rootCause"] - }, - "CiAnalysisState": { - "type": "string", - "enum": ["pending", "ready", "unavailable"], - "description": "`pending` for 15 minutes after a failed job finished with no analysis yet. `unavailable` after that: the organization is not enabled, AI features are off, or the analysis failed.", - "example": "ready" - }, - "CiLogExcerpt": { - "type": "object", - "properties": { - "startLine": { - "type": "integer", - "example": 69 + "enabled": { + "type": "boolean", + "example": true }, - "endLine": { + "activeTestCount": { "type": "integer", - "example": 71 + "description": "Tests the monitor is active on and has not muted.", + "example": 3 }, - "text": { - "type": ["string", "null"], - "description": "The stored reduced excerpt, which outlives the 30-day log. Null when the failure has no analysis. Read the lines with `GET /v2/ci-jobs/{id}/log-lines`.", - "example": "error TS2322: Type 'string' is not assignable to type 'number'." - } - }, - "required": ["startLine", "endLine", "text"], - "description": "The failure's lines in the job's log, 1-based and inclusive." - }, - "CiFailureClusterRef": { - "type": "object", - "properties": { - "id": { + "mutedTestCount": { + "type": "integer", + "description": "Tests whose mute on this monitor is in force, whether or not the monitor is active on them.", + "example": 1 + }, + "actions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MonitorAction" + }, + "maxItems": 100, + "description": "What the monitor does to a test it detects, oldest first. A label action is one entry per label. At most the first 100 are returned." + }, + "createdAt": { "type": "string", - "example": "0894d6a25f35e0786faac29a" + "format": "date-time", + "example": "2026-06-01T00:00:00.000Z" }, - "occurrences": { - "type": "integer", - "example": 6 + "updatedAt": { + "type": "string", + "format": "date-time", + "example": "2026-06-02T00:00:00.000Z" + }, + "monitorType": { + "type": "string", + "enum": ["failureCount"] + }, + "config": { + "$ref": "#/components/schemas/FailureCountMonitorConfig" } }, - "required": ["id", "occurrences"] + "required": [ + "id", + "testCollectionId", + "name", + "enabled", + "activeTestCount", + "mutedTestCount", + "actions", + "createdAt", + "updatedAt", + "monitorType", + "config" + ] }, - "CiWorkflowRunList": { + "FailureCountMonitorConfig": { "type": "object", "properties": { - "data": { + "branches": { "type": "array", "items": { - "$ref": "#/components/schemas/CiWorkflowRun" + "type": "string" }, - "maxItems": 100 - }, - "nextCursor": { - "type": ["string", "null"], - "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", - "example": "AQEKZm9vYmFy" + "maxItems": 100, + "description": "Branch name patterns the monitor watches. Empty, with `pullRequestOnly` false, watches every branch. At most the first 100 are returned.", + "example": ["main", "release/*"] }, - "hasMore": { + "pullRequestOnly": { "type": "boolean", - "description": "True when another page is available.", - "example": true + "description": "True when the monitor watches only pull-request runs; `branches` is then empty.", + "example": false }, - "total": { + "minFailureCount": { "type": "integer", - "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", - "example": 1247 + "description": "Failures needed to detect.", + "example": 1 + }, + "windowMinutes": { + "type": ["integer", "null"], + "description": "The rolling window the failures are counted over. Null counts only the runs each detection pass is given.", + "example": 1440 + }, + "resolveAfterMinutes": { + "type": "integer", + "description": "Resolves a test with no failure for this many minutes.", + "example": 4320 } }, - "required": ["data", "nextCursor", "hasMore"] + "required": [ + "branches", + "pullRequestOnly", + "minFailureCount", + "windowMinutes", + "resolveAfterMinutes" + ] }, - "CiWorkflowRun": { + "NewTestMonitor": { "type": "object", "properties": { "id": { "type": "string", - "example": "5e1d2c3b4a596877" + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" }, - "commitSha": { + "testCollectionId": { "type": "string", - "example": "a0de7a77e8d758a346f83ed19209a5a25814bb17" + "description": "The id of the test collection the monitor belongs to.", + "example": "aB3xY9kQ" }, - "runId": { + "name": { "type": "string", - "description": "The provider's run id: a GitHub run, or a Buildkite build number.", - "example": "36498062451" + "example": "Broken on main" }, - "name": { - "type": ["string", "null"], - "example": "CI" + "enabled": { + "type": "boolean", + "example": true }, - "path": { - "type": ["string", "null"], - "example": ".github/workflows/ci.yml" + "activeTestCount": { + "type": "integer", + "description": "Tests the monitor is active on and has not muted.", + "example": 3 }, - "attempt": { + "mutedTestCount": { "type": "integer", + "description": "Tests whose mute on this monitor is in force, whether or not the monitor is active on them.", "example": 1 }, - "status": { - "$ref": "#/components/schemas/CiWorkflowRunStatus" - }, - "conclusion": { - "anyOf": [ - { - "$ref": "#/components/schemas/CiConclusion" - }, - { - "type": "null" - } - ] + "actions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MonitorAction" + }, + "maxItems": 100, + "description": "What the monitor does to a test it detects, oldest first. A label action is one entry per label. At most the first 100 are returned." }, - "startedAt": { + "createdAt": { "type": "string", "format": "date-time", - "example": "2026-09-29T12:36:55.000Z" + "example": "2026-06-01T00:00:00.000Z" }, - "finishedAt": { - "type": ["string", "null"], + "updatedAt": { + "type": "string", "format": "date-time", - "example": "2026-09-29T12:58:10.000Z" + "example": "2026-06-02T00:00:00.000Z" }, - "url": { - "type": ["string", "null"], - "example": "https://github.com/acme/widgets/actions/runs/36498062451" + "monitorType": { + "type": "string", + "enum": ["newTest"] }, - "jobs": { - "$ref": "#/components/schemas/CiJobCounts" + "config": { + "$ref": "#/components/schemas/NewTestMonitorConfig" } }, "required": [ "id", - "commitSha", - "runId", + "testCollectionId", "name", - "path", - "attempt", - "status", - "conclusion", - "startedAt", - "finishedAt", - "url", - "jobs" - ], - "description": "The latest attempt of one workflow run, with its jobs counted." - }, - "CiWorkflowRunStatus": { - "type": "string", - "enum": ["running", "completed"], - "example": "completed" + "enabled", + "activeTestCount", + "mutedTestCount", + "actions", + "createdAt", + "updatedAt", + "monitorType", + "config" + ] }, - "CiLogLineList": { + "NewTestMonitorConfig": { "type": "object", "properties": { - "data": { + "branches": { "type": "array", "items": { - "$ref": "#/components/schemas/CiLogLine" + "type": "string" }, - "maxItems": 100 - }, - "nextCursor": { - "type": ["string", "null"], - "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", - "example": "AQEKZm9vYmFy" + "maxItems": 100, + "description": "Branch name patterns the monitor watches. Empty, with `pullRequestOnly` false, watches every branch. At most the first 100 are returned.", + "example": ["main", "release/*"] }, - "hasMore": { + "pullRequestOnly": { "type": "boolean", - "description": "True when another page is available.", - "example": true + "description": "True when the monitor watches only pull-request runs; `branches` is then empty.", + "example": false }, - "total": { + "newDays": { "type": "integer", - "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", - "example": 1247 + "description": "A test counts as new for this many days after it first ran.", + "example": 14 } }, - "required": ["data", "nextCursor", "hasMore"] + "required": ["branches", "pullRequestOnly", "newDays"] }, - "CiLogLine": { + "SkippedTestMonitor": { "type": "object", "properties": { - "lineNumber": { + "id": { + "type": "string", + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" + }, + "testCollectionId": { + "type": "string", + "description": "The id of the test collection the monitor belongs to.", + "example": "aB3xY9kQ" + }, + "name": { + "type": "string", + "example": "Broken on main" + }, + "enabled": { + "type": "boolean", + "example": true + }, + "activeTestCount": { "type": "integer", - "example": 70 + "description": "Tests the monitor is active on and has not muted.", + "example": 3 }, - "timestamp": { + "mutedTestCount": { + "type": "integer", + "description": "Tests whose mute on this monitor is in force, whether or not the monitor is active on them.", + "example": 1 + }, + "actions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MonitorAction" + }, + "maxItems": 100, + "description": "What the monitor does to a test it detects, oldest first. A label action is one entry per label. At most the first 100 are returned." + }, + "createdAt": { "type": "string", "format": "date-time", - "example": "2026-09-29T12:43:58.120Z" - }, - "severity": { - "$ref": "#/components/schemas/CiLogSeverity" + "example": "2026-06-01T00:00:00.000Z" }, - "step": { - "type": ["string", "null"], - "example": "Typecheck" + "updatedAt": { + "type": "string", + "format": "date-time", + "example": "2026-06-02T00:00:00.000Z" }, - "text": { + "monitorType": { "type": "string", - "example": "src/app.ts(3,1): error TS2322" + "enum": ["skippedTest"] + }, + "config": { + "$ref": "#/components/schemas/SkippedTestMonitorConfig" } }, - "required": ["lineNumber", "timestamp", "severity", "step", "text"] - }, - "CiLogSeverity": { - "type": "string", - "enum": ["debug", "info", "warning", "error"], - "example": "error" + "required": [ + "id", + "testCollectionId", + "name", + "enabled", + "activeTestCount", + "mutedTestCount", + "actions", + "createdAt", + "updatedAt", + "monitorType", + "config" + ] }, - "CiAnnotationList": { + "SkippedTestMonitorConfig": { "type": "object", "properties": { - "data": { + "branches": { "type": "array", "items": { - "$ref": "#/components/schemas/CiAnnotation" + "type": "string" }, - "maxItems": 100 - }, - "nextCursor": { - "type": ["string", "null"], - "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", - "example": "AQEKZm9vYmFy" + "maxItems": 100, + "description": "Branch name patterns the monitor watches. Empty, with `pullRequestOnly` false, watches every branch. At most the first 100 are returned.", + "example": ["main", "release/*"] }, - "hasMore": { + "pullRequestOnly": { "type": "boolean", - "description": "True when another page is available.", - "example": true + "description": "True when the monitor watches only pull-request runs; `branches` is then empty.", + "example": false }, - "total": { + "minSkippedCount": { "type": "integer", - "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", - "example": 1247 + "description": "Skips needed to detect.", + "example": 1 + }, + "windowMinutes": { + "type": ["integer", "null"], + "description": "The rolling window the skips are counted over. Null counts only the runs each detection pass is given.", + "example": 10080 + }, + "resolutionDays": { + "type": "integer", + "description": "Resolves a test not skipped for this many days.", + "example": 14 } }, - "required": ["data", "nextCursor", "hasMore"] + "required": [ + "branches", + "pullRequestOnly", + "minSkippedCount", + "windowMinutes", + "resolutionDays" + ] }, - "CiAnnotation": { + "SlowTestMonitor": { "type": "object", "properties": { - "index": { - "type": "integer", - "example": 0 + "id": { + "type": "string", + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" }, - "path": { + "testCollectionId": { "type": "string", - "example": ".github" + "description": "The id of the test collection the monitor belongs to.", + "example": "aB3xY9kQ" }, - "startLine": { + "name": { + "type": "string", + "example": "Broken on main" + }, + "enabled": { + "type": "boolean", + "example": true + }, + "activeTestCount": { "type": "integer", - "example": 1 + "description": "Tests the monitor is active on and has not muted.", + "example": 3 }, - "endLine": { + "mutedTestCount": { "type": "integer", + "description": "Tests whose mute on this monitor is in force, whether or not the monitor is active on them.", "example": 1 }, - "level": { - "$ref": "#/components/schemas/CiAnnotationLevel" + "actions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MonitorAction" + }, + "maxItems": 100, + "description": "What the monitor does to a test it detects, oldest first. A label action is one entry per label. At most the first 100 are returned." }, - "title": { + "createdAt": { "type": "string", - "example": "" + "format": "date-time", + "example": "2026-06-01T00:00:00.000Z" }, - "message": { + "updatedAt": { "type": "string", - "example": "The runner has received a shutdown signal." + "format": "date-time", + "example": "2026-06-02T00:00:00.000Z" }, - "cause": { - "$ref": "#/components/schemas/CiAnnotationCause" + "monitorType": { + "type": "string", + "enum": ["slowTest"] + }, + "config": { + "$ref": "#/components/schemas/SlowTestMonitorConfig" } }, "required": [ - "index", - "path", - "startLine", - "endLine", - "level", - "title", - "message", - "cause" - ], - "description": "A check-run annotation, for the failures a log does not explain, such as a runner that disconnected." - }, - "CiAnnotationLevel": { - "type": "string", - "enum": ["notice", "warning", "failure"], - "example": "failure" - }, - "CiAnnotationCause": { - "type": "string", - "enum": [ - "unclassified", - "runnerDisconnect", - "deploymentRejected", - "exitCode", - "cancelled", - "jobTimeout" - ], - "example": "runnerDisconnect" + "id", + "testCollectionId", + "name", + "enabled", + "activeTestCount", + "mutedTestCount", + "actions", + "createdAt", + "updatedAt", + "monitorType", + "config" + ] }, - "CiCommitList": { + "SlowTestMonitorConfig": { "type": "object", "properties": { - "data": { + "branches": { "type": "array", "items": { - "$ref": "#/components/schemas/CiCommit" + "type": "string" }, - "maxItems": 100 - }, - "nextCursor": { - "type": ["string", "null"], - "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", - "example": "AQEKZm9vYmFy" + "maxItems": 100, + "description": "Branch name patterns the monitor watches. Empty, with `pullRequestOnly` false, watches every branch. At most the first 100 are returned.", + "example": ["main", "release/*"] }, - "hasMore": { + "pullRequestOnly": { "type": "boolean", - "description": "True when another page is available.", - "example": true + "description": "True when the monitor watches only pull-request runs; `branches` is then empty.", + "example": false }, - "total": { + "windowMinutes": { "type": "integer", - "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", - "example": 1247 - } - }, - "required": ["data", "nextCursor", "hasMore"] - }, - "CiCommit": { - "type": "object", - "properties": { - "sha": { - "type": "string", - "example": "a0de7a77e8d758a346f83ed19209a5a25814bb17" + "description": "The window the duration is computed over.", + "example": 1440 }, - "firstSeenAt": { - "type": "string", - "format": "date-time", - "example": "2026-09-29T10:37:25.000Z" + "minSampleSize": { + "type": "integer", + "description": "Runs needed in the window before the monitor decides.", + "example": 10 }, - "lastSeenAt": { - "type": "string", - "format": "date-time", - "example": "2026-09-29T12:36:55.000Z" + "percentile": { + "type": "number", + "description": "The duration percentile compared, 0 to 1.", + "example": 0.95 }, - "jobsUrl": { - "type": "string", - "example": "/v2/ci-jobs?pullRequestId=0f8fad5b-d9cb-469f-a165-70867728950e&commitSha=a0de7a77e8d758a346f83ed19209a5a25814bb17" + "activationDurationMs": { + "type": "integer", + "description": "The duration, in milliseconds, at or above which it detects.", + "example": 60000 }, - "workflowRunsUrl": { - "type": "string", - "example": "/v2/ci-workflow-runs?pullRequestId=0f8fad5b-d9cb-469f-a165-70867728950e&commitSha=a0de7a77e8d758a346f83ed19209a5a25814bb17" + "resolutionDurationMs": { + "type": "integer", + "description": "The duration, in milliseconds, below which a detected test resolves. At most `activationDurationMs`.", + "example": 30000 + }, + "staleAfterMinutes": { + "type": ["integer", "null"], + "description": "Resolves a test that has not run for this many minutes. Null keeps it active until it runs again.", + "example": 1440 } }, "required": [ - "sha", - "firstSeenAt", - "lastSeenAt", - "jobsUrl", - "workflowRunsUrl" - ], - "description": "A commit that ran CI on the pull request. Read its jobs through `jobsUrl`." + "branches", + "pullRequestOnly", + "windowMinutes", + "minSampleSize", + "percentile", + "activationDurationMs", + "resolutionDurationMs", + "staleAfterMinutes" + ] }, - "CiFailureCluster": { + "TimeoutInflationMonitor": { "type": "object", "properties": { "id": { "type": "string", - "example": "0894d6a25f35e0786faac29a" + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" }, - "occurrences": { + "testCollectionId": { + "type": "string", + "description": "The id of the test collection the monitor belongs to.", + "example": "aB3xY9kQ" + }, + "name": { + "type": "string", + "example": "Broken on main" + }, + "enabled": { + "type": "boolean", + "example": true + }, + "activeTestCount": { "type": "integer", - "example": 6 + "description": "Tests the monitor is active on and has not muted.", + "example": 3 }, - "lastSeenAt": { + "mutedTestCount": { + "type": "integer", + "description": "Tests whose mute on this monitor is in force, whether or not the monitor is active on them.", + "example": 1 + }, + "actions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MonitorAction" + }, + "maxItems": 100, + "description": "What the monitor does to a test it detects, oldest first. A label action is one entry per label. At most the first 100 are returned." + }, + "createdAt": { "type": "string", "format": "date-time", - "example": "2026-09-29T12:44:03.000Z" + "example": "2026-06-01T00:00:00.000Z" }, - "representative": { - "anyOf": [ - { - "$ref": "#/components/schemas/CiFailureClusterRepresentative" - }, - { - "type": "null" - } - ] - } - }, - "required": ["id", "occurrences", "lastSeenAt", "representative"], - "description": "Failures with the same cause, grouped by the hourly clustering run." - }, - "CiFailureClusterRepresentative": { - "type": "object", - "properties": { - "summaryShort": { + "updatedAt": { "type": "string", - "example": "Frontend TypeScript checks failed" + "format": "date-time", + "example": "2026-06-02T00:00:00.000Z" }, - "summary": { + "monitorType": { "type": "string", - "example": "Frontend TypeScript checks failed on a type mismatch" + "enum": ["timeoutInflation"] }, - "rootCause": { - "type": "string", - "example": "A string is passed where a number is expected." + "config": { + "$ref": "#/components/schemas/TimeoutInflationMonitorConfig" } }, - "required": ["summaryShort", "summary", "rootCause"] + "required": [ + "id", + "testCollectionId", + "name", + "enabled", + "activeTestCount", + "mutedTestCount", + "actions", + "createdAt", + "updatedAt", + "monitorType", + "config" + ] }, - "SetPathsFiltersResult": { + "TimeoutInflationMonitorConfig": { "type": "object", "properties": { - "filters": { + "branches": { "type": "array", "items": { - "$ref": "#/components/schemas/WrittenFilter" + "type": "string" }, "maxItems": 100, - "description": "One per `filters` entry, leaving out an entry none of whose jobs resolved." + "description": "Branch name patterns the monitor watches. Empty, with `pullRequestOnly` false, watches every branch. At most the first 100 are returned.", + "example": ["main", "release/*"] }, - "jobs": { - "type": "array", - "items": { - "$ref": "#/components/schemas/WrittenJob" - }, - "maxItems": 500, - "description": "One per job named, in request order. A job named by `jobId` is reported by its path and key." + "pullRequestOnly": { + "type": "boolean", + "description": "True when the monitor watches only pull-request runs; `branches` is then empty.", + "example": false + }, + "windowMinutes": { + "type": "integer", + "description": "The window the durations are computed over.", + "example": 1440 + }, + "passPercentile": { + "type": "number", + "description": "The percentile of passing durations compared, 0 to 1.", + "example": 0.95 + }, + "failPercentile": { + "type": "number", + "description": "The percentile of failing durations compared, 0 to 1.", + "example": 0.5 + }, + "activationRatio": { + "type": "number", + "description": "Detects when the failing duration is at least this many times the passing one.", + "example": 3 + }, + "resolutionRatio": { + "type": "number", + "description": "Resolves when the ratio falls below this. At most `activationRatio`.", + "example": 2 + }, + "minPassSampleSize": { + "type": "integer", + "description": "Passing runs needed in the window.", + "example": 5 + }, + "minFailSampleSize": { + "type": "integer", + "description": "Failing runs needed in the window.", + "example": 5 + }, + "minAbsoluteGapMs": { + "type": "integer", + "description": "The failing duration must also exceed the passing one by at least this many milliseconds.", + "example": 5000 + }, + "staleAfterMinutes": { + "type": ["integer", "null"], + "description": "Resolves a test that has not run for this many minutes. Null keeps it active until it runs again.", + "example": 1440 } }, - "required": ["filters", "jobs"] + "required": [ + "branches", + "pullRequestOnly", + "windowMinutes", + "passPercentile", + "failPercentile", + "activationRatio", + "resolutionRatio", + "minPassSampleSize", + "minFailSampleSize", + "minAbsoluteGapMs", + "staleAfterMinutes" + ] }, - "WrittenJob": { + "MonitorTestStateList": { "type": "object", "properties": { - "workflowPath": { - "type": ["string", "null"], - "example": ".github/workflows/ci.yaml" - }, - "jobKey": { - "type": ["string", "null"], - "example": "web-unit" - }, - "status": { - "$ref": "#/components/schemas/WrittenJobStatus" - }, - "jobIds": { + "data": { "type": "array", "items": { - "type": "string" + "$ref": "#/components/schemas/MonitorTestState" }, - "maxItems": 500, - "description": "Every job the name matched; one name can match more than one. Empty for `unresolved`.", - "example": ["3c4d0b17-8e2a-4f6c-9d1b-7a5e3c2f1d0e"] + "maxItems": 100 + }, + "nextCursor": { + "type": ["string", "null"], + "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", + "example": "AQEKZm9vYmFy" + }, + "hasMore": { + "type": "boolean", + "description": "True when another page is available.", + "example": true + }, + "total": { + "type": "integer", + "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", + "example": 1247 } }, - "required": ["workflowPath", "jobKey", "status", "jobIds"] - }, - "WrittenJobStatus": { - "type": "string", - "enum": ["set", "unchanged", "cleared", "unresolved"], - "description": "`set`: the job now has the filter. `unchanged`: nothing was written. `cleared`: its filter was removed. `unresolved`: Trunk has not seen the job run, so nothing was written; send the request again after it runs.", - "example": "set" + "required": ["data", "nextCursor", "hasMore"] }, - "WrittenFilter": { + "MonitorTestState": { "type": "object", "properties": { - "pathsFilterId": { + "monitorId": { "type": "string", - "example": "e8f1c2a4-5b6d-4e7f-8a9b-0c1d2e3f4a5b" + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" }, - "name": { + "testId": { + "type": "string", + "description": "The test's globally unique id.", + "example": "bfeebcf4-0000-8000-8000-000000000001" + }, + "state": { + "$ref": "#/components/schemas/MonitorTestStateValue" + }, + "isMuted": { + "type": "boolean", + "description": "True when a mute is in force; the same as `state: muted`.", + "example": false + }, + "mutedUntil": { "type": ["string", "null"], - "description": "The stored name, which an existing named filter keeps.", - "example": "web" + "format": "date-time", + "description": "When the mute ends. Null for a mute with no end, and when the test is not muted.", + "example": "2026-06-10T00:00:00.000Z" }, - "status": { - "$ref": "#/components/schemas/WrittenFilterStatus" + "mutedBy": { + "anyOf": [ + { + "$ref": "#/components/schemas/MuteActor" + }, + { + "type": "null" + } + ], + "description": "Who muted the test. Null when it is not muted." }, - "jobCount": { - "type": "integer", - "description": "Distinct jobs on the filter after the write.", - "example": 1 + "muteReason": { + "type": ["string", "null"], + "description": "Null when no reason was given, or the test is not muted.", + "example": "Known flake, fix in progress" + }, + "lastDetectedAt": { + "type": ["string", "null"], + "format": "date-time", + "description": "When the monitor last detected the test: its last pass on retry, failure, skip or slow run, or when a new test first ran. Always null for a failure-rate monitor, which records no detection time.", + "example": "2026-06-03T10:00:00.000Z" + }, + "updatedAt": { + "type": "string", + "format": "date-time", + "description": "When the monitor's state for the test last changed. A mute or unmute moves it.", + "example": "2026-06-03T10:00:00.000Z" } }, - "required": ["pathsFilterId", "name", "status", "jobCount"] + "required": [ + "monitorId", + "testId", + "state", + "isMuted", + "mutedUntil", + "mutedBy", + "muteReason", + "lastDetectedAt", + "updatedAt" + ], + "description": "One test a monitor holds: one it is active on, or one whose mute on it is in force." }, - "WrittenFilterStatus": { + "MonitorTestStateValue": { "type": "string", - "enum": ["new", "existing"], - "description": "Whether the request created the filter or found it by its rules.", - "example": "new" + "enum": ["active", "muted"], + "description": "`active` when the monitor is active on the test and has not muted it, `muted` when a mute is in force.", + "example": "active" }, - "SetPathsFiltersRequest": { + "MuteActor": { "type": "object", "properties": { - "repo": { - "$ref": "#/components/schemas/PlanRepo" - }, - "overwrite": { - "type": "boolean", - "default": false, - "description": "Replace a different filter already on a job. Without it, such a job fails the request with `PATHS_FILTER_CONFLICT`.", - "example": false - }, - "filters": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PathsFilterEntry" - }, - "maxItems": 100 - }, - "clear": { - "type": "array", - "items": { - "$ref": "#/components/schemas/JobRef" - }, - "maxItems": 500, - "description": "Jobs to remove the paths filter from." + "displayName": { + "type": "string", + "description": "The name recorded for whoever muted the test, `API token` for a token.", + "example": "Ada Lovelace" } }, - "required": ["repo"], - "additionalProperties": false + "required": ["displayName"] }, - "JobRef": { - "anyOf": [ + "CreateMonitorRequest": { + "oneOf": [ { - "$ref": "#/components/schemas/JobRefByName" + "$ref": "#/components/schemas/CreateFailureRateMonitor" }, { - "$ref": "#/components/schemas/JobRefById" + "$ref": "#/components/schemas/CreatePassOnRetryMonitor" + }, + { + "$ref": "#/components/schemas/CreateFailureCountMonitor" + }, + { + "$ref": "#/components/schemas/CreateNewTestMonitor" + }, + { + "$ref": "#/components/schemas/CreateSkippedTestMonitor" + }, + { + "$ref": "#/components/schemas/CreateSlowTestMonitor" + }, + { + "$ref": "#/components/schemas/CreateTimeoutInflationMonitor" } ], - "description": "A job, as `{ workflowPath, jobKey }` or as `{ jobId }`." + "discriminator": { + "propertyName": "monitorType", + "mapping": { + "failureRate": "#/components/schemas/CreateFailureRateMonitor", + "passOnRetry": "#/components/schemas/CreatePassOnRetryMonitor", + "failureCount": "#/components/schemas/CreateFailureCountMonitor", + "newTest": "#/components/schemas/CreateNewTestMonitor", + "skippedTest": "#/components/schemas/CreateSkippedTestMonitor", + "slowTest": "#/components/schemas/CreateSlowTestMonitor", + "timeoutInflation": "#/components/schemas/CreateTimeoutInflationMonitor" + } + }, + "description": "A new monitor. `config` holds the fields of its `monitorType`; an optional field left out is unset." }, - "JobRefById": { + "CreateFailureRateMonitor": { "type": "object", "properties": { - "jobId": { + "monitorType": { "type": "string", - "format": "uuid", - "description": "A job's id from `dynamicCi.listPathsFilters` or `dynamicCi.listPrJobs`. A `workflowPath` or `jobKey` sent beside it must name the same job.", - "example": "3c4f8e21-6a1d-4b7e-9f02-5d8c1a2b3e4f" + "enum": ["failureRate"] }, - "workflowPath": { - "type": ["string", "null"], + "name": { + "type": "string", "minLength": 1, - "description": "The workflow file's repository-relative path, exactly.", - "example": ".github/workflows/ci.yaml" + "maxLength": 200, + "description": "Leading and trailing spaces are removed.", + "example": "Broken on main" }, - "jobKey": { - "type": ["string", "null"], - "minLength": 1, - "description": "The job's key under `jobs:` in that file.", - "example": "web-unit" + "enabled": { + "type": "boolean", + "description": "Defaults to `true`.", + "example": true + }, + "config": { + "type": "object", + "properties": { + "branches": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 256 + }, + "maxItems": 100, + "description": "Branch name patterns to watch (`*` and `?` are wildcards). An empty list watches every branch. Cannot be sent with `pullRequestOnly: true`.", + "example": ["main"] + }, + "pullRequestOnly": { + "type": "boolean", + "description": "Watch only pull-request runs. Cannot be sent with a non-empty `branches`.", + "example": false + }, + "windowMinutes": { + "type": "integer", + "example": 1440 + }, + "minSampleSize": { + "type": "integer", + "example": 10 + }, + "activationFailureThreshold": { + "type": "number", + "example": 0.9 + }, + "resolutionFailureThreshold": { + "type": ["number", "null"], + "example": 0.5, + "description": "Optional. `null` leaves it unset." + }, + "staleAfterMinutes": { + "type": ["integer", "null"], + "example": 1440, + "description": "Optional. `null` leaves it unset." + } + }, + "required": [ + "windowMinutes", + "minSampleSize", + "activationFailureThreshold" + ], + "additionalProperties": false } }, - "required": ["jobId"], + "required": ["monitorType", "name", "config"], "additionalProperties": false }, - "JobRefByName": { + "CreatePassOnRetryMonitor": { "type": "object", "properties": { - "workflowPath": { + "monitorType": { "type": "string", - "minLength": 1, - "description": "The workflow file's repository-relative path, exactly.", - "example": ".github/workflows/ci.yaml" + "enum": ["passOnRetry"] }, - "jobKey": { + "name": { "type": "string", "minLength": 1, - "description": "The job's key under `jobs:` in that file.", - "example": "web-unit" + "maxLength": 200, + "description": "Leading and trailing spaces are removed.", + "example": "Broken on main" + }, + "enabled": { + "type": "boolean", + "description": "Defaults to `true`.", + "example": true + }, + "config": { + "type": "object", + "properties": { + "branches": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 256 + }, + "maxItems": 100, + "description": "Branch name patterns to watch (`*` and `?` are wildcards). An empty list watches every branch. Cannot be sent with `pullRequestOnly: true`.", + "example": ["main"] + }, + "pullRequestOnly": { + "type": "boolean", + "description": "Watch only pull-request runs. Cannot be sent with a non-empty `branches`.", + "example": false + }, + "minPorCount": { + "type": "integer", + "example": 1 + }, + "windowMinutes": { + "type": ["integer", "null"], + "example": 10080, + "description": "Optional. `null` leaves it unset." + }, + "resolveAfterMinutes": { + "type": "integer", + "example": 10080 + } + }, + "required": ["minPorCount", "resolveAfterMinutes"], + "additionalProperties": false } }, - "required": ["workflowPath", "jobKey"], + "required": ["monitorType", "name", "config"], "additionalProperties": false }, - "PathsFilterEntry": { + "CreateFailureCountMonitor": { "type": "object", "properties": { + "monitorType": { + "type": "string", + "enum": ["failureCount"] + }, "name": { - "type": ["string", "null"], - "maxLength": 80, - "description": "Trimmed; blank or absent is unnamed. Names a new filter, or an existing unnamed one with the same rules; an existing name is kept.", - "example": "web" + "type": "string", + "minLength": 1, + "maxLength": 200, + "description": "Leading and trailing spaces are removed.", + "example": "Broken on main" }, - "rules": { - "$ref": "#/components/schemas/PathsFilterRulesInput" + "enabled": { + "type": "boolean", + "description": "Defaults to `true`.", + "example": true }, - "jobs": { - "type": "array", - "items": { - "$ref": "#/components/schemas/JobRef" + "config": { + "type": "object", + "properties": { + "branches": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 256 + }, + "maxItems": 100, + "description": "Branch name patterns to watch (`*` and `?` are wildcards). An empty list watches every branch. Cannot be sent with `pullRequestOnly: true`.", + "example": ["main"] + }, + "pullRequestOnly": { + "type": "boolean", + "description": "Watch only pull-request runs. Cannot be sent with a non-empty `branches`.", + "example": false + }, + "minFailureCount": { + "type": "integer", + "example": 1 + }, + "windowMinutes": { + "type": ["integer", "null"], + "example": 1440, + "description": "Optional. `null` leaves it unset." + }, + "resolveAfterMinutes": { + "type": "integer", + "example": 4320 + } }, - "minItems": 1, - "maxItems": 500 + "required": ["minFailureCount", "resolveAfterMinutes"], + "additionalProperties": false } }, - "required": ["rules", "jobs"], + "required": ["monitorType", "name", "config"], "additionalProperties": false }, - "PathsFilterRulesInput": { + "CreateNewTestMonitor": { "type": "object", "properties": { - "include": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PathsFilterRule" - }, - "minItems": 1, - "maxItems": 64, - "example": [ - { - "glob": "web/**" - } - ] + "monitorType": { + "type": "string", + "enum": ["newTest"] }, - "exclude": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PathsFilterRule" - }, - "maxItems": 64, - "description": "Defaults to none.", - "example": [ - { - "glob": "web/**/*.md" + "name": { + "type": "string", + "minLength": 1, + "maxLength": 200, + "description": "Leading and trailing spaces are removed.", + "example": "Broken on main" + }, + "enabled": { + "type": "boolean", + "description": "Defaults to `true`.", + "example": true + }, + "config": { + "type": "object", + "properties": { + "branches": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 256 + }, + "maxItems": 100, + "description": "Branch name patterns to watch (`*` and `?` are wildcards). An empty list watches every branch. Cannot be sent with `pullRequestOnly: true`.", + "example": ["main"] + }, + "pullRequestOnly": { + "type": "boolean", + "description": "Watch only pull-request runs. Cannot be sent with a non-empty `branches`.", + "example": false + }, + "newDays": { + "type": "integer", + "example": 14 } - ] + }, + "required": ["newDays"], + "additionalProperties": false } }, - "required": ["include"], + "required": ["monitorType", "name", "config"], "additionalProperties": false }, - "PathsFilterRule": { + "CreateSkippedTestMonitor": { "type": "object", "properties": { - "glob": { + "monitorType": { + "type": "string", + "enum": ["skippedTest"] + }, + "name": { "type": "string", "minLength": 1, - "maxLength": 256, - "description": "A picomatch glob, matched with `dot: true` against the repository-relative path. May not begin with `!` or `(`.", - "example": "web/**" + "maxLength": 200, + "description": "Leading and trailing spaces are removed.", + "example": "Broken on main" }, - "changeTypes": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ChangeType" + "enabled": { + "type": "boolean", + "description": "Defaults to `true`.", + "example": true + }, + "config": { + "type": "object", + "properties": { + "branches": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 256 + }, + "maxItems": 100, + "description": "Branch name patterns to watch (`*` and `?` are wildcards). An empty list watches every branch. Cannot be sent with `pullRequestOnly: true`.", + "example": ["main"] + }, + "pullRequestOnly": { + "type": "boolean", + "description": "Watch only pull-request runs. Cannot be sent with a non-empty `branches`.", + "example": false + }, + "minSkippedCount": { + "type": "integer", + "example": 1 + }, + "windowMinutes": { + "type": ["integer", "null"], + "example": 10080, + "description": "Optional. `null` leaves it unset." + }, + "resolutionDays": { + "type": "integer", + "example": 14 + } }, - "minItems": 1, - "maxItems": 6, - "description": "Match only these kinds of change. Absent matches any.", - "example": ["added", "modified"] + "required": ["minSkippedCount", "resolutionDays"], + "additionalProperties": false } }, - "required": ["glob"], + "required": ["monitorType", "name", "config"], "additionalProperties": false }, - "ChangeType": { - "type": "string", - "enum": [ - "added", - "copied", - "deleted", - "modified", - "renamed", - "unmerged" - ], - "description": "A kind of file change, as `dorny/paths-filter` names them.", - "example": "modified" - }, - "PathsFilterWithJobsList": { + "CreateSlowTestMonitor": { "type": "object", "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PathsFilterWithJobs" - }, - "maxItems": 100 + "monitorType": { + "type": "string", + "enum": ["slowTest"] }, - "nextCursor": { - "type": ["string", "null"], - "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", - "example": "AQEKZm9vYmFy" + "name": { + "type": "string", + "minLength": 1, + "maxLength": 200, + "description": "Leading and trailing spaces are removed.", + "example": "Broken on main" }, - "hasMore": { + "enabled": { "type": "boolean", - "description": "True when another page is available.", + "description": "Defaults to `true`.", "example": true }, - "total": { - "type": "integer", - "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", - "example": 1247 + "config": { + "type": "object", + "properties": { + "branches": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 256 + }, + "maxItems": 100, + "description": "Branch name patterns to watch (`*` and `?` are wildcards). An empty list watches every branch. Cannot be sent with `pullRequestOnly: true`.", + "example": ["main"] + }, + "pullRequestOnly": { + "type": "boolean", + "description": "Watch only pull-request runs. Cannot be sent with a non-empty `branches`.", + "example": false + }, + "windowMinutes": { + "type": "integer", + "example": 1440 + }, + "minSampleSize": { + "type": "integer", + "example": 10 + }, + "percentile": { + "type": "number", + "example": 0.95 + }, + "activationDurationMs": { + "type": "integer", + "example": 60000 + }, + "resolutionDurationMs": { + "type": "integer", + "example": 30000 + }, + "staleAfterMinutes": { + "type": ["integer", "null"], + "example": 1440, + "description": "Optional. `null` leaves it unset." + } + }, + "required": [ + "windowMinutes", + "minSampleSize", + "percentile", + "activationDurationMs", + "resolutionDurationMs" + ], + "additionalProperties": false } }, - "required": ["data", "nextCursor", "hasMore"] + "required": ["monitorType", "name", "config"], + "additionalProperties": false }, - "PathsFilterWithJobs": { + "CreateTimeoutInflationMonitor": { "type": "object", "properties": { - "pathsFilterId": { + "monitorType": { "type": "string", - "example": "e8f1c2a4-5b6d-4e7f-8a9b-0c1d2e3f4a5b" + "enum": ["timeoutInflation"] }, "name": { - "type": ["string", "null"], - "description": "Null for an unnamed filter, which the web app shows as Custom.", - "example": "web" + "type": "string", + "minLength": 1, + "maxLength": 200, + "description": "Leading and trailing spaces are removed.", + "example": "Broken on main" }, - "rules": { - "$ref": "#/components/schemas/PathsFilterRules" + "enabled": { + "type": "boolean", + "description": "Defaults to `true`.", + "example": true }, - "jobs": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PathsFilterJob" + "config": { + "type": "object", + "properties": { + "branches": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 256 + }, + "maxItems": 100, + "description": "Branch name patterns to watch (`*` and `?` are wildcards). An empty list watches every branch. Cannot be sent with `pullRequestOnly: true`.", + "example": ["main"] + }, + "pullRequestOnly": { + "type": "boolean", + "description": "Watch only pull-request runs. Cannot be sent with a non-empty `branches`.", + "example": false + }, + "windowMinutes": { + "type": "integer", + "example": 1440 + }, + "passPercentile": { + "type": "number", + "example": 0.95 + }, + "failPercentile": { + "type": "number", + "example": 0.5 + }, + "activationRatio": { + "type": "number", + "example": 3 + }, + "resolutionRatio": { + "type": "number", + "example": 2 + }, + "minPassSampleSize": { + "type": "integer", + "example": 5 + }, + "minFailSampleSize": { + "type": "integer", + "example": 5 + }, + "minAbsoluteGapMs": { + "type": "integer", + "example": 5000 + }, + "staleAfterMinutes": { + "type": ["integer", "null"], + "example": 1440, + "description": "Optional. `null` leaves it unset." + } }, - "maxItems": 10000, - "description": "The jobs the filter gates. A job the web app gave one filter for pull requests and another for the merge queue is listed under both." - }, - "createdAt": { + "required": [ + "windowMinutes", + "passPercentile", + "failPercentile", + "activationRatio", + "resolutionRatio", + "minPassSampleSize", + "minFailSampleSize", + "minAbsoluteGapMs" + ], + "additionalProperties": false + } + }, + "required": ["monitorType", "name", "config"], + "additionalProperties": false + }, + "UpdateMonitorRequest": { + "type": "object", + "properties": { + "name": { "type": "string", - "format": "date-time", - "example": "2026-10-26T20:31:04.512Z" + "minLength": 1, + "maxLength": 200, + "description": "Leading and trailing spaces are removed.", + "example": "Broken on main" }, - "updatedAt": { - "type": "string", - "format": "date-time", - "example": "2026-10-26T20:31:04.512Z" + "enabled": { + "type": "boolean", + "example": false + }, + "config": { + "anyOf": [ + { + "$ref": "#/components/schemas/FailureRateMonitorPatch" + }, + { + "$ref": "#/components/schemas/PassOnRetryMonitorPatch" + }, + { + "$ref": "#/components/schemas/FailureCountMonitorPatch" + }, + { + "$ref": "#/components/schemas/NewTestMonitorPatch" + }, + { + "$ref": "#/components/schemas/SkippedTestMonitorPatch" + }, + { + "$ref": "#/components/schemas/SlowTestMonitorPatch" + }, + { + "$ref": "#/components/schemas/TimeoutInflationMonitorPatch" + } + ], + "description": "Fields of the monitor's own type to change; any field left out keeps its value, and `null` unsets an optional one. A config valid only for another type is a `422`; one mixing fields of two types is a `400`." } }, - "required": [ - "pathsFilterId", - "name", - "rules", - "jobs", - "createdAt", - "updatedAt" - ] + "additionalProperties": false, + "description": "A merge patch. `monitorType` cannot change, and sending it is a `400`." }, - "PathsFilterJob": { + "FailureRateMonitorPatch": { "type": "object", "properties": { - "workflowPath": { - "type": ["string", "null"], - "description": "The workflow file's path. Null if Trunk has not seen one.", - "example": ".github/workflows/ci.yaml" + "branches": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 256 + }, + "maxItems": 100, + "description": "Branch name patterns to watch (`*` and `?` are wildcards). An empty list watches every branch. Cannot be sent with `pullRequestOnly: true`.", + "example": ["main"] }, - "jobKey": { - "type": ["string", "null"], - "description": "The job's key under `jobs:`. Null means the job is reachable only by `jobId`.", - "example": "web-unit" + "pullRequestOnly": { + "type": "boolean", + "description": "Watch only pull-request runs. Cannot be sent with a non-empty `branches`.", + "example": false }, - "jobId": { - "type": "string", - "example": "3c4d0b17-8e2a-4f6c-9d1b-7a5e3c2f1d0e" + "windowMinutes": { + "type": "integer", + "example": 1440 + }, + "minSampleSize": { + "type": "integer", + "example": 10 + }, + "activationFailureThreshold": { + "type": "number", + "example": 0.9 + }, + "resolutionFailureThreshold": { + "type": ["number", "null"], + "example": 0.5, + "description": "Optional. `null` leaves it unset." + }, + "staleAfterMinutes": { + "type": ["integer", "null"], + "example": 1440, + "description": "Optional. `null` leaves it unset." } }, - "required": ["workflowPath", "jobKey", "jobId"] + "additionalProperties": false }, - "PathsFilterRules": { + "PassOnRetryMonitorPatch": { "type": "object", "properties": { - "include": { + "branches": { "type": "array", "items": { - "$ref": "#/components/schemas/PathsFilterRule" + "type": "string", + "minLength": 1, + "maxLength": 256 }, - "minItems": 1, - "maxItems": 64, - "description": "A changed file counts when some `include` rule matches it and no `exclude` rule does.", - "example": [ - { - "glob": "web/**" + "maxItems": 100, + "description": "Branch name patterns to watch (`*` and `?` are wildcards). An empty list watches every branch. Cannot be sent with `pullRequestOnly: true`.", + "example": ["main"] + }, + "pullRequestOnly": { + "type": "boolean", + "description": "Watch only pull-request runs. Cannot be sent with a non-empty `branches`.", + "example": false + }, + "minPorCount": { + "type": "integer", + "example": 1 + }, + "windowMinutes": { + "type": ["integer", "null"], + "example": 10080, + "description": "Optional. `null` leaves it unset." + }, + "resolveAfterMinutes": { + "type": "integer", + "example": 10080 + } + }, + "additionalProperties": false + }, + "FailureCountMonitorPatch": { + "type": "object", + "properties": { + "branches": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 256 + }, + "maxItems": 100, + "description": "Branch name patterns to watch (`*` and `?` are wildcards). An empty list watches every branch. Cannot be sent with `pullRequestOnly: true`.", + "example": ["main"] + }, + "pullRequestOnly": { + "type": "boolean", + "description": "Watch only pull-request runs. Cannot be sent with a non-empty `branches`.", + "example": false + }, + "minFailureCount": { + "type": "integer", + "example": 1 + }, + "windowMinutes": { + "type": ["integer", "null"], + "example": 1440, + "description": "Optional. `null` leaves it unset." + }, + "resolveAfterMinutes": { + "type": "integer", + "example": 4320 + } + }, + "additionalProperties": false + }, + "NewTestMonitorPatch": { + "type": "object", + "properties": { + "branches": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 256 + }, + "maxItems": 100, + "description": "Branch name patterns to watch (`*` and `?` are wildcards). An empty list watches every branch. Cannot be sent with `pullRequestOnly: true`.", + "example": ["main"] + }, + "pullRequestOnly": { + "type": "boolean", + "description": "Watch only pull-request runs. Cannot be sent with a non-empty `branches`.", + "example": false + }, + "newDays": { + "type": "integer", + "example": 14 + } + }, + "additionalProperties": false + }, + "SkippedTestMonitorPatch": { + "type": "object", + "properties": { + "branches": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 256 + }, + "maxItems": 100, + "description": "Branch name patterns to watch (`*` and `?` are wildcards). An empty list watches every branch. Cannot be sent with `pullRequestOnly: true`.", + "example": ["main"] + }, + "pullRequestOnly": { + "type": "boolean", + "description": "Watch only pull-request runs. Cannot be sent with a non-empty `branches`.", + "example": false + }, + "minSkippedCount": { + "type": "integer", + "example": 1 + }, + "windowMinutes": { + "type": ["integer", "null"], + "example": 10080, + "description": "Optional. `null` leaves it unset." + }, + "resolutionDays": { + "type": "integer", + "example": 14 + } + }, + "additionalProperties": false + }, + "SlowTestMonitorPatch": { + "type": "object", + "properties": { + "branches": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 256 + }, + "maxItems": 100, + "description": "Branch name patterns to watch (`*` and `?` are wildcards). An empty list watches every branch. Cannot be sent with `pullRequestOnly: true`.", + "example": ["main"] + }, + "pullRequestOnly": { + "type": "boolean", + "description": "Watch only pull-request runs. Cannot be sent with a non-empty `branches`.", + "example": false + }, + "windowMinutes": { + "type": "integer", + "example": 1440 + }, + "minSampleSize": { + "type": "integer", + "example": 10 + }, + "percentile": { + "type": "number", + "example": 0.95 + }, + "activationDurationMs": { + "type": "integer", + "example": 60000 + }, + "resolutionDurationMs": { + "type": "integer", + "example": 30000 + }, + "staleAfterMinutes": { + "type": ["integer", "null"], + "example": 1440, + "description": "Optional. `null` leaves it unset." + } + }, + "additionalProperties": false + }, + "TimeoutInflationMonitorPatch": { + "type": "object", + "properties": { + "branches": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 256 + }, + "maxItems": 100, + "description": "Branch name patterns to watch (`*` and `?` are wildcards). An empty list watches every branch. Cannot be sent with `pullRequestOnly: true`.", + "example": ["main"] + }, + "pullRequestOnly": { + "type": "boolean", + "description": "Watch only pull-request runs. Cannot be sent with a non-empty `branches`.", + "example": false + }, + "windowMinutes": { + "type": "integer", + "example": 1440 + }, + "passPercentile": { + "type": "number", + "example": 0.95 + }, + "failPercentile": { + "type": "number", + "example": 0.5 + }, + "activationRatio": { + "type": "number", + "example": 3 + }, + "resolutionRatio": { + "type": "number", + "example": 2 + }, + "minPassSampleSize": { + "type": "integer", + "example": 5 + }, + "minFailSampleSize": { + "type": "integer", + "example": 5 + }, + "minAbsoluteGapMs": { + "type": "integer", + "example": 5000 + }, + "staleAfterMinutes": { + "type": ["integer", "null"], + "example": 1440, + "description": "Optional. `null` leaves it unset." + } + }, + "additionalProperties": false + }, + "CreatedTestUpload": { + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uuid", + "description": "The upload's id. The bundle uploaded to `uploadUrl` must carry it, with `createdAt`.", + "example": "f47ac10b-58cc-4372-a567-0e02b2c3d479" + }, + "status": { + "type": "string", + "enum": ["awaitingData"], + "description": "The bundle has not been uploaded yet.", + "example": "awaitingData" + }, + "uploadUrl": { + "type": "string", + "format": "uri", + "description": "A pre-signed URL to `PUT` the bundle to, without Trunk credentials. It expires at `expiresAt`.", + "example": "https://bundles.s3.us-west-2.amazonaws.com/20261006/0d9c3de1-14a0-4f68-a44a-2fbbcf0dcb2f/a1b2c3/f47ac10b-58cc-4372-a567-0e02b2c3d479.tar.zst?X-Amz-Signature=3f1b8c9e" + }, + "expiresAt": { + "type": "string", + "format": "date-time", + "description": "When `uploadUrl` stops accepting the bundle: at most an hour after `createdAt`, and at least 15 minutes.", + "example": "2026-10-06T17:00:00.000Z" + }, + "testCollectionUuid": { + "type": "string", + "format": "uuid", + "description": "The collection's internal UUID, which a test's `testId` is computed from (with `repositoryId` and the test's own id). Use it only for that: everywhere else a collection is addressed by its `id`.", + "example": "204b6c93-1c51-4e0f-a13c-e07b9bc60688" + }, + "repositoryId": { + "type": "string", + "format": "uuid", + "description": "The repository the tests are stored under. The nil UUID for an upload without a repository, or for a repository Trunk could not find or create.", + "example": "7a1f0e3d-2b4c-4d5e-8f90-123456789abc" + }, + "createdAt": { + "type": "string", + "format": "date-time", + "description": "When the upload was created.", + "example": "2026-10-06T16:00:00.000Z" + } + }, + "required": [ + "id", + "status", + "uploadUrl", + "expiresAt", + "testCollectionUuid", + "repositoryId", + "createdAt" + ], + "description": "A test-results upload, waiting for its bundle." + }, + "CreateTestUploadRequest": { + "type": "object", + "properties": { + "repo": { + "type": ["object", "null"], + "properties": { + "host": { + "type": "string", + "minLength": 1, + "maxLength": 256, + "example": "github.com" + }, + "owner": { + "type": "string", + "minLength": 1, + "maxLength": 512, + "example": "acme" + }, + "name": { + "type": "string", + "minLength": 1, + "maxLength": 512, + "example": "web" } - ] + }, + "required": ["host", "owner", "name"], + "description": "The repository the tests ran in, as the CLI reads it from git. `null` for an upload made without a repository (`--no-repo`)." }, - "exclude": { + "remoteUrls": { "type": "array", "items": { - "$ref": "#/components/schemas/PathsFilterRule" + "type": "string", + "minLength": 1, + "maxLength": 2048 }, - "maxItems": 64, - "example": [ - { - "glob": "web/**/*.md" + "maxItems": 20, + "description": "The repository's git remote URLs. When present and Trunk does not know the repository yet, it is created.", + "example": ["https://github.com/acme/web.git"] + }, + "clientVersion": { + "type": "string", + "maxLength": 256, + "description": "The uploading client's version.", + "example": "0.12.3" + }, + "externalId": { + "type": "string", + "maxLength": 256, + "description": "The CI job's own id, used to match the upload to its GitHub Actions job.", + "example": "45829103344" + } + }, + "required": ["repo"], + "description": "The repository the tests ran in, and the client uploading." + }, + "TestUpload": { + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uuid", + "description": "The upload's id.", + "example": "f47ac10b-58cc-4372-a567-0e02b2c3d479" + }, + "testCollectionId": { + "type": "string", + "description": "The id of the test collection the upload belongs to.", + "example": "aB3xY9kQ" + }, + "repositoryId": { + "type": "string", + "format": "uuid", + "description": "The repository the tests are stored under. The nil UUID for an upload without a repository.", + "example": "7a1f0e3d-2b4c-4d5e-8f90-123456789abc" + }, + "status": { + "$ref": "#/components/schemas/TestUploadStatus" + }, + "defects": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TestUploadDefect" + }, + "maxItems": 1000, + "description": "The problems ingestion found, oldest first. Empty until the bundle has been read. At most 1000; past that, every `invalid` defect is kept before any `suboptimal` one." + }, + "clientVersion": { + "type": "string", + "description": "The version of the client that built the bundle, as ingestion read it from the bundle. Empty until the bundle has been read. It is not the `clientVersion` sent on the create.", + "example": "trunk-analytics-cli 0.12.3" + }, + "createdAt": { + "type": "string", + "format": "date-time", + "description": "When the upload was created.", + "example": "2026-10-06T16:00:00.000Z" + }, + "updatedAt": { + "type": "string", + "format": "date-time", + "description": "The last time ingestion touched the upload. Each ingestion attempt moves it, even when `status` stays the same.", + "example": "2026-10-06T16:00:04.000Z" + } + }, + "required": [ + "id", + "testCollectionId", + "repositoryId", + "status", + "defects", + "clientVersion", + "createdAt", + "updatedAt" + ], + "description": "A test-results upload: where it is, and what ingestion found." + }, + "TestUploadStatus": { + "type": "string", + "enum": ["awaitingData", "received", "ingested", "skipped"], + "description": "Where an upload is. `awaitingData`: Trunk has not read the bundle. Past `expiresAt` on the create, it was never uploaded or could not be read. `received`: ingestion has started and not finished. Ingestion retries for about 10 minutes, so an upload still `received` with `updatedAt` more than 15 minutes old was not ingested and will not change. `ingested`: ingestion has recorded the upload. Its results and defects are written just after, so `defects` can still grow for a few seconds; each one moves `updatedAt`. If writing them fails, the upload stays `ingested` with its results incomplete. An `invalid` defect names a part of the bundle that was left out. `skipped`: it was read, but so many of its tests failed that Trunk treated the run as an infrastructure failure and stored no results.", + "example": "ingested" + }, + "TestUploadDefect": { + "type": "object", + "properties": { + "type": { + "$ref": "#/components/schemas/TestUploadDefectType" + }, + "level": { + "$ref": "#/components/schemas/TestUploadDefectLevel" + }, + "source": { + "type": "string", + "description": "Where in the upload the defect is, such as a report path.", + "example": "reports/junit.xml" + }, + "message": { + "type": "string", + "description": "What is wrong.", + "example": "Test case `login` has no timestamp" + } + }, + "required": ["type", "level", "source", "message"], + "description": "A problem ingestion found in an upload." + }, + "TestUploadDefectType": { + "type": "string", + "enum": [ + "unspecified", + "junit", + "env", + "repo", + "bundleSize", + "reportLimit", + "meta", + "deprecatedCli" + ], + "description": "What part of the upload a defect is about.", + "example": "junit" + }, + "TestUploadDefectLevel": { + "type": "string", + "enum": ["suboptimal", "invalid"], + "description": "`invalid`: Trunk could not use the part of the bundle the defect names (`type`, `source`), and ingested the rest. `suboptimal`: that part was used, with less information than it could have had.", + "example": "suboptimal" + }, + "BulkResult": { + "type": "object", + "properties": { + "results": { + "type": "array", + "items": { + "$ref": "#/components/schemas/BulkResultItem" + }, + "maxItems": 100, + "description": "One entry per requested item, in request order." + }, + "succeededCount": { + "type": "integer", + "example": 2 + }, + "unchangedCount": { + "type": "integer", + "example": 1 + }, + "failedCount": { + "type": "integer", + "example": 0 + } + }, + "required": [ + "results", + "succeededCount", + "unchangedCount", + "failedCount" + ], + "description": "The outcome of each item of a many-form request. A request that is refused as a whole answers a coded error instead, never a `BulkResult`." + }, + "BulkResultItem": { + "type": "object", + "properties": { + "testId": { + "type": "string", + "example": "bfeebcf4-0000-8000-8000-000000000001" + }, + "status": { + "$ref": "#/components/schemas/BulkItemStatus" + }, + "quarantineOverride": { + "anyOf": [ + { + "$ref": "#/components/schemas/QuarantineOverride" + }, + { + "type": "null" + } + ], + "description": "Quarantine: the test's override after the call, null when none is in force. Absent on a failed item." + }, + "monitorTestState": { + "allOf": [ + { + "$ref": "#/components/schemas/MonitorTestState" + }, + { + "description": "Mute and unmute: the monitor's state for the test after the call. Absent on a failed item." + } + ] + }, + "error": { + "$ref": "#/components/schemas/BulkItemError" + } + }, + "required": ["testId", "status"] + }, + "BulkItemStatus": { + "type": "string", + "enum": ["succeeded", "unchanged", "failed"], + "description": "`succeeded` changed the test. `unchanged` found it already in the requested state and wrote nothing. `failed` carries an `error` and changed nothing that stayed.", + "example": "succeeded" + }, + "BulkItemError": { + "type": "object", + "properties": { + "code": { + "type": "string", + "example": "TEST_NOT_FOUND" + }, + "message": { + "type": "string", + "example": "No test found with ID bfeebcf4-0000-8000-8000-000000000001" + }, + "param": { + "type": "string", + "description": "The request field the error is about.", + "example": "items[2].testId" + } + }, + "required": ["code", "message", "param"] + }, + "MuteMonitorTestsRequest": { + "type": "object", + "properties": { + "testIds": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "example": "bfeebcf4-0000-8000-8000-000000000001" + }, + "minItems": 1, + "maxItems": 100, + "description": "The tests, by their globally unique ids: at most 100, each once." + }, + "muteUntil": { + "type": "string", + "format": "date-time", + "description": "When the mute ends: in the future, and at most 30 days away. Left out, the mute has no end.", + "example": "2026-12-01T00:00:00.000Z" + }, + "reason": { + "type": "string", + "minLength": 1, + "maxLength": 1000, + "description": "Why the test is muted, shown with the mute.", + "example": "Known flake; fix tracked in TRUNK-1234." + } + }, + "required": ["testIds"], + "additionalProperties": false, + "description": "The tests to mute the monitor for, with one end and reason." + }, + "UnmuteMonitorTestsRequest": { + "type": "object", + "properties": { + "testIds": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "example": "bfeebcf4-0000-8000-8000-000000000001" + }, + "minItems": 1, + "maxItems": 100, + "description": "The tests, by their globally unique ids: at most 100, each once." + } + }, + "required": ["testIds"], + "additionalProperties": false, + "description": "The tests to unmute the monitor for." + }, + "MuteMonitorTestRequest": { + "type": "object", + "properties": { + "muteUntil": { + "type": "string", + "format": "date-time", + "description": "When the mute ends: in the future, and at most 30 days away. Left out, the mute has no end.", + "example": "2026-12-01T00:00:00.000Z" + }, + "reason": { + "type": "string", + "minLength": 1, + "maxLength": 1000, + "description": "Why the test is muted, shown with the mute.", + "example": "Known flake; fix tracked in TRUNK-1234." + } + }, + "additionalProperties": false, + "description": "How long, and why, to mute the monitor for one test." + }, + "SetQuarantineRequest": { + "type": "object", + "properties": { + "mode": { + "$ref": "#/components/schemas/SetQuarantineMode" + }, + "reason": { + "type": "string", + "minLength": 1, + "maxLength": 1000, + "description": "Why the override was set, shown with it in the web app and on the test's `quarantineOverride`.", + "example": "Fails only on the Windows shard; tracked in TRUNK-1234." + } + }, + "required": ["mode"], + "additionalProperties": false, + "description": "The quarantine override to set on one test." + }, + "SetQuarantineMode": { + "type": "string", + "enum": ["alwaysQuarantine", "neverQuarantine", "clear"], + "description": "`alwaysQuarantine` quarantines the test whatever its status. `neverQuarantine` keeps it out of quarantine whatever its status. `clear` removes the override, so the collection's quarantine settings and the test's status decide again.", + "example": "neverQuarantine" + }, + "SetQuarantineManyRequest": { + "type": "object", + "properties": { + "reason": { + "type": "string", + "minLength": 1, + "maxLength": 1000, + "description": "Why the override was set, shown with it in the web app and on the test's `quarantineOverride`.", + "example": "Fails only on the Windows shard; tracked in TRUNK-1234." + }, + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SetQuarantineItem" + }, + "minItems": 1, + "maxItems": 100, + "description": "The tests to change, at most 100, each id once." + } + }, + "required": ["items"], + "additionalProperties": false, + "description": "Quarantine overrides to set on many tests, with one `reason` for all of them." + }, + "SetQuarantineItem": { + "type": "object", + "properties": { + "testId": { + "type": "string", + "minLength": 1, + "description": "The test's globally unique id.", + "example": "bfeebcf4-0000-8000-8000-000000000001" + }, + "mode": { + "$ref": "#/components/schemas/SetQuarantineMode" + } + }, + "required": ["testId", "mode"], + "additionalProperties": false + }, + "Ticket": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "Trunk's id for the linked ticket.", + "example": "5d4c3b2a-1f0e-4a1b-8c9d-0e1f2a3b4c5d" + }, + "provider": { + "$ref": "#/components/schemas/TicketProvider" + }, + "key": { + "type": "string", + "description": "The provider's human-readable key. Mutable on some providers (a Jira issue moved between projects gets a new one).", + "example": "TRUNK-1234" + }, + "url": { + "type": "string", + "format": "uri", + "example": "https://acme.atlassian.net/browse/TRUNK-1234" + }, + "title": { + "type": "string", + "example": "[Flaky Test] suite::test_case_name" + }, + "status": { + "type": "string", + "description": "The provider's status name, as last synced.", + "example": "In Progress" + }, + "assignee": { + "type": ["string", "null"], + "description": "The provider's assignee display name; null when unassigned.", + "example": "Ada Lovelace" + }, + "syncedAt": { + "type": "string", + "format": "date-time", + "description": "When Trunk last read the ticket back from its provider.", + "example": "2026-09-15T14:45:01.000Z" + }, + "deletedAt": { + "type": ["string", "null"], + "format": "date-time", + "description": "When Trunk found that the ticketing provider no longer has this ticket; null while it exists. A deleted ticket stays linked until it is unlinked, and its `status` is the last one synced.", + "example": "2026-10-01T09:00:00.000Z" + } + }, + "required": [ + "id", + "provider", + "key", + "url", + "title", + "status", + "assignee", + "syncedAt", + "deletedAt" + ] + }, + "LinkTicketRequest": { + "type": "object", + "properties": { + "externalTicketId": { + "type": "string", + "minLength": 1, + "maxLength": 2048, + "description": "The ticket to link, as its provider key (`TRUNK-123`, a Linear identifier, an Asana task gid) or as its browser URL — either form is accepted.", + "example": "TRUNK-1234" + }, + "integrationId": { + "type": "string", + "format": "uuid", + "description": "Which of the organization's ticketing connections the ticket lives on. Defaults to the collection's default connection.", + "example": "2b3c4d5e-6f70-4a1b-8c9d-0e1f2a3b4c5d" + } + }, + "required": ["externalTicketId"], + "description": "The ticket to link to a test in a test collection." + }, + "CreateTicketRequest": { + "type": "object", + "properties": { + "title": { + "type": "string", + "minLength": 1, + "maxLength": 250, + "description": "The ticket's title. Defaults to the one the web app generates, such as `[Flaky Test] suite::test_case_name`.", + "example": "[Flaky Test] suite::test_case_name" + }, + "description": { + "type": "string", + "description": "The ticket's body, in Markdown. Defaults to the one the web app generates: the test's location, failure rate, owners and most common failure reasons, with a link back to the test in Trunk.", + "example": "See all details on the [Trunk Test Detail page](https://app.trunk.io/acme/flaky-tests/collections/ab12cd34/tests/bfeebcf4-0000-8000-8000-000000000001)" + }, + "fields": { + "type": "object", + "additionalProperties": {}, + "description": "Provider fields to set on the ticket, keyed by the provider's field id (a Jira custom field id, `assignee`, a Linear project id), in the shape the provider takes. Merged over the default fields saved on the collection's ticketing connection; a field set here wins.", + "example": { + "assignee": "5b10ac8d82e05b22cc7d4ef5" + } + }, + "replaceExisting": { + "type": "boolean", + "description": "Replace a ticket already linked to the test. When false or absent, a test that has a ticket is refused with `TEST_ALREADY_LINKED`.", + "example": false + } + }, + "additionalProperties": false, + "description": "The ticket to create for a test in a test collection." + }, + "RepositoryList": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Repository" + }, + "maxItems": 100 + }, + "nextCursor": { + "type": ["string", "null"], + "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", + "example": "AQEKZm9vYmFy" + }, + "hasMore": { + "type": "boolean", + "description": "True when another page is available.", + "example": true + }, + "total": { + "type": "integer", + "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", + "example": 1247 + } + }, + "required": ["data", "nextCursor", "hasMore"] + }, + "Repository": { + "type": "object", + "properties": { + "id": { + "type": "string", + "example": "7c9e6679-7425-40de-944b-e07fc1f90ae7" + }, + "provider": { + "$ref": "#/components/schemas/Provider" + }, + "path": { + "type": "string", + "description": "The provider-side path, `owner/repo`.", + "example": "acme/widgets" + }, + "host": { + "type": ["string", "null"], + "description": "Null for a repository on the provider's default host.", + "example": "github.com" + }, + "url": { + "type": "string", + "example": "https://github.com/acme/widgets" + }, + "defaultBranch": { + "type": ["string", "null"], + "description": "Null until Trunk has synced it.", + "example": "main" + }, + "isPrivate": { + "type": ["boolean", "null"], + "description": "Null until Trunk has synced it.", + "example": true + }, + "createdAt": { + "type": "string", + "format": "date-time", + "example": "2026-01-14T09:12:00.000Z" + }, + "updatedAt": { + "type": "string", + "format": "date-time", + "example": "2026-07-20T16:44:10.000Z" + } + }, + "required": [ + "id", + "provider", + "path", + "host", + "url", + "defaultBranch", + "isPrivate", + "createdAt", + "updatedAt" + ] + }, + "Provider": { + "type": "string", + "enum": ["github", "gitlab", "bitbucket", "unknown"], + "description": "The hosting provider. `unknown` is a repository Trunk has indexed without resolving a provider.", + "example": "github" + }, + "CiJobRunList": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CiJobRun" + }, + "maxItems": 100 + }, + "nextCursor": { + "type": ["string", "null"], + "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", + "example": "AQEKZm9vYmFy" + }, + "hasMore": { + "type": "boolean", + "description": "True when another page is available.", + "example": true + }, + "total": { + "type": "integer", + "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", + "example": 1247 + } + }, + "required": ["data", "nextCursor", "hasMore"] + }, + "CiJobRun": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "Opaque. Identifies the job's latest attempt.", + "example": "1a289f57705150d7~q1790685507000" + }, + "commitSha": { + "type": "string", + "example": "a0de7a77e8d758a346f83ed19209a5a25814bb17" + }, + "name": { + "type": "string", + "example": "test (2/2)" + }, + "workflowName": { + "type": ["string", "null"], + "example": "CI" + }, + "workflowRunId": { + "type": ["string", "null"], + "description": "The `CiWorkflowRun.id` of the job's run.", + "example": "5e1d2c3b4a596877" + }, + "attempt": { + "type": "integer", + "example": 1 + }, + "attemptCount": { + "type": "integer", + "description": "Every attempt of the job, the latest included.", + "example": 2 + }, + "failedAttemptCount": { + "type": "integer", + "example": 1 + }, + "status": { + "$ref": "#/components/schemas/CiJobStatus" + }, + "conclusion": { + "anyOf": [ + { + "$ref": "#/components/schemas/CiConclusion" + }, + { + "type": "null" + } + ], + "description": "Set when `status` is `completed`." + }, + "required": { + "type": ["boolean", "null"], + "description": "Whether the job is a required check on the pull request's base branch or its merge queue. Null when the list is read by commit, with no pull request to say which branch.", + "example": true + }, + "queuedAt": { + "type": ["string", "null"], + "format": "date-time", + "example": "2026-09-29T12:37:00.000Z" + }, + "startedAt": { + "type": ["string", "null"], + "format": "date-time", + "example": "2026-09-29T12:38:27.000Z" + }, + "finishedAt": { + "type": ["string", "null"], + "format": "date-time", + "example": "2026-09-29T12:44:03.000Z" + }, + "queuedMs": { + "type": ["integer", "null"], + "example": 87000 + }, + "durationMs": { + "type": ["integer", "null"], + "example": 336000 + }, + "updatedAt": { + "type": "string", + "format": "date-time", + "example": "2026-09-29T12:44:03.000Z" + }, + "url": { + "type": ["string", "null"], + "example": "https://github.com/acme/widgets/actions/runs/36498062451/job/1" + }, + "failure": { + "anyOf": [ + { + "$ref": "#/components/schemas/CiJobFailure" + }, + { + "type": "null" + } + ], + "description": "Set when `conclusion` is `failure` or `timedOut`." + } + }, + "required": [ + "id", + "commitSha", + "name", + "workflowName", + "workflowRunId", + "attempt", + "attemptCount", + "failedAttemptCount", + "status", + "conclusion", + "required", + "queuedAt", + "startedAt", + "finishedAt", + "queuedMs", + "durationMs", + "updatedAt", + "url", + "failure" + ], + "description": "The latest attempt of one CI job on a commit. Named apart from Dynamic CI's `CiJob`, which is a job's definition rather than a run of it. A job is a workflow run and a rendered job name, so each matrix leg is its own job." + }, + "CiJobStatus": { + "type": "string", + "enum": ["queued", "running", "completed", "abandoned"], + "description": "`abandoned` is a job whose queue or run never reported an end, past the 25-hour open-span cap.", + "example": "completed" + }, + "CiConclusion": { + "type": "string", + "enum": ["success", "failure", "timedOut", "cancelled", "skipped"], + "example": "failure" + }, + "CiJobFailure": { + "type": "object", + "properties": { + "failingStep": { + "type": ["string", "null"], + "example": "Typecheck" + }, + "analysis": { + "$ref": "#/components/schemas/CiFailureAnalysis" + }, + "logExcerpt": { + "anyOf": [ + { + "$ref": "#/components/schemas/CiLogExcerpt" + }, + { + "type": "null" + } + ] + }, + "cluster": { + "anyOf": [ + { + "$ref": "#/components/schemas/CiFailureClusterRef" + }, + { + "type": "null" + } + ], + "description": "Other failures with the same cause. Null until the hourly clustering run assigns this one." + }, + "annotationCount": { + "type": "integer", + "description": "Read them with `GET /v2/ci-jobs/{id}/annotations`.", + "example": 0 + } + }, + "required": [ + "failingStep", + "analysis", + "logExcerpt", + "cluster", + "annotationCount" + ] + }, + "CiFailureAnalysis": { + "type": "object", + "properties": { + "state": { + "$ref": "#/components/schemas/CiAnalysisState" + }, + "summaryShort": { + "type": ["string", "null"], + "example": "Frontend TypeScript checks failed" + }, + "summary": { + "type": ["string", "null"], + "example": "Frontend TypeScript checks failed on a type mismatch" + }, + "rootCause": { + "type": ["string", "null"], + "example": "A string is passed where a number is expected." + } + }, + "required": ["state", "summaryShort", "summary", "rootCause"] + }, + "CiAnalysisState": { + "type": "string", + "enum": ["pending", "ready", "unavailable"], + "description": "`pending` for 15 minutes after a failed job finished with no analysis yet. `unavailable` after that: the organization is not enabled, AI features are off, or the analysis failed.", + "example": "ready" + }, + "CiLogExcerpt": { + "type": "object", + "properties": { + "startLine": { + "type": "integer", + "example": 69 + }, + "endLine": { + "type": "integer", + "example": 71 + }, + "text": { + "type": ["string", "null"], + "description": "The stored reduced excerpt, which outlives the 30-day log. Null when the failure has no analysis, or without the **Read CI logs** permission. Read the lines with `GET /v2/ci-jobs/{id}/log-lines`.", + "example": "error TS2322: Type 'string' is not assignable to type 'number'." + } + }, + "required": ["startLine", "endLine", "text"], + "description": "The failure's lines in the job's log, 1-based and inclusive." + }, + "CiFailureClusterRef": { + "type": "object", + "properties": { + "id": { + "type": "string", + "example": "0894d6a25f35e0786faac29a" + }, + "occurrences": { + "type": "integer", + "example": 6 + } + }, + "required": ["id", "occurrences"] + }, + "CiWorkflowRunList": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CiWorkflowRun" + }, + "maxItems": 100 + }, + "nextCursor": { + "type": ["string", "null"], + "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", + "example": "AQEKZm9vYmFy" + }, + "hasMore": { + "type": "boolean", + "description": "True when another page is available.", + "example": true + }, + "total": { + "type": "integer", + "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", + "example": 1247 + } + }, + "required": ["data", "nextCursor", "hasMore"] + }, + "CiWorkflowRun": { + "type": "object", + "properties": { + "id": { + "type": "string", + "example": "5e1d2c3b4a596877" + }, + "commitSha": { + "type": "string", + "example": "a0de7a77e8d758a346f83ed19209a5a25814bb17" + }, + "runId": { + "type": "string", + "description": "The provider's run id: a GitHub run, or a Buildkite build number.", + "example": "36498062451" + }, + "name": { + "type": ["string", "null"], + "example": "CI" + }, + "path": { + "type": ["string", "null"], + "example": ".github/workflows/ci.yml" + }, + "attempt": { + "type": "integer", + "example": 1 + }, + "status": { + "$ref": "#/components/schemas/CiWorkflowRunStatus" + }, + "conclusion": { + "anyOf": [ + { + "$ref": "#/components/schemas/CiConclusion" + }, + { + "type": "null" + } + ] + }, + "startedAt": { + "type": "string", + "format": "date-time", + "example": "2026-09-29T12:36:55.000Z" + }, + "finishedAt": { + "type": ["string", "null"], + "format": "date-time", + "example": "2026-09-29T12:58:10.000Z" + }, + "url": { + "type": ["string", "null"], + "example": "https://github.com/acme/widgets/actions/runs/36498062451" + }, + "jobs": { + "$ref": "#/components/schemas/CiJobCounts" + } + }, + "required": [ + "id", + "commitSha", + "runId", + "name", + "path", + "attempt", + "status", + "conclusion", + "startedAt", + "finishedAt", + "url", + "jobs" + ], + "description": "The latest attempt of one workflow run, with its jobs counted." + }, + "CiWorkflowRunStatus": { + "type": "string", + "enum": ["running", "completed"], + "example": "completed" + }, + "CiLogLineList": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CiLogLine" + }, + "maxItems": 100 + }, + "nextCursor": { + "type": ["string", "null"], + "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", + "example": "AQEKZm9vYmFy" + }, + "hasMore": { + "type": "boolean", + "description": "True when another page is available.", + "example": true + }, + "total": { + "type": "integer", + "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", + "example": 1247 + } + }, + "required": ["data", "nextCursor", "hasMore"] + }, + "CiLogLine": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "example": 70 + }, + "timestamp": { + "type": "string", + "format": "date-time", + "example": "2026-09-29T12:43:58.120Z" + }, + "severity": { + "$ref": "#/components/schemas/CiLogSeverity" + }, + "step": { + "type": ["string", "null"], + "example": "Typecheck" + }, + "text": { + "type": "string", + "example": "src/app.ts(3,1): error TS2322" + } + }, + "required": ["lineNumber", "timestamp", "severity", "step", "text"] + }, + "CiLogSeverity": { + "type": "string", + "enum": ["debug", "info", "warning", "error"], + "example": "error" + }, + "CiAnnotationList": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CiAnnotation" + }, + "maxItems": 100 + }, + "nextCursor": { + "type": ["string", "null"], + "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", + "example": "AQEKZm9vYmFy" + }, + "hasMore": { + "type": "boolean", + "description": "True when another page is available.", + "example": true + }, + "total": { + "type": "integer", + "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", + "example": 1247 + } + }, + "required": ["data", "nextCursor", "hasMore"] + }, + "CiAnnotation": { + "type": "object", + "properties": { + "index": { + "type": "integer", + "example": 0 + }, + "path": { + "type": "string", + "example": ".github" + }, + "startLine": { + "type": "integer", + "example": 1 + }, + "endLine": { + "type": "integer", + "example": 1 + }, + "level": { + "$ref": "#/components/schemas/CiAnnotationLevel" + }, + "title": { + "type": "string", + "example": "" + }, + "message": { + "type": "string", + "example": "The runner has received a shutdown signal." + }, + "cause": { + "$ref": "#/components/schemas/CiAnnotationCause" + } + }, + "required": [ + "index", + "path", + "startLine", + "endLine", + "level", + "title", + "message", + "cause" + ], + "description": "A check-run annotation, for the failures a log does not explain, such as a runner that disconnected." + }, + "CiAnnotationLevel": { + "type": "string", + "enum": ["notice", "warning", "failure"], + "example": "failure" + }, + "CiAnnotationCause": { + "type": "string", + "enum": [ + "unclassified", + "runnerDisconnect", + "deploymentRejected", + "exitCode", + "cancelled", + "jobTimeout" + ], + "example": "runnerDisconnect" + }, + "CiCommitList": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CiCommit" + }, + "maxItems": 100 + }, + "nextCursor": { + "type": ["string", "null"], + "description": "Opaque cursor for the next page, or null on the last page. Pass it back verbatim as `cursor`; do not construct or inspect one.", + "example": "AQEKZm9vYmFy" + }, + "hasMore": { + "type": "boolean", + "description": "True when another page is available.", + "example": true + }, + "total": { + "type": "integer", + "description": "Total rows matching the filter. Present only when the request set `includeTotal=true`.", + "example": 1247 + } + }, + "required": ["data", "nextCursor", "hasMore"] + }, + "CiCommit": { + "type": "object", + "properties": { + "sha": { + "type": "string", + "example": "a0de7a77e8d758a346f83ed19209a5a25814bb17" + }, + "firstSeenAt": { + "type": "string", + "format": "date-time", + "example": "2026-09-29T10:37:25.000Z" + }, + "lastSeenAt": { + "type": "string", + "format": "date-time", + "example": "2026-09-29T12:36:55.000Z" + }, + "jobsUrl": { + "type": "string", + "example": "/v2/ci-jobs?pullRequestId=0f8fad5b-d9cb-469f-a165-70867728950e&commitSha=a0de7a77e8d758a346f83ed19209a5a25814bb17" + }, + "workflowRunsUrl": { + "type": "string", + "example": "/v2/ci-workflow-runs?pullRequestId=0f8fad5b-d9cb-469f-a165-70867728950e&commitSha=a0de7a77e8d758a346f83ed19209a5a25814bb17" + } + }, + "required": [ + "sha", + "firstSeenAt", + "lastSeenAt", + "jobsUrl", + "workflowRunsUrl" + ], + "description": "A commit that ran CI on the pull request. Read its jobs through `jobsUrl`." + }, + "CiFailureCluster": { + "type": "object", + "properties": { + "id": { + "type": "string", + "example": "0894d6a25f35e0786faac29a" + }, + "occurrences": { + "type": "integer", + "example": 6 + }, + "lastSeenAt": { + "type": "string", + "format": "date-time", + "example": "2026-09-29T12:44:03.000Z" + }, + "representative": { + "anyOf": [ + { + "$ref": "#/components/schemas/CiFailureClusterRepresentative" + }, + { + "type": "null" + } + ] + } + }, + "required": ["id", "occurrences", "lastSeenAt", "representative"], + "description": "Failures with the same cause, grouped by the hourly clustering run." + }, + "CiFailureClusterRepresentative": { + "type": "object", + "properties": { + "summaryShort": { + "type": "string", + "example": "Frontend TypeScript checks failed" + }, + "summary": { + "type": "string", + "example": "Frontend TypeScript checks failed on a type mismatch" + }, + "rootCause": { + "type": "string", + "example": "A string is passed where a number is expected." + } + }, + "required": ["summaryShort", "summary", "rootCause"] + } + }, + "parameters": {} + }, + "paths": { + "/v2/merge-queues": { + "get": { + "operationId": "mergeQueues.list", + "tags": ["mergeQueues"], + "summary": "List merge queues", + "description": "Lists the merge queues in your organization. `targetBranch` narrows within a single repository rather than searching branch names globally, so it must be sent together with `repositoryId`.", + "parameters": [ + { + "schema": { + "type": "integer", + "minimum": 1, + "maximum": 100, + "default": 25, + "description": "Page size, between 1 and 100.", + "example": 25 + }, + "required": false, + "description": "Page size, between 1 and 100.", + "name": "limit", + "in": "query" + }, + { + "schema": { + "type": "string", + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "example": "AQEKZm9vYmFy" + }, + "required": false, + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "name": "cursor", + "in": "query" + }, + { + "schema": { + "type": "boolean", + "default": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "example": false + }, + "required": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "name": "includeTotal", + "in": "query" + }, + { + "schema": { + "type": "string", + "format": "uuid", + "description": "Only queues belonging to this repository.", + "example": "7c9e6679-7425-40de-944b-e07fc1f90ae7" + }, + "required": false, + "description": "Only queues belonging to this repository.", + "name": "repositoryId", + "in": "query" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "description": "Only the queue for this target branch. Requires `repositoryId`.", + "example": "main" + }, + "required": false, + "description": "Only the queue for this target branch. Requires `repositoryId`.", + "name": "targetBranch", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A page of merge queues", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MergeQueueList" + } + } + } + }, + "400": { + "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "VALIDATION_FAILED": { + "summary": "VALIDATION_FAILED", + "value": { + "error": { + "code": "VALIDATION_FAILED", + "message": "Invalid input: expected string, received undefined" + } + } + }, + "INVALID_CURSOR": { + "summary": "INVALID_CURSOR", + "value": { + "error": { + "code": "INVALID_CURSOR", + "message": "Invalid or expired cursor." + } + } + } + } + } + } + }, + "401": { + "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "AUTHENTICATION_REQUIRED": { + "summary": "AUTHENTICATION_REQUIRED", + "value": { + "error": { + "code": "AUTHENTICATION_REQUIRED", + "message": "No credential was supplied" + } + } + }, + "INVALID_TOKEN": { + "summary": "INVALID_TOKEN", + "value": { + "error": { + "code": "INVALID_TOKEN", + "message": "The supplied token failed verification" + } + } + } + } + } + } + }, + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", + "value": { + "error": { + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" + } + } + } + } + } + } + }, + "429": { + "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "RATE_LIMIT_EXCEEDED": { + "summary": "RATE_LIMIT_EXCEEDED", + "value": { + "error": { + "code": "RATE_LIMIT_EXCEEDED", + "message": "Rate limit exceeded; retry with backoff" + } + } + } + } + } + } + }, + "500": { + "description": "`INTERNAL_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INTERNAL_ERROR": { + "summary": "INTERNAL_ERROR", + "value": { + "error": { + "code": "INTERNAL_ERROR", + "message": "An unexpected error occurred" + } + } + } + } + } + } + } + } + }, + "post": { + "operationId": "mergeQueues.create", + "tags": ["mergeQueues"], + "summary": "Create a merge queue", + "description": "Requires the **Update Merge Queue settings** permission. Creates a merge queue for a repository and target branch. At most one queue exists per pair, so a second create returns `QUEUE_ALREADY_EXISTS`.\n\n**This operation is not atomic.** `bisectionConcurrency` and `enqueueingLabel` are applied by a second write, so **an error response does not guarantee that no queue was created** — if the first write succeeded and the second failed, the queue exists with those two fields at their defaults and this call still returns the second write's error. Do not blindly retry: a retry returns `409 QUEUE_ALREADY_EXISTS`. Instead read the queue back (`GET /v2/merge-queues?repositoryId=…&targetBranch=…`) and, if it exists, finish the configuration with `PATCH /v2/merge-queues/{id}/config`.", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateMergeQueueRequest" + } + } + } + }, + "responses": { + "201": { + "description": "The created merge queue", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MergeQueue" + } + } + } + }, + "400": { + "description": "`VALIDATION_FAILED`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "VALIDATION_FAILED": { + "summary": "VALIDATION_FAILED", + "value": { + "error": { + "code": "VALIDATION_FAILED", + "message": "Invalid input: expected string, received undefined" + } + } + } + } + } + } + }, + "401": { + "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "AUTHENTICATION_REQUIRED": { + "summary": "AUTHENTICATION_REQUIRED", + "value": { + "error": { + "code": "AUTHENTICATION_REQUIRED", + "message": "No credential was supplied" + } + } + }, + "INVALID_TOKEN": { + "summary": "INVALID_TOKEN", + "value": { + "error": { + "code": "INVALID_TOKEN", + "message": "The supplied token failed verification" + } + } + } + } + } + } + }, + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", + "value": { + "error": { + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" + } + } + } + } + } + } + }, + "404": { + "description": "`REPOSITORY_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "REPOSITORY_NOT_FOUND": { + "summary": "REPOSITORY_NOT_FOUND", + "value": { + "error": { + "code": "REPOSITORY_NOT_FOUND", + "message": "Repository not found" + } + } + } + } + } + } + }, + "409": { + "description": "`QUEUE_ALREADY_EXISTS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "QUEUE_ALREADY_EXISTS": { + "summary": "QUEUE_ALREADY_EXISTS", + "value": { + "error": { + "code": "QUEUE_ALREADY_EXISTS", + "message": "A merge queue already exists for this repository and target branch" + } + } + } + } + } + } + }, + "422": { + "description": "`MERGE_QUEUE_NOT_CREATABLE`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "MERGE_QUEUE_NOT_CREATABLE": { + "summary": "MERGE_QUEUE_NOT_CREATABLE", + "value": { + "error": { + "code": "MERGE_QUEUE_NOT_CREATABLE", + "message": "Branch does not exist in your repo" + } + } + } + } + } + } + }, + "429": { + "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "RATE_LIMIT_EXCEEDED": { + "summary": "RATE_LIMIT_EXCEEDED", + "value": { + "error": { + "code": "RATE_LIMIT_EXCEEDED", + "message": "Rate limit exceeded; retry with backoff" + } + } + } + } + } + } + }, + "500": { + "description": "`INTERNAL_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INTERNAL_ERROR": { + "summary": "INTERNAL_ERROR", + "value": { + "error": { + "code": "INTERNAL_ERROR", + "message": "An unexpected error occurred" + } + } + } + } + } + } + }, + "502": { + "description": "`UPSTREAM_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "UPSTREAM_ERROR": { + "summary": "UPSTREAM_ERROR", + "value": { + "error": { + "code": "UPSTREAM_ERROR", + "message": "An upstream service did not respond" + } + } + } + } + } + } + } + } + } + }, + "/v2/merge-queues/metrics": { + "get": { + "operationId": "mergeQueues.organizationMetrics", + "tags": ["mergeQueues"], + "summary": "Get Prometheus metrics for every merge queue", + "description": "Returns Prometheus metrics for every merge queue in your organization, in the text exposition format, for a Prometheus scrape job. `repositoryId` narrows them to one repository's queues, across all its target branches, and is a 404 when your organization has no such repository. The metrics match v1's `getMergeQueueMetrics`.", + "parameters": [ + { + "schema": { + "type": "string", + "format": "uuid", + "description": "Only this repository's queues.", + "example": "7c9e6679-7425-40de-944b-e07fc1f90ae7" + }, + "required": false, + "description": "Only this repository's queues.", + "name": "repositoryId", + "in": "query" + } + ], + "responses": { + "200": { + "description": "The organization's merge-queue metrics", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/PrometheusExposition" + } + } + } + }, + "400": { + "description": "`VALIDATION_FAILED`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "VALIDATION_FAILED": { + "summary": "VALIDATION_FAILED", + "value": { + "error": { + "code": "VALIDATION_FAILED", + "message": "Invalid input: expected string, received undefined" + } + } + } + } + } + } + }, + "401": { + "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "AUTHENTICATION_REQUIRED": { + "summary": "AUTHENTICATION_REQUIRED", + "value": { + "error": { + "code": "AUTHENTICATION_REQUIRED", + "message": "No credential was supplied" + } + } + }, + "INVALID_TOKEN": { + "summary": "INVALID_TOKEN", + "value": { + "error": { + "code": "INVALID_TOKEN", + "message": "The supplied token failed verification" + } + } + } + } + } + } + }, + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", + "value": { + "error": { + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" + } + } + } + } + } + } + }, + "404": { + "description": "`REPOSITORY_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "REPOSITORY_NOT_FOUND": { + "summary": "REPOSITORY_NOT_FOUND", + "value": { + "error": { + "code": "REPOSITORY_NOT_FOUND", + "message": "Repository not found" + } + } + } + } + } + } + }, + "429": { + "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "RATE_LIMIT_EXCEEDED": { + "summary": "RATE_LIMIT_EXCEEDED", + "value": { + "error": { + "code": "RATE_LIMIT_EXCEEDED", + "message": "Rate limit exceeded; retry with backoff" + } + } + } + } + } + } + }, + "500": { + "description": "`INTERNAL_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INTERNAL_ERROR": { + "summary": "INTERNAL_ERROR", + "value": { + "error": { + "code": "INTERNAL_ERROR", + "message": "An unexpected error occurred" + } + } + } + } + } + } + } + } + } + }, + "/v2/merge-queues/{id}/metrics": { + "get": { + "operationId": "mergeQueues.metrics", + "tags": ["mergeQueues"], + "summary": "Get Prometheus metrics for a merge queue", + "description": "Returns Prometheus metrics for one merge queue, in the text exposition format, for a Prometheus scrape job. The series and labels are those of `GET /v2/merge-queues/metrics`, restricted to this queue.", + "parameters": [ + { + "schema": { + "type": "string", + "description": "The merge queue's id.", + "example": "xK9mP2nQ" + }, + "required": true, + "description": "The merge queue's id.", + "name": "id", + "in": "path" + } + ], + "responses": { + "200": { + "description": "The merge queue's metrics", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/PrometheusExposition" + } + } + } + }, + "401": { + "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "AUTHENTICATION_REQUIRED": { + "summary": "AUTHENTICATION_REQUIRED", + "value": { + "error": { + "code": "AUTHENTICATION_REQUIRED", + "message": "No credential was supplied" + } + } + }, + "INVALID_TOKEN": { + "summary": "INVALID_TOKEN", + "value": { + "error": { + "code": "INVALID_TOKEN", + "message": "The supplied token failed verification" + } + } + } + } + } + } + }, + "404": { + "description": "`MERGE_QUEUE_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "MERGE_QUEUE_NOT_FOUND": { + "summary": "MERGE_QUEUE_NOT_FOUND", + "value": { + "error": { + "code": "MERGE_QUEUE_NOT_FOUND", + "message": "Merge queue not found" + } + } + } + } + } + } + }, + "429": { + "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "RATE_LIMIT_EXCEEDED": { + "summary": "RATE_LIMIT_EXCEEDED", + "value": { + "error": { + "code": "RATE_LIMIT_EXCEEDED", + "message": "Rate limit exceeded; retry with backoff" + } + } + } + } + } + } + }, + "500": { + "description": "`INTERNAL_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INTERNAL_ERROR": { + "summary": "INTERNAL_ERROR", + "value": { + "error": { + "code": "INTERNAL_ERROR", + "message": "An unexpected error occurred" + } + } + } + } + } + } + } + } + } + }, + "/v2/merge-queues/{id}": { + "get": { + "operationId": "mergeQueues.get", + "tags": ["mergeQueues"], + "summary": "Get a merge queue", + "description": "Returns one merge queue, including its full configuration object.", + "parameters": [ + { + "schema": { + "type": "string", + "description": "The merge queue's id.", + "example": "xK9mP2nQ" + }, + "required": true, + "description": "The merge queue's id.", + "name": "id", + "in": "path" + } + ], + "responses": { + "200": { + "description": "The merge queue", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MergeQueue" + } + } + } + }, + "401": { + "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "AUTHENTICATION_REQUIRED": { + "summary": "AUTHENTICATION_REQUIRED", + "value": { + "error": { + "code": "AUTHENTICATION_REQUIRED", + "message": "No credential was supplied" + } + } + }, + "INVALID_TOKEN": { + "summary": "INVALID_TOKEN", + "value": { + "error": { + "code": "INVALID_TOKEN", + "message": "The supplied token failed verification" + } + } + } + } + } + } + }, + "404": { + "description": "`MERGE_QUEUE_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "MERGE_QUEUE_NOT_FOUND": { + "summary": "MERGE_QUEUE_NOT_FOUND", + "value": { + "error": { + "code": "MERGE_QUEUE_NOT_FOUND", + "message": "Merge queue not found" + } + } + } + } + } + } + }, + "429": { + "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "RATE_LIMIT_EXCEEDED": { + "summary": "RATE_LIMIT_EXCEEDED", + "value": { + "error": { + "code": "RATE_LIMIT_EXCEEDED", + "message": "Rate limit exceeded; retry with backoff" + } + } + } + } + } + } + }, + "500": { + "description": "`INTERNAL_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INTERNAL_ERROR": { + "summary": "INTERNAL_ERROR", + "value": { + "error": { + "code": "INTERNAL_ERROR", + "message": "An unexpected error occurred" + } + } + } + } + } + } + } + } + }, + "delete": { + "operationId": "mergeQueues.delete", + "tags": ["mergeQueues"], + "summary": "Delete a merge queue", + "description": "Requires the **Update Merge Queue settings** permission. **Destructive and not reversible.** Deletes a merge queue. The queue must be empty — drain or dequeue its pull requests first, or the call returns `QUEUE_HAS_ACTIVE_ENTRIES`. Historical queue entries and verification runs stay readable by id afterwards.", + "parameters": [ + { + "schema": { + "type": "string", + "description": "The merge queue's id.", + "example": "xK9mP2nQ" + }, + "required": true, + "description": "The merge queue's id.", + "name": "id", + "in": "path" + } + ], + "responses": { + "204": { + "description": "The queue was deleted" + }, + "401": { + "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "AUTHENTICATION_REQUIRED": { + "summary": "AUTHENTICATION_REQUIRED", + "value": { + "error": { + "code": "AUTHENTICATION_REQUIRED", + "message": "No credential was supplied" + } + } + }, + "INVALID_TOKEN": { + "summary": "INVALID_TOKEN", + "value": { + "error": { + "code": "INVALID_TOKEN", + "message": "The supplied token failed verification" + } + } + } + } + } + } + }, + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", + "value": { + "error": { + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" + } + } + } + } + } + } + }, + "404": { + "description": "`MERGE_QUEUE_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "MERGE_QUEUE_NOT_FOUND": { + "summary": "MERGE_QUEUE_NOT_FOUND", + "value": { + "error": { + "code": "MERGE_QUEUE_NOT_FOUND", + "message": "Merge queue not found" + } + } + } + } + } + } + }, + "409": { + "description": "`QUEUE_HAS_ACTIVE_ENTRIES`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "QUEUE_HAS_ACTIVE_ENTRIES": { + "summary": "QUEUE_HAS_ACTIVE_ENTRIES", + "value": { + "error": { + "code": "QUEUE_HAS_ACTIVE_ENTRIES", + "message": "This merge queue still has active pull requests; drain or dequeue them first" + } + } + } + } + } + } + }, + "429": { + "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "RATE_LIMIT_EXCEEDED": { + "summary": "RATE_LIMIT_EXCEEDED", + "value": { + "error": { + "code": "RATE_LIMIT_EXCEEDED", + "message": "Rate limit exceeded; retry with backoff" + } + } + } + } + } + } + }, + "500": { + "description": "`INTERNAL_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INTERNAL_ERROR": { + "summary": "INTERNAL_ERROR", + "value": { + "error": { + "code": "INTERNAL_ERROR", + "message": "An unexpected error occurred" + } + } + } + } + } + } + }, + "502": { + "description": "`UPSTREAM_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "UPSTREAM_ERROR": { + "summary": "UPSTREAM_ERROR", + "value": { + "error": { + "code": "UPSTREAM_ERROR", + "message": "An upstream service did not respond" + } + } + } + } + } + } + } + } + } + }, + "/v2/merge-queues/{id}/order": { + "get": { + "operationId": "mergeQueues.order", + "tags": ["mergeQueues"], + "summary": "Get a merge queue's dispatch order", + "description": "Returns the queue's batches with a verification run, what is admitted and waiting in the order the engine will consider it, and what has not been admitted yet.\n\n**A batch in `batches` is not necessarily still testing** — one that has passed, is merging, or is holding others back after a failure still has a run and is still listed. Read its `state`.\n\n**The order is one of consideration, not of execution, and array position is not a wait estimate.** `predictedBatch` repeats across every pull request predicted to start testing together, and in `graph` mode several predicted batches commonly start at once — so the pull requests ahead of yours may all start with it, and may sit on unrelated branches that never block yours. `directlyAhead` is what actually precedes a pull request; use it rather than counting.\n\nIt is a point-in-time prediction, up to a few seconds old. A new submission, a priority change or a failure regroups it, and four things outside this response still gate dispatch: `queueState: paused` stops it entirely, the queue's testing-concurrency cap bounds how many start, a batch whose predecessors have no usable test branch is skipped over rather than blocking, and bisections dispatch on their own budget.\n\nPull requests that are not ready are deliberately absent — they are not admitted, so they hold no position. Read one through `GET /v2/pull-requests/{id}`.\n\nUnpaginated: the engine caps its own graph, so the admitted set is bounded. `awaitingAdmission` is not, and is truncated.", + "parameters": [ + { + "schema": { + "type": "string", + "description": "The merge queue's id.", + "example": "xK9mP2nQ" + }, + "required": true, + "description": "The merge queue's id.", + "name": "id", + "in": "path" + } + ], + "responses": { + "200": { + "description": "The queue's dispatch order", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MergeQueueOrder" + } + } + } + }, + "401": { + "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "AUTHENTICATION_REQUIRED": { + "summary": "AUTHENTICATION_REQUIRED", + "value": { + "error": { + "code": "AUTHENTICATION_REQUIRED", + "message": "No credential was supplied" + } + } + }, + "INVALID_TOKEN": { + "summary": "INVALID_TOKEN", + "value": { + "error": { + "code": "INVALID_TOKEN", + "message": "The supplied token failed verification" + } + } + } + } + } + } + }, + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", + "value": { + "error": { + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" + } + } + } + } + } + } + }, + "404": { + "description": "`MERGE_QUEUE_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "MERGE_QUEUE_NOT_FOUND": { + "summary": "MERGE_QUEUE_NOT_FOUND", + "value": { + "error": { + "code": "MERGE_QUEUE_NOT_FOUND", + "message": "Merge queue not found" + } + } + } + } + } + } + }, + "429": { + "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "RATE_LIMIT_EXCEEDED": { + "summary": "RATE_LIMIT_EXCEEDED", + "value": { + "error": { + "code": "RATE_LIMIT_EXCEEDED", + "message": "Rate limit exceeded; retry with backoff" + } + } + } + } + } + } + }, + "500": { + "description": "`INTERNAL_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INTERNAL_ERROR": { + "summary": "INTERNAL_ERROR", + "value": { + "error": { + "code": "INTERNAL_ERROR", + "message": "An unexpected error occurred" + } + } + } + } + } + } + }, + "502": { + "description": "`UPSTREAM_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "UPSTREAM_ERROR": { + "summary": "UPSTREAM_ERROR", + "value": { + "error": { + "code": "UPSTREAM_ERROR", + "message": "An upstream service did not respond" + } + } + } + } + } + } + } + } + } + }, + "/v2/merge-queues/{id}/graph": { + "get": { + "operationId": "mergeQueues.graph", + "tags": ["mergeQueues"], + "summary": "Get a merge queue's dependency graph", + "description": "Returns the queue's dependency graph: which pull requests the engine considers related, and why.\n\n**This does not tell you what runs next.** The engine schedules on a priority that cascades backwards through the graph and on a pending-failure gate, and neither is in this payload — `priorityValue` here is each pull request's own value, not the cascaded one. For dispatch order use `GET /v2/merge-queues/{id}/order`.\n\nEdges are transitively reduced, so an indirect dependency appears through the node between its endpoints rather than as its own edge. They mean overlapping impacted targets, not a stacked-branch relationship.\n\nOnly pull requests the engine has admitted to its graph appear: anything past the graph's soft cap, or not yet ready, is absent. `includeImpactedTargets` adds the target lists that explain each node and edge; it is off by default because populating it costs a lookup per distinct commit.", + "parameters": [ + { + "schema": { + "type": "string", + "description": "The merge queue's id.", + "example": "xK9mP2nQ" + }, + "required": true, + "description": "The merge queue's id.", + "name": "id", + "in": "path" + }, + { + "schema": { + "type": "boolean", + "default": false, + "description": "Include the impacted-target lists on nodes and edges. Off by default: resolving them costs one lookup per distinct commit in the graph.", + "example": false + }, + "required": false, + "description": "Include the impacted-target lists on nodes and edges. Off by default: resolving them costs one lookup per distinct commit in the graph.", + "name": "includeImpactedTargets", + "in": "query" + } + ], + "responses": { + "200": { + "description": "The queue's dependency graph", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MergeGraph" + } + } + } + }, + "400": { + "description": "`VALIDATION_FAILED`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "VALIDATION_FAILED": { + "summary": "VALIDATION_FAILED", + "value": { + "error": { + "code": "VALIDATION_FAILED", + "message": "Invalid input: expected string, received undefined" + } + } + } + } + } + } + }, + "401": { + "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "AUTHENTICATION_REQUIRED": { + "summary": "AUTHENTICATION_REQUIRED", + "value": { + "error": { + "code": "AUTHENTICATION_REQUIRED", + "message": "No credential was supplied" + } + } + }, + "INVALID_TOKEN": { + "summary": "INVALID_TOKEN", + "value": { + "error": { + "code": "INVALID_TOKEN", + "message": "The supplied token failed verification" + } + } + } + } + } + } + }, + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", + "value": { + "error": { + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" + } + } + } + } + } + } + }, + "404": { + "description": "`MERGE_QUEUE_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "MERGE_QUEUE_NOT_FOUND": { + "summary": "MERGE_QUEUE_NOT_FOUND", + "value": { + "error": { + "code": "MERGE_QUEUE_NOT_FOUND", + "message": "Merge queue not found" + } + } + } + } + } + } + }, + "429": { + "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "RATE_LIMIT_EXCEEDED": { + "summary": "RATE_LIMIT_EXCEEDED", + "value": { + "error": { + "code": "RATE_LIMIT_EXCEEDED", + "message": "Rate limit exceeded; retry with backoff" + } + } + } + } + } + } + }, + "500": { + "description": "`INTERNAL_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INTERNAL_ERROR": { + "summary": "INTERNAL_ERROR", + "value": { + "error": { + "code": "INTERNAL_ERROR", + "message": "An unexpected error occurred" + } + } + } + } + } + } + }, + "502": { + "description": "`UPSTREAM_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "UPSTREAM_ERROR": { + "summary": "UPSTREAM_ERROR", + "value": { + "error": { + "code": "UPSTREAM_ERROR", + "message": "An upstream service did not respond" + } + } + } + } + } + } + } + } + } + }, + "/v2/merge-queues/{id}/testing-results": { + "get": { + "operationId": "mergeQueues.listTestingResults", + "tags": ["mergeQueues"], + "summary": "List a merge queue's completed testing", + "description": "Lists the stretches of testing the queue finished between `since` and `until`, newest first. One entry per pull request per attempt: a pull request appears several times if its testing restarted, and a batched run appears once per pull request it tested. Testing still in progress is not included. Pass an entry's `verificationRunId` to `GET /v2/merge-queue-verification-runs/{id}` for the run's checks and tested pull requests.\n\nThe range may span at most 45 days, which is also how long results are kept. When `until` is omitted it is fixed at the time of the first page, so later pages are not shifted by testing that finishes while you page.", + "parameters": [ + { + "schema": { + "type": "string", + "description": "The merge queue's id.", + "example": "xK9mP2nQ" + }, + "required": true, + "description": "The merge queue's id.", + "name": "id", + "in": "path" + }, + { + "schema": { + "type": "integer", + "minimum": 1, + "maximum": 100, + "default": 25, + "description": "Page size, between 1 and 100.", + "example": 25 + }, + "required": false, + "description": "Page size, between 1 and 100.", + "name": "limit", + "in": "query" + }, + { + "schema": { + "type": "string", + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "example": "AQEKZm9vYmFy" + }, + "required": false, + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "name": "cursor", + "in": "query" + }, + { + "schema": { + "type": "boolean", + "default": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "example": false + }, + "required": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "name": "includeTotal", + "in": "query" + }, + { + "schema": { + "type": "string", + "format": "date-time", + "description": "Only testing that ended at or after this instant (ISO-8601). At most 45 days before `until`.", + "example": "2026-09-01T00:00:00Z" + }, + "required": true, + "description": "Only testing that ended at or after this instant (ISO-8601). At most 45 days before `until`.", + "name": "since", + "in": "query" + }, + { + "schema": { + "type": "string", + "format": "date-time", + "description": "Only testing that ended at or before this instant (ISO-8601). Defaults to the time of the first page.", + "example": "2026-09-08T00:00:00Z" + }, + "required": false, + "description": "Only testing that ended at or before this instant (ISO-8601). Defaults to the time of the first page.", + "name": "until", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A page of testing results", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TestingResultList" + } + } + } + }, + "400": { + "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "VALIDATION_FAILED": { + "summary": "VALIDATION_FAILED", + "value": { + "error": { + "code": "VALIDATION_FAILED", + "message": "Invalid input: expected string, received undefined" + } + } + }, + "INVALID_CURSOR": { + "summary": "INVALID_CURSOR", + "value": { + "error": { + "code": "INVALID_CURSOR", + "message": "Invalid or expired cursor." + } + } + } + } + } + } + }, + "401": { + "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "AUTHENTICATION_REQUIRED": { + "summary": "AUTHENTICATION_REQUIRED", + "value": { + "error": { + "code": "AUTHENTICATION_REQUIRED", + "message": "No credential was supplied" + } + } + }, + "INVALID_TOKEN": { + "summary": "INVALID_TOKEN", + "value": { + "error": { + "code": "INVALID_TOKEN", + "message": "The supplied token failed verification" + } + } + } + } + } + } + }, + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", + "value": { + "error": { + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" + } + } + } + } + } + } + }, + "404": { + "description": "`MERGE_QUEUE_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "MERGE_QUEUE_NOT_FOUND": { + "summary": "MERGE_QUEUE_NOT_FOUND", + "value": { + "error": { + "code": "MERGE_QUEUE_NOT_FOUND", + "message": "Merge queue not found" + } + } + } + } + } + } + }, + "429": { + "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "RATE_LIMIT_EXCEEDED": { + "summary": "RATE_LIMIT_EXCEEDED", + "value": { + "error": { + "code": "RATE_LIMIT_EXCEEDED", + "message": "Rate limit exceeded; retry with backoff" + } + } + } + } + } + } + }, + "500": { + "description": "`INTERNAL_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INTERNAL_ERROR": { + "summary": "INTERNAL_ERROR", + "value": { + "error": { + "code": "INTERNAL_ERROR", + "message": "An unexpected error occurred" + } + } + } + } + } + } + }, + "502": { + "description": "`UPSTREAM_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "UPSTREAM_ERROR": { + "summary": "UPSTREAM_ERROR", + "value": { + "error": { + "code": "UPSTREAM_ERROR", + "message": "An upstream service did not respond" + } + } + } + } + } + } + } + } + } + }, + "/v2/merge-queues/{id}/pull-requests": { + "post": { + "operationId": "mergeQueues.submitPullRequest", + "tags": ["mergeQueues"], + "summary": "Submit a pull request to a merge queue", + "description": "Requires the **Merge and cancel PRs** permission, plus **Set priority on PRs** to send `priorityValue` or `priorityName`, **Skip batching** to send `allowBatching: false`, and **Merge PRs with direct to queue** to send `direct: true`. Choosing a `mergeMethod` needs no extra permission. Lower `priorityValue` numbers go first, from 0 to 255. The named priorities are `urgent` (0), `high` (10), `medium` (100, the default), and `low` (200). An `urgent` entry, or `priorityValue: 0`, restarts lower-priority entries that are already testing when it enters the queue (once it is ready), along with the entries tested on top of them.\n\nEnqueues a pull request. A pull request already enqueued in this queue is refused with `PR_ALREADY_ENQUEUED` rather than having its priority rewritten — change a live entry through `POST /v2/pull-requests/{id}/reprioritize` or `PATCH /v2/pull-requests/{id}/queue-entry`. `readiness.hasImpactedTargets` may be absent on the 201 if the post-write lookup failed; the enqueue still landed, so read the pull request again rather than retrying.\n\n`Idempotency-Key` is not honored. If a request times out, resolve the pull request by repository and number and inspect its queue entry before retrying.", + "parameters": [ + { + "schema": { + "type": "string", + "description": "The merge queue's id.", + "example": "xK9mP2nQ" + }, + "required": true, + "description": "The merge queue's id.", + "name": "id", + "in": "path" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SubmitPullRequestRequest" + } + } + } + }, + "responses": { + "201": { + "description": "The enqueued pull request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PullRequest" + } + } + } + }, + "400": { + "description": "`VALIDATION_FAILED`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "VALIDATION_FAILED": { + "summary": "VALIDATION_FAILED", + "value": { + "error": { + "code": "VALIDATION_FAILED", + "message": "Invalid input: expected string, received undefined" + } + } + } + } + } + } + }, + "401": { + "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "AUTHENTICATION_REQUIRED": { + "summary": "AUTHENTICATION_REQUIRED", + "value": { + "error": { + "code": "AUTHENTICATION_REQUIRED", + "message": "No credential was supplied" + } + } + }, + "INVALID_TOKEN": { + "summary": "INVALID_TOKEN", + "value": { + "error": { + "code": "INVALID_TOKEN", + "message": "The supplied token failed verification" + } + } + } + } + } + } + }, + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", + "value": { + "error": { + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" + } + } + } + } + } + } + }, + "404": { + "description": "`MERGE_QUEUE_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "MERGE_QUEUE_NOT_FOUND": { + "summary": "MERGE_QUEUE_NOT_FOUND", + "value": { + "error": { + "code": "MERGE_QUEUE_NOT_FOUND", + "message": "Merge queue not found" + } + } + } + } + } + } + }, + "409": { + "description": "`PR_ALREADY_ENQUEUED`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "PR_ALREADY_ENQUEUED": { + "summary": "PR_ALREADY_ENQUEUED", + "value": { + "error": { + "code": "PR_ALREADY_ENQUEUED", + "message": "This pull request is already enqueued in this merge queue" + } + } + } + } + } + } + }, + "422": { + "description": "`PR_NOT_ENQUEUEABLE`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "PR_NOT_ENQUEUEABLE": { + "summary": "PR_NOT_ENQUEUEABLE", + "value": { + "error": { + "code": "PR_NOT_ENQUEUEABLE", + "message": "This pull request cannot be enqueued" + } + } + } + } + } + } + }, + "429": { + "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "RATE_LIMIT_EXCEEDED": { + "summary": "RATE_LIMIT_EXCEEDED", + "value": { + "error": { + "code": "RATE_LIMIT_EXCEEDED", + "message": "Rate limit exceeded; retry with backoff" + } + } + } + } + } + } + }, + "500": { + "description": "`INTERNAL_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INTERNAL_ERROR": { + "summary": "INTERNAL_ERROR", + "value": { + "error": { + "code": "INTERNAL_ERROR", + "message": "An unexpected error occurred" + } + } + } + } + } + } + }, + "502": { + "description": "`UPSTREAM_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "UPSTREAM_ERROR": { + "summary": "UPSTREAM_ERROR", + "value": { + "error": { + "code": "UPSTREAM_ERROR", + "message": "An upstream service did not respond" + } + } + } + } } - ] + } } - }, - "required": ["include", "exclude"], - "additionalProperties": false - } - }, - "parameters": {} - }, - "paths": { - "/v2/merge-queues": { + } + }, "get": { - "operationId": "mergeQueues.list", + "operationId": "mergeQueues.listPullRequests", "tags": ["mergeQueues"], - "summary": "List merge queues", - "description": "Lists the merge queues in your organization. `targetBranch` narrows within a single repository rather than searching branch names globally, so it must be sent together with `repositoryId`.", + "summary": "List a merge queue's pull requests", + "description": "Lists the pull requests in a queue, **most recently enqueued first**.\n\n**This is not queue order** — do not infer position from this list's index. For the order the engine will consider, use `GET /v2/merge-queues/{id}/order`. `state` accepts a comma-separated list of queue-entry states. `readiness.hasImpactedTargets` is omitted on this list read, because resolving it costs a storage lookup per entry; read a single pull request to get it. `sort` and `direction` are not configurable yet: each accepts only the value this list already uses (`createdAt`, `desc`) and rejects anything else with `400`. Neither is ignored, so a client cannot silently receive an ordering it did not ask for.\n\n`concludedAfter` and `concludedBefore` keep pull requests that reached `merged`, `failed` or `cancelled` inside that window, both bounds inclusive — v1's `since`/`until`. That is a fact about the entry's history, not its current state: an entry that failed in the window and was later resubmitted still matches, so pair them with `state` to filter on where it is now.", "parameters": [ + { + "schema": { + "type": "string", + "description": "The merge queue's id.", + "example": "xK9mP2nQ" + }, + "required": true, + "description": "The merge queue's id.", + "name": "id", + "in": "path" + }, { "schema": { "type": "integer", @@ -6749,41 +10585,231 @@ { "schema": { "type": "string", - "format": "uuid", - "description": "Only queues belonging to this repository.", - "example": "7c9e6679-7425-40de-944b-e07fc1f90ae7" + "minLength": 1, + "description": "Comma-separated queue-entry states, e.g. `testing,pending`.", + "example": "testing,pending" }, "required": false, - "description": "Only queues belonging to this repository.", - "name": "repositoryId", + "description": "Comma-separated queue-entry states, e.g. `testing,pending`.", + "name": "state", "in": "query" }, { "schema": { "type": "string", "minLength": 1, - "description": "Only the queue for this target branch. Requires `repositoryId`.", - "example": "main" + "description": "Only pull requests opened by this author.", + "example": "octocat" }, "required": false, - "description": "Only the queue for this target branch. Requires `repositoryId`.", - "name": "targetBranch", + "description": "Only pull requests opened by this author.", + "name": "author", + "in": "query" + }, + { + "schema": { + "type": "string", + "format": "date-time", + "description": "Only entries that concluded at or after this instant (ISO-8601).", + "example": "2026-09-01T00:00:00Z" + }, + "required": false, + "description": "Only entries that concluded at or after this instant (ISO-8601).", + "name": "concludedAfter", + "in": "query" + }, + { + "schema": { + "type": "string", + "format": "date-time", + "description": "Only entries that concluded at or before this instant (ISO-8601).", + "example": "2026-09-08T00:00:00Z" + }, + "required": false, + "description": "Only entries that concluded at or before this instant (ISO-8601).", + "name": "concludedBefore", "in": "query" } ], "responses": { "200": { - "description": "A page of merge queues", + "description": "A page of pull requests", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PullRequestList" + } + } + } + }, + "400": { + "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "VALIDATION_FAILED": { + "summary": "VALIDATION_FAILED", + "value": { + "error": { + "code": "VALIDATION_FAILED", + "message": "Invalid input: expected string, received undefined" + } + } + }, + "INVALID_CURSOR": { + "summary": "INVALID_CURSOR", + "value": { + "error": { + "code": "INVALID_CURSOR", + "message": "Invalid or expired cursor." + } + } + } + } + } + } + }, + "401": { + "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "AUTHENTICATION_REQUIRED": { + "summary": "AUTHENTICATION_REQUIRED", + "value": { + "error": { + "code": "AUTHENTICATION_REQUIRED", + "message": "No credential was supplied" + } + } + }, + "INVALID_TOKEN": { + "summary": "INVALID_TOKEN", + "value": { + "error": { + "code": "INVALID_TOKEN", + "message": "The supplied token failed verification" + } + } + } + } + } + } + }, + "404": { + "description": "`MERGE_QUEUE_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "MERGE_QUEUE_NOT_FOUND": { + "summary": "MERGE_QUEUE_NOT_FOUND", + "value": { + "error": { + "code": "MERGE_QUEUE_NOT_FOUND", + "message": "Merge queue not found" + } + } + } + } + } + } + }, + "429": { + "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "RATE_LIMIT_EXCEEDED": { + "summary": "RATE_LIMIT_EXCEEDED", + "value": { + "error": { + "code": "RATE_LIMIT_EXCEEDED", + "message": "Rate limit exceeded; retry with backoff" + } + } + } + } + } + } + }, + "500": { + "description": "`INTERNAL_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INTERNAL_ERROR": { + "summary": "INTERNAL_ERROR", + "value": { + "error": { + "code": "INTERNAL_ERROR", + "message": "An unexpected error occurred" + } + } + } + } + } + } + } + } + } + }, + "/v2/merge-queues/{id}/switch-modes": { + "post": { + "operationId": "mergeQueues.switchModes", + "tags": ["mergeQueues"], + "summary": "Switch a merge queue's mode", + "description": "Requires the **Update Merge Queue settings** permission. Starts a conversion between `queue` and `graph` mode. Switching to the mode the queue is already in is an idempotent no-op. A queue already mid-conversion is refused with `MODE_CHANGE_IN_PROGRESS`. The response carries the state the merge engine reported after the write, so a started conversion reports `switchingModes`.", + "parameters": [ + { + "schema": { + "type": "string", + "description": "The merge queue's id.", + "example": "xK9mP2nQ" + }, + "required": true, + "description": "The merge queue's id.", + "name": "id", + "in": "path" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SwitchModesRequest" + } + } + } + }, + "responses": { + "200": { + "description": "The queue's post-write state", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/MergeQueueList" + "$ref": "#/components/schemas/MergeQueueStateChange" } } } }, "400": { - "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", + "description": "`VALIDATION_FAILED`", "content": { "application/json": { "schema": { @@ -6798,15 +10824,6 @@ "message": "Invalid input: expected string, received undefined" } } - }, - "INVALID_CURSOR": { - "summary": "INVALID_CURSOR", - "value": { - "error": { - "code": "INVALID_CURSOR", - "message": "Invalid or expired cursor." - } - } } } } @@ -6863,6 +10880,48 @@ } } }, + "404": { + "description": "`MERGE_QUEUE_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "MERGE_QUEUE_NOT_FOUND": { + "summary": "MERGE_QUEUE_NOT_FOUND", + "value": { + "error": { + "code": "MERGE_QUEUE_NOT_FOUND", + "message": "Merge queue not found" + } + } + } + } + } + } + }, + "409": { + "description": "`MODE_CHANGE_IN_PROGRESS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "MODE_CHANGE_IN_PROGRESS": { + "summary": "MODE_CHANGE_IN_PROGRESS", + "value": { + "error": { + "code": "MODE_CHANGE_IN_PROGRESS", + "message": "This merge queue is switching modes; retry once the transition completes" + } + } + } + } + } + } + }, "429": { "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", "content": { @@ -6904,31 +10963,57 @@ } } } + }, + "502": { + "description": "`UPSTREAM_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "UPSTREAM_ERROR": { + "summary": "UPSTREAM_ERROR", + "value": { + "error": { + "code": "UPSTREAM_ERROR", + "message": "An upstream service did not respond" + } + } + } + } + } + } } } - }, + } + }, + "/v2/merge-queues/{id}/pause": { "post": { - "operationId": "mergeQueues.create", + "operationId": "mergeQueues.pause", "tags": ["mergeQueues"], - "summary": "Create a merge queue", - "description": "Requires the **Update Merge Queue settings** permission. Creates a merge queue for a repository and target branch. At most one queue exists per pair, so a second create returns `QUEUE_ALREADY_EXISTS`.\n\n**This operation is not atomic.** `bisectionConcurrency` and `enqueueingLabel` are applied by a second write, so **an error response does not guarantee that no queue was created** — if the first write succeeded and the second failed, the queue exists with those two fields at their defaults and this call still returns the second write's error. Do not blindly retry: a retry returns `409 QUEUE_ALREADY_EXISTS`. Instead read the queue back (`GET /v2/merge-queues?repositoryId=…&targetBranch=…`) and, if it exists, finish the configuration with `PATCH /v2/merge-queues/{id}/config`.", - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateMergeQueueRequest" - } - } + "summary": "Pause a merge queue", + "description": "Requires the **Update Merge Queue settings** permission. **Disruptive — affects every entry in the queue.** Stops the queue testing or merging anything further; entries already in it stay enqueued and resume when the queue is resumed. `Idempotency-Key` is not honored; if the outcome is unknown, read the queue's state before retrying. The request body is ignored.", + "parameters": [ + { + "schema": { + "type": "string", + "description": "The merge queue's id.", + "example": "xK9mP2nQ" + }, + "required": true, + "description": "The merge queue's id.", + "name": "id", + "in": "path" } - }, + ], "responses": { - "201": { - "description": "The created merge queue", + "200": { + "description": "The queue's post-write state", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/MergeQueue" + "$ref": "#/components/schemas/MergeQueueStateChange" } } } @@ -7006,61 +11091,19 @@ } }, "404": { - "description": "`REPOSITORY_NOT_FOUND`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "REPOSITORY_NOT_FOUND": { - "summary": "REPOSITORY_NOT_FOUND", - "value": { - "error": { - "code": "REPOSITORY_NOT_FOUND", - "message": "Repository not found" - } - } - } - } - } - } - }, - "409": { - "description": "`QUEUE_ALREADY_EXISTS`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "QUEUE_ALREADY_EXISTS": { - "summary": "QUEUE_ALREADY_EXISTS", - "value": { - "error": { - "code": "QUEUE_ALREADY_EXISTS", - "message": "A merge queue already exists for this repository and target branch" - } - } - } - } - } - } - }, - "422": { - "description": "`MERGE_QUEUE_NOT_CREATABLE`", + "description": "`MERGE_QUEUE_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "MERGE_QUEUE_NOT_CREATABLE": { - "summary": "MERGE_QUEUE_NOT_CREATABLE", + "MERGE_QUEUE_NOT_FOUND": { + "summary": "MERGE_QUEUE_NOT_FOUND", "value": { "error": { - "code": "MERGE_QUEUE_NOT_CREATABLE", - "message": "Branch does not exist in your repo" + "code": "MERGE_QUEUE_NOT_FOUND", + "message": "Merge queue not found" } } } @@ -7134,33 +11177,32 @@ } } }, - "/v2/merge-queues/metrics": { - "get": { - "operationId": "mergeQueues.organizationMetrics", + "/v2/merge-queues/{id}/resume": { + "post": { + "operationId": "mergeQueues.resume", "tags": ["mergeQueues"], - "summary": "Get Prometheus metrics for every merge queue", - "description": "Returns Prometheus metrics for every merge queue in your organization, in the text exposition format, for a Prometheus scrape job. `repositoryId` narrows them to one repository's queues, across all its target branches, and is a 404 when your organization has no such repository. The metrics match v1's `getMergeQueueMetrics`.", + "summary": "Resume a merge queue", + "description": "Requires the **Update Merge Queue settings** permission. Returns a paused or draining queue to `running`. `Idempotency-Key` is not honored; if the outcome is unknown, read the queue's state before retrying. The request body is ignored.", "parameters": [ { "schema": { "type": "string", - "format": "uuid", - "description": "Only this repository's queues.", - "example": "7c9e6679-7425-40de-944b-e07fc1f90ae7" + "description": "The merge queue's id.", + "example": "xK9mP2nQ" }, - "required": false, - "description": "Only this repository's queues.", - "name": "repositoryId", - "in": "query" + "required": true, + "description": "The merge queue's id.", + "name": "id", + "in": "path" } ], "responses": { "200": { - "description": "The organization's merge-queue metrics", + "description": "The queue's post-write state", "content": { - "text/plain": { + "application/json": { "schema": { - "$ref": "#/components/schemas/PrometheusExposition" + "$ref": "#/components/schemas/MergeQueueStateChange" } } } @@ -7238,19 +11280,19 @@ } }, "404": { - "description": "`REPOSITORY_NOT_FOUND`", + "description": "`MERGE_QUEUE_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "REPOSITORY_NOT_FOUND": { - "summary": "REPOSITORY_NOT_FOUND", + "MERGE_QUEUE_NOT_FOUND": { + "summary": "MERGE_QUEUE_NOT_FOUND", "value": { "error": { - "code": "REPOSITORY_NOT_FOUND", - "message": "Repository not found" + "code": "MERGE_QUEUE_NOT_FOUND", + "message": "Merge queue not found" } } } @@ -7299,16 +11341,37 @@ } } } + }, + "502": { + "description": "`UPSTREAM_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "UPSTREAM_ERROR": { + "summary": "UPSTREAM_ERROR", + "value": { + "error": { + "code": "UPSTREAM_ERROR", + "message": "An upstream service did not respond" + } + } + } + } + } + } } } } }, - "/v2/merge-queues/{id}/metrics": { - "get": { - "operationId": "mergeQueues.metrics", + "/v2/merge-queues/{id}/drain": { + "post": { + "operationId": "mergeQueues.drain", "tags": ["mergeQueues"], - "summary": "Get Prometheus metrics for a merge queue", - "description": "Returns Prometheus metrics for one merge queue, in the text exposition format, for a Prometheus scrape job. The series and labels are those of `GET /v2/merge-queues/metrics`, restricted to this queue.", + "summary": "Drain a merge queue", + "description": "Requires the **Update Merge Queue settings** permission. **Disruptive — affects every entry in the queue.** Finishes the entries already in the queue but accepts no new submissions. `Idempotency-Key` is not honored; if the outcome is unknown, read the queue's state before retrying. The request body is ignored.", "parameters": [ { "schema": { @@ -7324,11 +11387,32 @@ ], "responses": { "200": { - "description": "The merge queue's metrics", + "description": "The queue's post-write state", "content": { - "text/plain": { + "application/json": { "schema": { - "$ref": "#/components/schemas/PrometheusExposition" + "$ref": "#/components/schemas/MergeQueueStateChange" + } + } + } + }, + "400": { + "description": "`VALIDATION_FAILED`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "VALIDATION_FAILED": { + "summary": "VALIDATION_FAILED", + "value": { + "error": { + "code": "VALIDATION_FAILED", + "message": "Invalid input: expected string, received undefined" + } + } + } } } } @@ -7363,6 +11447,27 @@ } } }, + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", + "value": { + "error": { + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" + } + } + } + } + } + } + }, "404": { "description": "`MERGE_QUEUE_NOT_FOUND`", "content": { @@ -7425,16 +11530,37 @@ } } } + }, + "502": { + "description": "`UPSTREAM_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "UPSTREAM_ERROR": { + "summary": "UPSTREAM_ERROR", + "value": { + "error": { + "code": "UPSTREAM_ERROR", + "message": "An upstream service did not respond" + } + } + } + } + } + } } } } }, - "/v2/merge-queues/{id}": { - "get": { - "operationId": "mergeQueues.get", + "/v2/merge-queues/{id}/config": { + "patch": { + "operationId": "mergeQueues.updateConfig", "tags": ["mergeQueues"], - "summary": "Get a merge queue", - "description": "Returns one merge queue, including its full configuration object.", + "summary": "Update a merge queue's configuration", + "description": "Requires the **Update Merge Queue settings** permission. Applies a JSON Merge Patch to the queue's configuration: an absent key leaves that setting unchanged, and an unknown key is rejected rather than silently dropped. Send `requiredStatuses: []` or `batchingRules: []` to clear those lists.\n\n**`requiredStatuses` is a merge-protection control, not a tuning knob**: it decides what must pass before an entry may merge (clearing it falls back to `.trunk/trunk.yaml` and the branch's protection rules). Treat access to this endpoint as security-relevant. Refused with `MODE_CHANGE_IN_PROGRESS` while the queue is converting between modes, and with `ALLOWED_BOT_SUBMITTERS_FROZEN` for a body carrying the removed `allowedBotSubmitters`: bots are approved on the Bots page of the organization's settings.", "parameters": [ { "schema": { @@ -7448,9 +11574,19 @@ "in": "path" } ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateMergeQueueConfigRequest" + } + } + } + }, "responses": { "200": { - "description": "The merge queue", + "description": "The updated merge queue", "content": { "application/json": { "schema": { @@ -7459,6 +11595,27 @@ } } }, + "400": { + "description": "`VALIDATION_FAILED`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "VALIDATION_FAILED": { + "summary": "VALIDATION_FAILED", + "value": { + "error": { + "code": "VALIDATION_FAILED", + "message": "Invalid input: expected string, received undefined" + } + } + } + } + } + } + }, "401": { "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", "content": { @@ -7489,6 +11646,27 @@ } } }, + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", + "value": { + "error": { + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" + } + } + } + } + } + } + }, "404": { "description": "`MERGE_QUEUE_NOT_FOUND`", "content": { @@ -7510,6 +11688,48 @@ } } }, + "409": { + "description": "`MODE_CHANGE_IN_PROGRESS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "MODE_CHANGE_IN_PROGRESS": { + "summary": "MODE_CHANGE_IN_PROGRESS", + "value": { + "error": { + "code": "MODE_CHANGE_IN_PROGRESS", + "message": "This merge queue is switching modes; retry once the transition completes" + } + } + } + } + } + } + }, + "422": { + "description": "`ALLOWED_BOT_SUBMITTERS_FROZEN`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "ALLOWED_BOT_SUBMITTERS_FROZEN": { + "summary": "ALLOWED_BOT_SUBMITTERS_FROZEN", + "value": { + "error": { + "code": "ALLOWED_BOT_SUBMITTERS_FROZEN", + "message": "allowedBotSubmitters has been removed. Bots are approved on the Bots page of the organization's settings instead." + } + } + } + } + } + } + }, "429": { "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", "content": { @@ -7551,30 +11771,71 @@ } } } + }, + "502": { + "description": "`UPSTREAM_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "UPSTREAM_ERROR": { + "summary": "UPSTREAM_ERROR", + "value": { + "error": { + "code": "UPSTREAM_ERROR", + "message": "An upstream service did not respond" + } + } + } + } + } + } } } - }, - "delete": { - "operationId": "mergeQueues.delete", - "tags": ["mergeQueues"], - "summary": "Delete a merge queue", - "description": "Requires the **Update Merge Queue settings** permission. **Destructive and not reversible.** Deletes a merge queue. The queue must be empty — drain or dequeue its pull requests first, or the call returns `QUEUE_HAS_ACTIVE_ENTRIES`. Historical queue entries and verification runs stay readable by id afterwards.", - "parameters": [ - { - "schema": { - "type": "string", - "description": "The merge queue's id.", - "example": "xK9mP2nQ" - }, - "required": true, - "description": "The merge queue's id.", - "name": "id", - "in": "path" + } + }, + "/v2/impacted-targets": { + "put": { + "operationId": "impactedTargets.upload", + "tags": ["impactedTargets"], + "summary": "Upload a pull request's impacted targets", + "description": "Requires the **Merge and cancel PRs** permission, or a GitHub Actions login for the run's own repository. Records which build targets a pull request's head sha impacts, for queues that gate on impacted targets. Address the pull request by exactly one of `number` or `branch`, and declare impact with exactly one of `impactedTargets` or `impactsAllTargets: true`. An empty `impactedTargets` array is a valid upload meaning the sha impacts nothing — it satisfies the queue's has-impacted-targets gate, because that gate asks whether CI reported, not whether it reported a non-zero result. Supported only for GitHub and GitLab repositories; anything else returns `IMPACTED_TARGETS_UNSUPPORTED`. Answers 202: the targets are stored, but readiness is re-evaluated asynchronously, so a 202 does not mean readiness has changed yet.\n\nA token from a GitHub Actions run may upload only for its own repository. One from a fork pull request's run is bound to that pull request and its head sha: address the pull request by `number`, and send that sha, or the upload is refused with `INSUFFICIENT_PERMISSIONS`. It is also refused unless the repository has a merge queue whose GitHub settings allow impacted targets from fork pull requests.", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UploadImpactedTargetsRequest" + } + } } - ], + }, "responses": { - "204": { - "description": "The queue was deleted" + "202": { + "description": "The targets were accepted" + }, + "400": { + "description": "`VALIDATION_FAILED`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "VALIDATION_FAILED": { + "summary": "VALIDATION_FAILED", + "value": { + "error": { + "code": "VALIDATION_FAILED", + "message": "Invalid input: expected string, received undefined" + } + } + } + } + } + } }, "401": { "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", @@ -7628,19 +11889,28 @@ } }, "404": { - "description": "`MERGE_QUEUE_NOT_FOUND`", + "description": "`REPOSITORY_NOT_FOUND` | `PR_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "MERGE_QUEUE_NOT_FOUND": { - "summary": "MERGE_QUEUE_NOT_FOUND", + "REPOSITORY_NOT_FOUND": { + "summary": "REPOSITORY_NOT_FOUND", "value": { "error": { - "code": "MERGE_QUEUE_NOT_FOUND", - "message": "Merge queue not found" + "code": "REPOSITORY_NOT_FOUND", + "message": "Repository not found" + } + } + }, + "PR_NOT_FOUND": { + "summary": "PR_NOT_FOUND", + "value": { + "error": { + "code": "PR_NOT_FOUND", + "message": "Pull request not found" } } } @@ -7648,20 +11918,20 @@ } } }, - "409": { - "description": "`QUEUE_HAS_ACTIVE_ENTRIES`", + "422": { + "description": "`IMPACTED_TARGETS_UNSUPPORTED`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "QUEUE_HAS_ACTIVE_ENTRIES": { - "summary": "QUEUE_HAS_ACTIVE_ENTRIES", + "IMPACTED_TARGETS_UNSUPPORTED": { + "summary": "IMPACTED_TARGETS_UNSUPPORTED", "value": { "error": { - "code": "QUEUE_HAS_ACTIVE_ENTRIES", - "message": "This merge queue still has active pull requests; drain or dequeue them first" + "code": "IMPACTED_TARGETS_UNSUPPORTED", + "message": "Impacted targets are supported only for GitHub and GitLab repositories" } } } @@ -7735,32 +12005,32 @@ } } }, - "/v2/merge-queues/{id}/order": { + "/v2/merge-queue-verification-runs/{id}": { "get": { - "operationId": "mergeQueues.order", - "tags": ["mergeQueues"], - "summary": "Get a merge queue's dispatch order", - "description": "Returns the queue's batches with a verification run, what is admitted and waiting in the order the engine will consider it, and what has not been admitted yet.\n\n**A batch in `batches` is not necessarily still testing** — one that has passed, is merging, or is holding others back after a failure still has a run and is still listed. Read its `state`.\n\n**The order is one of consideration, not of execution, and array position is not a wait estimate.** `predictedBatch` repeats across every pull request predicted to start testing together, and in `graph` mode several predicted batches commonly start at once — so the pull requests ahead of yours may all start with it, and may sit on unrelated branches that never block yours. `directlyAhead` is what actually precedes a pull request; use it rather than counting.\n\nIt is a point-in-time prediction. A new submission, a priority change or a failure regroups it, and four things outside this response still gate dispatch: `queueState: paused` stops it entirely, the queue's testing-concurrency cap bounds how many start, a batch whose predecessors have no usable test branch is skipped over rather than blocking, and bisections dispatch on their own budget.\n\nPull requests that are not ready are deliberately absent — they are not admitted, so they hold no position. Read one through `GET /v2/pull-requests/{id}`.\n\nUnpaginated: the engine caps its own graph, so the admitted set is bounded. `awaitingAdmission` is not, and is truncated.", + "operationId": "mergeQueueVerificationRuns.get", + "tags": ["mergeQueueVerificationRuns"], + "summary": "Get a verification run", + "description": "Returns one merge-queue verification run, including its normalized CI checks, the pull requests it tested, and the impacted targets uploaded for its commits.", "parameters": [ { "schema": { "type": "string", - "description": "The merge queue's id.", - "example": "xK9mP2nQ" + "description": "The verification run's id.", + "example": "a1b2c3d4-e5f6-4718-9a0b-1c2d3e4f5061" }, "required": true, - "description": "The merge queue's id.", + "description": "The verification run's id.", "name": "id", "in": "path" } ], "responses": { "200": { - "description": "The queue's dispatch order", + "description": "The verification run", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/MergeQueueOrder" + "$ref": "#/components/schemas/VerificationRun" } } } @@ -7795,41 +12065,20 @@ } } }, - "403": { - "description": "`INSUFFICIENT_PERMISSIONS`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "INSUFFICIENT_PERMISSIONS": { - "summary": "INSUFFICIENT_PERMISSIONS", - "value": { - "error": { - "code": "INSUFFICIENT_PERMISSIONS", - "message": "The supplied credential is missing the required permission" - } - } - } - } - } - } - }, "404": { - "description": "`MERGE_QUEUE_NOT_FOUND`", + "description": "`VERIFICATION_RUN_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "MERGE_QUEUE_NOT_FOUND": { - "summary": "MERGE_QUEUE_NOT_FOUND", + "VERIFICATION_RUN_NOT_FOUND": { + "summary": "VERIFICATION_RUN_NOT_FOUND", "value": { "error": { - "code": "MERGE_QUEUE_NOT_FOUND", - "message": "Merge queue not found" + "code": "VERIFICATION_RUN_NOT_FOUND", + "message": "Verification run not found" } } } @@ -7878,69 +12127,37 @@ } } } - }, - "502": { - "description": "`UPSTREAM_ERROR`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "UPSTREAM_ERROR": { - "summary": "UPSTREAM_ERROR", - "value": { - "error": { - "code": "UPSTREAM_ERROR", - "message": "An upstream service did not respond" - } - } - } - } - } - } } } } }, - "/v2/merge-queues/{id}/graph": { + "/v2/pull-requests/{id}/impacted-targets": { "get": { - "operationId": "mergeQueues.graph", - "tags": ["mergeQueues"], - "summary": "Get a merge queue's dependency graph", - "description": "Returns the queue's dependency graph: which pull requests the engine considers related, and why.\n\n**This does not tell you what runs next.** The engine schedules on a priority that cascades backwards through the graph and on a pending-failure gate, and neither is in this payload — `priorityValue` here is each pull request's own value, not the cascaded one. For dispatch order use `GET /v2/merge-queues/{id}/order`.\n\nEdges are transitively reduced, so an indirect dependency appears through the node between its endpoints rather than as its own edge. They mean overlapping impacted targets, not a stacked-branch relationship.\n\nOnly pull requests the engine has admitted to its graph appear: anything past the graph's soft cap, or not yet ready, is absent. `includeImpactedTargets` adds the target lists that explain each node and edge; it is off by default because populating it costs a lookup per distinct commit.", + "operationId": "pullRequests.impactedTargets", + "tags": ["pullRequests"], + "summary": "Get a pull request's impacted targets", + "description": "Returns the impacted targets most recently uploaded for this pull request's head commit, with `PUT /impacted-targets`. The head commit is the one Trunk has indexed for the pull request; a squash merge does not move it, so this answers for a merged pull request too. Uploads are stored per commit, so a push after the upload makes this a `404 IMPACTED_TARGETS_NOT_FOUND` until CI uploads for the new commit. For a stacked pull request this is its own commit's upload alone, not the stack's. This reflects uploads only: a queue that treats an older pull request as impacting everything through its backfill cutoff has no upload for it, and this read answers 404.", "parameters": [ { "schema": { "type": "string", - "description": "The merge queue's id.", - "example": "xK9mP2nQ" + "format": "uuid", + "description": "The pull request's id.", + "example": "0f8fad5b-d9cb-469f-a165-70867728950e" }, "required": true, - "description": "The merge queue's id.", + "description": "The pull request's id.", "name": "id", "in": "path" - }, - { - "schema": { - "type": "boolean", - "default": false, - "description": "Include the impacted-target lists on nodes and edges. Off by default: resolving them costs one lookup per distinct commit in the graph.", - "example": false - }, - "required": false, - "description": "Include the impacted-target lists on nodes and edges. Off by default: resolving them costs one lookup per distinct commit in the graph.", - "name": "includeImpactedTargets", - "in": "query" } ], "responses": { "200": { - "description": "The queue's dependency graph", + "description": "The pull request's impacted targets", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/MergeGraph" + "$ref": "#/components/schemas/PullRequestImpactedTargets" } } } @@ -8018,19 +12235,28 @@ } }, "404": { - "description": "`MERGE_QUEUE_NOT_FOUND`", + "description": "`PR_NOT_FOUND` | `IMPACTED_TARGETS_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "MERGE_QUEUE_NOT_FOUND": { - "summary": "MERGE_QUEUE_NOT_FOUND", + "PR_NOT_FOUND": { + "summary": "PR_NOT_FOUND", "value": { "error": { - "code": "MERGE_QUEUE_NOT_FOUND", - "message": "Merge queue not found" + "code": "PR_NOT_FOUND", + "message": "Pull request not found" + } + } + }, + "IMPACTED_TARGETS_NOT_FOUND": { + "summary": "IMPACTED_TARGETS_NOT_FOUND", + "value": { + "error": { + "code": "IMPACTED_TARGETS_NOT_FOUND", + "message": "No impacted targets have been uploaded for this pull request's head commit" } } } @@ -8079,37 +12305,16 @@ } } } - }, - "502": { - "description": "`UPSTREAM_ERROR`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "UPSTREAM_ERROR": { - "summary": "UPSTREAM_ERROR", - "value": { - "error": { - "code": "UPSTREAM_ERROR", - "message": "An upstream service did not respond" - } - } - } - } - } - } } } } }, - "/v2/merge-queues/{id}/testing-results": { + "/v2/merge-queues/{id}/verification-runs": { "get": { - "operationId": "mergeQueues.listTestingResults", + "operationId": "mergeQueues.listVerificationRuns", "tags": ["mergeQueues"], - "summary": "List a merge queue's completed testing", - "description": "Lists the stretches of testing the queue finished between `since` and `until`, newest first. One entry per pull request per attempt: a pull request appears several times if its testing restarted, and a batched run appears once per pull request it tested. Testing still in progress is not included. Pass an entry's `verificationRunId` to `GET /v2/merge-queue-verification-runs/{id}` for the run's checks and tested pull requests.\n\nThe range may span at most 45 days, which is also how long results are kept. When `until` is omitted it is fixed at the time of the first page, so later pages are not shifted by testing that finishes while you page.", + "summary": "List a merge queue's verification runs", + "description": "Lists the queue's verification runs, newest first. `sort` and `direction` are not configurable yet: sending either with a non-default value is rejected with `400` rather than ignored, so a client cannot silently receive an ordering it did not ask for.", "parameters": [ { "schema": { @@ -8161,36 +12366,40 @@ }, { "schema": { - "type": "string", - "format": "date-time", - "description": "Only testing that ended at or after this instant (ISO-8601). At most 45 days before `until`.", - "example": "2026-09-01T00:00:00Z" + "allOf": [ + { + "$ref": "#/components/schemas/VerificationRunStatus" + }, + { + "description": "One verification-run status. Sending any other value — including a comma-separated list, which is not supported yet — is a `400`." + } + ] }, - "required": true, - "description": "Only testing that ended at or after this instant (ISO-8601). At most 45 days before `until`.", - "name": "since", + "required": false, + "description": "One verification-run status. Sending any other value — including a comma-separated list, which is not supported yet — is a `400`.", + "name": "status", "in": "query" }, { "schema": { "type": "string", "format": "date-time", - "description": "Only testing that ended at or before this instant (ISO-8601). Defaults to the time of the first page.", - "example": "2026-09-08T00:00:00Z" + "description": "Only runs created strictly after this instant (ISO-8601, UTC).", + "example": "2026-07-24T20:26:04Z" }, "required": false, - "description": "Only testing that ended at or before this instant (ISO-8601). Defaults to the time of the first page.", - "name": "until", + "description": "Only runs created strictly after this instant (ISO-8601, UTC).", + "name": "createdAfter", "in": "query" } ], "responses": { "200": { - "description": "A page of testing results", + "description": "A page of verification runs", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/TestingResultList" + "$ref": "#/components/schemas/VerificationRunList" } } } @@ -8255,27 +12464,6 @@ } } }, - "403": { - "description": "`INSUFFICIENT_PERMISSIONS`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "INSUFFICIENT_PERMISSIONS": { - "summary": "INSUFFICIENT_PERMISSIONS", - "value": { - "error": { - "code": "INSUFFICIENT_PERMISSIONS", - "message": "The supplied credential is missing the required permission" - } - } - } - } - } - } - }, "404": { "description": "`MERGE_QUEUE_NOT_FOUND`", "content": { @@ -8338,73 +12526,96 @@ } } } - }, - "502": { - "description": "`UPSTREAM_ERROR`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "UPSTREAM_ERROR": { - "summary": "UPSTREAM_ERROR", - "value": { - "error": { - "code": "UPSTREAM_ERROR", - "message": "An upstream service did not respond" - } - } - } - } - } - } } } } }, - "/v2/merge-queues/{id}/pull-requests": { - "post": { - "operationId": "mergeQueues.submitPullRequest", - "tags": ["mergeQueues"], - "summary": "Submit a pull request to a merge queue", - "description": "Requires the **Merge and cancel PRs** permission, plus **Set priority on PRs** to send `priorityValue` or `priorityName`, **Skip batching** to send `allowBatching: false`, and **Merge PRs with direct to queue** to send `direct: true`. Choosing a `mergeMethod` needs no extra permission. Lower `priorityValue` numbers go first, from 0 to 255. The named priorities are `urgent` (0), `high` (10), `medium` (100, the default), and `low` (200). An `urgent` entry, or `priorityValue: 0`, restarts lower-priority entries that are already testing when it enters the queue (once it is ready), along with the entries tested on top of them.\n\nEnqueues a pull request. A pull request already enqueued in this queue is refused with `PR_ALREADY_ENQUEUED` rather than having its priority rewritten — change a live entry through `POST /v2/pull-requests/{id}/reprioritize` or `PATCH /v2/pull-requests/{id}/queue-entry`. `readiness.hasImpactedTargets` may be absent on the 201 if the post-write lookup failed; the enqueue still landed, so read the pull request again rather than retrying.\n\n`Idempotency-Key` is not honored. If a request times out, resolve the pull request by repository and number and inspect its queue entry before retrying.", + "/v2/pull-requests/{id}/verification-runs": { + "get": { + "operationId": "pullRequests.listVerificationRuns", + "tags": ["pullRequests"], + "summary": "List a pull request's verification runs", + "description": "Lists every verification run that tested this pull request, newest first — including a run it shared with others, which is reported here for each pull request in the batch. `sort` and `direction` are not configurable yet: each accepts only the value this list already uses (`createdAt`, `desc`) and rejects anything else with `400`. `createdAfter` is not served on this endpoint at all and is rejected with `400` whatever the value; the queue's own verification-run list does serve it.", "parameters": [ { "schema": { "type": "string", - "description": "The merge queue's id.", - "example": "xK9mP2nQ" + "format": "uuid", + "description": "The pull request's id.", + "example": "0f8fad5b-d9cb-469f-a165-70867728950e" + }, + "required": true, + "description": "The pull request's id.", + "name": "id", + "in": "path" + }, + { + "schema": { + "type": "integer", + "minimum": 1, + "maximum": 100, + "default": 25, + "description": "Page size, between 1 and 100.", + "example": 25 + }, + "required": false, + "description": "Page size, between 1 and 100.", + "name": "limit", + "in": "query" + }, + { + "schema": { + "type": "string", + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "example": "AQEKZm9vYmFy" }, - "required": true, - "description": "The merge queue's id.", - "name": "id", - "in": "path" + "required": false, + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "name": "cursor", + "in": "query" + }, + { + "schema": { + "type": "boolean", + "default": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "example": false + }, + "required": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "name": "includeTotal", + "in": "query" + }, + { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/VerificationRunStatus" + }, + { + "description": "One verification-run status. Sending any other value — including a comma-separated list, which is not supported yet — is a `400`." + } + ] + }, + "required": false, + "description": "One verification-run status. Sending any other value — including a comma-separated list, which is not supported yet — is a `400`.", + "name": "status", + "in": "query" } ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SubmitPullRequestRequest" - } - } - } - }, "responses": { - "201": { - "description": "The enqueued pull request", + "200": { + "description": "A page of verification runs", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PullRequest" + "$ref": "#/components/schemas/VerificationRunList" } } } }, "400": { - "description": "`VALIDATION_FAILED`", + "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", "content": { "application/json": { "schema": { @@ -8419,6 +12630,15 @@ "message": "Invalid input: expected string, received undefined" } } + }, + "INVALID_CURSOR": { + "summary": "INVALID_CURSOR", + "value": { + "error": { + "code": "INVALID_CURSOR", + "message": "Invalid or expired cursor." + } + } } } } @@ -8454,83 +12674,20 @@ } } }, - "403": { - "description": "`INSUFFICIENT_PERMISSIONS`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "INSUFFICIENT_PERMISSIONS": { - "summary": "INSUFFICIENT_PERMISSIONS", - "value": { - "error": { - "code": "INSUFFICIENT_PERMISSIONS", - "message": "The supplied credential is missing the required permission" - } - } - } - } - } - } - }, "404": { - "description": "`MERGE_QUEUE_NOT_FOUND`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "MERGE_QUEUE_NOT_FOUND": { - "summary": "MERGE_QUEUE_NOT_FOUND", - "value": { - "error": { - "code": "MERGE_QUEUE_NOT_FOUND", - "message": "Merge queue not found" - } - } - } - } - } - } - }, - "409": { - "description": "`PR_ALREADY_ENQUEUED`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "PR_ALREADY_ENQUEUED": { - "summary": "PR_ALREADY_ENQUEUED", - "value": { - "error": { - "code": "PR_ALREADY_ENQUEUED", - "message": "This pull request is already enqueued in this merge queue" - } - } - } - } - } - } - }, - "422": { - "description": "`PR_NOT_ENQUEUEABLE`", + "description": "`PR_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "PR_NOT_ENQUEUEABLE": { - "summary": "PR_NOT_ENQUEUEABLE", + "PR_NOT_FOUND": { + "summary": "PR_NOT_FOUND", "value": { "error": { - "code": "PR_NOT_ENQUEUEABLE", - "message": "This pull request cannot be enqueued" + "code": "PR_NOT_FOUND", + "message": "Pull request not found" } } } @@ -8579,44 +12736,26 @@ } } } - }, - "502": { - "description": "`UPSTREAM_ERROR`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "UPSTREAM_ERROR": { - "summary": "UPSTREAM_ERROR", - "value": { - "error": { - "code": "UPSTREAM_ERROR", - "message": "An upstream service did not respond" - } - } - } - } - } - } } } - }, + } + }, + "/v2/pull-requests/{id}/queue-entry-history": { "get": { - "operationId": "mergeQueues.listPullRequests", - "tags": ["mergeQueues"], - "summary": "List a merge queue's pull requests", - "description": "Lists the pull requests in a queue, **most recently enqueued first**.\n\n**This is not queue order** — do not infer position from this list's index. For the order the engine will consider, use `GET /v2/merge-queues/{id}/order`. `state` accepts a comma-separated list of queue-entry states. `readiness.hasImpactedTargets` is omitted on this list read, because resolving it costs a storage lookup per entry; read a single pull request to get it. `sort` and `direction` are not configurable yet: each accepts only the value this list already uses (`createdAt`, `desc`) and rejects anything else with `400`. Neither is ignored, so a client cannot silently receive an ordering it did not ask for.\n\n`concludedAfter` and `concludedBefore` keep pull requests that reached `merged`, `failed` or `cancelled` inside that window, both bounds inclusive — v1's `since`/`until`. That is a fact about the entry's history, not its current state: an entry that failed in the window and was later resubmitted still matches, so pair them with `state` to filter on where it is now.", + "operationId": "pullRequests.queueEntryHistory", + "tags": ["pullRequests"], + "summary": "List a pull request's queue-entry state history", + "description": "Returns the state transitions of this pull request's queue entry. Defaults to **oldest first** — the one list in this API that does, because it is an append-only log a reader replays forward — so finding the CURRENT transition means paging to the end, and `hasMore: false` is how you know you are there. Send `direction=newest` for v1's `includeTimeline` order, where the current transition is the first row of the first page. A pull request that was never enqueued is a 200 with an empty page, not a 404.", "parameters": [ { "schema": { "type": "string", - "description": "The merge queue's id.", - "example": "xK9mP2nQ" + "format": "uuid", + "description": "The pull request's id.", + "example": "0f8fad5b-d9cb-469f-a165-70867728950e" }, "required": true, - "description": "The merge queue's id.", + "description": "The pull request's id.", "name": "id", "in": "path" }, @@ -8660,59 +12799,24 @@ { "schema": { "type": "string", - "minLength": 1, - "description": "Comma-separated queue-entry states, e.g. `testing,pending`.", - "example": "testing,pending" - }, - "required": false, - "description": "Comma-separated queue-entry states, e.g. `testing,pending`.", - "name": "state", - "in": "query" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "description": "Only pull requests opened by this author.", - "example": "octocat" - }, - "required": false, - "description": "Only pull requests opened by this author.", - "name": "author", - "in": "query" - }, - { - "schema": { - "type": "string", - "format": "date-time", - "description": "Only entries that concluded at or after this instant (ISO-8601).", - "example": "2026-09-01T00:00:00Z" - }, - "required": false, - "description": "Only entries that concluded at or after this instant (ISO-8601).", - "name": "concludedAfter", - "in": "query" - }, - { - "schema": { - "type": "string", - "format": "date-time", - "description": "Only entries that concluded at or before this instant (ISO-8601).", - "example": "2026-09-08T00:00:00Z" + "enum": ["oldest", "newest"], + "default": "oldest", + "description": "Order of the transitions within a timeline. `oldest` (the default) reads the log forward; `newest` matches v1's `includeTimeline` order, so the current transition is the first row rather than the last.", + "example": "oldest" }, "required": false, - "description": "Only entries that concluded at or before this instant (ISO-8601).", - "name": "concludedBefore", + "description": "Order of the transitions within a timeline. `oldest` (the default) reads the log forward; `newest` matches v1's `includeTimeline` order, so the current transition is the first row rather than the last.", + "name": "direction", "in": "query" } ], "responses": { "200": { - "description": "A page of pull requests", + "description": "A page of state transitions", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PullRequestList" + "$ref": "#/components/schemas/QueueEntryHistoryList" } } } @@ -8778,19 +12882,19 @@ } }, "404": { - "description": "`MERGE_QUEUE_NOT_FOUND`", + "description": "`PR_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "MERGE_QUEUE_NOT_FOUND": { - "summary": "MERGE_QUEUE_NOT_FOUND", + "PR_NOT_FOUND": { + "summary": "PR_NOT_FOUND", "value": { "error": { - "code": "MERGE_QUEUE_NOT_FOUND", - "message": "Merge queue not found" + "code": "PR_NOT_FOUND", + "message": "Pull request not found" } } } @@ -8843,42 +12947,33 @@ } } }, - "/v2/merge-queues/{id}/switch-modes": { - "post": { - "operationId": "mergeQueues.switchModes", - "tags": ["mergeQueues"], - "summary": "Switch a merge queue's mode", - "description": "Requires the **Update Merge Queue settings** permission. Starts a conversion between `queue` and `graph` mode. Switching to the mode the queue is already in is an idempotent no-op. A queue already mid-conversion is refused with `MODE_CHANGE_IN_PROGRESS`. The response carries the state the merge engine reported after the write, so a started conversion reports `switchingModes`.", + "/v2/pull-requests/{id}/queue-entry-estimate": { + "get": { + "operationId": "pullRequests.queueEntryEstimate", + "tags": ["pullRequests"], + "summary": "Estimate when a queued pull request will merge", + "description": "Returns a live estimate for this pull request's queue entry: when it is expected to merge, when it starts and finishes testing, and how many pull requests it is waiting behind. An entry in `pendingFailure` instead reports when that failure is expected to resolve (`kind: pendingFailureResolution`) and which pull requests it is waiting on.\n\nThe estimate is computed on each request by simulating the queue forward, so it changes as the queue moves. Read it when the answer is needed rather than in a tight loop: each call runs a fresh simulation, and like the other pull-request reads it is rate-limited per caller. When no estimate can be given — a queue with too little test history, a pull request that is not ready yet, a paused queue — the response says why (`status: unavailable`, `reason`).\n\nNot every queue serves estimates yet: one that does not answers 404 `ESTIMATE_NOT_ENABLED`.", "parameters": [ { "schema": { "type": "string", - "description": "The merge queue's id.", - "example": "xK9mP2nQ" + "format": "uuid", + "description": "The pull request's id.", + "example": "0f8fad5b-d9cb-469f-a165-70867728950e" }, "required": true, - "description": "The merge queue's id.", + "description": "The pull request's id.", "name": "id", "in": "path" } ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SwitchModesRequest" - } - } - } - }, "responses": { "200": { - "description": "The queue's post-write state", + "description": "The entry's estimate, or why there is none", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/MergeQueueStateChange" + "$ref": "#/components/schemas/QueueEntryEstimate" } } } @@ -8956,19 +13051,28 @@ } }, "404": { - "description": "`MERGE_QUEUE_NOT_FOUND`", + "description": "`PR_NOT_FOUND` | `ESTIMATE_NOT_ENABLED`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "MERGE_QUEUE_NOT_FOUND": { - "summary": "MERGE_QUEUE_NOT_FOUND", + "PR_NOT_FOUND": { + "summary": "PR_NOT_FOUND", "value": { "error": { - "code": "MERGE_QUEUE_NOT_FOUND", - "message": "Merge queue not found" + "code": "PR_NOT_FOUND", + "message": "Pull request not found" + } + } + }, + "ESTIMATE_NOT_ENABLED": { + "summary": "ESTIMATE_NOT_ENABLED", + "value": { + "error": { + "code": "ESTIMATE_NOT_ENABLED", + "message": "Estimates are not enabled for this pull request's merge queue" } } } @@ -8977,19 +13081,19 @@ } }, "409": { - "description": "`MODE_CHANGE_IN_PROGRESS`", + "description": "`PR_NOT_IN_ACTIVE_STATE`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "MODE_CHANGE_IN_PROGRESS": { - "summary": "MODE_CHANGE_IN_PROGRESS", + "PR_NOT_IN_ACTIVE_STATE": { + "summary": "PR_NOT_IN_ACTIVE_STATE", "value": { "error": { - "code": "MODE_CHANGE_IN_PROGRESS", - "message": "This merge queue is switching modes; retry once the transition completes" + "code": "PR_NOT_IN_ACTIVE_STATE", + "message": "This pull request is not in an active queue state" } } } @@ -9063,38 +13167,88 @@ } } }, - "/v2/merge-queues/{id}/pause": { - "post": { - "operationId": "mergeQueues.pause", - "tags": ["mergeQueues"], - "summary": "Pause a merge queue", - "description": "Requires the **Update Merge Queue settings** permission. **Disruptive — affects every entry in the queue.** Stops the queue testing or merging anything further; entries already in it stay enqueued and resume when the queue is resumed. `Idempotency-Key` is not honored; if the outcome is unknown, read the queue's state before retrying. The request body is ignored.", + "/v2/queue-entry-history": { + "get": { + "operationId": "pullRequests.queueEntryHistoryBatch", + "tags": ["pullRequests"], + "summary": "List queue-entry state history for several pull requests", + "description": "Returns up to 50 pull requests' complete queue-entry timelines in one response — the batch form of `GET /v2/pull-requests/{id}/queue-entry-history`, and the equivalent of v1's `getSubmittedPullRequests` with `includeTimeline`.\n\n`limit` counts **pull requests**, not transitions, and every group carries that pull request's whole timeline (oldest-first by default; send `direction=newest` for v1's `includeTimeline` order), so one call answers for the whole set and each group is complete on arrival. A page's byte size therefore follows the data rather than a fixed row count: for a pull request with an exceptionally long timeline, page within it using the single-pull-request endpoint instead.\n\nAn id naming a pull request in another organization, or one that was never enqueued, comes back as an **empty group** rather than an error — this route never 404s, so diff the ids you asked for against the groups you got.", "parameters": [ + { + "schema": { + "type": "integer", + "minimum": 1, + "maximum": 100, + "default": 25, + "description": "Page size, between 1 and 100.", + "example": 25 + }, + "required": false, + "description": "Page size, between 1 and 100.", + "name": "limit", + "in": "query" + }, { "schema": { "type": "string", - "description": "The merge queue's id.", - "example": "xK9mP2nQ" + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "example": "AQEKZm9vYmFy" + }, + "required": false, + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "name": "cursor", + "in": "query" + }, + { + "schema": { + "type": "boolean", + "default": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "example": false + }, + "required": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "name": "includeTotal", + "in": "query" + }, + { + "schema": { + "type": "string", + "enum": ["oldest", "newest"], + "default": "oldest", + "description": "Order of the transitions within a timeline. `oldest` (the default) reads the log forward; `newest` matches v1's `includeTimeline` order, so the current transition is the first row rather than the last.", + "example": "oldest" + }, + "required": false, + "description": "Order of the transitions within a timeline. `oldest` (the default) reads the log forward; `newest` matches v1's `includeTimeline` order, so the current transition is the first row rather than the last.", + "name": "direction", + "in": "query" + }, + { + "schema": { + "type": "string", + "description": "Comma-separated pull request ids, at most 50 — v1's own batch ceiling. A member that is not a uuid is a 400 naming it; a repeated id is read once. Ids are normalized to lowercase in the response (and for paging), so diff against the lowercased set you asked for.", + "example": "6f1d2c3b-4a59-4e6f-8a7b-9c0d1e2f3a4b,7a2e3d4c-5b60-4f71-9b8c-0d1e2f3a4b5c" }, "required": true, - "description": "The merge queue's id.", - "name": "id", - "in": "path" + "description": "Comma-separated pull request ids, at most 50 — v1's own batch ceiling. A member that is not a uuid is a 400 naming it; a repeated id is read once. Ids are normalized to lowercase in the response (and for paging), so diff against the lowercased set you asked for.", + "name": "pullRequestIds", + "in": "query" } ], "responses": { "200": { - "description": "The queue's post-write state", + "description": "A page of pull requests, each with its timeline", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/MergeQueueStateChange" + "$ref": "#/components/schemas/BatchQueueEntryHistoryList" } } } }, "400": { - "description": "`VALIDATION_FAILED`", + "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", "content": { "application/json": { "schema": { @@ -9109,6 +13263,15 @@ "message": "Invalid input: expected string, received undefined" } } + }, + "INVALID_CURSOR": { + "summary": "INVALID_CURSOR", + "value": { + "error": { + "code": "INVALID_CURSOR", + "message": "Invalid or expired cursor." + } + } } } } @@ -9165,27 +13328,6 @@ } } }, - "404": { - "description": "`MERGE_QUEUE_NOT_FOUND`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "MERGE_QUEUE_NOT_FOUND": { - "summary": "MERGE_QUEUE_NOT_FOUND", - "value": { - "error": { - "code": "MERGE_QUEUE_NOT_FOUND", - "message": "Merge queue not found" - } - } - } - } - } - } - }, "429": { "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", "content": { @@ -9227,57 +13369,47 @@ } } } - }, - "502": { - "description": "`UPSTREAM_ERROR`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "UPSTREAM_ERROR": { - "summary": "UPSTREAM_ERROR", - "value": { - "error": { - "code": "UPSTREAM_ERROR", - "message": "An upstream service did not respond" - } - } - } - } - } - } } } } }, - "/v2/merge-queues/{id}/resume": { + "/v2/pull-requests/{id}/reprioritize": { "post": { - "operationId": "mergeQueues.resume", - "tags": ["mergeQueues"], - "summary": "Resume a merge queue", - "description": "Requires the **Update Merge Queue settings** permission. Returns a paused or draining queue to `running`. `Idempotency-Key` is not honored; if the outcome is unknown, read the queue's state before retrying. The request body is ignored.", + "operationId": "pullRequests.reprioritize", + "tags": ["pullRequests"], + "summary": "Reprioritize a queued pull request", + "description": "Requires the **Set priority on PRs** permission. Lower `priorityValue` numbers go first, from 0 to 255. The named priorities are `urgent` (0), `high` (10), `medium` (100, the default), and `low` (200). Raising an entry that is already queued doesn't restart anything: the new priority applies the next time the entry is placed in the queue. An entry still `notReady` set to `urgent` restarts lower-priority entries already testing when it enters the queue.\n\nChanges a live queue entry's priority. Exactly one of `priorityValue` or `priorityName` is required. `priorityValue: 0` is the write path for skipping the line. The entry keeps its merge method. The pull request must have a non-terminal queue entry, or the call returns `PR_NOT_IN_ACTIVE_STATE`.\n\n`Idempotency-Key` is not honored. If a request times out, read the pull request's queue entry before retrying.", "parameters": [ { "schema": { "type": "string", - "description": "The merge queue's id.", - "example": "xK9mP2nQ" + "format": "uuid", + "description": "The pull request's id.", + "example": "0f8fad5b-d9cb-469f-a165-70867728950e" }, "required": true, - "description": "The merge queue's id.", + "description": "The pull request's id.", "name": "id", "in": "path" } ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ReprioritizeRequest" + } + } + } + }, "responses": { "200": { - "description": "The queue's post-write state", + "description": "The updated pull request", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/MergeQueueStateChange" + "$ref": "#/components/schemas/PullRequest" } } } @@ -9345,8 +13477,59 @@ "summary": "INSUFFICIENT_PERMISSIONS", "value": { "error": { - "code": "INSUFFICIENT_PERMISSIONS", - "message": "The supplied credential is missing the required permission" + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" + } + } + } + } + } + } + }, + "404": { + "description": "`PR_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "PR_NOT_FOUND": { + "summary": "PR_NOT_FOUND", + "value": { + "error": { + "code": "PR_NOT_FOUND", + "message": "Pull request not found" + } + } + } + } + } + } + }, + "409": { + "description": "`PR_NOT_IN_ACTIVE_STATE` | `PR_ALREADY_ENQUEUED`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "PR_NOT_IN_ACTIVE_STATE": { + "summary": "PR_NOT_IN_ACTIVE_STATE", + "value": { + "error": { + "code": "PR_NOT_IN_ACTIVE_STATE", + "message": "This pull request is not in an active queue state" + } + } + }, + "PR_ALREADY_ENQUEUED": { + "summary": "PR_ALREADY_ENQUEUED", + "value": { + "error": { + "code": "PR_ALREADY_ENQUEUED", + "message": "This pull request is already enqueued in this merge queue" } } } @@ -9354,20 +13537,20 @@ } } }, - "404": { - "description": "`MERGE_QUEUE_NOT_FOUND`", + "422": { + "description": "`PR_NOT_ENQUEUEABLE`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "MERGE_QUEUE_NOT_FOUND": { - "summary": "MERGE_QUEUE_NOT_FOUND", + "PR_NOT_ENQUEUEABLE": { + "summary": "PR_NOT_ENQUEUEABLE", "value": { "error": { - "code": "MERGE_QUEUE_NOT_FOUND", - "message": "Merge queue not found" + "code": "PR_NOT_ENQUEUEABLE", + "message": "This pull request cannot be enqueued" } } } @@ -9441,32 +13624,43 @@ } } }, - "/v2/merge-queues/{id}/drain": { - "post": { - "operationId": "mergeQueues.drain", - "tags": ["mergeQueues"], - "summary": "Drain a merge queue", - "description": "Requires the **Update Merge Queue settings** permission. **Disruptive — affects every entry in the queue.** Finishes the entries already in the queue but accepts no new submissions. `Idempotency-Key` is not honored; if the outcome is unknown, read the queue's state before retrying. The request body is ignored.", + "/v2/pull-requests/{id}/queue-entry": { + "patch": { + "operationId": "pullRequests.updateQueueEntry", + "tags": ["pullRequests"], + "summary": "Update a queued pull request's entry", + "description": "Requires **Set priority on PRs** to send `priorityValue` or `priorityName`, **Skip batching** to send `allowBatching`, **Merge PRs with direct to queue** to send `direct`, and **Merge and cancel PRs** to send `mergeMethod`. Lower `priorityValue` numbers go first, from 0 to 255. The named priorities are `urgent` (0), `high` (10), `medium` (100, the default), and `low` (200). Raising an entry that is already queued doesn't restart anything: the new priority applies the next time the entry is placed in the queue. An entry still `notReady` set to `urgent` restarts lower-priority entries already testing when it enters the queue.\n\nPatches a live queue entry; an omitted field leaves that attribute unchanged. `priorityValue` and `priorityName` are mutually exclusive. `skipsTheLine` is not settable — it is derived from `priorityValue === 0`, so send that instead. `direct` sends the entry directly to the queue past unmet readiness (it needs the **Merge PRs with direct to queue** permission, and a signed-in user also needs repository-admin permission). `allowBatching: false` gives the entry a test run of its own. `mergeMethod` chooses how this pull request is merged, and `null` returns it to the queue's merge method.", "parameters": [ { "schema": { "type": "string", - "description": "The merge queue's id.", - "example": "xK9mP2nQ" + "format": "uuid", + "description": "The pull request's id.", + "example": "0f8fad5b-d9cb-469f-a165-70867728950e" }, "required": true, - "description": "The merge queue's id.", + "description": "The pull request's id.", "name": "id", "in": "path" } ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateQueueEntryRequest" + } + } + } + }, "responses": { "200": { - "description": "The queue's post-write state", + "description": "The updated pull request", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/MergeQueueStateChange" + "$ref": "#/components/schemas/PullRequest" } } } @@ -9544,19 +13738,70 @@ } }, "404": { - "description": "`MERGE_QUEUE_NOT_FOUND`", + "description": "`PR_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "MERGE_QUEUE_NOT_FOUND": { - "summary": "MERGE_QUEUE_NOT_FOUND", + "PR_NOT_FOUND": { + "summary": "PR_NOT_FOUND", "value": { "error": { - "code": "MERGE_QUEUE_NOT_FOUND", - "message": "Merge queue not found" + "code": "PR_NOT_FOUND", + "message": "Pull request not found" + } + } + } + } + } + } + }, + "409": { + "description": "`PR_NOT_IN_ACTIVE_STATE` | `PR_ALREADY_ENQUEUED`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "PR_NOT_IN_ACTIVE_STATE": { + "summary": "PR_NOT_IN_ACTIVE_STATE", + "value": { + "error": { + "code": "PR_NOT_IN_ACTIVE_STATE", + "message": "This pull request is not in an active queue state" + } + } + }, + "PR_ALREADY_ENQUEUED": { + "summary": "PR_ALREADY_ENQUEUED", + "value": { + "error": { + "code": "PR_ALREADY_ENQUEUED", + "message": "This pull request is already enqueued in this merge queue" + } + } + } + } + } + } + }, + "422": { + "description": "`PR_NOT_ENQUEUEABLE`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "PR_NOT_ENQUEUEABLE": { + "summary": "PR_NOT_ENQUEUEABLE", + "value": { + "error": { + "code": "PR_NOT_ENQUEUEABLE", + "message": "This pull request cannot be enqueued" } } } @@ -9630,42 +13875,33 @@ } } }, - "/v2/merge-queues/{id}/config": { - "patch": { - "operationId": "mergeQueues.updateConfig", - "tags": ["mergeQueues"], - "summary": "Update a merge queue's configuration", - "description": "Requires the **Update Merge Queue settings** permission. Applies a JSON Merge Patch to the queue's configuration: an absent key leaves that setting unchanged, and an unknown key is rejected rather than silently dropped. Send `requiredStatuses: []` or `batchingRules: []` to clear those lists.\n\n**`requiredStatuses` is a merge-protection control, not a tuning knob**: it decides what must pass before an entry may merge (clearing it falls back to `.trunk/trunk.yaml` and the branch's protection rules). Treat access to this endpoint as security-relevant. Refused with `MODE_CHANGE_IN_PROGRESS` while the queue is converting between modes, and with `ALLOWED_BOT_SUBMITTERS_FROZEN` for a body carrying the removed `allowedBotSubmitters`: bots are approved on the Bots page of the organization's settings.", + "/v2/pull-requests/{id}/dequeue": { + "post": { + "operationId": "pullRequests.dequeue", + "tags": ["pullRequests"], + "summary": "Dequeue a pull request", + "description": "Requires the **Merge and cancel PRs** permission. **Disruptive.** Removes a pull request from its merge queue, abandoning any in-flight verification. The entry must be non-terminal, or the call returns `PR_NOT_IN_ACTIVE_STATE`. `Idempotency-Key` is not honored; if a request times out, read the pull request's queue entry before retrying. The request body is ignored.", "parameters": [ { "schema": { "type": "string", - "description": "The merge queue's id.", - "example": "xK9mP2nQ" + "format": "uuid", + "description": "The pull request's id.", + "example": "0f8fad5b-d9cb-469f-a165-70867728950e" }, "required": true, - "description": "The merge queue's id.", + "description": "The pull request's id.", "name": "id", "in": "path" } ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UpdateMergeQueueConfigRequest" - } - } - } - }, "responses": { "200": { - "description": "The updated merge queue", + "description": "The updated pull request", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/MergeQueue" + "$ref": "#/components/schemas/PullRequest" } } } @@ -9743,19 +13979,19 @@ } }, "404": { - "description": "`MERGE_QUEUE_NOT_FOUND`", + "description": "`PR_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "MERGE_QUEUE_NOT_FOUND": { - "summary": "MERGE_QUEUE_NOT_FOUND", + "PR_NOT_FOUND": { + "summary": "PR_NOT_FOUND", "value": { "error": { - "code": "MERGE_QUEUE_NOT_FOUND", - "message": "Merge queue not found" + "code": "PR_NOT_FOUND", + "message": "Pull request not found" } } } @@ -9764,40 +14000,19 @@ } }, "409": { - "description": "`MODE_CHANGE_IN_PROGRESS`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "MODE_CHANGE_IN_PROGRESS": { - "summary": "MODE_CHANGE_IN_PROGRESS", - "value": { - "error": { - "code": "MODE_CHANGE_IN_PROGRESS", - "message": "This merge queue is switching modes; retry once the transition completes" - } - } - } - } - } - } - }, - "422": { - "description": "`ALLOWED_BOT_SUBMITTERS_FROZEN`", + "description": "`PR_NOT_IN_ACTIVE_STATE`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "ALLOWED_BOT_SUBMITTERS_FROZEN": { - "summary": "ALLOWED_BOT_SUBMITTERS_FROZEN", + "PR_NOT_IN_ACTIVE_STATE": { + "summary": "PR_NOT_IN_ACTIVE_STATE", "value": { "error": { - "code": "ALLOWED_BOT_SUBMITTERS_FROZEN", - "message": "allowedBotSubmitters has been removed. Bots are approved on the Bots page of the organization's settings instead." + "code": "PR_NOT_IN_ACTIVE_STATE", + "message": "This pull request is not in an active queue state" } } } @@ -9871,25 +14086,36 @@ } } }, - "/v2/impacted-targets": { - "put": { - "operationId": "impactedTargets.upload", - "tags": ["impactedTargets"], - "summary": "Upload a pull request's impacted targets", - "description": "Requires the **Merge and cancel PRs** permission, or a GitHub Actions login for the run's own repository. Records which build targets a pull request's head sha impacts, for queues that gate on impacted targets. Address the pull request by exactly one of `number` or `branch`, and declare impact with exactly one of `impactedTargets` or `impactsAllTargets: true`. An empty `impactedTargets` array is a valid upload meaning the sha impacts nothing — it satisfies the queue's has-impacted-targets gate, because that gate asks whether CI reported, not whether it reported a non-zero result. Supported only for GitHub and GitLab repositories; anything else returns `IMPACTED_TARGETS_UNSUPPORTED`. Answers 202: the targets are stored, but readiness is re-evaluated asynchronously, so a 202 does not mean readiness has changed yet.\n\nA token from a GitHub Actions run may upload only for its own repository. One from a fork pull request's run is bound to that pull request and its head sha: address the pull request by `number`, and send that sha, or the upload is refused with `INSUFFICIENT_PERMISSIONS`. It is also refused unless the repository has a merge queue whose GitHub settings allow impacted targets from fork pull requests.", - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UploadImpactedTargetsRequest" - } - } + "/v2/pull-requests/{id}/restart-tests": { + "post": { + "operationId": "pullRequests.restartTests", + "tags": ["pullRequests"], + "summary": "Restart a queued pull request's tests", + "description": "Requires the **Merge and cancel PRs** permission. **Disruptive.** Abandons the entry's in-flight verification and starts a new one, discarding CI progress. Only possible while the entry is testing or in pending-failure; other live states are refused with `PR_TESTS_NOT_RESTARTABLE`.\n\nThis endpoint does not diagnose anything — to find out *why* an entry keeps being re-tested, read `GET /v2/pull-requests/{id}/queue-entry-history` and inspect each transition's `reason`. `Idempotency-Key` is not yet honored, so a retry after a timeout starts a second restart; read the entry back instead of retrying. The request body is ignored.", + "parameters": [ + { + "schema": { + "type": "string", + "format": "uuid", + "description": "The pull request's id.", + "example": "0f8fad5b-d9cb-469f-a165-70867728950e" + }, + "required": true, + "description": "The pull request's id.", + "name": "id", + "in": "path" } - }, + ], "responses": { - "202": { - "description": "The targets were accepted" + "200": { + "description": "The updated pull request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PullRequest" + } + } + } }, "400": { "description": "`VALIDATION_FAILED`", @@ -9964,28 +14190,40 @@ } }, "404": { - "description": "`REPOSITORY_NOT_FOUND` | `PR_NOT_FOUND`", + "description": "`PR_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "PR_NOT_FOUND": { + "summary": "PR_NOT_FOUND", + "value": { + "error": { + "code": "PR_NOT_FOUND", + "message": "Pull request not found" + } + } + } + } + } + } + }, + "409": { + "description": "`PR_NOT_IN_ACTIVE_STATE`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "REPOSITORY_NOT_FOUND": { - "summary": "REPOSITORY_NOT_FOUND", - "value": { - "error": { - "code": "REPOSITORY_NOT_FOUND", - "message": "Repository not found" - } - } - }, - "PR_NOT_FOUND": { - "summary": "PR_NOT_FOUND", + "PR_NOT_IN_ACTIVE_STATE": { + "summary": "PR_NOT_IN_ACTIVE_STATE", "value": { "error": { - "code": "PR_NOT_FOUND", - "message": "Pull request not found" + "code": "PR_NOT_IN_ACTIVE_STATE", + "message": "This pull request is not in an active queue state" } } } @@ -9994,19 +14232,19 @@ } }, "422": { - "description": "`IMPACTED_TARGETS_UNSUPPORTED`", + "description": "`PR_TESTS_NOT_RESTARTABLE`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "IMPACTED_TARGETS_UNSUPPORTED": { - "summary": "IMPACTED_TARGETS_UNSUPPORTED", + "PR_TESTS_NOT_RESTARTABLE": { + "summary": "PR_TESTS_NOT_RESTARTABLE", "value": { "error": { - "code": "IMPACTED_TARGETS_UNSUPPORTED", - "message": "Impacted targets are supported only for GitHub and GitLab repositories" + "code": "PR_TESTS_NOT_RESTARTABLE", + "message": "This pull request's tests cannot be restarted in its current state" } } } @@ -10080,32 +14318,64 @@ } } }, - "/v2/merge-queue-verification-runs/{id}": { - "get": { - "operationId": "mergeQueueVerificationRuns.get", - "tags": ["mergeQueueVerificationRuns"], - "summary": "Get a verification run", - "description": "Returns one merge-queue verification run, including its normalized CI checks, the pull requests it tested, and the impacted targets uploaded for its commits.", + "/v2/pull-requests/{id}/rerun-failed-checks": { + "post": { + "operationId": "pullRequests.rerunFailedChecks", + "tags": ["pullRequests"], + "summary": "Re-run a pull request's failed checks", + "description": "Requires the **Merge and cancel PRs** permission. Re-runs the failed jobs of the GitHub Actions workflows behind the failed required checks, and keeps the pull request's place in the queue: it stays in `pendingFailure` until the re-run starts or `rerun.until` passes, whichever is first. If the re-run has not started by then, the pull request fails as it would have without the request. Only possible while the entry is in `pendingFailure` on a queue that keeps failed test runs; every refusal is a `422` with its own code.\n\n`mode` is required. **Disruptive** with `mode: now`: it stops the jobs still running in the failed checks' workflows. `mode: wait` lets them finish first. `now` on a request that is waiting switches it to `now` (`rerun.switchedToNow`). `Idempotency-Key` is not honored, but a repeat with the same `mode` is safe: it answers `rerun.alreadyHeld` and changes nothing.", "parameters": [ { "schema": { "type": "string", - "description": "The verification run's id.", - "example": "a1b2c3d4-e5f6-4718-9a0b-1c2d3e4f5061" + "format": "uuid", + "description": "The pull request's id.", + "example": "0f8fad5b-d9cb-469f-a165-70867728950e" }, "required": true, - "description": "The verification run's id.", + "description": "The pull request's id.", "name": "id", "in": "path" } ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RerunFailedChecksRequest" + } + } + } + }, "responses": { "200": { - "description": "The verification run", + "description": "The pull request, and the re-run it is waiting for", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/VerificationRun" + "$ref": "#/components/schemas/RerunFailedChecksResult" + } + } + } + }, + "400": { + "description": "`VALIDATION_FAILED`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "VALIDATION_FAILED": { + "summary": "VALIDATION_FAILED", + "value": { + "error": { + "code": "VALIDATION_FAILED", + "message": "Invalid input: expected string, received undefined" + } + } + } } } } @@ -10140,20 +14410,20 @@ } } }, - "404": { - "description": "`VERIFICATION_RUN_NOT_FOUND`", + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "VERIFICATION_RUN_NOT_FOUND": { - "summary": "VERIFICATION_RUN_NOT_FOUND", + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", "value": { "error": { - "code": "VERIFICATION_RUN_NOT_FOUND", - "message": "Verification run not found" + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" } } } @@ -10161,20 +14431,29 @@ } } }, - "429": { - "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", + "404": { + "description": "`PR_NOT_FOUND` | `MERGE_QUEUE_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "RATE_LIMIT_EXCEEDED": { - "summary": "RATE_LIMIT_EXCEEDED", + "PR_NOT_FOUND": { + "summary": "PR_NOT_FOUND", "value": { "error": { - "code": "RATE_LIMIT_EXCEEDED", - "message": "Rate limit exceeded; retry with backoff" + "code": "PR_NOT_FOUND", + "message": "Pull request not found" + } + } + }, + "MERGE_QUEUE_NOT_FOUND": { + "summary": "MERGE_QUEUE_NOT_FOUND", + "value": { + "error": { + "code": "MERGE_QUEUE_NOT_FOUND", + "message": "Merge queue not found" } } } @@ -10182,199 +14461,104 @@ } } }, - "500": { - "description": "`INTERNAL_ERROR`", + "409": { + "description": "`PR_NOT_IN_ACTIVE_STATE`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "INTERNAL_ERROR": { - "summary": "INTERNAL_ERROR", + "PR_NOT_IN_ACTIVE_STATE": { + "summary": "PR_NOT_IN_ACTIVE_STATE", "value": { "error": { - "code": "INTERNAL_ERROR", - "message": "An unexpected error occurred" + "code": "PR_NOT_IN_ACTIVE_STATE", + "message": "This pull request is not in an active queue state" } } } } } } - } - } - } - }, - "/v2/merge-queues/{id}/verification-runs": { - "get": { - "operationId": "mergeQueues.listVerificationRuns", - "tags": ["mergeQueues"], - "summary": "List a merge queue's verification runs", - "description": "Lists the queue's verification runs, newest first. `sort` and `direction` are not configurable yet: sending either with a non-default value is rejected with `400` rather than ignored, so a client cannot silently receive an ordering it did not ask for.", - "parameters": [ - { - "schema": { - "type": "string", - "description": "The merge queue's id.", - "example": "xK9mP2nQ" - }, - "required": true, - "description": "The merge queue's id.", - "name": "id", - "in": "path" - }, - { - "schema": { - "type": "integer", - "minimum": 1, - "maximum": 100, - "default": 25, - "description": "Page size, between 1 and 100.", - "example": 25 - }, - "required": false, - "description": "Page size, between 1 and 100.", - "name": "limit", - "in": "query" - }, - { - "schema": { - "type": "string", - "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", - "example": "AQEKZm9vYmFy" - }, - "required": false, - "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", - "name": "cursor", - "in": "query" - }, - { - "schema": { - "type": "boolean", - "default": false, - "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", - "example": false - }, - "required": false, - "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", - "name": "includeTotal", - "in": "query" - }, - { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/VerificationRunStatus" - }, - { - "description": "One verification-run status. Sending any other value — including a comma-separated list, which is not supported yet — is a `400`." - } - ] - }, - "required": false, - "description": "One verification-run status. Sending any other value — including a comma-separated list, which is not supported yet — is a `400`.", - "name": "status", - "in": "query" - }, - { - "schema": { - "type": "string", - "format": "date-time", - "description": "Only runs created strictly after this instant (ISO-8601, UTC).", - "example": "2026-07-24T20:26:04Z" - }, - "required": false, - "description": "Only runs created strictly after this instant (ISO-8601, UTC).", - "name": "createdAfter", - "in": "query" - } - ], - "responses": { - "200": { - "description": "A page of verification runs", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/VerificationRunList" - } - } - } }, - "400": { - "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", + "422": { + "description": "`PR_RERUN_FEATURE_DISABLED` | `PR_RERUN_NOT_PENDING_FAILURE` | `PR_RERUN_QUEUE_DOES_NOT_KEEP_FAILED_RUNS` | `PR_RERUN_NOT_A_REQUIRED_CHECK_FAILURE` | `PR_RERUN_CHECK_NOT_RERUNNABLE` | `PR_RERUN_RUN_TORN_DOWN` | `PR_RERUN_HOLD_LIMIT_REACHED` | `PR_RERUN_FORGE_NOT_SUPPORTED`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "VALIDATION_FAILED": { - "summary": "VALIDATION_FAILED", + "PR_RERUN_FEATURE_DISABLED": { + "summary": "PR_RERUN_FEATURE_DISABLED", + "value": { + "error": { + "code": "PR_RERUN_FEATURE_DISABLED", + "message": "You cannot re-run failed checks from Trunk on this queue." + } + } + }, + "PR_RERUN_NOT_PENDING_FAILURE": { + "summary": "PR_RERUN_NOT_PENDING_FAILURE", + "value": { + "error": { + "code": "PR_RERUN_NOT_PENDING_FAILURE", + "message": "You cannot re-run checks for this pull request now." + } + } + }, + "PR_RERUN_QUEUE_DOES_NOT_KEEP_FAILED_RUNS": { + "summary": "PR_RERUN_QUEUE_DOES_NOT_KEEP_FAILED_RUNS", + "value": { + "error": { + "code": "PR_RERUN_QUEUE_DOES_NOT_KEEP_FAILED_RUNS", + "message": "This queue does not allow re-runs. A queue admin can turn on \"Allow Re-running Failed Checks\"." + } + } + }, + "PR_RERUN_NOT_A_REQUIRED_CHECK_FAILURE": { + "summary": "PR_RERUN_NOT_A_REQUIRED_CHECK_FAILURE", "value": { "error": { - "code": "VALIDATION_FAILED", - "message": "Invalid input: expected string, received undefined" + "code": "PR_RERUN_NOT_A_REQUIRED_CHECK_FAILURE", + "message": "No required check failed. Use Restart tests." } } }, - "INVALID_CURSOR": { - "summary": "INVALID_CURSOR", + "PR_RERUN_CHECK_NOT_RERUNNABLE": { + "summary": "PR_RERUN_CHECK_NOT_RERUNNABLE", "value": { "error": { - "code": "INVALID_CURSOR", - "message": "Invalid or expired cursor." + "code": "PR_RERUN_CHECK_NOT_RERUNNABLE", + "message": "Trunk can re-run only GitHub Actions checks. Re-run `buildkite/ci` in its own CI, or use Restart tests." } } - } - } - } - } - }, - "401": { - "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "AUTHENTICATION_REQUIRED": { - "summary": "AUTHENTICATION_REQUIRED", + }, + "PR_RERUN_RUN_TORN_DOWN": { + "summary": "PR_RERUN_RUN_TORN_DOWN", "value": { "error": { - "code": "AUTHENTICATION_REQUIRED", - "message": "No credential was supplied" + "code": "PR_RERUN_RUN_TORN_DOWN", + "message": "These checks cannot be re-run now. Use Restart tests." } } }, - "INVALID_TOKEN": { - "summary": "INVALID_TOKEN", + "PR_RERUN_HOLD_LIMIT_REACHED": { + "summary": "PR_RERUN_HOLD_LIMIT_REACHED", "value": { "error": { - "code": "INVALID_TOKEN", - "message": "The supplied token failed verification" + "code": "PR_RERUN_HOLD_LIMIT_REACHED", + "message": "These checks were already re-run two times. Use Restart tests." } } - } - } - } - } - }, - "404": { - "description": "`MERGE_QUEUE_NOT_FOUND`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "MERGE_QUEUE_NOT_FOUND": { - "summary": "MERGE_QUEUE_NOT_FOUND", + }, + "PR_RERUN_FORGE_NOT_SUPPORTED": { + "summary": "PR_RERUN_FORGE_NOT_SUPPORTED", "value": { "error": { - "code": "MERGE_QUEUE_NOT_FOUND", - "message": "Merge queue not found" + "code": "PR_RERUN_FORGE_NOT_SUPPORTED", + "message": "Trunk can re-run checks only for GitHub repositories. Use Restart tests." } } } @@ -10423,96 +14607,60 @@ } } } + }, + "502": { + "description": "`UPSTREAM_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "UPSTREAM_ERROR": { + "summary": "UPSTREAM_ERROR", + "value": { + "error": { + "code": "UPSTREAM_ERROR", + "message": "An upstream service did not respond" + } + } + } + } + } + } } } } }, - "/v2/pull-requests/{id}/verification-runs": { - "get": { - "operationId": "pullRequests.listVerificationRuns", - "tags": ["pullRequests"], - "summary": "List a pull request's verification runs", - "description": "Lists every verification run that tested this pull request, newest first — including a run it shared with others, which is reported here for each pull request in the batch. `sort` and `direction` are not configurable yet: each accepts only the value this list already uses (`createdAt`, `desc`) and rejects anything else with `400`. `createdAfter` is not served on this endpoint at all and is rejected with `400` whatever the value; the queue's own verification-run list does serve it.", - "parameters": [ - { - "schema": { - "type": "string", - "format": "uuid", - "description": "The pull request's id.", - "example": "0f8fad5b-d9cb-469f-a165-70867728950e" - }, - "required": true, - "description": "The pull request's id.", - "name": "id", - "in": "path" - }, - { - "schema": { - "type": "integer", - "minimum": 1, - "maximum": 100, - "default": 25, - "description": "Page size, between 1 and 100.", - "example": 25 - }, - "required": false, - "description": "Page size, between 1 and 100.", - "name": "limit", - "in": "query" - }, - { - "schema": { - "type": "string", - "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", - "example": "AQEKZm9vYmFy" - }, - "required": false, - "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", - "name": "cursor", - "in": "query" - }, - { - "schema": { - "type": "boolean", - "default": false, - "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", - "example": false - }, - "required": false, - "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", - "name": "includeTotal", - "in": "query" - }, - { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/VerificationRunStatus" - }, - { - "description": "One verification-run status. Sending any other value — including a comma-separated list, which is not supported yet — is a `400`." - } - ] - }, - "required": false, - "description": "One verification-run status. Sending any other value — including a comma-separated list, which is not supported yet — is a `400`.", - "name": "status", - "in": "query" + "/v2/dynamic-ci/generate-plan": { + "post": { + "operationId": "dynamicCi.generatePlan", + "tags": ["dynamicCi"], + "summary": "Generate a CI skip plan", + "description": "Requires the **Generate Dynamic CI plans** permission.\n\nReturns a per-job verdict for one workflow run: which jobs the change makes it safe to skip, and the evidence behind each decision. Normally called once per run by the [`trunk-io/dynamic-ci`](https://github.com/trunk-io/dynamic-ci) action, which maps the verdicts onto job outputs.\n\n**Fail open.** A job absent from `jobs` must be run — that is the contract, not an error. Treat any non-200 the same way.\n\nSend the changed files as `changedFiles` when you can compute them. Without it, Trunk fetches the diff between `baseSha` and `commitSha` through your GitHub App installation, which needs both commits on GitHub.", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CiPlanRequest" + } + } } - ], + }, "responses": { "200": { - "description": "A page of verification runs", + "description": "The plan", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/VerificationRunList" + "$ref": "#/components/schemas/CiPlan" } } } }, "400": { - "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", + "description": "`VALIDATION_FAILED` | `CI_HOST_UNSUPPORTED`", "content": { "application/json": { "schema": { @@ -10528,12 +14676,12 @@ } } }, - "INVALID_CURSOR": { - "summary": "INVALID_CURSOR", + "CI_HOST_UNSUPPORTED": { + "summary": "CI_HOST_UNSUPPORTED", "value": { "error": { - "code": "INVALID_CURSOR", - "message": "Invalid or expired cursor." + "code": "CI_HOST_UNSUPPORTED", + "message": "Dynamic CI does not support the repository host gitlab.example.com" } } } @@ -10571,20 +14719,41 @@ } } }, + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", + "value": { + "error": { + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" + } + } + } + } + } + } + }, "404": { - "description": "`PR_NOT_FOUND`", + "description": "`REPOSITORY_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "PR_NOT_FOUND": { - "summary": "PR_NOT_FOUND", + "REPOSITORY_NOT_FOUND": { + "summary": "REPOSITORY_NOT_FOUND", "value": { "error": { - "code": "PR_NOT_FOUND", - "message": "Pull request not found" + "code": "REPOSITORY_NOT_FOUND", + "message": "Repository not found" } } } @@ -10633,93 +14802,60 @@ } } } + }, + "502": { + "description": "`UPSTREAM_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "UPSTREAM_ERROR": { + "summary": "UPSTREAM_ERROR", + "value": { + "error": { + "code": "UPSTREAM_ERROR", + "message": "An upstream service did not respond" + } + } + } + } + } + } + } + } + } + }, + "/v2/dynamic-ci/generate-buildkite-plan": { + "post": { + "operationId": "dynamicCi.generateBuildkitePlan", + "tags": ["dynamicCi"], + "summary": "Generate a CI skip plan for a Buildkite pipeline", + "description": "Requires the **Generate Dynamic CI plans** permission.\n\nAs [`dynamicCi.generatePlan`](#tag/dynamicCi/operation/dynamicCi.generatePlan), for a Buildkite pipeline. Identical request and response but for the workflow identity: Buildkite has no workflow file, so the pipeline is named by the organization and pipeline slugs its agent exports, and `jobKeys` are step `key:` values.\n\n**Fail open.** A job absent from `jobs` must be run — that is the contract, not an error. Treat any non-200 the same way.\n\nSend the changed files as `changedFiles` when you can compute them. Without it, Trunk fetches the diff between `baseSha` and `commitSha` through your GitHub App installation, which needs both commits on GitHub.", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BuildkitePlanRequest" + } + } } - } - } - }, - "/v2/pull-requests/{id}/queue-entry-history": { - "get": { - "operationId": "pullRequests.queueEntryHistory", - "tags": ["pullRequests"], - "summary": "List a pull request's queue-entry state history", - "description": "Returns the state transitions of this pull request's queue entry. Defaults to **oldest first** — the one list in this API that does, because it is an append-only log a reader replays forward — so finding the CURRENT transition means paging to the end, and `hasMore: false` is how you know you are there. Send `direction=newest` for v1's `includeTimeline` order, where the current transition is the first row of the first page. A pull request that was never enqueued is a 200 with an empty page, not a 404.", - "parameters": [ - { - "schema": { - "type": "string", - "format": "uuid", - "description": "The pull request's id.", - "example": "0f8fad5b-d9cb-469f-a165-70867728950e" - }, - "required": true, - "description": "The pull request's id.", - "name": "id", - "in": "path" - }, - { - "schema": { - "type": "integer", - "minimum": 1, - "maximum": 100, - "default": 25, - "description": "Page size, between 1 and 100.", - "example": 25 - }, - "required": false, - "description": "Page size, between 1 and 100.", - "name": "limit", - "in": "query" - }, - { - "schema": { - "type": "string", - "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", - "example": "AQEKZm9vYmFy" - }, - "required": false, - "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", - "name": "cursor", - "in": "query" - }, - { - "schema": { - "type": "boolean", - "default": false, - "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", - "example": false - }, - "required": false, - "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", - "name": "includeTotal", - "in": "query" - }, - { - "schema": { - "type": "string", - "enum": ["oldest", "newest"], - "default": "oldest", - "description": "Order of the transitions within a timeline. `oldest` (the default) reads the log forward; `newest` matches v1's `includeTimeline` order, so the current transition is the first row rather than the last.", - "example": "oldest" - }, - "required": false, - "description": "Order of the transitions within a timeline. `oldest` (the default) reads the log forward; `newest` matches v1's `includeTimeline` order, so the current transition is the first row rather than the last.", - "name": "direction", - "in": "query" - } - ], + }, "responses": { "200": { - "description": "A page of state transitions", + "description": "The plan", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/QueueEntryHistoryList" + "$ref": "#/components/schemas/CiPlan" } } } }, "400": { - "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", + "description": "`VALIDATION_FAILED` | `CI_HOST_UNSUPPORTED`", "content": { "application/json": { "schema": { @@ -10735,12 +14871,12 @@ } } }, - "INVALID_CURSOR": { - "summary": "INVALID_CURSOR", + "CI_HOST_UNSUPPORTED": { + "summary": "CI_HOST_UNSUPPORTED", "value": { "error": { - "code": "INVALID_CURSOR", - "message": "Invalid or expired cursor." + "code": "CI_HOST_UNSUPPORTED", + "message": "Dynamic CI does not support the repository host gitlab.example.com" } } } @@ -10778,20 +14914,41 @@ } } }, + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", + "value": { + "error": { + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" + } + } + } + } + } + } + }, "404": { - "description": "`PR_NOT_FOUND`", + "description": "`REPOSITORY_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "PR_NOT_FOUND": { - "summary": "PR_NOT_FOUND", + "REPOSITORY_NOT_FOUND": { + "summary": "REPOSITORY_NOT_FOUND", "value": { "error": { - "code": "PR_NOT_FOUND", - "message": "Pull request not found" + "code": "REPOSITORY_NOT_FOUND", + "message": "Repository not found" } } } @@ -10840,43 +14997,121 @@ } } } + }, + "502": { + "description": "`UPSTREAM_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "UPSTREAM_ERROR": { + "summary": "UPSTREAM_ERROR", + "value": { + "error": { + "code": "UPSTREAM_ERROR", + "message": "An upstream service did not respond" + } + } + } + } + } + } } } } }, - "/v2/pull-requests/{id}/queue-entry-estimate": { + "/v2/dynamic-ci/pr-jobs": { "get": { - "operationId": "pullRequests.queueEntryEstimate", - "tags": ["pullRequests"], - "summary": "Estimate when a queued pull request will merge", - "description": "Returns a live estimate for this pull request's queue entry: when it is expected to merge, when it starts and finishes testing, and how many pull requests it is waiting behind. An entry in `pendingFailure` instead reports when that failure is expected to resolve (`kind: pendingFailureResolution`) and which pull requests it is waiting on.\n\nThe estimate is computed on each request by simulating the queue forward, so it changes as the queue moves. Read it when the answer is needed rather than in a tight loop: each call runs a fresh simulation, and like the other pull-request reads it is rate-limited per caller. When no estimate can be given — a queue with too little test history, a pull request that is not ready yet, a paused queue — the response says why (`status: unavailable`, `reason`).\n\nNot every queue serves estimates yet: one that does not answers 404 `ESTIMATE_NOT_ENABLED`.", + "operationId": "dynamicCi.listPrJobs", + "tags": ["dynamicCi"], + "summary": "List the jobs Dynamic CI sees", + "description": "The workflows that have run on a pull request in this repository recently, with the jobs each defines. Use it to find the `workflowId` and `jobId` to force with `dynamicCi.setForceOverrides`.\n\n`jobKey` is `null` for a job whose key Trunk has not resolved — it can never be skipped, and is listed so that is visible rather than silently missing.", "parameters": [ + { + "schema": { + "type": "integer", + "minimum": 1, + "maximum": 100, + "default": 25, + "description": "Page size, between 1 and 100.", + "example": 25 + }, + "required": false, + "description": "Page size, between 1 and 100.", + "name": "limit", + "in": "query" + }, { "schema": { "type": "string", - "format": "uuid", - "description": "The pull request's id.", - "example": "0f8fad5b-d9cb-469f-a165-70867728950e" + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "example": "AQEKZm9vYmFy" + }, + "required": false, + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "name": "cursor", + "in": "query" + }, + { + "schema": { + "type": "boolean", + "default": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "example": false + }, + "required": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "name": "includeTotal", + "in": "query" + }, + { + "schema": { + "type": "string", + "default": "github.com", + "description": "`github.com` is the only supported value today.", + "example": "github.com" + }, + "required": false, + "description": "`github.com` is the only supported value today.", + "name": "host", + "in": "query" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "example": "acme" }, "required": true, - "description": "The pull request's id.", - "name": "id", - "in": "path" + "name": "owner", + "in": "query" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "example": "widgets" + }, + "required": true, + "name": "name", + "in": "query" } ], "responses": { "200": { - "description": "The entry's estimate, or why there is none", + "description": "A page of workflows", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/QueueEntryEstimate" + "$ref": "#/components/schemas/CiWorkflowList" } } } }, "400": { - "description": "`VALIDATION_FAILED`", + "description": "`VALIDATION_FAILED` | `INVALID_CURSOR` | `CI_HOST_UNSUPPORTED`", "content": { "application/json": { "schema": { @@ -10891,55 +15126,22 @@ "message": "Invalid input: expected string, received undefined" } } - } - } - } - } - }, - "401": { - "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "AUTHENTICATION_REQUIRED": { - "summary": "AUTHENTICATION_REQUIRED", - "value": { - "error": { - "code": "AUTHENTICATION_REQUIRED", - "message": "No credential was supplied" - } - } }, - "INVALID_TOKEN": { - "summary": "INVALID_TOKEN", + "INVALID_CURSOR": { + "summary": "INVALID_CURSOR", "value": { "error": { - "code": "INVALID_TOKEN", - "message": "The supplied token failed verification" + "code": "INVALID_CURSOR", + "message": "Invalid or expired cursor." } } - } - } - } - } - }, - "403": { - "description": "`INSUFFICIENT_PERMISSIONS`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "INSUFFICIENT_PERMISSIONS": { - "summary": "INSUFFICIENT_PERMISSIONS", + }, + "CI_HOST_UNSUPPORTED": { + "summary": "CI_HOST_UNSUPPORTED", "value": { "error": { - "code": "INSUFFICIENT_PERMISSIONS", - "message": "The supplied credential is missing the required permission" + "code": "CI_HOST_UNSUPPORTED", + "message": "Dynamic CI does not support the repository host gitlab.example.com" } } } @@ -10947,29 +15149,29 @@ } } }, - "404": { - "description": "`PR_NOT_FOUND` | `ESTIMATE_NOT_ENABLED`", + "401": { + "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "PR_NOT_FOUND": { - "summary": "PR_NOT_FOUND", + "AUTHENTICATION_REQUIRED": { + "summary": "AUTHENTICATION_REQUIRED", "value": { "error": { - "code": "PR_NOT_FOUND", - "message": "Pull request not found" + "code": "AUTHENTICATION_REQUIRED", + "message": "No credential was supplied" } } }, - "ESTIMATE_NOT_ENABLED": { - "summary": "ESTIMATE_NOT_ENABLED", + "INVALID_TOKEN": { + "summary": "INVALID_TOKEN", "value": { "error": { - "code": "ESTIMATE_NOT_ENABLED", - "message": "Estimates are not enabled for this pull request's merge queue" + "code": "INVALID_TOKEN", + "message": "The supplied token failed verification" } } } @@ -10977,20 +15179,20 @@ } } }, - "409": { - "description": "`PR_NOT_IN_ACTIVE_STATE`", + "404": { + "description": "`REPOSITORY_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "PR_NOT_IN_ACTIVE_STATE": { - "summary": "PR_NOT_IN_ACTIVE_STATE", + "REPOSITORY_NOT_FOUND": { + "summary": "REPOSITORY_NOT_FOUND", "value": { "error": { - "code": "PR_NOT_IN_ACTIVE_STATE", - "message": "This pull request is not in an active queue state" + "code": "REPOSITORY_NOT_FOUND", + "message": "Repository not found" } } } @@ -11039,37 +15241,16 @@ } } } - }, - "502": { - "description": "`UPSTREAM_ERROR`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "UPSTREAM_ERROR": { - "summary": "UPSTREAM_ERROR", - "value": { - "error": { - "code": "UPSTREAM_ERROR", - "message": "An upstream service did not respond" - } - } - } - } - } - } } } } }, - "/v2/queue-entry-history": { + "/v2/dynamic-ci/force-overrides": { "get": { - "operationId": "pullRequests.queueEntryHistoryBatch", - "tags": ["pullRequests"], - "summary": "List queue-entry state history for several pull requests", - "description": "Returns up to 50 pull requests' complete queue-entry timelines in one response — the batch form of `GET /v2/pull-requests/{id}/queue-entry-history`, and the equivalent of v1's `getSubmittedPullRequests` with `includeTimeline`.\n\n`limit` counts **pull requests**, not transitions, and every group carries that pull request's whole timeline (oldest-first by default; send `direction=newest` for v1's `includeTimeline` order), so one call answers for the whole set and each group is complete on arrival. A page's byte size therefore follows the data rather than a fixed row count: for a pull request with an exceptionally long timeline, page within it using the single-pull-request endpoint instead.\n\nAn id naming a pull request in another organization, or one that was never enqueued, comes back as an **empty group** rather than an error — this route never 404s, so diff the ids you asked for against the groups you got.", + "operationId": "dynamicCi.listForceOverrides", + "tags": ["dynamicCi"], + "summary": "List a pull request's force overrides", + "description": "The forces currently active on a pull request. A force makes Dynamic CI run the jobs it covers whatever the signals say. `workflowId` and `jobId` are the ids `dynamicCi.listPrJobs` returns; revoked forces are retained for audit but not listed.", "parameters": [ { "schema": { @@ -11111,41 +15292,59 @@ { "schema": { "type": "string", - "enum": ["oldest", "newest"], - "default": "oldest", - "description": "Order of the transitions within a timeline. `oldest` (the default) reads the log forward; `newest` matches v1's `includeTimeline` order, so the current transition is the first row rather than the last.", - "example": "oldest" + "default": "github.com", + "description": "`github.com` is the only supported value today.", + "example": "github.com" }, "required": false, - "description": "Order of the transitions within a timeline. `oldest` (the default) reads the log forward; `newest` matches v1's `includeTimeline` order, so the current transition is the first row rather than the last.", - "name": "direction", + "description": "`github.com` is the only supported value today.", + "name": "host", "in": "query" }, { "schema": { "type": "string", - "description": "Comma-separated pull request ids, at most 50 — v1's own batch ceiling. A member that is not a uuid is a 400 naming it; a repeated id is read once. Ids are normalized to lowercase in the response (and for paging), so diff against the lowercased set you asked for.", - "example": "6f1d2c3b-4a59-4e6f-8a7b-9c0d1e2f3a4b,7a2e3d4c-5b60-4f71-9b8c-0d1e2f3a4b5c" + "minLength": 1, + "example": "acme" }, "required": true, - "description": "Comma-separated pull request ids, at most 50 — v1's own batch ceiling. A member that is not a uuid is a 400 naming it; a repeated id is read once. Ids are normalized to lowercase in the response (and for paging), so diff against the lowercased set you asked for.", - "name": "pullRequestIds", + "name": "owner", + "in": "query" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "example": "widgets" + }, + "required": true, + "name": "name", + "in": "query" + }, + { + "schema": { + "type": "integer", + "exclusiveMinimum": 0, + "example": 4213 + }, + "required": true, + "name": "prNumber", "in": "query" } ], "responses": { "200": { - "description": "A page of pull requests, each with its timeline", + "description": "A page of active forces", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/BatchQueueEntryHistoryList" + "$ref": "#/components/schemas/ForceOverrideList" } } } }, "400": { - "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", + "description": "`VALIDATION_FAILED` | `INVALID_CURSOR` | `CI_HOST_UNSUPPORTED`", "content": { "application/json": { "schema": { @@ -11169,6 +15368,15 @@ "message": "Invalid or expired cursor." } } + }, + "CI_HOST_UNSUPPORTED": { + "summary": "CI_HOST_UNSUPPORTED", + "value": { + "error": { + "code": "CI_HOST_UNSUPPORTED", + "message": "Dynamic CI does not support the repository host gitlab.example.com" + } + } } } } @@ -11204,20 +15412,20 @@ } } }, - "403": { - "description": "`INSUFFICIENT_PERMISSIONS`", + "404": { + "description": "`REPOSITORY_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "INSUFFICIENT_PERMISSIONS": { - "summary": "INSUFFICIENT_PERMISSIONS", + "REPOSITORY_NOT_FOUND": { + "summary": "REPOSITORY_NOT_FOUND", "value": { "error": { - "code": "INSUFFICIENT_PERMISSIONS", - "message": "The supplied credential is missing the required permission" + "code": "REPOSITORY_NOT_FOUND", + "message": "Repository not found" } } } @@ -11268,51 +15476,28 @@ } } } - } - }, - "/v2/pull-requests/{id}/reprioritize": { - "post": { - "operationId": "pullRequests.reprioritize", - "tags": ["pullRequests"], - "summary": "Reprioritize a queued pull request", - "description": "Requires the **Set priority on PRs** permission. Lower `priorityValue` numbers go first, from 0 to 255. The named priorities are `urgent` (0), `high` (10), `medium` (100, the default), and `low` (200). Raising an entry that is already queued doesn't restart anything: the new priority applies the next time the entry is placed in the queue. An entry still `notReady` set to `urgent` restarts lower-priority entries already testing when it enters the queue.\n\nChanges a live queue entry's priority. Exactly one of `priorityValue` or `priorityName` is required. `priorityValue: 0` is the write path for skipping the line. The entry keeps its merge method. The pull request must have a non-terminal queue entry, or the call returns `PR_NOT_IN_ACTIVE_STATE`.\n\n`Idempotency-Key` is not honored. If a request times out, read the pull request's queue entry before retrying.", - "parameters": [ - { - "schema": { - "type": "string", - "format": "uuid", - "description": "The pull request's id.", - "example": "0f8fad5b-d9cb-469f-a165-70867728950e" - }, - "required": true, - "description": "The pull request's id.", - "name": "id", - "in": "path" - } - ], + }, + "put": { + "operationId": "dynamicCi.setForceOverrides", + "tags": ["dynamicCi"], + "summary": "Replace a pull request's force overrides", + "description": "Requires the **Force CI jobs to run** permission.\n\nSets the complete list of forces active on a pull request. **This replaces the set, it does not add to it** — a force you omit is revoked, and an empty list clears them all. Send the desired end state, not a delta.\n\nScopes are addressed by the `workflowId` and `jobId` that `dynamicCi.listPrJobs` returns. An already-active force is left alone, so re-sending an unchanged list changes nothing. Forces are applied the next time `dynamicCi.generatePlan` runs for this pull request; this does not re-run anything itself.", "requestBody": { "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ReprioritizeRequest" + "$ref": "#/components/schemas/SetForceOverridesRequest" } } } }, "responses": { - "200": { - "description": "The updated pull request", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PullRequest" - } - } - } + "204": { + "description": "The forces were replaced" }, "400": { - "description": "`VALIDATION_FAILED`", + "description": "`VALIDATION_FAILED` | `CI_HOST_UNSUPPORTED`", "content": { "application/json": { "schema": { @@ -11327,6 +15512,15 @@ "message": "Invalid input: expected string, received undefined" } } + }, + "CI_HOST_UNSUPPORTED": { + "summary": "CI_HOST_UNSUPPORTED", + "value": { + "error": { + "code": "CI_HOST_UNSUPPORTED", + "message": "Dynamic CI does not support the repository host gitlab.example.com" + } + } } } } @@ -11384,70 +15578,28 @@ } }, "404": { - "description": "`PR_NOT_FOUND`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "PR_NOT_FOUND": { - "summary": "PR_NOT_FOUND", - "value": { - "error": { - "code": "PR_NOT_FOUND", - "message": "Pull request not found" - } - } - } - } - } - } - }, - "409": { - "description": "`PR_NOT_IN_ACTIVE_STATE` | `PR_ALREADY_ENQUEUED`", + "description": "`REPOSITORY_NOT_FOUND` | `CI_SCOPE_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "PR_NOT_IN_ACTIVE_STATE": { - "summary": "PR_NOT_IN_ACTIVE_STATE", + "REPOSITORY_NOT_FOUND": { + "summary": "REPOSITORY_NOT_FOUND", "value": { "error": { - "code": "PR_NOT_IN_ACTIVE_STATE", - "message": "This pull request is not in an active queue state" + "code": "REPOSITORY_NOT_FOUND", + "message": "Repository not found" } } }, - "PR_ALREADY_ENQUEUED": { - "summary": "PR_ALREADY_ENQUEUED", - "value": { - "error": { - "code": "PR_ALREADY_ENQUEUED", - "message": "This pull request is already enqueued in this merge queue" - } - } - } - } - } - } - }, - "422": { - "description": "`PR_NOT_ENQUEUEABLE`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "PR_NOT_ENQUEUEABLE": { - "summary": "PR_NOT_ENQUEUEABLE", + "CI_SCOPE_NOT_FOUND": { + "summary": "CI_SCOPE_NOT_FOUND", "value": { "error": { - "code": "PR_NOT_ENQUEUEABLE", - "message": "This pull request cannot be enqueued" + "code": "CI_SCOPE_NOT_FOUND", + "message": "A workflow or job in the request does not belong to this repository" } } } @@ -11496,74 +15648,100 @@ } } } - }, - "502": { - "description": "`UPSTREAM_ERROR`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "UPSTREAM_ERROR": { - "summary": "UPSTREAM_ERROR", - "value": { - "error": { - "code": "UPSTREAM_ERROR", - "message": "An upstream service did not respond" - } - } - } - } - } - } } } } }, - "/v2/pull-requests/{id}/queue-entry": { - "patch": { - "operationId": "pullRequests.updateQueueEntry", - "tags": ["pullRequests"], - "summary": "Update a queued pull request's entry", - "description": "Requires **Set priority on PRs** to send `priorityValue` or `priorityName`, **Skip batching** to send `allowBatching`, **Merge PRs with direct to queue** to send `direct`, and **Merge and cancel PRs** to send `mergeMethod`. Lower `priorityValue` numbers go first, from 0 to 255. The named priorities are `urgent` (0), `high` (10), `medium` (100, the default), and `low` (200). Raising an entry that is already queued doesn't restart anything: the new priority applies the next time the entry is placed in the queue. An entry still `notReady` set to `urgent` restarts lower-priority entries already testing when it enters the queue.\n\nPatches a live queue entry; an omitted field leaves that attribute unchanged. `priorityValue` and `priorityName` are mutually exclusive. `skipsTheLine` is not settable — it is derived from `priorityValue === 0`, so send that instead. `direct` sends the entry directly to the queue past unmet readiness (it needs the **Merge PRs with direct to queue** permission, and a signed-in user also needs repository-admin permission). `allowBatching: false` gives the entry a test run of its own. `mergeMethod` chooses how this pull request is merged, and `null` returns it to the queue's merge method.", + "/v2/dynamic-ci/paths-filters": { + "get": { + "operationId": "dynamicCi.listPathsFilters", + "tags": ["dynamicCi"], + "summary": "List a repository's paths filters", + "description": "Every paths filter in the repository, each with the jobs it gates. A paths filter decides which changed files make a job run, on pull requests and in the merge queue alike. An item with jobs can be sent back as one `filters` entry of `dynamicCi.setPathsFilters`, with its `name`, `rules` and `jobs`. A job the web app gave one filter for pull requests and another for the merge queue is listed under both: sending both items back leaves it as is, and sending one alone is a conflict, since the job also has the other filter.", "parameters": [ + { + "schema": { + "type": "integer", + "minimum": 1, + "maximum": 100, + "default": 25, + "description": "Page size, between 1 and 100.", + "example": 25 + }, + "required": false, + "description": "Page size, between 1 and 100.", + "name": "limit", + "in": "query" + }, { "schema": { "type": "string", - "format": "uuid", - "description": "The pull request's id.", - "example": "0f8fad5b-d9cb-469f-a165-70867728950e" + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "example": "AQEKZm9vYmFy" + }, + "required": false, + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "name": "cursor", + "in": "query" + }, + { + "schema": { + "type": "boolean", + "default": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "example": false + }, + "required": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "name": "includeTotal", + "in": "query" + }, + { + "schema": { + "type": "string", + "default": "github.com", + "description": "`github.com` is the only supported value today.", + "example": "github.com" + }, + "required": false, + "description": "`github.com` is the only supported value today.", + "name": "host", + "in": "query" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "example": "acme" }, "required": true, - "description": "The pull request's id.", - "name": "id", - "in": "path" + "name": "owner", + "in": "query" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "example": "widgets" + }, + "required": true, + "name": "name", + "in": "query" } ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UpdateQueueEntryRequest" - } - } - } - }, "responses": { "200": { - "description": "The updated pull request", + "description": "A page of paths filters", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PullRequest" + "$ref": "#/components/schemas/PathsFilterWithJobsList" } } } }, "400": { - "description": "`VALIDATION_FAILED`", + "description": "`VALIDATION_FAILED` | `INVALID_CURSOR` | `CI_HOST_UNSUPPORTED`", "content": { "application/json": { "schema": { @@ -11578,6 +15756,24 @@ "message": "Invalid input: expected string, received undefined" } } + }, + "INVALID_CURSOR": { + "summary": "INVALID_CURSOR", + "value": { + "error": { + "code": "INVALID_CURSOR", + "message": "Invalid or expired cursor." + } + } + }, + "CI_HOST_UNSUPPORTED": { + "summary": "CI_HOST_UNSUPPORTED", + "value": { + "error": { + "code": "CI_HOST_UNSUPPORTED", + "message": "Dynamic CI does not support the repository host gitlab.example.com" + } + } } } } @@ -11613,92 +15809,20 @@ } } }, - "403": { - "description": "`INSUFFICIENT_PERMISSIONS`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "INSUFFICIENT_PERMISSIONS": { - "summary": "INSUFFICIENT_PERMISSIONS", - "value": { - "error": { - "code": "INSUFFICIENT_PERMISSIONS", - "message": "The supplied credential is missing the required permission" - } - } - } - } - } - } - }, "404": { - "description": "`PR_NOT_FOUND`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "PR_NOT_FOUND": { - "summary": "PR_NOT_FOUND", - "value": { - "error": { - "code": "PR_NOT_FOUND", - "message": "Pull request not found" - } - } - } - } - } - } - }, - "409": { - "description": "`PR_NOT_IN_ACTIVE_STATE` | `PR_ALREADY_ENQUEUED`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "PR_NOT_IN_ACTIVE_STATE": { - "summary": "PR_NOT_IN_ACTIVE_STATE", - "value": { - "error": { - "code": "PR_NOT_IN_ACTIVE_STATE", - "message": "This pull request is not in an active queue state" - } - } - }, - "PR_ALREADY_ENQUEUED": { - "summary": "PR_ALREADY_ENQUEUED", - "value": { - "error": { - "code": "PR_ALREADY_ENQUEUED", - "message": "This pull request is already enqueued in this merge queue" - } - } - } - } - } - } - }, - "422": { - "description": "`PR_NOT_ENQUEUEABLE`", + "description": "`REPOSITORY_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "PR_NOT_ENQUEUEABLE": { - "summary": "PR_NOT_ENQUEUEABLE", + "REPOSITORY_NOT_FOUND": { + "summary": "REPOSITORY_NOT_FOUND", "value": { "error": { - "code": "PR_NOT_ENQUEUEABLE", - "message": "This pull request cannot be enqueued" + "code": "REPOSITORY_NOT_FOUND", + "message": "Repository not found" } } } @@ -11747,64 +15871,37 @@ } } } - }, - "502": { - "description": "`UPSTREAM_ERROR`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "UPSTREAM_ERROR": { - "summary": "UPSTREAM_ERROR", - "value": { - "error": { - "code": "UPSTREAM_ERROR", - "message": "An upstream service did not respond" - } - } - } - } + } + } + }, + "patch": { + "operationId": "dynamicCi.setPathsFilters", + "tags": ["dynamicCi"], + "summary": "Set or clear paths filters on jobs", + "description": "Requires the **Update Dynamic CI settings** permission.\n\nSets a paths filter on each job named in `filters`, and removes it from each job in `clear`. Name a job by its workflow file and its key under `jobs:`. Each filter applies to pull requests and the merge queue alike. A request names at most 500 jobs in all, across every `filters[].jobs` and `clear`.\n\nIt changes only the jobs it names. It never deletes a filter; one the request leaves with no jobs stays in the list, with no jobs. Sending the same body again changes nothing, so no `Idempotency-Key` is needed. A job that already has a different filter fails the request with `PATHS_FILTER_CONFLICT` unless `overwrite` is true. Any error means nothing was written.", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SetPathsFiltersRequest" } } } - } - } - }, - "/v2/pull-requests/{id}/dequeue": { - "post": { - "operationId": "pullRequests.dequeue", - "tags": ["pullRequests"], - "summary": "Dequeue a pull request", - "description": "Requires the **Merge and cancel PRs** permission. **Disruptive.** Removes a pull request from its merge queue, abandoning any in-flight verification. The entry must be non-terminal, or the call returns `PR_NOT_IN_ACTIVE_STATE`. `Idempotency-Key` is not honored; if a request times out, read the pull request's queue entry before retrying. The request body is ignored.", - "parameters": [ - { - "schema": { - "type": "string", - "format": "uuid", - "description": "The pull request's id.", - "example": "0f8fad5b-d9cb-469f-a165-70867728950e" - }, - "required": true, - "description": "The pull request's id.", - "name": "id", - "in": "path" - } - ], + }, "responses": { "200": { - "description": "The updated pull request", + "description": "What the request did to each job", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PullRequest" + "$ref": "#/components/schemas/SetPathsFiltersResult" } } } }, "400": { - "description": "`VALIDATION_FAILED`", + "description": "`VALIDATION_FAILED` | `CI_HOST_UNSUPPORTED`", "content": { "application/json": { "schema": { @@ -11819,6 +15916,15 @@ "message": "Invalid input: expected string, received undefined" } } + }, + "CI_HOST_UNSUPPORTED": { + "summary": "CI_HOST_UNSUPPORTED", + "value": { + "error": { + "code": "CI_HOST_UNSUPPORTED", + "message": "Dynamic CI does not support the repository host gitlab.example.com" + } + } } } } @@ -11876,19 +15982,28 @@ } }, "404": { - "description": "`PR_NOT_FOUND`", + "description": "`REPOSITORY_NOT_FOUND` | `CI_SCOPE_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "PR_NOT_FOUND": { - "summary": "PR_NOT_FOUND", + "REPOSITORY_NOT_FOUND": { + "summary": "REPOSITORY_NOT_FOUND", "value": { "error": { - "code": "PR_NOT_FOUND", - "message": "Pull request not found" + "code": "REPOSITORY_NOT_FOUND", + "message": "Repository not found" + } + } + }, + "CI_SCOPE_NOT_FOUND": { + "summary": "CI_SCOPE_NOT_FOUND", + "value": { + "error": { + "code": "CI_SCOPE_NOT_FOUND", + "message": "A workflow or job in the request does not belong to this repository" } } } @@ -11897,19 +16012,19 @@ } }, "409": { - "description": "`PR_NOT_IN_ACTIVE_STATE`", + "description": "`PATHS_FILTER_CONFLICT`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "PR_NOT_IN_ACTIVE_STATE": { - "summary": "PR_NOT_IN_ACTIVE_STATE", + "PATHS_FILTER_CONFLICT": { + "summary": "PATHS_FILTER_CONFLICT", "value": { "error": { - "code": "PR_NOT_IN_ACTIVE_STATE", - "message": "This pull request is not in an active queue state" + "code": "PATHS_FILTER_CONFLICT", + "message": "1 job already has a different paths filter: .github/workflows/ci.yml test (job 3c4f8e21-6a1d-4b7e-9f02-5d8c1a2b3e4f, \"backend\"). Send \"overwrite\": true to replace them." } } } @@ -11958,64 +16073,80 @@ } } } - }, - "502": { - "description": "`UPSTREAM_ERROR`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "UPSTREAM_ERROR": { - "summary": "UPSTREAM_ERROR", - "value": { - "error": { - "code": "UPSTREAM_ERROR", - "message": "An upstream service did not respond" - } - } - } - } - } - } } } } }, - "/v2/pull-requests/{id}/restart-tests": { - "post": { - "operationId": "pullRequests.restartTests", - "tags": ["pullRequests"], - "summary": "Restart a queued pull request's tests", - "description": "Requires the **Merge and cancel PRs** permission. **Disruptive.** Abandons the entry's in-flight verification and starts a new one, discarding CI progress. Only possible while the entry is testing or in pending-failure; other live states are refused with `PR_TESTS_NOT_RESTARTABLE`.\n\nThis endpoint does not diagnose anything — to find out *why* an entry keeps being re-tested, read `GET /v2/pull-requests/{id}/queue-entry-history` and inspect each transition's `reason`. `Idempotency-Key` is not yet honored, so a retry after a timeout starts a second restart; read the entry back instead of retrying. The request body is ignored.", + "/v2/test-collections": { + "get": { + "operationId": "testCollections.list", + "tags": ["testCollections"], + "summary": "List test collections", + "description": "Lists the test collections in your organization, newest first. Every other flaky-tests endpoint takes a collection's `id` from here, either as a filter or in a request body.", "parameters": [ + { + "schema": { + "type": "integer", + "minimum": 1, + "maximum": 100, + "default": 25, + "description": "Page size, between 1 and 100.", + "example": 25 + }, + "required": false, + "description": "Page size, between 1 and 100.", + "name": "limit", + "in": "query" + }, { "schema": { "type": "string", - "format": "uuid", - "description": "The pull request's id.", - "example": "0f8fad5b-d9cb-469f-a165-70867728950e" + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "example": "AQEKZm9vYmFy" }, - "required": true, - "description": "The pull request's id.", - "name": "id", - "in": "path" + "required": false, + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "name": "cursor", + "in": "query" + }, + { + "schema": { + "type": "boolean", + "default": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "example": false + }, + "required": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "name": "includeTotal", + "in": "query" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "description": "Case-insensitive substring match on the name.", + "example": "backend" + }, + "required": false, + "description": "Case-insensitive substring match on the name.", + "name": "q", + "in": "query" } ], "responses": { "200": { - "description": "The updated pull request", + "description": "A page of test collections", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PullRequest" + "$ref": "#/components/schemas/TestCollectionList" } } } }, "400": { - "description": "`VALIDATION_FAILED`", + "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", "content": { "application/json": { "schema": { @@ -12030,6 +16161,15 @@ "message": "Invalid input: expected string, received undefined" } } + }, + "INVALID_CURSOR": { + "summary": "INVALID_CURSOR", + "value": { + "error": { + "code": "INVALID_CURSOR", + "message": "Invalid or expired cursor." + } + } } } } @@ -12065,20 +16205,111 @@ } } }, - "403": { - "description": "`INSUFFICIENT_PERMISSIONS`", + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", + "value": { + "error": { + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" + } + } + } + } + } + } + }, + "429": { + "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "RATE_LIMIT_EXCEEDED": { + "summary": "RATE_LIMIT_EXCEEDED", + "value": { + "error": { + "code": "RATE_LIMIT_EXCEEDED", + "message": "Rate limit exceeded; retry with backoff" + } + } + } + } + } + } + }, + "500": { + "description": "`INTERNAL_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INTERNAL_ERROR": { + "summary": "INTERNAL_ERROR", + "value": { + "error": { + "code": "INTERNAL_ERROR", + "message": "An unexpected error occurred" + } + } + } + } + } + } + } + } + }, + "post": { + "operationId": "testCollections.create", + "tags": ["testCollections"], + "summary": "Create a test collection", + "description": "Creates a test collection and returns it. Its `id` is server-assigned; `testCount` is 0 until the collection's first upload is ingested.", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateTestCollectionRequest" + } + } + } + }, + "responses": { + "201": { + "description": "The created test collection", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TestCollection" + } + } + } + }, + "400": { + "description": "`VALIDATION_FAILED`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "INSUFFICIENT_PERMISSIONS": { - "summary": "INSUFFICIENT_PERMISSIONS", + "VALIDATION_FAILED": { + "summary": "VALIDATION_FAILED", "value": { "error": { - "code": "INSUFFICIENT_PERMISSIONS", - "message": "The supplied credential is missing the required permission" + "code": "VALIDATION_FAILED", + "message": "Invalid input: expected string, received undefined" } } } @@ -12086,41 +16317,29 @@ } } }, - "404": { - "description": "`PR_NOT_FOUND`", + "401": { + "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "PR_NOT_FOUND": { - "summary": "PR_NOT_FOUND", + "AUTHENTICATION_REQUIRED": { + "summary": "AUTHENTICATION_REQUIRED", "value": { "error": { - "code": "PR_NOT_FOUND", - "message": "Pull request not found" + "code": "AUTHENTICATION_REQUIRED", + "message": "No credential was supplied" } } - } - } - } - } - }, - "409": { - "description": "`PR_NOT_IN_ACTIVE_STATE`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "PR_NOT_IN_ACTIVE_STATE": { - "summary": "PR_NOT_IN_ACTIVE_STATE", + }, + "INVALID_TOKEN": { + "summary": "INVALID_TOKEN", "value": { "error": { - "code": "PR_NOT_IN_ACTIVE_STATE", - "message": "This pull request is not in an active queue state" + "code": "INVALID_TOKEN", + "message": "The supplied token failed verification" } } } @@ -12128,20 +16347,20 @@ } } }, - "422": { - "description": "`PR_TESTS_NOT_RESTARTABLE`", + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "PR_TESTS_NOT_RESTARTABLE": { - "summary": "PR_TESTS_NOT_RESTARTABLE", + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", "value": { "error": { - "code": "PR_TESTS_NOT_RESTARTABLE", - "message": "This pull request's tests cannot be restarted in its current state" + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" } } } @@ -12190,68 +16409,37 @@ } } } - }, - "502": { - "description": "`UPSTREAM_ERROR`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "UPSTREAM_ERROR": { - "summary": "UPSTREAM_ERROR", - "value": { - "error": { - "code": "UPSTREAM_ERROR", - "message": "An upstream service did not respond" - } - } - } - } - } - } } } } }, - "/v2/pull-requests/{id}/rerun-failed-checks": { - "post": { - "operationId": "pullRequests.rerunFailedChecks", - "tags": ["pullRequests"], - "summary": "Re-run a pull request's failed checks", - "description": "Requires the **Merge and cancel PRs** permission. Re-runs the failed jobs of the GitHub Actions workflows behind the failed required checks, and keeps the pull request's place in the queue: it stays in `pendingFailure` until the re-run starts or `rerun.until` passes, whichever is first. If the re-run has not started by then, the pull request fails as it would have without the request. Only possible while the entry is in `pendingFailure` on a queue that keeps failed test runs; every refusal is a `422` with its own code.\n\n`mode` is required. **Disruptive** with `mode: now`: it stops the jobs still running in the failed checks' workflows. `mode: wait` lets them finish first. `now` on a request that is waiting switches it to `now` (`rerun.switchedToNow`). `Idempotency-Key` is not honored, but a repeat with the same `mode` is safe: it answers `rerun.alreadyHeld` and changes nothing.", + "/v2/test-collections/{id}": { + "get": { + "operationId": "testCollections.get", + "tags": ["testCollections"], + "summary": "Get a test collection", + "description": "Returns one test collection. `quarantineEnabled` and `autoQuarantineEnabled` are read on every call, so a CI run can check them before it uploads; `testCount` may lag by up to a minute. A collection in another organization is reported as `404`, not `403`.", "parameters": [ { "schema": { "type": "string", - "format": "uuid", - "description": "The pull request's id.", - "example": "0f8fad5b-d9cb-469f-a165-70867728950e" + "pattern": "^[0-9A-Za-z]{8}$", + "description": "The collection's id: 8 alphanumeric characters.", + "example": "aB3xY9kQ" }, "required": true, - "description": "The pull request's id.", + "description": "The collection's id: 8 alphanumeric characters.", "name": "id", "in": "path" } ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RerunFailedChecksRequest" - } - } - } - }, "responses": { "200": { - "description": "The pull request, and the re-run it is waiting for", + "description": "The test collection", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RerunFailedChecksResult" + "$ref": "#/components/schemas/TestCollection" } } } @@ -12307,20 +16495,20 @@ } } }, - "403": { - "description": "`INSUFFICIENT_PERMISSIONS`", + "404": { + "description": "`TEST_COLLECTION_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "INSUFFICIENT_PERMISSIONS": { - "summary": "INSUFFICIENT_PERMISSIONS", + "TEST_COLLECTION_NOT_FOUND": { + "summary": "TEST_COLLECTION_NOT_FOUND", "value": { "error": { - "code": "INSUFFICIENT_PERMISSIONS", - "message": "The supplied credential is missing the required permission" + "code": "TEST_COLLECTION_NOT_FOUND", + "message": "Test collection not found" } } } @@ -12328,29 +16516,20 @@ } } }, - "404": { - "description": "`PR_NOT_FOUND` | `MERGE_QUEUE_NOT_FOUND`", + "429": { + "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "PR_NOT_FOUND": { - "summary": "PR_NOT_FOUND", - "value": { - "error": { - "code": "PR_NOT_FOUND", - "message": "Pull request not found" - } - } - }, - "MERGE_QUEUE_NOT_FOUND": { - "summary": "MERGE_QUEUE_NOT_FOUND", + "RATE_LIMIT_EXCEEDED": { + "summary": "RATE_LIMIT_EXCEEDED", "value": { "error": { - "code": "MERGE_QUEUE_NOT_FOUND", - "message": "Merge queue not found" + "code": "RATE_LIMIT_EXCEEDED", + "message": "Rate limit exceeded; retry with backoff" } } } @@ -12358,104 +16537,157 @@ } } }, - "409": { - "description": "`PR_NOT_IN_ACTIVE_STATE`", + "500": { + "description": "`INTERNAL_ERROR`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "PR_NOT_IN_ACTIVE_STATE": { - "summary": "PR_NOT_IN_ACTIVE_STATE", + "INTERNAL_ERROR": { + "summary": "INTERNAL_ERROR", "value": { "error": { - "code": "PR_NOT_IN_ACTIVE_STATE", - "message": "This pull request is not in an active queue state" + "code": "INTERNAL_ERROR", + "message": "An unexpected error occurred" } } } } } } + } + } + } + }, + "/v2/test-collections/{id}/quarantine-status": { + "post": { + "operationId": "testCollections.getQuarantineStatus", + "tags": ["testCollections"], + "summary": "Get quarantine status for a CI run", + "description": "**Internal.** This endpoint is intended for internal use by Trunk's analytics-cli and test-runner plugins. Use it at your own risk: it may change without notice.\n\nReports which tests are quarantined in a collection for one repository, so a CI run can ignore their failures. Send the run's failing tests as `testIdentifiers` to get an answer for each. This is a read sent as `POST` because the identifier list can be large. Requires the **Upload test results** permission. Quarantine changes reach this response within a minute.", + "parameters": [ + { + "schema": { + "type": "string", + "pattern": "^[0-9A-Za-z]{8}$", + "description": "The collection's id: 8 alphanumeric characters.", + "example": "aB3xY9kQ" + }, + "required": true, + "description": "The collection's id: 8 alphanumeric characters.", + "name": "id", + "in": "path" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/QuarantineStatusRequest" + } + } + } + }, + "responses": { + "200": { + "description": "The collection's quarantine status", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/QuarantineStatus" + } + } + } }, - "422": { - "description": "`PR_RERUN_FEATURE_DISABLED` | `PR_RERUN_NOT_PENDING_FAILURE` | `PR_RERUN_QUEUE_DOES_NOT_KEEP_FAILED_RUNS` | `PR_RERUN_NOT_A_REQUIRED_CHECK_FAILURE` | `PR_RERUN_CHECK_NOT_RERUNNABLE` | `PR_RERUN_RUN_TORN_DOWN` | `PR_RERUN_HOLD_LIMIT_REACHED` | `PR_RERUN_FORGE_NOT_SUPPORTED`", + "400": { + "description": "`VALIDATION_FAILED`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "PR_RERUN_FEATURE_DISABLED": { - "summary": "PR_RERUN_FEATURE_DISABLED", - "value": { - "error": { - "code": "PR_RERUN_FEATURE_DISABLED", - "message": "You cannot re-run failed checks from Trunk on this queue." - } - } - }, - "PR_RERUN_NOT_PENDING_FAILURE": { - "summary": "PR_RERUN_NOT_PENDING_FAILURE", - "value": { - "error": { - "code": "PR_RERUN_NOT_PENDING_FAILURE", - "message": "You cannot re-run checks for this pull request now." - } - } - }, - "PR_RERUN_QUEUE_DOES_NOT_KEEP_FAILED_RUNS": { - "summary": "PR_RERUN_QUEUE_DOES_NOT_KEEP_FAILED_RUNS", - "value": { - "error": { - "code": "PR_RERUN_QUEUE_DOES_NOT_KEEP_FAILED_RUNS", - "message": "This queue does not allow re-runs. A queue admin can turn on \"Accept Manual Re-runs of Failed Required Checks\"." - } - } - }, - "PR_RERUN_NOT_A_REQUIRED_CHECK_FAILURE": { - "summary": "PR_RERUN_NOT_A_REQUIRED_CHECK_FAILURE", + "VALIDATION_FAILED": { + "summary": "VALIDATION_FAILED", "value": { "error": { - "code": "PR_RERUN_NOT_A_REQUIRED_CHECK_FAILURE", - "message": "No required check failed. Use Restart tests." + "code": "VALIDATION_FAILED", + "message": "Invalid input: expected string, received undefined" } } - }, - "PR_RERUN_CHECK_NOT_RERUNNABLE": { - "summary": "PR_RERUN_CHECK_NOT_RERUNNABLE", + } + } + } + } + }, + "401": { + "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "AUTHENTICATION_REQUIRED": { + "summary": "AUTHENTICATION_REQUIRED", "value": { "error": { - "code": "PR_RERUN_CHECK_NOT_RERUNNABLE", - "message": "Trunk can re-run only GitHub Actions checks. Re-run `buildkite/ci` in its own CI, or use Restart tests." + "code": "AUTHENTICATION_REQUIRED", + "message": "No credential was supplied" } } }, - "PR_RERUN_RUN_TORN_DOWN": { - "summary": "PR_RERUN_RUN_TORN_DOWN", + "INVALID_TOKEN": { + "summary": "INVALID_TOKEN", "value": { "error": { - "code": "PR_RERUN_RUN_TORN_DOWN", - "message": "These checks cannot be re-run now. Use Restart tests." + "code": "INVALID_TOKEN", + "message": "The supplied token failed verification" } } - }, - "PR_RERUN_HOLD_LIMIT_REACHED": { - "summary": "PR_RERUN_HOLD_LIMIT_REACHED", + } + } + } + } + }, + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", "value": { "error": { - "code": "PR_RERUN_HOLD_LIMIT_REACHED", - "message": "These checks were already re-run two times. Use Restart tests." + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" } } - }, - "PR_RERUN_FORGE_NOT_SUPPORTED": { - "summary": "PR_RERUN_FORGE_NOT_SUPPORTED", + } + } + } + } + }, + "404": { + "description": "`TEST_COLLECTION_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "TEST_COLLECTION_NOT_FOUND": { + "summary": "TEST_COLLECTION_NOT_FOUND", "value": { "error": { - "code": "PR_RERUN_FORGE_NOT_SUPPORTED", - "message": "Trunk can re-run checks only for GitHub repositories. Use Restart tests." + "code": "TEST_COLLECTION_NOT_FOUND", + "message": "Test collection not found" } } } @@ -12504,60 +16736,90 @@ } } } - }, - "502": { - "description": "`UPSTREAM_ERROR`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "UPSTREAM_ERROR": { - "summary": "UPSTREAM_ERROR", - "value": { - "error": { - "code": "UPSTREAM_ERROR", - "message": "An upstream service did not respond" - } - } - } - } - } - } } } } }, - "/v2/dynamic-ci/generate-plan": { + "/v2/test-collections/{id}/all-quarantined-tests": { "post": { - "operationId": "dynamicCi.generatePlan", - "tags": ["dynamicCi"], - "summary": "Generate a CI skip plan", - "description": "Returns a per-job verdict for one workflow run: which jobs the change makes it safe to skip, and the evidence behind each decision. Normally called once per run by the [`trunk-io/dynamic-ci`](https://github.com/trunk-io/dynamic-ci) action, which maps the verdicts onto job outputs.\n\n**Fail open.** A job absent from `jobs` must be run — that is the contract, not an error. Treat any non-200 the same way.\n\nSend the changed files as `changedFiles` when you can compute them. Without it, Trunk fetches the diff between `baseSha` and `commitSha` through your GitHub App installation, which needs both commits on GitHub.", + "operationId": "testCollections.listAllQuarantinedTests", + "tags": ["testCollections"], + "summary": "List every quarantined test for a CI run", + "description": "**Internal.** This endpoint is intended for internal use by Trunk's analytics-cli and test-runner plugins. Use it at your own risk: it may change without notice.\n\nLists the `testId` of every quarantined test in a collection for one repository, in `testId` order, so a test runner can decide each failure itself as it happens. Name the repository the tests ran in as `repo` in the body, or `null` for an upload without a repository (`--no-repo`); the cursor and `limit` stay in the query. This is a read sent as `POST` so the repository travels in the body, as it does for `quarantine-status`. Every page also carries the collection's `testCollectionUuid`, the `repositoryId` the tests are stored under, and `quarantineEnabled`; while quarantining is off the list is empty. A runner computes each test's `testId` from `testCollectionUuid`, `repositoryId` and its own test id, and matches on it. A page holds up to 25,000 tests. Requires the **Upload test results** permission. Quarantine changes reach this list within a minute, so a test that joins or leaves the set while you page through it may be missed, or still listed, until your next pass.", + "parameters": [ + { + "schema": { + "type": "string", + "pattern": "^[0-9A-Za-z]{8}$", + "description": "The collection's id: 8 alphanumeric characters.", + "example": "aB3xY9kQ" + }, + "required": true, + "description": "The collection's id: 8 alphanumeric characters.", + "name": "id", + "in": "path" + }, + { + "schema": { + "type": "integer", + "minimum": 1, + "maximum": 25000, + "default": 25, + "description": "Page size, between 1 and 25000.", + "example": 25 + }, + "required": false, + "description": "Page size, between 1 and 25000.", + "name": "limit", + "in": "query" + }, + { + "schema": { + "type": "string", + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "example": "AQEKZm9vYmFy" + }, + "required": false, + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "name": "cursor", + "in": "query" + }, + { + "schema": { + "type": "boolean", + "default": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "example": false + }, + "required": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "name": "includeTotal", + "in": "query" + } + ], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/CiPlanRequest" + "$ref": "#/components/schemas/AllQuarantinedTestsRequest" } } } }, "responses": { "200": { - "description": "The plan", + "description": "A page of quarantined tests", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/CiPlan" + "$ref": "#/components/schemas/QuarantinedTestList" } } } }, "400": { - "description": "`VALIDATION_FAILED` | `CI_HOST_UNSUPPORTED`", + "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", "content": { "application/json": { "schema": { @@ -12573,12 +16835,12 @@ } } }, - "CI_HOST_UNSUPPORTED": { - "summary": "CI_HOST_UNSUPPORTED", + "INVALID_CURSOR": { + "summary": "INVALID_CURSOR", "value": { "error": { - "code": "CI_HOST_UNSUPPORTED", - "message": "Dynamic CI does not support the repository host gitlab.example.com" + "code": "INVALID_CURSOR", + "message": "Invalid or expired cursor." } } } @@ -12616,20 +16878,20 @@ } } }, - "404": { - "description": "`REPOSITORY_NOT_FOUND`", + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "REPOSITORY_NOT_FOUND": { - "summary": "REPOSITORY_NOT_FOUND", + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", "value": { "error": { - "code": "REPOSITORY_NOT_FOUND", - "message": "Repository not found" + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" } } } @@ -12637,20 +16899,20 @@ } } }, - "429": { - "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", + "404": { + "description": "`TEST_COLLECTION_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "RATE_LIMIT_EXCEEDED": { - "summary": "RATE_LIMIT_EXCEEDED", + "TEST_COLLECTION_NOT_FOUND": { + "summary": "TEST_COLLECTION_NOT_FOUND", "value": { "error": { - "code": "RATE_LIMIT_EXCEEDED", - "message": "Rate limit exceeded; retry with backoff" + "code": "TEST_COLLECTION_NOT_FOUND", + "message": "Test collection not found" } } } @@ -12658,20 +16920,20 @@ } } }, - "500": { - "description": "`INTERNAL_ERROR`", + "429": { + "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "INTERNAL_ERROR": { - "summary": "INTERNAL_ERROR", + "RATE_LIMIT_EXCEEDED": { + "summary": "RATE_LIMIT_EXCEEDED", "value": { "error": { - "code": "INTERNAL_ERROR", - "message": "An unexpected error occurred" + "code": "RATE_LIMIT_EXCEEDED", + "message": "Rate limit exceeded; retry with backoff" } } } @@ -12679,20 +16941,20 @@ } } }, - "502": { - "description": "`UPSTREAM_ERROR`", + "500": { + "description": "`INTERNAL_ERROR`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "UPSTREAM_ERROR": { - "summary": "UPSTREAM_ERROR", + "INTERNAL_ERROR": { + "summary": "INTERNAL_ERROR", "value": { "error": { - "code": "UPSTREAM_ERROR", - "message": "An upstream service did not respond" + "code": "INTERNAL_ERROR", + "message": "An unexpected error occurred" } } } @@ -12703,35 +16965,63 @@ } } }, - "/v2/dynamic-ci/generate-buildkite-plan": { - "post": { - "operationId": "dynamicCi.generateBuildkitePlan", - "tags": ["dynamicCi"], - "summary": "Generate a CI skip plan for a Buildkite pipeline", - "description": "As [`dynamicCi.generatePlan`](#tag/dynamicCi/operation/dynamicCi.generatePlan), for a Buildkite pipeline. Identical request and response but for the workflow identity: Buildkite has no workflow file, so the pipeline is named by the organization and pipeline slugs its agent exports, and `jobKeys` are step `key:` values.\n\n**Fail open.** A job absent from `jobs` must be run — that is the contract, not an error. Treat any non-200 the same way.\n\nSend the changed files as `changedFiles` when you can compute them. Without it, Trunk fetches the diff between `baseSha` and `commitSha` through your GitHub App installation, which needs both commits on GitHub.", - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/BuildkitePlanRequest" - } - } + "/v2/tests/{testId}": { + "get": { + "operationId": "tests.get", + "tags": ["tests"], + "summary": "Get a test", + "description": "Returns one test by its globally unique id, with the labels, quarantine override and active monitors currently applied to it. Ids come from list responses; they are opaque and not derivable client-side.\n\nA test in another organization is reported as `404`, not `403`, and so is a malformed id — a caller must not be able to probe which ids exist.", + "parameters": [ + { + "schema": { + "type": "string", + "minLength": 1, + "description": "The test's globally unique id.", + "example": "bfeebcf4-0000-8000-8000-000000000001" + }, + "required": true, + "description": "The test's globally unique id.", + "name": "testId", + "in": "path" + }, + { + "schema": { + "type": "string", + "enum": ["metrics"], + "description": "Set to `metrics` to embed this test's metrics for `period`.", + "example": "metrics" + }, + "required": false, + "description": "Set to `metrics` to embed this test's metrics for `period`.", + "name": "include", + "in": "query" + }, + { + "schema": { + "type": "string", + "enum": ["1d", "7d", "14d", "30d"], + "description": "Metrics window. Required with `include=metrics`.", + "example": "7d" + }, + "required": false, + "description": "Metrics window. Required with `include=metrics`.", + "name": "period", + "in": "query" } - }, + ], "responses": { "200": { - "description": "The plan", + "description": "The test", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/CiPlan" + "$ref": "#/components/schemas/Test" } } } }, "400": { - "description": "`VALIDATION_FAILED` | `CI_HOST_UNSUPPORTED`", + "description": "`VALIDATION_FAILED`", "content": { "application/json": { "schema": { @@ -12746,15 +17036,6 @@ "message": "Invalid input: expected string, received undefined" } } - }, - "CI_HOST_UNSUPPORTED": { - "summary": "CI_HOST_UNSUPPORTED", - "value": { - "error": { - "code": "CI_HOST_UNSUPPORTED", - "message": "Dynamic CI does not support the repository host gitlab.example.com" - } - } } } } @@ -12791,19 +17072,19 @@ } }, "404": { - "description": "`REPOSITORY_NOT_FOUND`", + "description": "`TEST_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "REPOSITORY_NOT_FOUND": { - "summary": "REPOSITORY_NOT_FOUND", + "TEST_NOT_FOUND": { + "summary": "TEST_NOT_FOUND", "value": { "error": { - "code": "REPOSITORY_NOT_FOUND", - "message": "Repository not found" + "code": "TEST_NOT_FOUND", + "message": "Test not found" } } } @@ -12852,37 +17133,16 @@ } } } - }, - "502": { - "description": "`UPSTREAM_ERROR`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "UPSTREAM_ERROR": { - "summary": "UPSTREAM_ERROR", - "value": { - "error": { - "code": "UPSTREAM_ERROR", - "message": "An upstream service did not respond" - } - } - } - } - } - } } } } }, - "/v2/dynamic-ci/pr-jobs": { + "/v2/tests": { "get": { - "operationId": "dynamicCi.listPrJobs", - "tags": ["dynamicCi"], - "summary": "List the jobs Dynamic CI sees", - "description": "The workflows that have run on a pull request in this repository recently, with the jobs each defines. Use it to find the `workflowId` and `jobId` to force with `dynamicCi.setForceOverrides`.\n\n`jobKey` is `null` for a job whose key Trunk has not resolved — it can never be skipped, and is listed so that is visible rather than silently missing.", + "operationId": "tests.list", + "tags": ["tests"], + "summary": "List and search tests", + "description": "Lists tests, by default across every test collection in your organization — pass `testCollectionId` to narrow to one. Each row carries the `id` to pass to the per-test endpoints.\n\n`q` searches name, file, class and parent as case-insensitive substrings. Several words are separate requirements, not a phrase — `q=flaky slow` returns tests matching both, in any position. It also accepts per-field qualifiers mixed freely with those words: `q=file:checkout flaky class:PaymentTest`. Qualifier keys are case-sensitive, and an unrecognized prefix is treated as literal text rather than guessed at.\n\nRows omit `quarantineOverride`, `activeMonitors`, `manualFlag`, `firstSeenAt` and `lastFailureAt` — fetch a single test for those.", "parameters": [ { "schema": { @@ -12924,49 +17184,237 @@ { "schema": { "type": "string", - "default": "github.com", - "description": "`github.com` is the only supported value today.", - "example": "github.com" + "minLength": 1, + "description": "Narrow to one collection, by its id. Omitted searches every collection in your organization.", + "example": "aB3xY9kQ" }, "required": false, - "description": "`github.com` is the only supported value today.", - "name": "host", + "description": "Narrow to one collection, by its id. Omitted searches every collection in your organization.", + "name": "testCollectionId", "in": "query" }, { "schema": { "type": "string", "minLength": 1, - "example": "acme" + "description": "Comma-separated statuses to include: `healthy`, `flaky`, `broken`.", + "example": "flaky,broken" }, - "required": true, + "required": false, + "description": "Comma-separated statuses to include: `healthy`, `flaky`, `broken`.", + "name": "status", + "in": "query" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "description": "Free-text search, with optional `file:` / `class:` / `parent:` / `name:` qualifiers.", + "example": "file:checkout flaky" + }, + "required": false, + "description": "Free-text search, with optional `file:` / `class:` / `parent:` / `name:` qualifiers.", + "name": "q", + "in": "query" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "description": "Substring match on the test's file path.", + "example": "src/payments" + }, + "required": false, + "description": "Substring match on the test's file path.", + "name": "file", + "in": "query" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "description": "Exact match on one of the test's code owners.", + "example": "@acme/platform" + }, + "required": false, + "description": "Exact match on one of the test's code owners.", "name": "owner", "in": "query" }, { "schema": { "type": "string", - "minLength": 1, - "example": "widgets" + "minLength": 1, + "description": "Exact match on the test's variant.", + "example": "ubuntu-22.04" + }, + "required": false, + "description": "Exact match on the test's variant.", + "name": "variant", + "in": "query" + }, + { + "schema": { + "type": "string", + "enum": ["metrics"], + "description": "Set to `metrics` to embed each test's metrics for `period` in the same response, instead of fetching them per test.", + "example": "metrics" + }, + "required": false, + "description": "Set to `metrics` to embed each test's metrics for `period` in the same response, instead of fetching them per test.", + "name": "include", + "in": "query" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "description": "Only tests carrying this label, by name. Matched exactly, including case, since two labels may differ only in case. An unknown name returns an empty page, not an error.", + "example": "slow-on-prs" + }, + "required": false, + "description": "Only tests carrying this label, by name. Matched exactly, including case, since two labels may differ only in case. An unknown name returns an empty page, not an error.", + "name": "label", + "in": "query" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "description": "Only tests currently linked to this ticket, by its Trunk id (`ticket.id` on a test). Spans every collection unless `testCollectionId` narrows it. An unknown id returns an empty page, not an error. Cannot be combined with `ticketKey`.", + "example": "5b0e8f8a-1c2d-4e3f-8a9b-0c1d2e3f4a5b" + }, + "required": false, + "description": "Only tests currently linked to this ticket, by its Trunk id (`ticket.id` on a test). Spans every collection unless `testCollectionId` narrows it. An unknown id returns an empty page, not an error. Cannot be combined with `ticketKey`.", + "name": "ticketId", + "in": "query" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "description": "Only tests currently linked to the ticket with this provider key or URL. A convenience: a key can change (a Jira issue moved between projects) and two connections can share one, so prefer `ticketId`, and pass `integrationId` to narrow to one connection. An unknown key returns an empty page.", + "example": "TRUNK-12345" + }, + "required": false, + "description": "Only tests currently linked to the ticket with this provider key or URL. A convenience: a key can change (a Jira issue moved between projects) and two connections can share one, so prefer `ticketId`, and pass `integrationId` to narrow to one connection. An unknown key returns an empty page.", + "name": "ticketKey", + "in": "query" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "description": "The ticketing connection `ticketKey` is looked up in. Only valid with `ticketKey`.", + "example": "6c1f9a9b-2d3e-4f40-9b0c-1d2e3f4a5b6c" + }, + "required": false, + "description": "The ticketing connection `ticketKey` is looked up in. Only valid with `ticketKey`.", + "name": "integrationId", + "in": "query" + }, + { + "schema": { + "type": "string", + "enum": ["quarantined", "notQuarantined"], + "description": "Filter on effective quarantine state, derived from the test's status, its collection's quarantine settings and any per-test override.", + "example": "quarantined" + }, + "required": false, + "description": "Filter on effective quarantine state, derived from the test's status, its collection's quarantine settings and any per-test override.", + "name": "quarantineState", + "in": "query" + }, + { + "schema": { + "type": "string", + "enum": ["alwaysQuarantine", "neverQuarantine", "any"], + "description": "Only tests with a quarantine override, as set by `POST /v2/tests/{testId}/quarantine`: `alwaysQuarantine` or `neverQuarantine` for one mode, `any` for either. Matches the mode of a test's `quarantineOverride`, so a cleared override matches nothing. It filters on the override alone, whether or not the test's collection has quarantining turned on; combine it with `quarantineState` for the effective state.", + "example": "neverQuarantine" + }, + "required": false, + "description": "Only tests with a quarantine override, as set by `POST /v2/tests/{testId}/quarantine`: `alwaysQuarantine` or `neverQuarantine` for one mode, `any` for either. Matches the mode of a test's `quarantineOverride`, so a cleared override matches nothing. It filters on the override alone, whether or not the test's collection has quarantining turned on; combine it with `quarantineState` for the effective state.", + "name": "quarantineOverride", + "in": "query" + }, + { + "schema": { + "type": "boolean", + "description": "Filter on whether the manual 'flag as flaky' mark is currently set.", + "example": true + }, + "required": false, + "description": "Filter on whether the manual 'flag as flaky' mark is currently set.", + "name": "markedFlaky", + "in": "query" + }, + { + "schema": { + "type": "boolean", + "description": "Only tests that first became flaky inside `period`. Requires `period`.", + "example": true + }, + "required": false, + "description": "Only tests that first became flaky inside `period`. Requires `period`.", + "name": "newlyFlaky", + "in": "query" + }, + { + "schema": { + "type": "string", + "enum": ["1d", "7d", "14d", "30d"], + "description": "Metrics window for `include=metrics`, any metric `sort`, and `newlyFlaky`. Required by each of them.", + "example": "7d" + }, + "required": false, + "description": "Metrics window for `include=metrics`, any metric `sort`, and `newlyFlaky`. Required by each of them.", + "name": "period", + "in": "query" + }, + { + "schema": { + "type": "string", + "enum": [ + "name", + "failureRate", + "durationP95", + "prsImpacted", + "lastRunAt", + "lastFailureAt" + ], + "default": "name", + "description": "Field to sort by. A metric sort requires `period`, and excludes tests with no comparable value in it — no runs at all for most metrics, and additionally no failure for `lastFailureAt`." + }, + "required": false, + "description": "Field to sort by. A metric sort requires `period`, and excludes tests with no comparable value in it — no runs at all for most metrics, and additionally no failure for `lastFailureAt`.", + "name": "sort", + "in": "query" + }, + { + "schema": { + "type": "string", + "enum": ["asc", "desc"], + "description": "Sort direction. Defaults per sort: ascending for `name`, descending for every metric sort, which order worst-first." }, - "required": true, - "name": "name", + "required": false, + "description": "Sort direction. Defaults per sort: ascending for `name`, descending for every metric sort, which order worst-first.", + "name": "direction", "in": "query" } ], "responses": { "200": { - "description": "A page of workflows", + "description": "A page of tests", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/CiWorkflowList" + "$ref": "#/components/schemas/TestList" } } } }, "400": { - "description": "`VALIDATION_FAILED` | `INVALID_CURSOR` | `CI_HOST_UNSUPPORTED`", + "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", "content": { "application/json": { "schema": { @@ -12990,15 +17438,6 @@ "message": "Invalid or expired cursor." } } - }, - "CI_HOST_UNSUPPORTED": { - "summary": "CI_HOST_UNSUPPORTED", - "value": { - "error": { - "code": "CI_HOST_UNSUPPORTED", - "message": "Dynamic CI does not support the repository host gitlab.example.com" - } - } } } } @@ -13034,20 +17473,20 @@ } } }, - "404": { - "description": "`REPOSITORY_NOT_FOUND`", + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "REPOSITORY_NOT_FOUND": { - "summary": "REPOSITORY_NOT_FOUND", + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", "value": { "error": { - "code": "REPOSITORY_NOT_FOUND", - "message": "Repository not found" + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" } } } @@ -13100,13 +17539,25 @@ } } }, - "/v2/dynamic-ci/force-overrides": { + "/v2/tests/{testId}/status-history": { "get": { - "operationId": "dynamicCi.listForceOverrides", - "tags": ["dynamicCi"], - "summary": "List a pull request's force overrides", - "description": "The forces currently active on a pull request. A force makes Dynamic CI run the jobs it covers whatever the signals say. `workflowId` and `jobId` are the ids `dynamicCi.listPrJobs` returns; revoked forces are retained for audit but not listed.", + "operationId": "tests.listStatusHistory", + "tags": ["tests"], + "summary": "List a test's status transitions", + "description": "Returns the test's status transitions, newest first. A row is recorded only when the composite status changes, so `fromStatus` is the status it moved away from and the series has no repeats.\n\n`activeMonitors` is the set active immediately after each transition, as recorded at the time. Transitions predating this report an empty set.", "parameters": [ + { + "schema": { + "type": "string", + "minLength": 1, + "description": "The test's globally unique id.", + "example": "bfeebcf4-0000-8000-8000-000000000001" + }, + "required": true, + "description": "The test's globally unique id.", + "name": "testId", + "in": "path" + }, { "schema": { "type": "integer", @@ -13147,59 +17598,41 @@ { "schema": { "type": "string", - "default": "github.com", - "description": "`github.com` is the only supported value today.", - "example": "github.com" + "format": "date-time", + "description": "Only transitions at or after this time.", + "example": "2026-06-01T00:00:00.000Z" }, "required": false, - "description": "`github.com` is the only supported value today.", - "name": "host", - "in": "query" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "example": "acme" - }, - "required": true, - "name": "owner", + "description": "Only transitions at or after this time.", + "name": "startedAfter", "in": "query" }, { "schema": { "type": "string", - "minLength": 1, - "example": "widgets" - }, - "required": true, - "name": "name", - "in": "query" - }, - { - "schema": { - "type": "integer", - "exclusiveMinimum": 0, - "example": 4213 + "format": "date-time", + "description": "Only transitions strictly before this time.", + "example": "2026-06-30T00:00:00.000Z" }, - "required": true, - "name": "prNumber", + "required": false, + "description": "Only transitions strictly before this time.", + "name": "startedBefore", "in": "query" } ], "responses": { "200": { - "description": "A page of active forces", + "description": "A page of status transitions", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ForceOverrideList" + "$ref": "#/components/schemas/StatusHistoryEntryList" } } } }, "400": { - "description": "`VALIDATION_FAILED` | `INVALID_CURSOR` | `CI_HOST_UNSUPPORTED`", + "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", "content": { "application/json": { "schema": { @@ -13223,15 +17656,6 @@ "message": "Invalid or expired cursor." } } - }, - "CI_HOST_UNSUPPORTED": { - "summary": "CI_HOST_UNSUPPORTED", - "value": { - "error": { - "code": "CI_HOST_UNSUPPORTED", - "message": "Dynamic CI does not support the repository host gitlab.example.com" - } - } } } } @@ -13268,19 +17692,19 @@ } }, "404": { - "description": "`REPOSITORY_NOT_FOUND`", + "description": "`TEST_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "REPOSITORY_NOT_FOUND": { - "summary": "REPOSITORY_NOT_FOUND", + "TEST_NOT_FOUND": { + "summary": "TEST_NOT_FOUND", "value": { "error": { - "code": "REPOSITORY_NOT_FOUND", - "message": "Repository not found" + "code": "TEST_NOT_FOUND", + "message": "Test not found" } } } @@ -13309,50 +17733,171 @@ } } }, - "500": { - "description": "`INTERNAL_ERROR`", + "500": { + "description": "`INTERNAL_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INTERNAL_ERROR": { + "summary": "INTERNAL_ERROR", + "value": { + "error": { + "code": "INTERNAL_ERROR", + "message": "An unexpected error occurred" + } + } + } + } + } + } + } + } + } + }, + "/v2/tests/{testId}/test-runs": { + "get": { + "operationId": "tests.listTestRuns", + "tags": ["tests"], + "summary": "List a test's runs", + "description": "Returns the individual runs recorded for a test, newest first, each with the branch, commit and CI job it came from.\n\n`branches` takes shell-style globs, where `*` matches any run of characters and `?` exactly one (`main,release-?.*`); `pullRequestOnly=true` selects pull-request runs instead. They are alternatives, so sending both is a `400` rather than a silent intersection.\n\n`startedAfter` and `startedBefore` bound when the run started, as your CI reported it.", + "parameters": [ + { + "schema": { + "type": "string", + "minLength": 1, + "description": "The test's globally unique id.", + "example": "bfeebcf4-0000-8000-8000-000000000001" + }, + "required": true, + "description": "The test's globally unique id.", + "name": "testId", + "in": "path" + }, + { + "schema": { + "type": "integer", + "minimum": 1, + "maximum": 100, + "default": 25, + "description": "Page size, between 1 and 100.", + "example": 25 + }, + "required": false, + "description": "Page size, between 1 and 100.", + "name": "limit", + "in": "query" + }, + { + "schema": { + "type": "string", + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "example": "AQEKZm9vYmFy" + }, + "required": false, + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "name": "cursor", + "in": "query" + }, + { + "schema": { + "type": "boolean", + "default": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "example": false + }, + "required": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "name": "includeTotal", + "in": "query" + }, + { + "schema": { + "type": "string", + "enum": ["success", "failure", "skipped"], + "description": "Only runs that finished this way.", + "example": "failure" + }, + "required": false, + "description": "Only runs that finished this way.", + "name": "conclusion", + "in": "query" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "description": "Comma-separated branch globs, e.g. `main,release-*`. `*` matches any run of characters, `?` exactly one. Cannot be combined with `pullRequestOnly`.", + "example": "main,release-*" + }, + "required": false, + "description": "Comma-separated branch globs, e.g. `main,release-*`. `*` matches any run of characters, `?` exactly one. Cannot be combined with `pullRequestOnly`.", + "name": "branches", + "in": "query" + }, + { + "schema": { + "type": "boolean", + "description": "Only runs on pull-request branches. Cannot be combined with `branches`.", + "example": true + }, + "required": false, + "description": "Only runs on pull-request branches. Cannot be combined with `branches`.", + "name": "pullRequestOnly", + "in": "query" + }, + { + "schema": { + "type": "string", + "enum": ["quarantined", "notQuarantined"], + "description": "Only runs recorded while the test was in this quarantine state.", + "example": "quarantined" + }, + "required": false, + "description": "Only runs recorded while the test was in this quarantine state.", + "name": "quarantineState", + "in": "query" + }, + { + "schema": { + "type": "string", + "format": "date-time", + "description": "Only runs that started at or after this time.", + "example": "2026-06-01T00:00:00.000Z" + }, + "required": false, + "description": "Only runs that started at or after this time.", + "name": "startedAfter", + "in": "query" + }, + { + "schema": { + "type": "string", + "format": "date-time", + "description": "Only runs that started strictly before this time.", + "example": "2026-06-30T00:00:00.000Z" + }, + "required": false, + "description": "Only runs that started strictly before this time.", + "name": "startedBefore", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A page of test runs", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "INTERNAL_ERROR": { - "summary": "INTERNAL_ERROR", - "value": { - "error": { - "code": "INTERNAL_ERROR", - "message": "An unexpected error occurred" - } - } - } + "$ref": "#/components/schemas/TestRunList" } } } - } - } - }, - "put": { - "operationId": "dynamicCi.setForceOverrides", - "tags": ["dynamicCi"], - "summary": "Replace a pull request's force overrides", - "description": "Sets the complete list of forces active on a pull request. **This replaces the set, it does not add to it** — a force you omit is revoked, and an empty list clears them all. Send the desired end state, not a delta.\n\nScopes are addressed by the `workflowId` and `jobId` that `dynamicCi.listPrJobs` returns. An already-active force is left alone, so re-sending an unchanged list changes nothing. Forces are applied the next time `dynamicCi.generatePlan` runs for this pull request; this does not re-run anything itself.", - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SetForceOverridesRequest" - } - } - } - }, - "responses": { - "204": { - "description": "The forces were replaced" }, "400": { - "description": "`VALIDATION_FAILED` | `CI_HOST_UNSUPPORTED`", + "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", "content": { "application/json": { "schema": { @@ -13368,12 +17913,12 @@ } } }, - "CI_HOST_UNSUPPORTED": { - "summary": "CI_HOST_UNSUPPORTED", + "INVALID_CURSOR": { + "summary": "INVALID_CURSOR", "value": { "error": { - "code": "CI_HOST_UNSUPPORTED", - "message": "Dynamic CI does not support the repository host gitlab.example.com" + "code": "INVALID_CURSOR", + "message": "Invalid or expired cursor." } } } @@ -13412,28 +17957,19 @@ } }, "404": { - "description": "`REPOSITORY_NOT_FOUND` | `CI_SCOPE_NOT_FOUND`", + "description": "`TEST_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "REPOSITORY_NOT_FOUND": { - "summary": "REPOSITORY_NOT_FOUND", - "value": { - "error": { - "code": "REPOSITORY_NOT_FOUND", - "message": "Repository not found" - } - } - }, - "CI_SCOPE_NOT_FOUND": { - "summary": "CI_SCOPE_NOT_FOUND", + "TEST_NOT_FOUND": { + "summary": "TEST_NOT_FOUND", "value": { "error": { - "code": "CI_SCOPE_NOT_FOUND", - "message": "A workflow or job in the request does not belong to this repository" + "code": "TEST_NOT_FOUND", + "message": "Test not found" } } } @@ -13486,12 +18022,12 @@ } } }, - "/v2/dynamic-ci/paths-filters": { + "/v2/detection-events": { "get": { - "operationId": "dynamicCi.listPathsFilters", - "tags": ["dynamicCi"], - "summary": "List a repository's paths filters", - "description": "Every paths filter in the repository, each with the jobs it gates. A paths filter decides which changed files make a job run, on pull requests and in the merge queue alike. An item with jobs can be sent back as one `filters` entry of `dynamicCi.setPathsFilters`, with its `name`, `rules` and `jobs`. A job the web app gave one filter for pull requests and another for the merge queue is listed under both: sending both items back leaves it as is, and sending one alone is a conflict, since the job also has the other filter.", + "operationId": "detectionEvents.list", + "tags": ["detectionEvents"], + "summary": "List detection events", + "description": "Lists each verdict a monitor recorded on a test: `active` when it detected the condition it watches for, `inactive` when the test recovered or the monitor was disabled or deleted. An `active` event whose `deactivationReason` is `classifyActionChanged` records a change to the monitor's classify action, not a detection. By default it reads every test collection in your organization; pass `testCollectionId` to narrow to one.\n\nThe window is `detectedAfter` to `detectedBefore`, at most 30 days. `detectedBefore` defaults to now and `detectedAfter` to 30 days before it. A wider window is a `400 OUT_OF_RANGE`.\n\nAn unknown `monitorId` or `testId` returns an empty page. The 'flag as flaky' mark is not listed here: see a test's status history.", "parameters": [ { "schema": { @@ -13533,49 +18069,136 @@ { "schema": { "type": "string", - "default": "github.com", - "description": "`github.com` is the only supported value today.", - "example": "github.com" + "minLength": 1, + "description": "Narrow to one collection, by its id. Omitted reads every collection in your organization.", + "example": "aB3xY9kQ" }, "required": false, - "description": "`github.com` is the only supported value today.", - "name": "host", + "description": "Narrow to one collection, by its id. Omitted reads every collection in your organization.", + "name": "testCollectionId", "in": "query" }, { "schema": { "type": "string", "minLength": 1, - "example": "acme" + "description": "Only events this monitor recorded.", + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" }, - "required": true, - "name": "owner", + "required": false, + "description": "Only events this monitor recorded.", + "name": "monitorId", "in": "query" }, { "schema": { "type": "string", "minLength": 1, - "example": "widgets" + "description": "Comma-separated monitor types to include, e.g. `failureRate,passOnRetry`.", + "example": "failureRate,passOnRetry" }, - "required": true, - "name": "name", + "required": false, + "description": "Comma-separated monitor types to include, e.g. `failureRate,passOnRetry`.", + "name": "monitorType", + "in": "query" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "description": "Only events on this test, by its globally unique id.", + "example": "bfeebcf4-0000-8000-8000-000000000001" + }, + "required": false, + "description": "Only events on this test, by its globally unique id.", + "name": "testId", + "in": "query" + }, + { + "schema": { + "type": "string", + "enum": ["active", "inactive"], + "description": "Only events with this verdict.", + "example": "active" + }, + "required": false, + "description": "Only events with this verdict.", + "name": "monitorStatus", + "in": "query" + }, + { + "schema": { + "type": "boolean", + "description": "`true` for only the events that carry a classify action, `false` for only those that do not.", + "example": true + }, + "required": false, + "description": "`true` for only the events that carry a classify action, `false` for only those that do not.", + "name": "isClassificationEvent", + "in": "query" + }, + { + "schema": { + "type": "string", + "format": "date-time", + "description": "Only events detected at or after this time.", + "example": "2026-06-01T00:00:00.000Z" + }, + "required": false, + "description": "Only events detected at or after this time.", + "name": "detectedAfter", + "in": "query" + }, + { + "schema": { + "type": "string", + "format": "date-time", + "description": "Only events detected strictly before this time.", + "example": "2026-06-30T00:00:00.000Z" + }, + "required": false, + "description": "Only events detected strictly before this time.", + "name": "detectedBefore", + "in": "query" + }, + { + "schema": { + "type": "string", + "enum": ["detectedAt"], + "default": "detectedAt", + "description": "Field to sort by." + }, + "required": false, + "description": "Field to sort by.", + "name": "sort", + "in": "query" + }, + { + "schema": { + "type": "string", + "enum": ["asc", "desc"], + "default": "desc", + "description": "Sort direction. Newest first by default." + }, + "required": false, + "description": "Sort direction. Newest first by default.", + "name": "direction", "in": "query" } ], "responses": { "200": { - "description": "A page of paths filters", + "description": "A page of detection events", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PathsFilterWithJobsList" + "$ref": "#/components/schemas/DetectionEventList" } } } }, "400": { - "description": "`VALIDATION_FAILED` | `INVALID_CURSOR` | `CI_HOST_UNSUPPORTED`", + "description": "`VALIDATION_FAILED` | `INVALID_CURSOR` | `OUT_OF_RANGE`", "content": { "application/json": { "schema": { @@ -13600,12 +18223,12 @@ } } }, - "CI_HOST_UNSUPPORTED": { - "summary": "CI_HOST_UNSUPPORTED", + "OUT_OF_RANGE": { + "summary": "OUT_OF_RANGE", "value": { "error": { - "code": "CI_HOST_UNSUPPORTED", - "message": "Dynamic CI does not support the repository host gitlab.example.com" + "code": "OUT_OF_RANGE", + "message": "The requested time window is wider than the endpoint allows" } } } @@ -13643,20 +18266,20 @@ } } }, - "404": { - "description": "`REPOSITORY_NOT_FOUND`", + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "REPOSITORY_NOT_FOUND": { - "summary": "REPOSITORY_NOT_FOUND", + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", "value": { "error": { - "code": "REPOSITORY_NOT_FOUND", - "message": "Repository not found" + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" } } } @@ -13707,35 +18330,51 @@ } } } - }, - "patch": { - "operationId": "dynamicCi.setPathsFilters", - "tags": ["dynamicCi"], - "summary": "Set or clear paths filters on jobs", - "description": "Requires the **Update Dynamic CI settings** permission.\n\nSets a paths filter on each job named in `filters`, and removes it from each job in `clear`. Name a job by its workflow file and its key under `jobs:`. Each filter applies to pull requests and the merge queue alike. A request names at most 500 jobs in all, across every `filters[].jobs` and `clear`.\n\nIt changes only the jobs it names. It never deletes a filter; one the request leaves with no jobs stays in the list, with no jobs. Sending the same body again changes nothing, so no `Idempotency-Key` is needed. A job that already has a different filter fails the request with `PATHS_FILTER_CONFLICT` unless `overwrite` is true. Any error means nothing was written.", + } + }, + "/v2/tests/{testId}/add-labels": { + "post": { + "operationId": "tests.addLabels", + "tags": ["tests"], + "summary": "Add labels to a test", + "description": "Requires the **Flag tests** permission.\n\nApplies 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.\n\nAnswers the test's labels after the change, in the shape of `Test.labels`, read in the same transaction as the write.\n\nA label changes no status, so this sends no webhook and does not reconcile the test.\n\nThe `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.\n\nThe 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`.\n\n`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.\n\nA test in another organization is reported as `404`, not `403`.", + "parameters": [ + { + "schema": { + "type": "string", + "minLength": 1, + "description": "The test's globally unique id.", + "example": "bfeebcf4-0000-8000-8000-000000000001" + }, + "required": true, + "description": "The test's globally unique id.", + "name": "testId", + "in": "path" + } + ], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/SetPathsFiltersRequest" + "$ref": "#/components/schemas/TestLabelsRequest" } } } }, "responses": { "200": { - "description": "What the request did to each job", + "description": "The test's labels after the change", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/SetPathsFiltersResult" + "$ref": "#/components/schemas/TestLabels" } } } }, "400": { - "description": "`VALIDATION_FAILED` | `CI_HOST_UNSUPPORTED`", + "description": "`VALIDATION_FAILED`", "content": { "application/json": { "schema": { @@ -13750,15 +18389,6 @@ "message": "Invalid input: expected string, received undefined" } } - }, - "CI_HOST_UNSUPPORTED": { - "summary": "CI_HOST_UNSUPPORTED", - "value": { - "error": { - "code": "CI_HOST_UNSUPPORTED", - "message": "Dynamic CI does not support the repository host gitlab.example.com" - } - } } } } @@ -13816,49 +18446,19 @@ } }, "404": { - "description": "`REPOSITORY_NOT_FOUND` | `CI_SCOPE_NOT_FOUND`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "REPOSITORY_NOT_FOUND": { - "summary": "REPOSITORY_NOT_FOUND", - "value": { - "error": { - "code": "REPOSITORY_NOT_FOUND", - "message": "Repository not found" - } - } - }, - "CI_SCOPE_NOT_FOUND": { - "summary": "CI_SCOPE_NOT_FOUND", - "value": { - "error": { - "code": "CI_SCOPE_NOT_FOUND", - "message": "A workflow or job in the request does not belong to this repository" - } - } - } - } - } - } - }, - "409": { - "description": "`PATHS_FILTER_CONFLICT`", + "description": "`TEST_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "PATHS_FILTER_CONFLICT": { - "summary": "PATHS_FILTER_CONFLICT", + "TEST_NOT_FOUND": { + "summary": "TEST_NOT_FOUND", "value": { "error": { - "code": "PATHS_FILTER_CONFLICT", - "message": "1 job already has a different paths filter: .github/workflows/ci.yml test (job 3c4f8e21-6a1d-4b7e-9f02-5d8c1a2b3e4f, \"backend\"). Send \"overwrite\": true to replace them." + "code": "TEST_NOT_FOUND", + "message": "Test not found" } } } @@ -13911,76 +18511,49 @@ } } }, - "/v2/test-collections": { - "get": { - "operationId": "testCollections.list", - "tags": ["testCollections"], - "summary": "List test collections", - "description": "Lists the test collections in your organization, newest first. Every other flaky-tests endpoint takes a collection's `id` from here, either as a filter or in a request body.", + "/v2/tests/{testId}/remove-labels": { + "post": { + "operationId": "tests.removeLabels", + "tags": ["tests"], + "summary": "Remove labels from a test", + "description": "Requires the **Flag tests** permission.\n\nRemoves each named label's hand-applied source from the test. A label a monitor also applies stays on the test, with only its `monitor` sources, until the monitor stops applying it; mute the monitor for the test to stop it sooner. A name the organization has no label for, or one not applied to this test by hand, is ignored. Labels themselves are not deleted.\n\nAnswers the test's labels after the change, in the shape of `Test.labels`, read in the same transaction as the write.\n\nA label changes no status, so this sends no webhook and does not reconcile the test.\n\nThe `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.\n\nThe 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`.\n\n`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.\n\nA test in another organization is reported as `404`, not `403`.", "parameters": [ - { - "schema": { - "type": "integer", - "minimum": 1, - "maximum": 100, - "default": 25, - "description": "Page size, between 1 and 100.", - "example": 25 - }, - "required": false, - "description": "Page size, between 1 and 100.", - "name": "limit", - "in": "query" - }, - { - "schema": { - "type": "string", - "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", - "example": "AQEKZm9vYmFy" - }, - "required": false, - "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", - "name": "cursor", - "in": "query" - }, - { - "schema": { - "type": "boolean", - "default": false, - "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", - "example": false - }, - "required": false, - "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", - "name": "includeTotal", - "in": "query" - }, { "schema": { "type": "string", "minLength": 1, - "description": "Case-insensitive substring match on the name.", - "example": "backend" + "description": "The test's globally unique id.", + "example": "bfeebcf4-0000-8000-8000-000000000001" }, - "required": false, - "description": "Case-insensitive substring match on the name.", - "name": "q", - "in": "query" + "required": true, + "description": "The test's globally unique id.", + "name": "testId", + "in": "path" } ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TestLabelsRequest" + } + } + } + }, "responses": { "200": { - "description": "A page of test collections", + "description": "The test's labels after the change", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/TestCollectionList" + "$ref": "#/components/schemas/TestLabels" } } } }, "400": { - "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", + "description": "`VALIDATION_FAILED`", "content": { "application/json": { "schema": { @@ -13995,15 +18568,6 @@ "message": "Invalid input: expected string, received undefined" } } - }, - "INVALID_CURSOR": { - "summary": "INVALID_CURSOR", - "value": { - "error": { - "code": "INVALID_CURSOR", - "message": "Invalid or expired cursor." - } - } } } } @@ -14060,6 +18624,27 @@ } } }, + "404": { + "description": "`TEST_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "TEST_NOT_FOUND": { + "summary": "TEST_NOT_FOUND", + "value": { + "error": { + "code": "TEST_NOT_FOUND", + "message": "Test not found" + } + } + } + } + } + } + }, "429": { "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", "content": { @@ -14103,35 +18688,101 @@ } } } - }, - "post": { - "operationId": "testCollections.create", - "tags": ["testCollections"], - "summary": "Create a test collection", - "description": "Creates a test collection and returns it. Its `id` is server-assigned; `testCount` is 0 until the collection's first upload is ingested.", - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateTestCollectionRequest" - } - } + } + }, + "/v2/monitors": { + "get": { + "operationId": "monitors.list", + "tags": ["monitors"], + "summary": "List monitors", + "description": "Lists the monitors of every test collection in your organization, oldest first. Pass `testCollectionId` to narrow to one collection. Each monitor's `config` holds the fields of its `monitorType`. A deleted monitor is not listed.", + "parameters": [ + { + "schema": { + "type": "integer", + "minimum": 1, + "maximum": 100, + "default": 25, + "description": "Page size, between 1 and 100.", + "example": 25 + }, + "required": false, + "description": "Page size, between 1 and 100.", + "name": "limit", + "in": "query" + }, + { + "schema": { + "type": "string", + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "example": "AQEKZm9vYmFy" + }, + "required": false, + "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", + "name": "cursor", + "in": "query" + }, + { + "schema": { + "type": "boolean", + "default": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "example": false + }, + "required": false, + "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", + "name": "includeTotal", + "in": "query" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "description": "Narrow to one collection, by its id. Omitted reads every collection in your organization.", + "example": "aB3xY9kQ" + }, + "required": false, + "description": "Narrow to one collection, by its id. Omitted reads every collection in your organization.", + "name": "testCollectionId", + "in": "query" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "description": "Comma-separated monitor types to include, e.g. `failureRate,passOnRetry`.", + "example": "failureRate,passOnRetry" + }, + "required": false, + "description": "Comma-separated monitor types to include, e.g. `failureRate,passOnRetry`.", + "name": "monitorType", + "in": "query" + }, + { + "schema": { + "type": "boolean", + "description": "`true` for only enabled monitors, `false` for only disabled ones.", + "example": true + }, + "required": false, + "description": "`true` for only enabled monitors, `false` for only disabled ones.", + "name": "enabled", + "in": "query" } - }, + ], "responses": { - "201": { - "description": "The created test collection", + "200": { + "description": "A page of monitors", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/TestCollection" + "$ref": "#/components/schemas/MonitorList" } } } }, "400": { - "description": "`VALIDATION_FAILED`", + "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", "content": { "application/json": { "schema": { @@ -14142,8 +18793,17 @@ "summary": "VALIDATION_FAILED", "value": { "error": { - "code": "VALIDATION_FAILED", - "message": "Invalid input: expected string, received undefined" + "code": "VALIDATION_FAILED", + "message": "Invalid input: expected string, received undefined" + } + } + }, + "INVALID_CURSOR": { + "summary": "INVALID_CURSOR", + "value": { + "error": { + "code": "INVALID_CURSOR", + "message": "Invalid or expired cursor." } } } @@ -14247,33 +18907,33 @@ } } }, - "/v2/test-collections/{id}": { + "/v2/monitors/{monitorId}": { "get": { - "operationId": "testCollections.get", - "tags": ["testCollections"], - "summary": "Get a test collection", - "description": "Returns one test collection. `quarantineEnabled` and `autoQuarantineEnabled` are read on every call, so a CI run can check them before it uploads; `testCount` may lag by up to a minute. A collection in another organization is reported as `404`, not `403`.", + "operationId": "monitors.get", + "tags": ["monitors"], + "summary": "Get a monitor", + "description": "Returns one monitor, its configuration and how many tests it holds. A deleted monitor, or one in another organization, is reported as `404`.", "parameters": [ { "schema": { "type": "string", - "pattern": "^[0-9A-Za-z]{8}$", - "description": "The collection's id: 8 alphanumeric characters.", - "example": "aB3xY9kQ" + "minLength": 1, + "description": "The monitor's id.", + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" }, "required": true, - "description": "The collection's id: 8 alphanumeric characters.", - "name": "id", + "description": "The monitor's id.", + "name": "monitorId", "in": "path" } ], "responses": { "200": { - "description": "The test collection", + "description": "The monitor", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/TestCollection" + "$ref": "#/components/schemas/Monitor" } } } @@ -14330,19 +18990,19 @@ } }, "404": { - "description": "`TEST_COLLECTION_NOT_FOUND`", + "description": "`MONITOR_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "TEST_COLLECTION_NOT_FOUND": { - "summary": "TEST_COLLECTION_NOT_FOUND", + "MONITOR_NOT_FOUND": { + "summary": "MONITOR_NOT_FOUND", "value": { "error": { - "code": "TEST_COLLECTION_NOT_FOUND", - "message": "Test collection not found" + "code": "MONITOR_NOT_FOUND", + "message": "Monitor not found" } } } @@ -14393,25 +19053,23 @@ } } } - } - }, - "/v2/test-collections/{id}/quarantine-status": { - "post": { - "operationId": "testCollections.getQuarantineStatus", - "tags": ["testCollections"], - "summary": "Get quarantine status for a CI run", - "description": "**Internal.** This endpoint is intended for internal use by Trunk's analytics-cli and test-runner plugins. Use it at your own risk: it may change without notice.\n\nReports which tests are quarantined in a collection for one repository, so a CI run can ignore their failures. Send the run's failing tests as `testIdentifiers` to get an answer for each. This is a read sent as `POST` because the identifier list can be large. Requires the **Upload test results** permission. Quarantine changes reach this response within a minute.", + }, + "patch": { + "operationId": "monitors.update", + "tags": ["monitors"], + "summary": "Edit a monitor", + "description": "Requires the **Manage monitors** permission.\n\nA merge patch: `name`, `enabled` and the fields of `config` that are sent change, and the rest keep their values. `null` unsets an optional config field. `monitorType` cannot change. A `config` that is valid only for another monitor type is a `422`, and one that mixes fields of two types is a `400`; a value out of range, or `branches` with `pullRequestOnly: true`, is a `400`. Sending `pullRequestOnly: false` alone makes a pull-request-only monitor watch every branch.\n\nTurning a monitor off deactivates it on every test it is active on, shortly after this answers, as it does in the web app: a test it classified recovers unless another monitor holds it. A config change takes effect at the monitor's next detection run.\n\nThe change is recorded as made by the person whose token made the call.\n\n`Idempotency-Key` is not honored. The edit is idempotent by state.\n\nA monitor in another organization is reported as `404`, not `403`.", "parameters": [ { "schema": { "type": "string", - "pattern": "^[0-9A-Za-z]{8}$", - "description": "The collection's id: 8 alphanumeric characters.", - "example": "aB3xY9kQ" + "minLength": 1, + "description": "The monitor's id.", + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" }, "required": true, - "description": "The collection's id: 8 alphanumeric characters.", - "name": "id", + "description": "The monitor's id.", + "name": "monitorId", "in": "path" } ], @@ -14420,18 +19078,18 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/QuarantineStatusRequest" + "$ref": "#/components/schemas/UpdateMonitorRequest" } } } }, "responses": { "200": { - "description": "The collection's quarantine status", + "description": "The monitor after the edit", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/QuarantineStatus" + "$ref": "#/components/schemas/Monitor" } } } @@ -14509,19 +19167,40 @@ } }, "404": { - "description": "`TEST_COLLECTION_NOT_FOUND`", + "description": "`MONITOR_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "TEST_COLLECTION_NOT_FOUND": { - "summary": "TEST_COLLECTION_NOT_FOUND", + "MONITOR_NOT_FOUND": { + "summary": "MONITOR_NOT_FOUND", "value": { "error": { - "code": "TEST_COLLECTION_NOT_FOUND", - "message": "Test collection not found" + "code": "MONITOR_NOT_FOUND", + "message": "Monitor not found" + } + } + } + } + } + } + }, + "422": { + "description": "`VALIDATION_FAILED`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "VALIDATION_FAILED": { + "summary": "VALIDATION_FAILED", + "value": { + "error": { + "code": "VALIDATION_FAILED", + "message": "Invalid input: expected string, received undefined" } } } @@ -14574,36 +19253,36 @@ } } }, - "/v2/test-collections/{id}/all-quarantined-tests": { - "post": { - "operationId": "testCollections.listAllQuarantinedTests", - "tags": ["testCollections"], - "summary": "List every quarantined test for a CI run", - "description": "**Internal.** This endpoint is intended for internal use by Trunk's analytics-cli and test-runner plugins. Use it at your own risk: it may change without notice.\n\nLists the `testId` of every quarantined test in a collection for one repository, in `testId` order, so a test runner can decide each failure itself as it happens. Name the repository the tests ran in as `repo` in the body, or `null` for an upload without a repository (`--no-repo`); the cursor and `limit` stay in the query. This is a read sent as `POST` so the repository travels in the body, as it does for `quarantine-status`. Every page also carries the collection's `testCollectionUuid`, the `repositoryId` the tests are stored under, and `quarantineEnabled`; while quarantining is off the list is empty. A runner computes each test's `testId` from `testCollectionUuid`, `repositoryId` and its own test id, and matches on it. A page holds up to 25,000 tests. Requires the **Upload test results** permission. Quarantine changes reach this list within a minute, so a test that joins or leaves the set while you page through it may be missed, or still listed, until your next pass.", + "/v2/monitors/{monitorId}/tests": { + "get": { + "operationId": "monitorTests.list", + "tags": ["monitorTests"], + "summary": "List a monitor's tests", + "description": "Lists the tests a monitor holds: the tests it is active on, and any test whose mute on it is still in force, ordered by test. A mute outlives the detection it silenced, so a muted test stays listed after the monitor stops being active on it, until the mute ends or the test is unmuted. `state` and `isMuted` filter the same thing two ways.", "parameters": [ { "schema": { "type": "string", - "pattern": "^[0-9A-Za-z]{8}$", - "description": "The collection's id: 8 alphanumeric characters.", - "example": "aB3xY9kQ" + "minLength": 1, + "description": "The monitor's id.", + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" }, "required": true, - "description": "The collection's id: 8 alphanumeric characters.", - "name": "id", + "description": "The monitor's id.", + "name": "monitorId", "in": "path" }, { "schema": { "type": "integer", "minimum": 1, - "maximum": 25000, + "maximum": 100, "default": 25, - "description": "Page size, between 1 and 25000.", + "description": "Page size, between 1 and 100.", "example": 25 }, "required": false, - "description": "Page size, between 1 and 25000.", + "description": "Page size, between 1 and 100.", "name": "limit", "in": "query" }, @@ -14629,25 +19308,38 @@ "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", "name": "includeTotal", "in": "query" + }, + { + "schema": { + "type": "string", + "enum": ["active", "muted"], + "description": "Only tests in this state.", + "example": "muted" + }, + "required": false, + "description": "Only tests in this state.", + "name": "state", + "in": "query" + }, + { + "schema": { + "type": "boolean", + "description": "`true` for only muted tests, `false` for only the ones not muted.", + "example": true + }, + "required": false, + "description": "`true` for only muted tests, `false` for only the ones not muted.", + "name": "isMuted", + "in": "query" } ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AllQuarantinedTestsRequest" - } - } - } - }, "responses": { "200": { - "description": "A page of quarantined tests", + "description": "A page of the monitor's tests", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/QuarantinedTestList" + "$ref": "#/components/schemas/MonitorTestStateList" } } } @@ -14712,41 +19404,20 @@ } } }, - "403": { - "description": "`INSUFFICIENT_PERMISSIONS`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "INSUFFICIENT_PERMISSIONS": { - "summary": "INSUFFICIENT_PERMISSIONS", - "value": { - "error": { - "code": "INSUFFICIENT_PERMISSIONS", - "message": "The supplied credential is missing the required permission" - } - } - } - } - } - } - }, "404": { - "description": "`TEST_COLLECTION_NOT_FOUND`", + "description": "`MONITOR_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "TEST_COLLECTION_NOT_FOUND": { - "summary": "TEST_COLLECTION_NOT_FOUND", + "MONITOR_NOT_FOUND": { + "summary": "MONITOR_NOT_FOUND", "value": { "error": { - "code": "TEST_COLLECTION_NOT_FOUND", - "message": "Test collection not found" + "code": "MONITOR_NOT_FOUND", + "message": "Monitor not found" } } } @@ -14799,57 +19470,43 @@ } } }, - "/v2/tests/{testId}": { - "get": { - "operationId": "tests.get", - "tags": ["tests"], - "summary": "Get a test", - "description": "Returns one test by its globally unique id, with the labels, quarantine override and active monitors currently applied to it. Ids come from list responses; they are opaque and not derivable client-side.\n\nA test in another organization is reported as `404`, not `403`, and so is a malformed id — a caller must not be able to probe which ids exist.", + "/v2/test-collections/{id}/monitors": { + "post": { + "operationId": "testCollections.createMonitor", + "tags": ["testCollections"], + "summary": "Create a monitor", + "description": "Requires the **Manage monitors** permission.\n\nAdds a monitor to the collection, enabled unless `enabled` is `false`. It starts with no actions: it detects tests but classifies and labels none until actions are added in the web app. A collection holds at most 10 monitors of each type (`409 MONITOR_LIMIT_EXCEEDED`).\n\nThe config is checked against the same rules as the web app's monitor settings: a value out of range, or `branches` sent with `pullRequestOnly: true`, is a `400`.\n\nThe change is recorded as made by the person whose token made the call.\n\n`Idempotency-Key` is not honored. A request whose outcome is unknown may have created the monitor: list the collection's monitors before sending it again.", "parameters": [ { "schema": { "type": "string", - "minLength": 1, - "description": "The test's globally unique id.", - "example": "bfeebcf4-0000-8000-8000-000000000001" + "pattern": "^[0-9A-Za-z]{8}$", + "description": "The collection's id: 8 alphanumeric characters.", + "example": "aB3xY9kQ" }, "required": true, - "description": "The test's globally unique id.", - "name": "testId", + "description": "The collection's id: 8 alphanumeric characters.", + "name": "id", "in": "path" - }, - { - "schema": { - "type": "string", - "enum": ["metrics"], - "description": "Set to `metrics` to embed this test's metrics for `period`.", - "example": "metrics" - }, - "required": false, - "description": "Set to `metrics` to embed this test's metrics for `period`.", - "name": "include", - "in": "query" - }, - { - "schema": { - "type": "string", - "enum": ["1d", "7d", "14d", "30d"], - "description": "Metrics window. Required with `include=metrics`.", - "example": "7d" - }, - "required": false, - "description": "Metrics window. Required with `include=metrics`.", - "name": "period", - "in": "query" } ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateMonitorRequest" + } + } + } + }, "responses": { - "200": { - "description": "The test", + "201": { + "description": "The new monitor", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Test" + "$ref": "#/components/schemas/Monitor" } } } @@ -14861,64 +19518,13 @@ "schema": { "$ref": "#/components/schemas/ErrorResponse" }, - "examples": { - "VALIDATION_FAILED": { - "summary": "VALIDATION_FAILED", - "value": { - "error": { - "code": "VALIDATION_FAILED", - "message": "Invalid input: expected string, received undefined" - } - } - } - } - } - } - }, - "401": { - "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "AUTHENTICATION_REQUIRED": { - "summary": "AUTHENTICATION_REQUIRED", - "value": { - "error": { - "code": "AUTHENTICATION_REQUIRED", - "message": "No credential was supplied" - } - } - }, - "INVALID_TOKEN": { - "summary": "INVALID_TOKEN", - "value": { - "error": { - "code": "INVALID_TOKEN", - "message": "The supplied token failed verification" - } - } - } - } - } - } - }, - "404": { - "description": "`TEST_NOT_FOUND`", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorResponse" - }, - "examples": { - "TEST_NOT_FOUND": { - "summary": "TEST_NOT_FOUND", + "examples": { + "VALIDATION_FAILED": { + "summary": "VALIDATION_FAILED", "value": { "error": { - "code": "TEST_NOT_FOUND", - "message": "Test not found" + "code": "VALIDATION_FAILED", + "message": "Invalid input: expected string, received undefined" } } } @@ -14926,20 +19532,29 @@ } } }, - "429": { - "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", + "401": { + "description": "`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`. A malformed, expired, or deleted credential. Trunk's edge usually answers this before the request reaches the API, with a body that is not this envelope (`{\"error\": \"unauthorized: invalid api key\"}` for a bad API key, or plain text for a bad `x-trunk-token`), so branch on the status. A request with no credential at all gets `403` from the edge.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "RATE_LIMIT_EXCEEDED": { - "summary": "RATE_LIMIT_EXCEEDED", + "AUTHENTICATION_REQUIRED": { + "summary": "AUTHENTICATION_REQUIRED", "value": { "error": { - "code": "RATE_LIMIT_EXCEEDED", - "message": "Rate limit exceeded; retry with backoff" + "code": "AUTHENTICATION_REQUIRED", + "message": "No credential was supplied" + } + } + }, + "INVALID_TOKEN": { + "summary": "INVALID_TOKEN", + "value": { + "error": { + "code": "INVALID_TOKEN", + "message": "The supplied token failed verification" } } } @@ -14947,296 +19562,157 @@ } } }, - "500": { - "description": "`INTERNAL_ERROR`", + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "INTERNAL_ERROR": { - "summary": "INTERNAL_ERROR", + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", "value": { "error": { - "code": "INTERNAL_ERROR", - "message": "An unexpected error occurred" + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" } } } } } } - } - } - } - }, - "/v2/tests": { - "get": { - "operationId": "tests.list", - "tags": ["tests"], - "summary": "List and search tests", - "description": "Lists tests, by default across every test collection in your organization — pass `testCollectionId` to narrow to one. Each row carries the `id` to pass to the per-test endpoints.\n\n`q` searches name, file, class and parent as case-insensitive substrings. Several words are separate requirements, not a phrase — `q=flaky slow` returns tests matching both, in any position. It also accepts per-field qualifiers mixed freely with those words: `q=file:checkout flaky class:PaymentTest`. Qualifier keys are case-sensitive, and an unrecognized prefix is treated as literal text rather than guessed at.\n\nRows omit `quarantineOverride`, `activeMonitors`, `firstSeenAt` and `lastFailureAt` — fetch a single test for those.", - "parameters": [ - { - "schema": { - "type": "integer", - "minimum": 1, - "maximum": 100, - "default": 25, - "description": "Page size, between 1 and 100.", - "example": 25 - }, - "required": false, - "description": "Page size, between 1 and 100.", - "name": "limit", - "in": "query" - }, - { - "schema": { - "type": "string", - "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", - "example": "AQEKZm9vYmFy" - }, - "required": false, - "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", - "name": "cursor", - "in": "query" - }, - { - "schema": { - "type": "boolean", - "default": false, - "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", - "example": false - }, - "required": false, - "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", - "name": "includeTotal", - "in": "query" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "description": "Narrow to one collection, by its id. Omitted searches every collection in your organization.", - "example": "aB3xY9kQ" - }, - "required": false, - "description": "Narrow to one collection, by its id. Omitted searches every collection in your organization.", - "name": "testCollectionId", - "in": "query" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "description": "Comma-separated statuses to include: `healthy`, `flaky`, `broken`.", - "example": "flaky,broken" - }, - "required": false, - "description": "Comma-separated statuses to include: `healthy`, `flaky`, `broken`.", - "name": "status", - "in": "query" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "description": "Free-text search, with optional `file:` / `class:` / `parent:` / `name:` qualifiers.", - "example": "file:checkout flaky" - }, - "required": false, - "description": "Free-text search, with optional `file:` / `class:` / `parent:` / `name:` qualifiers.", - "name": "q", - "in": "query" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "description": "Substring match on the test's file path.", - "example": "src/payments" - }, - "required": false, - "description": "Substring match on the test's file path.", - "name": "file", - "in": "query" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "description": "Exact match on one of the test's code owners.", - "example": "@acme/platform" - }, - "required": false, - "description": "Exact match on one of the test's code owners.", - "name": "owner", - "in": "query" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "description": "Exact match on the test's variant.", - "example": "ubuntu-22.04" - }, - "required": false, - "description": "Exact match on the test's variant.", - "name": "variant", - "in": "query" - }, - { - "schema": { - "type": "string", - "enum": ["metrics"], - "description": "Set to `metrics` to embed each test's metrics for `period` in the same response, instead of fetching them per test.", - "example": "metrics" - }, - "required": false, - "description": "Set to `metrics` to embed each test's metrics for `period` in the same response, instead of fetching them per test.", - "name": "include", - "in": "query" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "description": "Only tests carrying this label, by name. Matched exactly, including case, since two labels may differ only in case. An unknown name returns an empty page, not an error.", - "example": "slow-on-prs" - }, - "required": false, - "description": "Only tests carrying this label, by name. Matched exactly, including case, since two labels may differ only in case. An unknown name returns an empty page, not an error.", - "name": "label", - "in": "query" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "description": "Only tests currently linked to this ticket, by its Trunk id (`ticket.id` on a test). Spans every collection unless `testCollectionId` narrows it. An unknown id returns an empty page, not an error. Cannot be combined with `ticketKey`.", - "example": "5b0e8f8a-1c2d-4e3f-8a9b-0c1d2e3f4a5b" - }, - "required": false, - "description": "Only tests currently linked to this ticket, by its Trunk id (`ticket.id` on a test). Spans every collection unless `testCollectionId` narrows it. An unknown id returns an empty page, not an error. Cannot be combined with `ticketKey`.", - "name": "ticketId", - "in": "query" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "description": "Only tests currently linked to the ticket with this provider key or URL. A convenience: a key can change (a Jira issue moved between projects) and two connections can share one, so prefer `ticketId`, and pass `integrationId` to narrow to one connection. An unknown key returns an empty page.", - "example": "TRUNK-12345" - }, - "required": false, - "description": "Only tests currently linked to the ticket with this provider key or URL. A convenience: a key can change (a Jira issue moved between projects) and two connections can share one, so prefer `ticketId`, and pass `integrationId` to narrow to one connection. An unknown key returns an empty page.", - "name": "ticketKey", - "in": "query" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "description": "The ticketing connection `ticketKey` is looked up in. Only valid with `ticketKey`.", - "example": "6c1f9a9b-2d3e-4f40-9b0c-1d2e3f4a5b6c" - }, - "required": false, - "description": "The ticketing connection `ticketKey` is looked up in. Only valid with `ticketKey`.", - "name": "integrationId", - "in": "query" - }, - { - "schema": { - "type": "string", - "enum": ["quarantined", "notQuarantined"], - "description": "Filter on effective quarantine state, derived from the test's status, its collection's quarantine settings and any per-test override.", - "example": "quarantined" - }, - "required": false, - "description": "Filter on effective quarantine state, derived from the test's status, its collection's quarantine settings and any per-test override.", - "name": "quarantineState", - "in": "query" - }, - { - "schema": { - "type": "boolean", - "description": "Filter on whether the manual 'flag as flaky' mark is currently set.", - "example": true - }, - "required": false, - "description": "Filter on whether the manual 'flag as flaky' mark is currently set.", - "name": "markedFlaky", - "in": "query" }, - { - "schema": { - "type": "boolean", - "description": "Only tests that first became flaky inside `period`. Requires `period`.", - "example": true - }, - "required": false, - "description": "Only tests that first became flaky inside `period`. Requires `period`.", - "name": "newlyFlaky", - "in": "query" + "404": { + "description": "`TEST_COLLECTION_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "TEST_COLLECTION_NOT_FOUND": { + "summary": "TEST_COLLECTION_NOT_FOUND", + "value": { + "error": { + "code": "TEST_COLLECTION_NOT_FOUND", + "message": "Test collection not found" + } + } + } + } + } + } }, - { - "schema": { - "type": "string", - "enum": ["1d", "7d", "14d", "30d"], - "description": "Metrics window for `include=metrics`, any metric `sort`, and `newlyFlaky`. Required by each of them.", - "example": "7d" - }, - "required": false, - "description": "Metrics window for `include=metrics`, any metric `sort`, and `newlyFlaky`. Required by each of them.", - "name": "period", - "in": "query" + "409": { + "description": "`MONITOR_LIMIT_EXCEEDED`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "MONITOR_LIMIT_EXCEEDED": { + "summary": "MONITOR_LIMIT_EXCEEDED", + "value": { + "error": { + "code": "MONITOR_LIMIT_EXCEEDED", + "message": "The collection already has the most monitors of this type it can hold" + } + } + } + } + } + } }, - { - "schema": { - "type": "string", - "enum": [ - "name", - "failureRate", - "durationP95", - "prsImpacted", - "lastRunAt", - "lastFailureAt" - ], - "default": "name", - "description": "Field to sort by. A metric sort requires `period`, and excludes tests with no comparable value in it — no runs at all for most metrics, and additionally no failure for `lastFailureAt`." - }, - "required": false, - "description": "Field to sort by. A metric sort requires `period`, and excludes tests with no comparable value in it — no runs at all for most metrics, and additionally no failure for `lastFailureAt`.", - "name": "sort", - "in": "query" + "429": { + "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "RATE_LIMIT_EXCEEDED": { + "summary": "RATE_LIMIT_EXCEEDED", + "value": { + "error": { + "code": "RATE_LIMIT_EXCEEDED", + "message": "Rate limit exceeded; retry with backoff" + } + } + } + } + } + } }, + "500": { + "description": "`INTERNAL_ERROR`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INTERNAL_ERROR": { + "summary": "INTERNAL_ERROR", + "value": { + "error": { + "code": "INTERNAL_ERROR", + "message": "An unexpected error occurred" + } + } + } + } + } + } + } + } + } + }, + "/v2/test-collections/{id}/uploads": { + "post": { + "operationId": "testCollections.createUpload", + "tags": ["testCollections"], + "summary": "Create a test-results upload", + "description": "**Internal.** This endpoint is intended for internal use by Trunk's analytics-cli and test-runner plugins. Use it at your own risk: it may change without notice.\n\nStarts an upload of one CI run's test results to a collection. `PUT` the results bundle to the returned `uploadUrl` before `expiresAt`. A repository Trunk does not know is created when `remoteUrls` is sent. Requires the **Upload test results** permission.", + "parameters": [ { "schema": { "type": "string", - "enum": ["asc", "desc"], - "description": "Sort direction. Defaults per sort: ascending for `name`, descending for every metric sort, which order worst-first." + "pattern": "^[0-9A-Za-z]{8}$", + "description": "The collection's id: 8 alphanumeric characters.", + "example": "aB3xY9kQ" }, - "required": false, - "description": "Sort direction. Defaults per sort: ascending for `name`, descending for every metric sort, which order worst-first.", - "name": "direction", - "in": "query" + "required": true, + "description": "The collection's id: 8 alphanumeric characters.", + "name": "id", + "in": "path" } ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateTestUploadRequest" + } + } + } + }, "responses": { - "200": { - "description": "A page of tests", + "201": { + "description": "The upload, waiting for its bundle", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/TestList" + "$ref": "#/components/schemas/CreatedTestUpload" } } } }, "400": { - "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", + "description": "`VALIDATION_FAILED`", "content": { "application/json": { "schema": { @@ -15251,15 +19727,6 @@ "message": "Invalid input: expected string, received undefined" } } - }, - "INVALID_CURSOR": { - "summary": "INVALID_CURSOR", - "value": { - "error": { - "code": "INVALID_CURSOR", - "message": "Invalid or expired cursor." - } - } } } } @@ -15316,6 +19783,27 @@ } } }, + "404": { + "description": "`TEST_COLLECTION_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "TEST_COLLECTION_NOT_FOUND": { + "summary": "TEST_COLLECTION_NOT_FOUND", + "value": { + "error": { + "code": "TEST_COLLECTION_NOT_FOUND", + "message": "Test collection not found" + } + } + } + } + } + } + }, "429": { "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", "content": { @@ -15361,100 +19849,39 @@ } } }, - "/v2/tests/{testId}/status-history": { + "/v2/test-uploads/{id}": { "get": { - "operationId": "tests.listStatusHistory", - "tags": ["tests"], - "summary": "List a test's status transitions", - "description": "Returns the test's status transitions, newest first. A row is recorded only when the composite status changes, so `fromStatus` is the status it moved away from and the series has no repeats.\n\n`activeMonitors` is the set active immediately after each transition, as recorded at the time. Transitions predating this report an empty set.", + "operationId": "testUploads.get", + "tags": ["testUploads"], + "summary": "Get a test-results upload", + "description": "Returns where an upload is (waiting for its bundle, received, ingested or skipped) and the problems ingestion found in it. Requires read access to the upload's test collection.", "parameters": [ { "schema": { "type": "string", - "minLength": 1, - "description": "The test's globally unique id.", - "example": "bfeebcf4-0000-8000-8000-000000000001" + "format": "uuid", + "description": "The upload's id, as its create returned it.", + "example": "f47ac10b-58cc-4372-a567-0e02b2c3d479" }, "required": true, - "description": "The test's globally unique id.", - "name": "testId", + "description": "The upload's id, as its create returned it.", + "name": "id", "in": "path" - }, - { - "schema": { - "type": "integer", - "minimum": 1, - "maximum": 100, - "default": 25, - "description": "Page size, between 1 and 100.", - "example": 25 - }, - "required": false, - "description": "Page size, between 1 and 100.", - "name": "limit", - "in": "query" - }, - { - "schema": { - "type": "string", - "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", - "example": "AQEKZm9vYmFy" - }, - "required": false, - "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", - "name": "cursor", - "in": "query" - }, - { - "schema": { - "type": "boolean", - "default": false, - "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", - "example": false - }, - "required": false, - "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", - "name": "includeTotal", - "in": "query" - }, - { - "schema": { - "type": "string", - "format": "date-time", - "description": "Only transitions at or after this time.", - "example": "2026-06-01T00:00:00.000Z" - }, - "required": false, - "description": "Only transitions at or after this time.", - "name": "startedAfter", - "in": "query" - }, - { - "schema": { - "type": "string", - "format": "date-time", - "description": "Only transitions strictly before this time.", - "example": "2026-06-30T00:00:00.000Z" - }, - "required": false, - "description": "Only transitions strictly before this time.", - "name": "startedBefore", - "in": "query" } ], "responses": { "200": { - "description": "A page of status transitions", + "description": "The upload", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/StatusHistoryEntryList" + "$ref": "#/components/schemas/TestUpload" } } } }, "400": { - "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", + "description": "`VALIDATION_FAILED`", "content": { "application/json": { "schema": { @@ -15469,15 +19896,6 @@ "message": "Invalid input: expected string, received undefined" } } - }, - "INVALID_CURSOR": { - "summary": "INVALID_CURSOR", - "value": { - "error": { - "code": "INVALID_CURSOR", - "message": "Invalid or expired cursor." - } - } } } } @@ -15514,19 +19932,19 @@ } }, "404": { - "description": "`TEST_NOT_FOUND`", + "description": "`TEST_UPLOAD_NOT_FOUND`: no such upload in your organization, or it is more than 45 days old. A new upload also reads as not found until its record is written, usually within a second of the create, so a `404` shortly after the create means \"not visible yet\", not a failure.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "TEST_NOT_FOUND": { - "summary": "TEST_NOT_FOUND", + "TEST_UPLOAD_NOT_FOUND": { + "summary": "TEST_UPLOAD_NOT_FOUND", "value": { "error": { - "code": "TEST_NOT_FOUND", - "message": "Test not found" + "code": "TEST_UPLOAD_NOT_FOUND", + "message": "Test upload not found" } } } @@ -15579,12 +19997,12 @@ } } }, - "/v2/tests/{testId}/test-runs": { - "get": { - "operationId": "tests.listTestRuns", + "/v2/tests/{testId}/mark-flaky": { + "post": { + "operationId": "tests.markFlaky", "tags": ["tests"], - "summary": "List a test's runs", - "description": "Returns the individual runs recorded for a test, newest first, each with the branch, commit and CI job it came from.\n\n`branches` takes shell-style globs, where `*` matches any run of characters and `?` exactly one (`main,release-?.*`); `pullRequestOnly=true` selects pull-request runs instead. They are alternatives, so sending both is a `400` rather than a silent intersection.\n\n`startedAfter` and `startedBefore` bound when the run started, as your CI reported it.", + "summary": "Mark a test flaky", + "description": "Requires the **Flag tests** permission.\n\nMarks a test flaky by hand, as Flag as Flaky does in the web app, and returns the test with `manualFlag` set. Takes no body. Marking a test that is already marked changes nothing and returns it as it is.\n\nThe mark is not a status override. It counts as one more monitor classifying the test as flaky, so `status` is reconciled across every active monitor and a monitor classifying the test as broken still wins. The answer is the test after that reconcile.\n\nA status change this causes sends the same customer webhooks as one made in the web app or by a monitor. That is deliberate: a consumer must hear about every status change, whatever made it.\n\nA collection whose settings let only admins flag tests as flaky refuses anyone else with `INSUFFICIENT_PERMISSIONS`. An API token made on the API Keys page passes that check, since only an admin can make one or give it this permission; the organization's legacy API token does not, since every member can see it.\n\nThe change is recorded as made by the API token, or by the person whose token made the call.\n\nA `500 INTERNAL_ERROR` says in its message whether the test was put back as it was. A `503 TEST_UNAVAILABLE` means the change was made but the test could not be read back in time; read it with `GET /v2/tests/{testId}` rather than treating the change as failed.\n\n`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.\n\nA test in another organization is reported as `404`, not `403`.", "parameters": [ { "schema": { @@ -15597,129 +20015,21 @@ "description": "The test's globally unique id.", "name": "testId", "in": "path" - }, - { - "schema": { - "type": "integer", - "minimum": 1, - "maximum": 100, - "default": 25, - "description": "Page size, between 1 and 100.", - "example": 25 - }, - "required": false, - "description": "Page size, between 1 and 100.", - "name": "limit", - "in": "query" - }, - { - "schema": { - "type": "string", - "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", - "example": "AQEKZm9vYmFy" - }, - "required": false, - "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", - "name": "cursor", - "in": "query" - }, - { - "schema": { - "type": "boolean", - "default": false, - "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", - "example": false - }, - "required": false, - "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", - "name": "includeTotal", - "in": "query" - }, - { - "schema": { - "type": "string", - "enum": ["success", "failure", "skipped"], - "description": "Only runs that finished this way.", - "example": "failure" - }, - "required": false, - "description": "Only runs that finished this way.", - "name": "conclusion", - "in": "query" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "description": "Comma-separated branch globs, e.g. `main,release-*`. `*` matches any run of characters, `?` exactly one. Cannot be combined with `pullRequestOnly`.", - "example": "main,release-*" - }, - "required": false, - "description": "Comma-separated branch globs, e.g. `main,release-*`. `*` matches any run of characters, `?` exactly one. Cannot be combined with `pullRequestOnly`.", - "name": "branches", - "in": "query" - }, - { - "schema": { - "type": "boolean", - "description": "Only runs on pull-request branches. Cannot be combined with `branches`.", - "example": true - }, - "required": false, - "description": "Only runs on pull-request branches. Cannot be combined with `branches`.", - "name": "pullRequestOnly", - "in": "query" - }, - { - "schema": { - "type": "string", - "enum": ["quarantined", "notQuarantined"], - "description": "Only runs recorded while the test was in this quarantine state.", - "example": "quarantined" - }, - "required": false, - "description": "Only runs recorded while the test was in this quarantine state.", - "name": "quarantineState", - "in": "query" - }, - { - "schema": { - "type": "string", - "format": "date-time", - "description": "Only runs that started at or after this time.", - "example": "2026-06-01T00:00:00.000Z" - }, - "required": false, - "description": "Only runs that started at or after this time.", - "name": "startedAfter", - "in": "query" - }, - { - "schema": { - "type": "string", - "format": "date-time", - "description": "Only runs that started strictly before this time.", - "example": "2026-06-30T00:00:00.000Z" - }, - "required": false, - "description": "Only runs that started strictly before this time.", - "name": "startedBefore", - "in": "query" } ], "responses": { "200": { - "description": "A page of test runs", + "description": "The test, after the reconcile", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/TestRunList" + "$ref": "#/components/schemas/Test" } } } }, "400": { - "description": "`VALIDATION_FAILED` | `INVALID_CURSOR`", + "description": "`VALIDATION_FAILED`", "content": { "application/json": { "schema": { @@ -15734,15 +20044,6 @@ "message": "Invalid input: expected string, received undefined" } } - }, - "INVALID_CURSOR": { - "summary": "INVALID_CURSOR", - "value": { - "error": { - "code": "INVALID_CURSOR", - "message": "Invalid or expired cursor." - } - } } } } @@ -15778,6 +20079,27 @@ } } }, + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", + "value": { + "error": { + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" + } + } + } + } + } + } + }, "404": { "description": "`TEST_NOT_FOUND`", "content": { @@ -15836,191 +20158,68 @@ "message": "An unexpected error occurred" } } - } - } - } - } - } - } - } - }, - "/v2/detection-events": { - "get": { - "operationId": "detectionEvents.list", - "tags": ["detectionEvents"], - "summary": "List detection events", - "description": "Lists each verdict a monitor recorded on a test: `active` when it detected the condition it watches for, `inactive` when the test recovered or the monitor was disabled or deleted. By default it reads every test collection in your organization; pass `testCollectionId` to narrow to one.\n\nThe window is `detectedAfter` to `detectedBefore`, at most 30 days. `detectedBefore` defaults to now and `detectedAfter` to 30 days before it. A wider window is a `400 OUT_OF_RANGE`.\n\nAn unknown `monitorId` or `testId` returns an empty page. The 'flag as flaky' mark is not listed here: see a test's status history.", - "parameters": [ - { - "schema": { - "type": "integer", - "minimum": 1, - "maximum": 100, - "default": 25, - "description": "Page size, between 1 and 100.", - "example": 25 - }, - "required": false, - "description": "Page size, between 1 and 100.", - "name": "limit", - "in": "query" - }, - { - "schema": { - "type": "string", - "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", - "example": "AQEKZm9vYmFy" - }, - "required": false, - "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", - "name": "cursor", - "in": "query" - }, - { - "schema": { - "type": "boolean", - "default": false, - "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", - "example": false - }, - "required": false, - "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", - "name": "includeTotal", - "in": "query" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "description": "Narrow to one collection, by its id. Omitted reads every collection in your organization.", - "example": "aB3xY9kQ" - }, - "required": false, - "description": "Narrow to one collection, by its id. Omitted reads every collection in your organization.", - "name": "testCollectionId", - "in": "query" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "description": "Only events this monitor recorded.", - "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" - }, - "required": false, - "description": "Only events this monitor recorded.", - "name": "monitorId", - "in": "query" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "description": "Comma-separated monitor types to include, e.g. `failureRate,passOnRetry`.", - "example": "failureRate,passOnRetry" - }, - "required": false, - "description": "Comma-separated monitor types to include, e.g. `failureRate,passOnRetry`.", - "name": "monitorType", - "in": "query" + } + } + } + } }, + "503": { + "description": "`TEST_UNAVAILABLE`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "TEST_UNAVAILABLE": { + "summary": "TEST_UNAVAILABLE", + "value": { + "error": { + "code": "TEST_UNAVAILABLE", + "message": "The change was saved, but the test could not be read back; read it again" + } + } + } + } + } + } + } + } + } + }, + "/v2/tests/{testId}/unmark-flaky": { + "post": { + "operationId": "tests.unmarkFlaky", + "tags": ["tests"], + "summary": "Clear a test's flaky mark", + "description": "Requires the **Flag tests** permission.\n\nClears a flaky mark set by hand and returns the test with `manualFlag` null. Takes no body. A monitor still classifying the test keeps its status. Unmarking a test that is not marked changes nothing and returns it as it is.\n\nThe mark is not a status override. It counts as one more monitor classifying the test as flaky, so `status` is reconciled across every active monitor and a monitor classifying the test as broken still wins. The answer is the test after that reconcile.\n\nA status change this causes sends the same customer webhooks as one made in the web app or by a monitor. That is deliberate: a consumer must hear about every status change, whatever made it.\n\nA collection whose settings let only admins flag tests as flaky refuses anyone else with `INSUFFICIENT_PERMISSIONS`. An API token made on the API Keys page passes that check, since only an admin can make one or give it this permission; the organization's legacy API token does not, since every member can see it.\n\nThe change is recorded as made by the API token, or by the person whose token made the call.\n\nA `500 INTERNAL_ERROR` says in its message whether the test was put back as it was. A `503 TEST_UNAVAILABLE` means the change was made but the test could not be read back in time; read it with `GET /v2/tests/{testId}` rather than treating the change as failed.\n\n`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.\n\nA test in another organization is reported as `404`, not `403`.", + "parameters": [ { "schema": { "type": "string", "minLength": 1, - "description": "Only events on this test, by its globally unique id.", + "description": "The test's globally unique id.", "example": "bfeebcf4-0000-8000-8000-000000000001" }, - "required": false, - "description": "Only events on this test, by its globally unique id.", + "required": true, + "description": "The test's globally unique id.", "name": "testId", - "in": "query" - }, - { - "schema": { - "type": "string", - "enum": ["active", "inactive"], - "description": "Only events with this verdict.", - "example": "active" - }, - "required": false, - "description": "Only events with this verdict.", - "name": "monitorStatus", - "in": "query" - }, - { - "schema": { - "type": "boolean", - "description": "`true` for only the events that carry a classify action, `false` for only those that do not.", - "example": true - }, - "required": false, - "description": "`true` for only the events that carry a classify action, `false` for only those that do not.", - "name": "isClassificationEvent", - "in": "query" - }, - { - "schema": { - "type": "string", - "format": "date-time", - "description": "Only events detected at or after this time.", - "example": "2026-06-01T00:00:00.000Z" - }, - "required": false, - "description": "Only events detected at or after this time.", - "name": "detectedAfter", - "in": "query" - }, - { - "schema": { - "type": "string", - "format": "date-time", - "description": "Only events detected strictly before this time.", - "example": "2026-06-30T00:00:00.000Z" - }, - "required": false, - "description": "Only events detected strictly before this time.", - "name": "detectedBefore", - "in": "query" - }, - { - "schema": { - "type": "string", - "enum": ["detectedAt"], - "default": "detectedAt", - "description": "Field to sort by." - }, - "required": false, - "description": "Field to sort by.", - "name": "sort", - "in": "query" - }, - { - "schema": { - "type": "string", - "enum": ["asc", "desc"], - "default": "desc", - "description": "Sort direction. Newest first by default." - }, - "required": false, - "description": "Sort direction. Newest first by default.", - "name": "direction", - "in": "query" + "in": "path" } ], "responses": { "200": { - "description": "A page of detection events", + "description": "The test, after the reconcile", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/DetectionEventList" + "$ref": "#/components/schemas/Test" } } } }, "400": { - "description": "`VALIDATION_FAILED` | `INVALID_CURSOR` | `OUT_OF_RANGE`", + "description": "`VALIDATION_FAILED`", "content": { "application/json": { "schema": { @@ -16035,24 +20234,6 @@ "message": "Invalid input: expected string, received undefined" } } - }, - "INVALID_CURSOR": { - "summary": "INVALID_CURSOR", - "value": { - "error": { - "code": "INVALID_CURSOR", - "message": "Invalid or expired cursor." - } - } - }, - "OUT_OF_RANGE": { - "summary": "OUT_OF_RANGE", - "value": { - "error": { - "code": "OUT_OF_RANGE", - "message": "The requested time window is wider than the endpoint allows" - } - } } } } @@ -16109,6 +20290,27 @@ } } }, + "404": { + "description": "`TEST_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "TEST_NOT_FOUND": { + "summary": "TEST_NOT_FOUND", + "value": { + "error": { + "code": "TEST_NOT_FOUND", + "message": "Test not found" + } + } + } + } + } + } + }, "429": { "description": "`RATE_LIMIT_EXCEEDED`. Trunk's edge answers this, and does not yet wrap it in the error envelope or send `Retry-After`: treat any `429` as rate limiting, whatever its body, and retry with backoff.", "content": { @@ -16150,128 +20352,74 @@ } } } + }, + "503": { + "description": "`TEST_UNAVAILABLE`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "TEST_UNAVAILABLE": { + "summary": "TEST_UNAVAILABLE", + "value": { + "error": { + "code": "TEST_UNAVAILABLE", + "message": "The change was saved, but the test could not be read back; read it again" + } + } + } + } + } + } } } } }, - "/v2/tests/{testId}/investigations": { - "get": { - "operationId": "testInvestigations.list", - "tags": ["testInvestigations"], - "summary": "List a test's AI investigations", - "description": "Returns the AI investigations Trunk ran on a test, newest first. An investigation that was retried appears once, as its latest attempt, and the filters apply to that attempt.\n\nTrunk keeps investigations for 45 days. `createdAfter` and `createdBefore` bound when an investigation was created; when `createdAfter` is set, the window up to `createdBefore` (or now) may span at most 30 days.", + "/v2/monitors/{monitorId}/tests/mute": { + "post": { + "operationId": "monitorTests.muteMany", + "tags": ["monitorTests"], + "summary": "Mute a monitor for many tests", + "description": "Requires the **Mute monitors** permission.\n\nMutes the monitor for each listed test, as `POST /v2/monitors/{monitorId}/tests/{testId}/mute` does for one, and reports each test's outcome in request order. At most 100 tests, and a test listed twice refuses the whole request with `VALIDATION_FAILED`, as does a `muteUntil` that is not in the next 30 days.\n\nEach item either `succeeded`, was `unchanged` (already muted; its end and reason stay as they were), or `failed` with an `error`: `TEST_NOT_FOUND` for an id that is not a test of the monitor's collection, `MONITOR_NOT_ACTIVE` for a test the monitor is not active on, and `INTERNAL_ERROR` for one that could not be saved, which kept nothing and may be sent again. One item failing does not undo the others.\n\nMuting a monitor for a test stops it from counting toward the test's status, and removes the labels it applied to the test, as muting it in the web app does. Unmuting puts both back. A change to a monitor that classifies reconciles the test's status, which can send the `v2.test_case.status_changed` webhook.\n\nThe change is recorded as made by the person whose token made the call, and as `API token` for an API token, on the test's state and in the mute history.\n\n`Idempotency-Key` is not honored. The change is idempotent by state, so a request whose outcome is unknown is safe to send again: a test already in the requested state reports `unchanged`.", "parameters": [ { "schema": { - "type": "string", - "minLength": 1, - "description": "The test's globally unique id.", - "example": "bfeebcf4-0000-8000-8000-000000000001" - }, - "required": true, - "description": "The test's globally unique id.", - "name": "testId", - "in": "path" - }, - { - "schema": { - "type": "integer", - "minimum": 1, - "maximum": 100, - "default": 25, - "description": "Page size, between 1 and 100.", - "example": 25 - }, - "required": false, - "description": "Page size, between 1 and 100.", - "name": "limit", - "in": "query" - }, - { - "schema": { - "type": "string", - "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", - "example": "AQEKZm9vYmFy" - }, - "required": false, - "description": "Opaque cursor from a previous response's `nextCursor`. A cursor is bound to the operation and filter it was minted for.", - "name": "cursor", - "in": "query" - }, - { - "schema": { - "type": "boolean", - "default": false, - "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", - "example": false - }, - "required": false, - "description": "Set true to include `total` in the response. Costs an extra COUNT query, so it is off by default.", - "name": "includeTotal", - "in": "query" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "description": "Comma-separated statuses to include: `completed`, `failed`, `skipped`.", - "example": "completed" - }, - "required": false, - "description": "Comma-separated statuses to include: `completed`, `failed`, `skipped`.", - "name": "status", - "in": "query" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "description": "Comma-separated trigger types to include: `manual`, `automatic`, `mcp`.", - "example": "manual,mcp" - }, - "required": false, - "description": "Comma-separated trigger types to include: `manual`, `automatic`, `mcp`.", - "name": "triggerType", - "in": "query" - }, - { - "schema": { - "type": "string", - "format": "date-time", - "description": "Only investigations created at or after this time.", - "example": "2026-06-01T00:00:00.000Z" - }, - "required": false, - "description": "Only investigations created at or after this time.", - "name": "createdAfter", - "in": "query" - }, - { - "schema": { - "type": "string", - "format": "date-time", - "description": "Only investigations created strictly before this time.", - "example": "2026-06-30T00:00:00.000Z" + "type": "string", + "minLength": 1, + "description": "The monitor's id.", + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" }, - "required": false, - "description": "Only investigations created strictly before this time.", - "name": "createdBefore", - "in": "query" + "required": true, + "description": "The monitor's id.", + "name": "monitorId", + "in": "path" } ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MuteMonitorTestsRequest" + } + } + } + }, "responses": { "200": { - "description": "A page of investigations", + "description": "Each test's outcome, in request order", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/InvestigationSummaryList" + "$ref": "#/components/schemas/BulkResult" } } } }, "400": { - "description": "`VALIDATION_FAILED` | `INVALID_CURSOR` | `OUT_OF_RANGE`", + "description": "`VALIDATION_FAILED`", "content": { "application/json": { "schema": { @@ -16286,24 +20434,6 @@ "message": "Invalid input: expected string, received undefined" } } - }, - "INVALID_CURSOR": { - "summary": "INVALID_CURSOR", - "value": { - "error": { - "code": "INVALID_CURSOR", - "message": "Invalid or expired cursor." - } - } - }, - "OUT_OF_RANGE": { - "summary": "OUT_OF_RANGE", - "value": { - "error": { - "code": "OUT_OF_RANGE", - "message": "The requested time window is wider than the endpoint allows" - } - } } } } @@ -16339,20 +20469,41 @@ } } }, + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", + "value": { + "error": { + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" + } + } + } + } + } + } + }, "404": { - "description": "`TEST_NOT_FOUND`", + "description": "`MONITOR_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "TEST_NOT_FOUND": { - "summary": "TEST_NOT_FOUND", + "MONITOR_NOT_FOUND": { + "summary": "MONITOR_NOT_FOUND", "value": { "error": { - "code": "TEST_NOT_FOUND", - "message": "Test not found" + "code": "MONITOR_NOT_FOUND", + "message": "Monitor not found" } } } @@ -16405,45 +20556,43 @@ } } }, - "/v2/tests/{testId}/investigations/{investigationId}": { - "get": { - "operationId": "testInvestigations.get", - "tags": ["testInvestigations"], - "summary": "Get an AI investigation", - "description": "Returns one AI investigation of a test, at its latest attempt, with the facts it found and the evidence each cites.\n\nAn investigation of another test, or of a test you cannot read, is reported as `404`.", + "/v2/monitors/{monitorId}/tests/unmute": { + "post": { + "operationId": "monitorTests.unmuteMany", + "tags": ["monitorTests"], + "summary": "Unmute a monitor for many tests", + "description": "Requires the **Mute monitors** permission.\n\nUnmutes the monitor for each listed test and reports each test's outcome in request order. At most 100 tests, each listed once.\n\nEach item either `succeeded`, was `unchanged` (not muted, or its mute had already ended), or `failed` with an `error`: `TEST_NOT_FOUND` for an id that is not a test of the monitor's collection, `MONITOR_NOT_ACTIVE` for a test the monitor has never held, and `INTERNAL_ERROR` for one that could not be saved.\n\nMuting a monitor for a test stops it from counting toward the test's status, and removes the labels it applied to the test, as muting it in the web app does. Unmuting puts both back. A change to a monitor that classifies reconciles the test's status, which can send the `v2.test_case.status_changed` webhook.\n\nThe change is recorded as made by the person whose token made the call, and as `API token` for an API token, on the test's state and in the mute history.\n\n`Idempotency-Key` is not honored. The change is idempotent by state, so a request whose outcome is unknown is safe to send again: a test already in the requested state reports `unchanged`.", "parameters": [ { "schema": { "type": "string", "minLength": 1, - "description": "The test's globally unique id.", - "example": "bfeebcf4-0000-8000-8000-000000000001" - }, - "required": true, - "description": "The test's globally unique id.", - "name": "testId", - "in": "path" - }, - { - "schema": { - "type": "string", - "minLength": 1, - "description": "The investigation's id.", - "example": "5a7fef9e-c8cd-4eed-8a87-9494bdf96bed" + "description": "The monitor's id.", + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" }, "required": true, - "description": "The investigation's id.", - "name": "investigationId", + "description": "The monitor's id.", + "name": "monitorId", "in": "path" } ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UnmuteMonitorTestsRequest" + } + } + } + }, "responses": { "200": { - "description": "The investigation", + "description": "Each test's outcome, in request order", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Investigation" + "$ref": "#/components/schemas/BulkResult" } } } @@ -16499,29 +20648,41 @@ } } }, - "404": { - "description": "`TEST_NOT_FOUND` | `INVESTIGATION_NOT_FOUND`", + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "TEST_NOT_FOUND": { - "summary": "TEST_NOT_FOUND", + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", "value": { "error": { - "code": "TEST_NOT_FOUND", - "message": "Test not found" + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" } } - }, - "INVESTIGATION_NOT_FOUND": { - "summary": "INVESTIGATION_NOT_FOUND", + } + } + } + } + }, + "404": { + "description": "`MONITOR_NOT_FOUND`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "MONITOR_NOT_FOUND": { + "summary": "MONITOR_NOT_FOUND", "value": { "error": { - "code": "INVESTIGATION_NOT_FOUND", - "message": "Investigation not found" + "code": "MONITOR_NOT_FOUND", + "message": "Monitor not found" } } } @@ -16574,23 +20735,35 @@ } } }, - "/v2/test-collections/{id}/uploads": { + "/v2/monitors/{monitorId}/tests/{testId}/mute": { "post": { - "operationId": "testCollections.createUpload", - "tags": ["testCollections"], - "summary": "Create a test-results upload", - "description": "**Internal.** This endpoint is intended for internal use by Trunk's analytics-cli and test-runner plugins. Use it at your own risk: it may change without notice.\n\nStarts an upload of one CI run's test results to a collection. `PUT` the results bundle to the returned `uploadUrl` before `expiresAt`. A repository Trunk does not know is created when `remoteUrls` is sent. Requires the **Upload test results** permission.", + "operationId": "monitorTests.mute", + "tags": ["monitorTests"], + "summary": "Mute a monitor for one test", + "description": "Requires the **Mute monitors** permission.\n\nMutes the monitor for the test until `muteUntil`, at most 30 days away, or with no end, and returns the monitor's state for the test. The monitor must be active on the test (`409 MONITOR_NOT_ACTIVE` otherwise). A test already muted is left as it is, with its end and reason.\n\nMuting a monitor for a test stops it from counting toward the test's status, and removes the labels it applied to the test, as muting it in the web app does. Unmuting puts both back. A change to a monitor that classifies reconciles the test's status, which can send the `v2.test_case.status_changed` webhook.\n\nThe change is recorded as made by the person whose token made the call, and as `API token` for an API token, on the test's state and in the mute history.\n\n`Idempotency-Key` is not honored. The change is idempotent by state, so a request whose outcome is unknown is safe to send again: a test already in the requested state reports `unchanged`.", "parameters": [ { "schema": { "type": "string", - "pattern": "^[0-9A-Za-z]{8}$", - "description": "The collection's id: 8 alphanumeric characters.", - "example": "aB3xY9kQ" + "minLength": 1, + "description": "The monitor's id.", + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" }, "required": true, - "description": "The collection's id: 8 alphanumeric characters.", - "name": "id", + "description": "The monitor's id.", + "name": "monitorId", + "in": "path" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "description": "The test's globally unique id.", + "example": "bfeebcf4-0000-8000-8000-000000000001" + }, + "required": true, + "description": "The test's globally unique id.", + "name": "testId", "in": "path" } ], @@ -16599,18 +20772,18 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/CreateTestUploadRequest" + "$ref": "#/components/schemas/MuteMonitorTestRequest" } } } }, "responses": { - "201": { - "description": "The upload, waiting for its bundle", + "200": { + "description": "The monitor's state for the test", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/CreatedTestUpload" + "$ref": "#/components/schemas/MonitorTestState" } } } @@ -16688,19 +20861,49 @@ } }, "404": { - "description": "`TEST_COLLECTION_NOT_FOUND`", + "description": "`MONITOR_NOT_FOUND` | `TEST_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "TEST_COLLECTION_NOT_FOUND": { - "summary": "TEST_COLLECTION_NOT_FOUND", + "MONITOR_NOT_FOUND": { + "summary": "MONITOR_NOT_FOUND", "value": { "error": { - "code": "TEST_COLLECTION_NOT_FOUND", - "message": "Test collection not found" + "code": "MONITOR_NOT_FOUND", + "message": "Monitor not found" + } + } + }, + "TEST_NOT_FOUND": { + "summary": "TEST_NOT_FOUND", + "value": { + "error": { + "code": "TEST_NOT_FOUND", + "message": "Test not found" + } + } + } + } + } + } + }, + "409": { + "description": "`MONITOR_NOT_ACTIVE`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "MONITOR_NOT_ACTIVE": { + "summary": "MONITOR_NOT_ACTIVE", + "value": { + "error": { + "code": "MONITOR_NOT_ACTIVE", + "message": "The monitor is not active on the test, or holds no state for it" } } } @@ -16753,33 +20956,45 @@ } } }, - "/v2/test-uploads/{id}": { - "get": { - "operationId": "testUploads.get", - "tags": ["testUploads"], - "summary": "Get a test-results upload", - "description": "Returns where an upload is (waiting for its bundle, received, ingested or skipped) and the problems ingestion found in it. Requires read access to the upload's test collection.", + "/v2/monitors/{monitorId}/tests/{testId}/unmute": { + "post": { + "operationId": "monitorTests.unmute", + "tags": ["monitorTests"], + "summary": "Unmute a monitor for one test", + "description": "Requires the **Mute monitors** permission.\n\nUnmutes the monitor for the test and returns the monitor's state for it. A test that is not muted is left as it is. A test the monitor has never held is `409 MONITOR_NOT_ACTIVE`. Takes no body.\n\nMuting a monitor for a test stops it from counting toward the test's status, and removes the labels it applied to the test, as muting it in the web app does. Unmuting puts both back. A change to a monitor that classifies reconciles the test's status, which can send the `v2.test_case.status_changed` webhook.\n\nThe change is recorded as made by the person whose token made the call, and as `API token` for an API token, on the test's state and in the mute history.\n\n`Idempotency-Key` is not honored. The change is idempotent by state, so a request whose outcome is unknown is safe to send again: a test already in the requested state reports `unchanged`.", "parameters": [ { "schema": { "type": "string", - "format": "uuid", - "description": "The upload's id, as its create returned it.", - "example": "f47ac10b-58cc-4372-a567-0e02b2c3d479" + "minLength": 1, + "description": "The monitor's id.", + "example": "1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d" }, "required": true, - "description": "The upload's id, as its create returned it.", - "name": "id", + "description": "The monitor's id.", + "name": "monitorId", + "in": "path" + }, + { + "schema": { + "type": "string", + "minLength": 1, + "description": "The test's globally unique id.", + "example": "bfeebcf4-0000-8000-8000-000000000001" + }, + "required": true, + "description": "The test's globally unique id.", + "name": "testId", "in": "path" } ], "responses": { "200": { - "description": "The upload", + "description": "The monitor's state for the test", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/TestUpload" + "$ref": "#/components/schemas/MonitorTestState" } } } @@ -16835,20 +21050,71 @@ } } }, + "403": { + "description": "`INSUFFICIENT_PERMISSIONS`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "INSUFFICIENT_PERMISSIONS": { + "summary": "INSUFFICIENT_PERMISSIONS", + "value": { + "error": { + "code": "INSUFFICIENT_PERMISSIONS", + "message": "The supplied credential is missing the required permission" + } + } + } + } + } + } + }, "404": { - "description": "`TEST_UPLOAD_NOT_FOUND`: no such upload in your organization, or it is more than 45 days old. A new upload also reads as not found until its record is written, usually within a second of the create, so a `404` shortly after the create means \"not visible yet\", not a failure.", + "description": "`MONITOR_NOT_FOUND` | `TEST_NOT_FOUND`", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" }, "examples": { - "TEST_UPLOAD_NOT_FOUND": { - "summary": "TEST_UPLOAD_NOT_FOUND", + "MONITOR_NOT_FOUND": { + "summary": "MONITOR_NOT_FOUND", "value": { "error": { - "code": "TEST_UPLOAD_NOT_FOUND", - "message": "Test upload not found" + "code": "MONITOR_NOT_FOUND", + "message": "Monitor not found" + } + } + }, + "TEST_NOT_FOUND": { + "summary": "TEST_NOT_FOUND", + "value": { + "error": { + "code": "TEST_NOT_FOUND", + "message": "Test not found" + } + } + } + } + } + } + }, + "409": { + "description": "`MONITOR_NOT_ACTIVE`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "examples": { + "MONITOR_NOT_ACTIVE": { + "summary": "MONITOR_NOT_ACTIVE", + "value": { + "error": { + "code": "MONITOR_NOT_ACTIVE", + "message": "The monitor is not active on the test, or holds no state for it" } } } @@ -17405,7 +21671,7 @@ "operationId": "tests.linkTicket", "tags": ["tests"], "summary": "Link a ticket to a test", - "description": "Links an existing ticket from one of your organization's ticketing connections to a test, and returns the ticket as Trunk now holds it. The ticket is fetched from its provider first, so a key or URL the provider does not recognize is refused.\n\nA test carries at most one ticket. Linking replaces any ticket already linked; linking the one already there changes nothing. Which connection is used is `integrationId`, defaulting to the collection's default connection — with no default and no `integrationId`, the call is refused with `TICKETING_NOT_CONFIGURED`.\n\nThe call round-trips to the ticketing provider twice (to validate the connection, then to fetch the ticket) and answers `504` if that takes longer than five seconds. A `504` does not mean the link failed — retry it; re-linking the same ticket is a no-op. A `502 UPSTREAM_ERROR` means the provider did not answer; when it was rate-limiting, `Retry-After` says how long to wait.\n\nA test in another organization is reported as `404`, not `403`, and so is a malformed id.", + "description": "Requires the **Link tickets** permission.\n\nLinks an existing ticket from one of your organization's ticketing connections to a test, and returns the ticket as Trunk now holds it. The ticket is fetched from its provider first, so a key or URL the provider does not recognize is refused.\n\nA test carries at most one ticket. Linking replaces any ticket already linked; linking the one already there changes nothing. Which connection is used is `integrationId`, defaulting to the collection's default connection — with no default and no `integrationId`, the call is refused with `TICKETING_NOT_CONFIGURED`.\n\nThe call round-trips to the ticketing provider twice (to validate the connection, then to fetch the ticket) and answers `504` if that takes longer than five seconds. A `504` does not mean the link failed — retry it; re-linking the same ticket is a no-op. A `502 UPSTREAM_ERROR` means the provider did not answer; when it was rate-limiting, `Retry-After` says how long to wait.\n\nA test in another organization is reported as `404`, not `403`, and so is a malformed id.", "parameters": [ { "schema": { @@ -17672,7 +21938,7 @@ "operationId": "tests.unlinkTicket", "tags": ["tests"], "summary": "Unlink a test's ticket", - "description": "Removes the link between a test and its ticket. The ticket itself is not changed or closed in its provider. A test with no linked ticket is refused with `404 TICKET_NOT_LINKED`, so a retry after a successful unlink answers that rather than `204`.\n\nA test in another organization is reported as `404 TEST_NOT_FOUND`, not `403`, and so is a malformed id.", + "description": "Requires the **Link tickets** permission.\n\nRemoves the link between a test and its ticket. The ticket itself is not changed or closed in its provider. A test with no linked ticket is refused with `404 TICKET_NOT_LINKED`, so a retry after a successful unlink answers that rather than `204`.\n\nA test in another organization is reported as `404 TEST_NOT_FOUND`, not `403`, and so is a malformed id.", "parameters": [ { "schema": { @@ -17843,7 +22109,7 @@ "operationId": "tests.createTicket", "tags": ["tests"], "summary": "Create a ticket for a test", - "description": "Files a new ticket in the test collection's default ticketing connection and links it to a test, returning the ticket as Trunk now holds it. A collection with no default connection is refused with `TICKETING_NOT_CONFIGURED`.\n\nThe ticket gets the default fields saved on that connection, with `fields` merged over them. The provider may still refuse the ticket: a field it does not accept, or a required one neither sets, is `422 TICKET_FIELDS_REJECTED` with the provider's own message, and a connection the provider will not let create tickets (no access to its project, a missing scope, a plan limit) is `409 TICKETING_CREATE_REFUSED`.\n\nA `title` or `description` you leave out is generated the way the web app generates it: the test's location, failure rate, owners and most common failure reasons, with a link back to the test. Failure summaries are left out while your organization has AI features turned off. A test with no data to generate from is refused with `TICKET_CONTENT_UNAVAILABLE`; pass both to create its ticket anyway.\n\nA test carries at most one ticket. If one is already linked, the call is refused with `TEST_ALREADY_LINKED` and files nothing, unless `replaceExisting` is true.\n\n`Idempotency-Key` is not honored. The call files the ticket with the provider and answers `504` if that takes longer than five seconds; a `504` does not mean nothing was filed. Before retrying, read the test (`GET /v2/tests/{testId}`): if its `ticket` is set, the ticket was created and linked. A `502 UPSTREAM_ERROR` means the provider did not answer; when it was rate-limiting, `Retry-After` says how long to wait.\n\nA test in another organization is reported as `404`, not `403`, and so is a malformed id.", + "description": "Requires the **Create tickets** permission.\n\nFiles a new ticket in the test collection's default ticketing connection and links it to a test, returning the ticket as Trunk now holds it. A collection with no default connection is refused with `TICKETING_NOT_CONFIGURED`.\n\nThe ticket gets the default fields saved on that connection, with `fields` merged over them. The provider may still refuse the ticket: a field it does not accept, or a required one neither sets, is `422 TICKET_FIELDS_REJECTED` with the provider's own message, and a connection the provider will not let create tickets (no access to its project, a missing scope, a plan limit) is `409 TICKETING_CREATE_REFUSED`.\n\nA `title` or `description` you leave out is generated the way the web app generates it: the test's location, failure rate, owners and most common failure reasons, with a link back to the test. Failure summaries are left out while your organization has AI features turned off. A test with no data to generate from is refused with `TICKET_CONTENT_UNAVAILABLE`; pass both to create its ticket anyway.\n\nA test carries at most one ticket. If one is already linked, the call is refused with `TEST_ALREADY_LINKED` and files nothing, unless `replaceExisting` is true.\n\n`Idempotency-Key` is not honored. The call files the ticket with the provider and answers `504` if that takes longer than five seconds; a `504` does not mean nothing was filed. Before retrying, read the test (`GET /v2/tests/{testId}`): if its `ticket` is set, the ticket was created and linked. A `502 UPSTREAM_ERROR` means the provider did not answer; when it was rate-limiting, `Retry-After` says how long to wait.\n\nA test in another organization is reported as `404`, not `403`, and so is a malformed id.", "parameters": [ { "schema": { @@ -19493,7 +23759,7 @@ "operationId": "ciJobs.listLogLines", "tags": ["ciJobs"], "summary": "List a CI job's log lines", - "description": "A job's log in line order. Send a failure's `logExcerpt.startLine` and `endLine` as `fromLine` and `toLine` to read exactly the failing lines. Logs are kept for 30 days, and a job that has not finished has none yet.", + "description": "Requires the **Read CI logs** permission.\n\nA job's log in line order. Send a failure's `logExcerpt.startLine` and `endLine` as `fromLine` and `toLine` to read exactly the failing lines. Logs are kept for 30 days, and a job that has not finished has none yet.", "parameters": [ { "schema": {