> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/code-repository/2.0/use-harness-code/manage-repositories/delete-repo.md).

# Delete repositories

Delete repositories in Harness Code

{% hint style="warning" %}
Deleting a repository removes it, and all its contents, including files, commits, branches, and pull requests, from view immediately.

Harness Code keeps a deleted repository in a soft-deleted state for 90 days before permanently purging it. You can restore a repository within that window using the API. After 90 days, deletion is permanent and the repository can't be recovered.
{% endhint %}

To delete a repository in Harness Code:

1. In the Harness Code module, go to the Harness account, organization, or project that contains the repo you want to delete.

   This depends on where the repo was created or imported. For example, if it was created at the project scope, you need to navigate to the repo within that specific project.
2. Select **Repositories**.
3. Select the repository you want to delete.
4. Go to **Settings** and select **Delete**.
5. Follow the prompts to confirm deletion.

## Restore a deleted repository

Within 90 days of deletion, you can restore a repository, along with its pull requests and other metadata, using the Code repository API. Restoring from the UI is not supported.

1. List the deleted repositories in the account, organization, or project, filtering by deletion time. Pass `deleted_before_or_at` as a Unix epoch timestamp **in milliseconds**.

   <pre class="language-bash" data-title="List deleted repositories" data-overflow="wrap"><code class="lang-bash">curl --location 'https://app.harness.io/gateway/code/api/v1/repos?accountIdentifier={ACCOUNT_ID}&#x26;orgIdentifier={ORG_ID}&#x26;projectIdentifier={PROJECT_ID}&#x26;deleted_before_or_at={EPOCH_MILLISECONDS}&#x26;recursive=true' \
     --header 'x-api-key: {API_KEY}'
   </code></pre>
2. From the response, note the identifier and `deleted_at` timestamp of the repository you want to restore.
3. Restore the repository using its `deleted_at` timestamp.

   <pre class="language-bash" data-title="Restore a deleted repository" data-overflow="wrap"><code class="lang-bash">curl --location --request POST 'https://app.harness.io/gateway/code/api/v1/repos/{REPO_IDENTIFIER}/restore?accountIdentifier={ACCOUNT_ID}&#x26;orgIdentifier={ORG_ID}&#x26;projectIdentifier={PROJECT_ID}&#x26;deleted_at={DELETED_AT_TIMESTAMP}' \
     --header 'x-api-key: {API_KEY}'
   </code></pre>

The repository is restored with its full state at the time of deletion, including branches, commits, and pull requests.

{% @harness-feedback/feedback module="code-repository" pagePath="code-repository/use-harness-code/manage-repositories/delete-repo" %}
