Skip to content

Create a project's GitHub repository

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

Creates the project’s private repository in the organization’s GitHub, named name or, without one, from the project’s code (a taken name answers 409, never a changed name; no name and no code answers 422), from template (a repository of the organization marked as a template on GitHub; one that is missing or not a template answers 422), from the template chosen in Settings when template is omitted, or empty when it is null. It adds a develop branch, protects it for agents, gives access to the GitHub teams linked to the project’s Chelsea teams, and links it to the project with pull requests going to develop. The repository stays unlinked and the call answers 409 naming it when it cannot be verified as holding agents back. It runs once per project: a project that already has a repository answers it with 200 and isCreated: false, unless name names another repository, which answers 409; while another call is creating it, 409. The body is optional. A project the caller cannot reach answers 404. Requires github.manage and the App’s Administration and Members write access.

projectId
required

Project identifier (CUID2).

string
>= 1 characters

Project identifier (CUID2).

Media typeapplication/json
object
name

The repository’s name inside the organization, such as acme-theme. Omit it to name the repository from the project’s code.

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

The repository to start from: a repository of the organization marked as a template on GitHub. Omit it to use the template chosen in Settings when there is one; null creates an empty repository.

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

Example generated

{
"name": "example",
"template": "example"
}

The project already had a repository.

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
string
isCreated
required

true when this call created the repository. false when the project already had one, which is returned as it is.

boolean
notices
required

What did not go as planned without stopping the repository from working.

Array<string>
teamsGranted
required

The slugs of the GitHub teams given access, from the Chelsea teams of the project that are linked to one.

Array<string>

Example generated

{
"data": {
"baseBranch": "example",
"fullName": "example",
"isCreated": true,
"notices": [
"example"
],
"teamsGranted": [
"example"
]
}
}

The repository was created and linked.

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
string
isCreated
required

true when this call created the repository. false when the project already had one, which is returned as it is.

boolean
notices
required

What did not go as planned without stopping the repository from working.

Array<string>
teamsGranted
required

The slugs of the GitHub teams given access, from the Chelsea teams of the project that are linked to one.

Array<string>

Example generated

{
"data": {
"baseBranch": "example",
"fullName": "example",
"isCreated": true,
"notices": [
"example"
],
"teamsGranted": [
"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.