---
title: "Exchange a GitHub code for repositories to link"
method: POST
path: "/v0/github/exchange"
tags: ["projects", "github"]
---

# Exchange a GitHub code for repositories to link

`POST /v0/github/exchange`

## Request

- The document declares no server URL.
- Auth: none declared

Exchange the code that GitHub sent back with a link state for every repository the user can push to, in every installation of the app the user can see. Each repository whose installation has granted the app contents write comes with a grant to link it, which lasts ten minutes. The state must be from this user, and the user must have `manage` permissions for its project.

## Request body

- JsonOAuth
  - `code` string, required
  - `state` string, required

## Response `200`

successful operation

- JsonGitHubRepositories: The repositories the user may link to the project, from a GitHub code exchange.
  - `project` string, required
  - `repositories` JsonGitHubRepository[], required: Every repository the user can push to, in every installation of the app the user can see.
    - `full_name` string, required
    - `grant` string
    - `installation` integer, required
    - `installation_url` string, uri, required: The installation's page on GitHub, where its owner approves a new permission.
    - `permission` union, required: Whether an installation of the app has approved its contents write.
      - 'granted'
      - 'approval_required': The installation must approve the new permission on GitHub before it can mint.

## Other responses

- `4XX`: Error
- `5XX`: Error

## Changes

- **2026-10-31** `538b39b8d755`: 1 info
  - endpoint added
- **2026-10-31** `00d8f4574c39`: 1 breaking
  - api path removed without deprecation
- **2026-10-31** `c41a83b8d187`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/bencherdev/apis/bencher-api/changes/v0/github/exchange/post.md)

---

[API](https://skmtc.dev/bencherdev/apis/bencher-api.md) - [All operations](https://skmtc.dev/bencherdev/apis/bencher-api/llms.txt) - [OpenAPI document](https://skmtc.dev/bencherdev/apis/bencher-api/revisions/538b39b8d755?raw)
