Assign a repository to a coding environment
curl --request POST \
--url https://api.coderabbit.ai/v1/code/environments/{environmentId}/repositories \
--header 'Content-Type: application/json' \
--header 'x-coderabbitai-api-key: <api-key>' \
--data '
{
"repository": {
"repositoryId": "<string>",
"repositoryName": "<string>"
},
"setup": {
"setupMethod": "automatic",
"setupScript": "<string>",
"startupScript": "<string>",
"startupInstructions": "<string>"
},
"org_id": "<string>",
"org_name": "<string>"
}
'import requests
url = "https://api.coderabbit.ai/v1/code/environments/{environmentId}/repositories"
payload = {
"repository": {
"repositoryId": "<string>",
"repositoryName": "<string>"
},
"setup": {
"setupMethod": "automatic",
"setupScript": "<string>",
"startupScript": "<string>",
"startupInstructions": "<string>"
},
"org_id": "<string>",
"org_name": "<string>"
}
headers = {
"x-coderabbitai-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-coderabbitai-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
repository: {repositoryId: '<string>', repositoryName: '<string>'},
setup: {
setupMethod: 'automatic',
setupScript: '<string>',
startupScript: '<string>',
startupInstructions: '<string>'
},
org_id: '<string>',
org_name: '<string>'
})
};
fetch('https://api.coderabbit.ai/v1/code/environments/{environmentId}/repositories', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"repository": {
"id": "<string>",
"environmentId": "<string>",
"repositoryProvider": "<string>",
"repositoryId": "<string>",
"repositoryName": "<string>",
"status": "preparing",
"machineSize": "<string>",
"setupMethod": "<string>",
"setupScript": "<string>",
"startupScript": "<string>",
"startupInstructions": "<string>",
"configRevision": 123,
"preparedRevision": 123,
"setupAgentTaskId": "<string>",
"lastPreparedAt": "<string>",
"lastError": "<string>",
"createdAt": "<string>",
"updatedAt": "<string>"
}
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"retry_after": 1
}
}{
"error": {
"code": "unauthenticated",
"message": "<string>",
"retry_after": 1
}
}{
"error": {
"code": "forbidden",
"message": "<string>",
"retry_after": 1
}
}{
"error": {
"code": "not_found",
"message": "<string>",
"retry_after": 1
}
}{
"error": {
"code": "head_changed",
"message": "<string>",
"retry_after": 1
}
}{
"error": {
"code": "precondition_failed",
"message": "<string>",
"retry_after": 1
}
}{
"error": {
"code": "payload_too_large",
"message": "<string>",
"retry_after": 1
}
}{
"error": {
"code": "rate_limit_exceeded",
"message": "<string>",
"retry_after": 1
}
}{
"error": {
"code": "internal_error",
"message": "<string>",
"retry_after": 1
}
}{
"error": {
"code": "unavailable",
"message": "<string>",
"retry_after": 1
}
}Assign a repository to a coding environment
Assigns a repository to the environment with its setup configuration, in the preparing status. The repository must match the organization’s Git provider. Returns a conflict if the repository is already assigned and not preparing.
POST
/
v1
/
code
/
environments
/
{environmentId}
/
repositories
Assign a repository to a coding environment
curl --request POST \
--url https://api.coderabbit.ai/v1/code/environments/{environmentId}/repositories \
--header 'Content-Type: application/json' \
--header 'x-coderabbitai-api-key: <api-key>' \
--data '
{
"repository": {
"repositoryId": "<string>",
"repositoryName": "<string>"
},
"setup": {
"setupMethod": "automatic",
"setupScript": "<string>",
"startupScript": "<string>",
"startupInstructions": "<string>"
},
"org_id": "<string>",
"org_name": "<string>"
}
'import requests
url = "https://api.coderabbit.ai/v1/code/environments/{environmentId}/repositories"
payload = {
"repository": {
"repositoryId": "<string>",
"repositoryName": "<string>"
},
"setup": {
"setupMethod": "automatic",
"setupScript": "<string>",
"startupScript": "<string>",
"startupInstructions": "<string>"
},
"org_id": "<string>",
"org_name": "<string>"
}
headers = {
"x-coderabbitai-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-coderabbitai-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
repository: {repositoryId: '<string>', repositoryName: '<string>'},
setup: {
setupMethod: 'automatic',
setupScript: '<string>',
startupScript: '<string>',
startupInstructions: '<string>'
},
org_id: '<string>',
org_name: '<string>'
})
};
fetch('https://api.coderabbit.ai/v1/code/environments/{environmentId}/repositories', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"repository": {
"id": "<string>",
"environmentId": "<string>",
"repositoryProvider": "<string>",
"repositoryId": "<string>",
"repositoryName": "<string>",
"status": "preparing",
"machineSize": "<string>",
"setupMethod": "<string>",
"setupScript": "<string>",
"startupScript": "<string>",
"startupInstructions": "<string>",
"configRevision": 123,
"preparedRevision": 123,
"setupAgentTaskId": "<string>",
"lastPreparedAt": "<string>",
"lastError": "<string>",
"createdAt": "<string>",
"updatedAt": "<string>"
}
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"retry_after": 1
}
}{
"error": {
"code": "unauthenticated",
"message": "<string>",
"retry_after": 1
}
}{
"error": {
"code": "forbidden",
"message": "<string>",
"retry_after": 1
}
}{
"error": {
"code": "not_found",
"message": "<string>",
"retry_after": 1
}
}{
"error": {
"code": "head_changed",
"message": "<string>",
"retry_after": 1
}
}{
"error": {
"code": "precondition_failed",
"message": "<string>",
"retry_after": 1
}
}{
"error": {
"code": "payload_too_large",
"message": "<string>",
"retry_after": 1
}
}{
"error": {
"code": "rate_limit_exceeded",
"message": "<string>",
"retry_after": 1
}
}{
"error": {
"code": "internal_error",
"message": "<string>",
"retry_after": 1
}
}{
"error": {
"code": "unavailable",
"message": "<string>",
"retry_after": 1
}
}- CLI Tool
- MCP Server
coderabbit api request "/code/environments/$ENVIRONMENT_ID/repositories" --input request.json
An agent connected to the CodeRabbit MCP server runs this operation as the
add_code_environment_repository tool. The connection selects the organization, so the arguments have no org_id or org_name.{
"method": "tools/call",
"params": {
"name": "add_code_environment_repository",
"arguments": {
"environmentId": "<environmentId>",
"repository": {},
"setup": {}
}
}
}
Authorizations
See Authentication for the key types and where to create a key.
Body
application/json
Organization for a workspace key: the Git-provider organization ID (scope.provider_organization_id) or the CodeRabbit organization ID (scope.id, or id from list organizations). Supply either org_id or org_name, never both. Omit for organization keys and MCP connections.
Minimum string length:
1Was this page helpful?