Skip to content

Link a project to an existing GitHub repository

PUT
/projects/{projectId}/repository
Code sample: Shell / cURL
curl --request PUT \
--url https://example.com/api/v1/projects/example/repository \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "baseBranch": "example", "repository": "example" }'

Links the project to a repository that already exists in the organization Chelsea manages, named by repository, the way the project’s Overview does. The name is looked up only inside that organization, never in another account the App is installed on. Linking again replaces the previous link. baseBranch sets where pull requests go and is checked before anything is saved, so a refusal never leaves the project linked. Requires both projects.manage and settings.manage, and a project the caller reaches. Answers: 403 FORBIDDEN without both permissions; 404 NOT_FOUND when the project is not one the caller reaches, or the organization has no such repository that the App reaches (an archived one, or one moved to another owner, counts as missing); 409 CONFLICT when the repository already serves a project of another company, does not hold agents back (the message names what is missing; POST /github/repositories/{name}/agent-protection adds the rule set that does), or Chelsea has no organization to administer yet; 422 INVALID_INPUT when baseBranch does not exist or is under agent/; 424 GITHUB_API_ERROR when GitHub cannot be read, or GITHUB_ACCESS_MISSING when the App or the organization lacks the access this needs; 429 RATE_LIMITED when GitHub or Chelsea throttles the call.

projectId
required

Project identifier (CUID2).

string
>= 1 characters

Project identifier (CUID2).

Media typeapplication/json
object
baseBranch

The branch pull requests go to. Omit it to keep the current one when the same repository is linked again (a different repository starts on its default branch); null goes back to the repository’s default branch.

Any of:
string
>= 1 characters <= 250 characters
repository
required

The repository’s name inside the organization, such as acme-theme. It must be one the GitHub App reaches.

string
/^(?!\.{1,2}$)[A-Za-z0-9._-]{1,100}$/

Example generated

{
"baseBranch": "example",
"repository": "example"
}

The linked repository and the branch pull requests go to.

Media typeapplication/json
object
data
required
object
baseBranch
required

The branch pull requests go to; null means the repository’s default branch.

string | null
fullName
required

The linked repository, as organization/name.

string

Example generated

{
"data": {
"baseBranch": "example",
"fullName": "example"
}
}

Validation error. Parse failures include field paths and expectations.

Media typeapplication/json

Validation error with safe field paths and expected values; submitted values are never returned.

object
error
required
object
code
required

Stable machine-readable error code.

string
issues
Array<object>
object
expected
required
string
message
required
string
path
required
Array<string | number>
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Unauthorized.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Forbidden.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Not found.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Conflict.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Invalid input.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

GitHub failed (GITHUB_API_ERROR), or Chelsea’s GitHub App or the organization has not granted the access this needs (GITHUB_ACCESS_MISSING; the message names the step in Settings, Integrations, GitHub).

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Rate limit exceeded. Wait for Retry-After before retrying.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}
RateLimit-Limit
string
/^\d+$/

Maximum requests in the current quota window.

RateLimit-Policy
string

Quota policy in requests and window seconds, for example 60;w=60.

RateLimit-Remaining
string
/^\d+$/

Requests left in this quota window (zero when blocked).

RateLimit-Reset
string
/^\d+$/

Seconds until the current quota window resets, when available from the rate-limit store.

Retry-After
string
/^\d+$/

Seconds until another request may be attempted.