LogoLogo
SlackLogin
  • Overview
    • Welcome
  • Setup & Configuration
    • Connecting to Trunk
    • Managing Your Organization
      • GitHub App Permissions
  • Integration with Slack
  • Flaky Tests (Beta)
    • Overview
    • Get Started
      • Test Frameworks
        • Android
        • Bazel
        • Behave
        • cargo-nextest
        • Cypress
        • Dart Test
        • Go
        • GoogleTest
        • Gradle
        • Jasmine
        • Jest
        • Karma
        • Maven
        • minitest
        • Mocha
        • Nightwatch
        • NUnit
        • Pest
        • PHPUnit
        • Playwright
        • Pytest
        • Robot Framework
        • RSpec
        • Swift Testing
        • Vitest
        • XCTest
        • Other Test Frameworks
      • CI Providers
        • Azure DevOps Pipelines
        • BitBucket Pipelines
        • Buildkite
        • CircleCI
        • Drone CI
        • GitHub Actions
        • GitLab
        • Jenkins
        • Semaphore CI
        • TeamCity
        • Travis CI
        • Other CI Providers
    • Dashboard
    • Flaky Test Detection
    • Quarantining
    • PR Comments
    • Ticketing Integrations
      • Jira Integration
      • Linear Integration
      • Other Ticketing Platforms
    • Webhooks
      • Slack Integration
      • Microsoft Teams Integration
      • GitHub Issues Integration
      • Linear Integration
    • Uploader CLI Reference
  • Merge Queue
    • Overview
    • How does it work?
    • Setup
      • Quick Start
      • Settings
      • Integration for Slack
    • Concepts and Optimizations
      • Predictive Testing
      • Optimistic Merging
      • Pending Failure Depth
      • Anti-Flake Protection
      • Batching
      • Parallel Queues
        • Bazel
        • Nx
        • API
      • FAQ
    • Priority
    • Managing Merge Queue
      • Using the Merge UI
      • Metrics
      • Command Line
    • Webhooks
    • Reference
  • Code Quality
    • Overview
    • Why Metalinters?
      • How does it work?
      • Why Code Quality?
    • Setup & Installation
      • Initialize Trunk
      • Local Linting
      • Linting in CI
      • Nightly Report (Deprecated)
    • IDE Integration
      • VSCode
      • Neovim
      • GitHub Codespaces
    • Linters
      • Supported Linters
        • Actionlint
        • Ansible-lint
        • Autopep8
        • Bandit
        • Biome
        • Black
        • Brakeman
        • buf
        • Buildifier
        • cfnlint
        • Checkov
        • circleci
        • ClangFormat
        • clang-tidy
        • Clippy
        • cmake-format
        • codespell
        • cspell
        • cue-fmt
        • dart
        • deno
        • Detekt
        • djlint
        • dotenv-linter
        • dotnet-format
        • dustilock
        • ESLint
        • Flake8
        • git-diff-check
        • Gitleaks
        • Gofmt
        • gofumpt
        • goimports
        • gokart
        • golangci-lint
        • golines
        • google-java-format
        • graphql-schema-linter
        • hadolint
        • haml-lint
        • isort
        • iwyu
        • ktlint
        • kube-linter
        • markdown-link-check
        • markdown-table-prettify
        • Markdownlint
        • markdownlint-cli2
        • mypy
        • nancy
        • nixpkgs-fmt
        • opa
        • OSV-Scanner
        • Oxipng
        • perlcritic
        • perltidy
        • php-cs-fixer
        • phpstan
        • pmd
        • pragma-once
        • pre-commit-hooks
        • Prettier
        • prisma
        • psscriptanalyzer
        • Pylint
        • pyright
        • regal
        • remark-lint
        • renovate
        • rome
        • rubocop
        • Ruff
        • rufo
        • rustfmt
        • scalafmt
        • semgrep
        • ShellCheck
        • shfmt
        • sort-package-json
        • sourcery
        • sql-formatter
        • SQLFluff
        • sqlfmt
        • squawk
        • standardrb
        • stringslint
        • stylelint
        • stylua
        • SVGO
        • swiftformat
        • swiftlint
        • taplo
        • Terraform
        • terragrunt
        • terrascan
        • TFLint
        • tfsec
        • tofu
        • Trivy
        • Trufflehog
        • txtpbfmt
        • vale
        • Yamllint
        • yapf
      • Run Linters
      • Manage Linters
      • Configure Linters
      • Ignoring Issues and Files
      • Custom Linters
      • Shared Configs
      • Upgrades
    • Debugging
    • Licensing
  • CLI & API References
    • CLI Reference
      • Install
      • Getting Started
        • Code Quality
        • Merge Queue
        • Flaky Tests
        • Tools
        • Actions
          • Git Hooks
        • Announce
      • Compatibility
      • Caching
      • Commands Reference
        • Code Quality
        • Actions
        • Merge
      • Configuration
        • Plugins
          • Share Config Between Codebases
          • Exporting Linter Configs
        • Runtimes
        • Tools
        • Lint
          • Definitions
          • Commands
          • Output
          • Output Parsing
          • Files and Caching
          • Dependencies
          • Auto-Enable
        • Actions
          • Notifications
          • Logging and Troubleshooting
        • Merge
        • Telemetry
        • Per User Overrides
    • API Reference
      • Flaky Tests
      • Merge Queue
      • Webhooks Reference
  • Pricing & Security
    • Security
  • Billing
  • Community & Support
  • Links
    • Open App
    • Slack Community
    • Changelog
    • Feature Requests
On this page
Edit on GitHub
  1. CLI & API References
  2. API Reference

Merge Queue

Public Trunk Merge Queue API. All requests should be authenticated.

Last updated 4 months ago

The Trunk Merge Queue API provides access to submit PRs for testing and merging, canceling PRs, and providing extra information to optimize the queue. The API is an HTTP REST API, returns JSON from all requests, and uses standard HTTP response codes.

All requests must be by providing the x-api-token header.

authenticated
  • POSTSubmit a pull request to be tested and merged
  • POSTGet information on a pull request that has been submitted to the queue
  • POSTRestarts tests on a PR in the queue without moving its position or causing other PRs to be retested
  • POSTCancel a pull request already in the queue.
  • POSTGet information on your merge queue and the PRs currently in it
  • POSTSet impacted targets

Submit a pull request to be tested and merged

post
Authorizations
Body
targetBranchstringOptional

The branch the merge queue will be merging PRs into

Example: main
priorityone ofOptional
string ยท enumOptional

The priority name to assign to the PR when it begins testing in the queue

Default: mediumExample: highPossible values:
or
numberOptional

The priority number (0 - 255, 0 is the highest) to assign to the PR when it begins testing in the queue

Example: 1
Responses
200
OK
401
Unauthorized
post
POST /v1/submitPullRequest HTTP/1.1
Host: api.trunk.io
x-api-token: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 124

{
  "repo": {
    "host": "github.com",
    "owner": "trunk-io",
    "name": "trunk"
  },
  "pr": {
    "number": 1
  },
  "targetBranch": "main",
  "priority": "medium"
}

No content

Get information on a pull request that has been submitted to the queue

post
Authorizations
Body
targetBranchstringOptional

The branch the merge queue will be merging PRs into

Example: main
priorityone ofOptional
string ยท enumOptional

The priority name to assign to the PR when it begins testing in the queue

Default: mediumExample: highPossible values:
or
numberOptional

The priority number (0 - 255, 0 is the highest) to assign to the PR when it begins testing in the queue

Example: 1
Responses
200
Information on the pull request
application/json
401
Unauthorized
404
Pull request with the provided number does not exist or has never been submitted to the specified queue before
post
POST /v1/getSubmittedPullRequest HTTP/1.1
Host: api.trunk.io
x-api-token: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 124

{
  "repo": {
    "host": "github.com",
    "owner": "trunk-io",
    "name": "trunk"
  },
  "pr": {
    "number": 1
  },
  "targetBranch": "main",
  "priority": "medium"
}
{
  "id": "1234567890abcdef",
  "state": "PENDING",
  "stateChangedAt": "2021-01-01T00:00:00Z",
  "priorityValue": 100,
  "priorityName": "medium",
  "usedDefaultPriorityName": "medium",
  "skipTheLine": false,
  "isCurrentlySubmittedToQueue": true,
  "readiness": {
    "hasImpactedTargets": false,
    "requiresImpactedTargets": false,
    "doesBaseBranchMatch": true,
    "gitHubMergeability": "MERGEABLE"
  },
  "prNumber": 1,
  "prTitle": "Add new feature",
  "prSha": "1234567890abcdef",
  "prBaseBranch": "main",
  "prAuthor": "dependabot"
}

Restarts tests on a PR in the queue without moving its position or causing other PRs to be retested

post
Authorizations
Body
targetBranchstringOptional

The branch the merge queue will be merging PRs into

Example: main
Responses
200
OK
401
Unauthorized
post
POST /v1/restartTestsOnPullRequest HTTP/1.1
Host: api.trunk.io
x-api-token: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 104

{
  "repo": {
    "host": "github.com",
    "owner": "trunk-io",
    "name": "trunk"
  },
  "pr": {
    "number": 1
  },
  "targetBranch": "main"
}

No content

Cancel a pull request already in the queue.

post
Authorizations
Body
targetBranchstringOptional

The branch the merge queue will be merging PRs into

Example: main
Responses
200
OK
401
Unauthorized
post
POST /v1/cancelPullRequest HTTP/1.1
Host: api.trunk.io
x-api-token: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 104

{
  "repo": {
    "host": "github.com",
    "owner": "trunk-io",
    "name": "trunk"
  },
  "pr": {
    "number": 1
  },
  "targetBranch": "main"
}

No content

Get information on your merge queue and the PRs currently in it

post
Authorizations
Body
targetBranchstringOptional

The branch the merge queue will be merging PRs into

Example: main
Responses
200
Information on the pull request
application/json
401
Unauthorized
404
Pull request with the provided number does not exist or has never been submitted to the specified queue before
post
POST /v1/getQueue HTTP/1.1
Host: api.trunk.io
x-api-token: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 86

{
  "repo": {
    "host": "github.com",
    "owner": "trunk-io",
    "name": "trunk"
  },
  "targetBranch": "main"
}
{
  "state": "RUNNING",
  "branch": "main",
  "concurrency": 1,
  "testingTimeoutMins": 60,
  "mode": "SINGLE",
  "canOptimisticallyMerge": true,
  "pendingFailureDepth": 1,
  "batchingMode": "SPECULATIVE",
  "batchingMaxWaitTimeMins": 60,
  "batchingMinSize": 1,
  "createPrsForTestingBranches": true,
  "enqueuedPullRequests": [
    {
      "id": "1234567890abcdef",
      "state": "PENDING",
      "stateChangedAt": "2021-01-01T00:00:00Z",
      "priorityValue": 100,
      "priorityName": "medium",
      "usedDefaultPriorityName": "medium",
      "skipTheLine": false,
      "prNumber": 1,
      "prTitle": "Add new feature",
      "prSha": "1234567890abcdef",
      "prBaseBranch": "main",
      "prAuthor": "dependabot"
    }
  ]
}

Set impacted targets

post

Upload impacted targets for the PR and its current SHA. Used specifically when running the queue in Parallel mode

Authorizations
Body
targetBranchstringOptional

The branch the merge queue will be merging PRs into

Example: main
impactedTargetsone ofOptional
string[]Optional

Name of the target impacted by the changes in the pull request

Example: services_backend
or
string ยท enumOptional

Special value to indicate that all targets are impacted by the changes in the pull request

Possible values:
Responses
200
OK
401
Unauthorized
post
POST /v1/setImpactedTargets HTTP/1.1
Host: api.trunk.io
x-api-token: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 188

{
  "repo": {
    "host": "github.com",
    "owner": "trunk-io",
    "name": "trunk"
  },
  "pr": {
    "number": 1,
    "sha": "1234567890abcdef"
  },
  "targetBranch": "main",
  "impactedTargets": [
    "services_backend",
    "services_frontend"
  ]
}

No content