---
title: "Link a Repository to a Project"
url: https://docs.sentry.io/api/projects/link-a-repository-to-a-project/
---

# Link a Repository to a Project | Sentry Docs

POST /api/0/projects/{organization\_id\_or\_slug}/{project\_id\_or\_slug}/repo/

Link a repository to a project. The repository must already exist in the organization (connected via a VCS integration). Idempotent: returns 200 if the link already exists, 201 if created.

### Path Parameters

* `organization_id_or_slug` *(string)*

  REQUIRED

  The ID or slug of the organization the resource belongs to.

* `project_id_or_slug` *(string)*

  REQUIRED

  The ID or slug of the project the resource belongs to. Project slugs are unique within each organization.

### Body Parameters

* `repositoryId` *(integer)*

  REQUIRED

  The ID of the repository to link.

### Scopes

You need to [authenticate via bearer auth token.](https://docs.sentry.io/api/auth.md)

`<auth_token>` requires one of the following scopes:

* `project:admin`
* `project:write`

```
curl https://sentry.io/api/0/projects/{organization_id_or_slug}/{project_id_or_slug}/repo/ \
 -H 'Authorization: Bearer <auth_token>' \
 -H 'Content-Type: application/json' \
 -d '{}'
```

RESPONSESCHEMA

```
Copied
.
```

---

Find other pages: [Sitemap](https://docs.sentry.io/sitemap.md) lists every page with a one-line summary, and [llms.txt](https://docs.sentry.io/llms.txt) gives an overview with guidance for agents.
