---
title: "Create Policy Repo"
method: POST
path: "/v2/projects/{proj_id}/repos"
tags: ["Policy Git Repositories"]
---

# Create Policy Repo

`POST /v2/projects/{proj_id}/repos`

Creates a new policy repository configuration under a given project.
The given repository is created with status 'pending', it will be changed and used as the 'active' repository for
the policy only after a successful attempt to use it.
The repository main branch must be present in the remote.

## Path parameters

- `proj_id` string, required — Either the unique id of the project, or the URL-friendly key of the project (i.e: the "slug").

## Request body

- PolicyRepoCreate
  - `key` string, required — A URL-friendly name of the policy repo (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the policy repo.
  - `url` string, required — The SSH URL of the git repository (e.g. git@github.com:username/repository.git)
  - `main_branch_name` string
  - `credentials` SSHAuthData, required
    - `auth_type` 'ssh'
    - `username` string, required — SSH username
    - `public_key` string — SSH public key
    - `private_key` string, required — SSH private key
  - `activate_when_validated` boolean — if you want to change your policy repository to this repo right after it is validated

## Response `200`

Successful Response

- PolicyRepoRead
  - `id` string, uuid, required — Unique id of the policy repo
  - `status` 'invalid' | 'pending' | 'valid', required — An enumeration.
  - `key` string, required — A URL-friendly name of the policy repo (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the policy repo.
  - `url` string, required — The SSH URL of the git repository (e.g. git@github.com:username/repository.git)
  - `main_branch_name` string
  - `credentials` SSHAuthDataRead, required
    - `auth_type` 'ssh'
    - `username` string, required — SSH username
    - `public_key` string — SSH public key
    - `private_key` string, required — SSH private key
  - `activate_when_validated` boolean — if you want to change your policy repository to this repo right after it is validated

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/permit/apis/permit-io-api.md) · [All operations](https://skmtc.net/permit/apis/permit-io-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/permit/permit-io-api/versions/dd6be355a62e/schema)
