---
title: "Create or replace the repository"
method: POST
path: "/projects/{project_id}/repository"
tags: ["Repositories"]
---

# Create or replace the repository

`POST /projects/{project_id}/repository`

## Request

- Base URL: `https://sg.deployhq.com`
- URL: `https://sg.deployhq.com/projects/{project_id}/repository`
- Auth: HTTP basic

Replaces the project's repository configuration. Any existing repository is destroyed and a new one is created with the provided settings.

## Path parameters

- `project_id` string, required

## Request body

- RepositoryObject2
  - `repository` object, required
    - `url` string
    - `scm_type` string
    - `username` string
    - `password` string
    - `branch` string
    - `port` integer
    - `root_path` string
    - `hosting_service_type` string
    - `manual_config` boolean

## Response `200`

Success

- Repository
  - `scm_type` string
  - `url` string
  - `port` integer, nullable
  - `username` string, nullable
  - `branch` string
  - `cached` boolean
  - `hosting_service` object
    - `name` string
    - `url` string
    - `tree_url` string
    - `commits_url` string

## Other responses

- `401`: You are not authorized to access this resource. You need to authenticate yourself first.
- `403`: You are not allowed to access this resource. You do not have the necessary permissions.
- `422`: Unprocessable Entity
- `500`: An unexpected error occurred on the server. The server was unable to process the request.

---

[API](https://skmtc.dev/deployhq/apis/deployhq-api-interactive-documentation.md) · [All operations](https://skmtc.dev/deployhq/apis/deployhq-api-interactive-documentation/llms.txt) · [OpenAPI document](https://skmtc.dev/deployhq/apis/deployhq-api-interactive-documentation/revisions/830264ae58be?raw)
