---
title: "Connect a project to a GitHub repository"
method: PUT
path: "/v1/apps/{appId}/repository"
tags: ["Projects"]
deprecated: true
---

# Connect a project to a GitHub repository

`PUT /v1/apps/{appId}/repository`

## Request

- Base URL: `https://api.spice.ai`
- URL: `https://api.spice.ai/v1/apps/{appId}/repository`
- Auth: HTTP bearer

> **Deprecated.**

Legacy alias of `/v1/projects/{projectId}/repository`. Projects were previously called apps. Connects the project to a repository in the organization's GitHub
account, through the organization's Spice Cloud GitHub App
installation. The next deployment reads spicepod.yaml (or
spicepod.yml) from `root_directory` on `production_branch`.
Connecting sets the project description to the repository
description. Connecting again replaces the repository, root directory
and production branch.
Requires `apps:write`.

## Path parameters

- `appId` integer, required

## Headers

- `X-Org-Name` string

## Request body

- object
  - `repository` string, required: Repository in the organization's GitHub account, as `name` or `owner/name`. The owner must be the organization's GitHub account.
  - `root_directory` string, nullable: Directory inside the repository that contains spicepod.yaml. Omit it, or send null or an empty string, for the repository root.
  - `production_branch` string: Branch that deployments read. Defaults to the repository's default branch. A branch that GitHub renamed is stored under its new name.

## Response `200`

Project connected

- object
  - `project_id` integer, required: The project ID
  - `repository` string, required: The repository as `owner/name`
  - `repository_id` integer, required: The GitHub repository ID
  - `root_directory` string, nullable, required: The stored root directory. Null is the repository root.
  - `production_branch` string, required: The branch that deployments read
  - `connected_at` string, date-time, required: When the project was connected
  - `has_spicepod` boolean, required: True when spicepod.yaml or spicepod.yml exists in the root directory on the production branch. A deployment fails until it does.

## Other responses

- `400`: Invalid project ID or request body, a repository outside the organization's GitHub account (code: `invalid_repository`), or a root directory outside the repository (code: `invalid_root_directory`)
- `401`: Unauthorized
- `403`: Insufficient scope, or viewer role cannot mutate projects
- `404`: Project not found, or the organization's GitHub App installation cannot read the repository (code: `repository_not_found`)
- `409`: The organization has no usable GitHub App installation (code: `github_not_connected`), or another project already deploys this repository and root directory (code: `root_directory_conflict`)
- `413`: Request body too large
- `422`: The repository has no branch named `production_branch` (code: `branch_not_found`), the project has no spicepod configuration (code: `spicepod_missing`), or the organization is not fully configured
- `500`: Internal server error
- `503`: GitHub did not answer (code: `github_unavailable`)

---

[API](https://skmtc.dev/spice/apis/spice-cloud-control-plane-api.md) - [All operations](https://skmtc.dev/spice/apis/spice-cloud-control-plane-api/llms.txt) - [OpenAPI document](https://skmtc.dev/spice/apis/spice-cloud-control-plane-api/revisions/5f3b75dd847d?raw)
