---
title: "Transfer ownership"
method: POST
path: "/repos/{repo_id}/transfer"
tags: ["Repository Manipulation"]
---

# Transfer ownership

`POST /repos/{repo_id}/transfer`

Transfer repository ownership or attach to an organization.

Two modes of operation:
- Transfer ownership within an organization: Provide new_owner_user_id to change the repository owner to another user in the same organization
- Transfer personal repo to organization: Provide target_organization_id to attach a personal repository to an organization

Exactly one of new_owner_user_id or target_organization_id must be provided.

## Request body

- TransferOwnershipRequest — Transfer repository ownership or attach to organization: - User ID: Transfer ownership within an organization to another user - Organization ID: Attach a personal repository to an organization
  - `target_id` string, required — ID of the transfer target (user or organization).
  - `source_organization_id` string, nullable — ID of the source organization (optional, for future org-to-org transfers)

## Response `200`

Repository transferred successfully

- Repo
  - `repo_name` string, required
  - `description` string
  - `organization_id` string — The ID of the organization to associate the repo with. If not provided, the system will use the user's organization if they belong to exactly one.
  - `repo_id` string, required
  - `default_branch_id` string
  - `default_branch_name` string
  - `size_bytes` number, float, required
  - `owner_user_id` string, required
  - `created_timestamp` integer, required — Seconds since epoch UTC
  - `sync_git_repo_url` string — Optional URL of the git repository being synced with the repo
  - `sync_git_level` 1 | 2 | 3 | 4 — One of: 1 - latest commit of default branch, 2 - default branch with history, 3 - full repo with history, 4 - full repo with history and sync [default]
  - `digest_method` 'sha1' | 'md5' — The method used to calculate the digest of BLOBs in the repo.
  - `def_auto_forwarding_enabled` boolean

## Other responses

- `400` — Invalid request (same user, naming conflict, invalid target ID format, etc.)
- `403` — Only repository owner can transfer ownership, or user is not a member/admin/owner of target organization
- `404` — Repository or target user not found
- `default` — An error occurred

---

[API](https://skmtc.net/diversion/apis/diversion-core-api.md) · [All operations](https://skmtc.net/diversion/apis/diversion-core-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/diversion/diversion-core-api/revisions/38a18aba804b/schema)
