### Get Repository Webhook Request Example Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories This example shows how to make a GET request to retrieve a specific webhook subscription for a repository. Ensure you include your access token in the Authorization header. ```bash curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/hooks/{uid}' \ --header 'Authorization: Bearer ' \ --header 'Accept: application/json' ``` -------------------------------- ### Get Repository Webhook Response Example Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories This is an example of a successful response when retrieving a webhook subscription. It includes details like the webhook's UUID, URL, description, and the events it's configured for. ```json { "type": "", "uuid": "", "url": "", "description": "", "subject_type": "repository", "active": true, "created_at": "", "events": [ "issue:comment_created" ], "secret_set": true, "secret": "" } ``` -------------------------------- ### Paginated Repositories Response Example Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Example JSON structure for a paginated response of repositories, including metadata like size, page, and links to next/previous pages. ```json { "size": 142, "page": 102, "pagelen": 159, "next": "", "previous": "", "values": [ { "type": "", "links": { "self": { "href": "", "name": "" }, "html": { "href": "", "name": "" }, "avatar": { "href": "", "name": "" }, "pullrequests": { "href": "", "name": "" }, "commits": { "href": "", "name": "" }, "forks": { "href": "", "name": "" }, "watchers": { "href": "", "name": "" }, "downloads": { "href": "", "name": "" }, "clone": [ { "href": "", "name": "" } ], "hooks": { "href": "", "name": "" } }, "uuid": "", "full_name": "", "is_private": true, "scm": "git", "owner": { "type": "" }, "name": "", "description": "", "created_on": "", "updated_on": "", "size": 2154, "language": "", "has_issues": true, "has_wiki": true, "fork_policy": "allow_forks", "project": { "type": "" }, "mainbranch": { "type": "" } } ] } ``` -------------------------------- ### Create a Repository (POST) with Project Key Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Use this endpoint to create a new repository. This example shows how to specify the project using its key. ```curl curl -X POST -H "Content-Type: application/json" -d '{ "scm": "git", "project": { "key": "MARS" } }' https://api.bitbucket.org/2.0/repositories/teamsinspace/hablanding ``` -------------------------------- ### Example JSON Response for Repository Permissions Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories This is an example of the JSON response structure when fetching paginated repository permissions. It includes details about the user, repository, and their permission level. ```json { "pagelen": 10, "values": [ { "type": "repository_permission", "user": { "type": "user", "nickname": "evzijst", "display_name": "Erik van Zijst", "uuid": "{d301aafa-d676-4ee0-88be-962be7417567}" }, "repository": { "type": "repository", "name": "geordi", "full_name": "bitbucket/geordi", "uuid": "{85d08b4e-571d-44e9-a507-fa476535aa98}" }, "permission": "admin" } ], "page": 1, "size": 1 } ``` -------------------------------- ### Get a repository Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Returns the object describing this repository. ```APIDOC ## GET /repositories/{workspace}/{repo_slug} ### Description Returns the object describing this repository. ##### Scopes **OAuth 2.0 and Connect app scopes required:** `repository` **Forge app and API Token scopes required:** `read:repository:bitbucket` ### Request #### Path parameters **workspace** (string) - Required **repo_slug** (string) - Required ### Responses #### Success Response (200 OK) - **type** (string) - **links** (object) - **uuid** (string) - **full_name** (string) - **is_private** (boolean) - **scm** (string) - **owner** (object) - **name** (string) - **description** (string) - **created_on** (string) - **updated_on** (string) - **size** (integer) - **language** (string) - **has_issues** (boolean) - **has_wiki** (boolean) - **fork_policy** (string) - **project** (object) - **mainbranch** (object) #### Response Example (200 OK) ```json { "type": "", "links": { "self": {"href": "", "name": ""}, "html": {"href": "", "name": ""}, "avatar": {"href": "", "name": ""}, "pullrequests": {"href": "", "name": ""}, "commits": {"href": "", "name": ""}, "forks": {"href": "", "name": ""}, "watchers": {"href": "", "name": ""}, "downloads": {"href": "", "name": ""}, "clone": [{"href": "", "name": ""}], "hooks": {"href": "", "name": ""} }, "uuid": "", "full_name": "", "is_private": true, "scm": "git", "owner": {"type": ""}, "name": "", "description": "", "created_on": "", "updated_on": "", "size": 2154, "language": "", "has_issues": true, "has_wiki": true, "fork_policy": "allow_forks", "project": {"type": ""}, "mainbranch": {"type": ""} } ``` ``` -------------------------------- ### Repository settings inheritance state response Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Example JSON response indicating the repository's setting inheritance status. ```json { "type": "", "override_settings": {} } ``` -------------------------------- ### Create a Repository (POST) with Project UUID Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Use this endpoint to create a new repository. This example demonstrates specifying the project using its UUID. ```curl curl -X POST -H "Content-Type: application/json" -d '{ "scm": "git", "project": { "key": "{ba516952-992a-4c2d-acbd-17d502922f96}" } }' https://api.bitbucket.org/2.0/repositories/teamsinspace/hablanding ``` -------------------------------- ### Update Repository Webhook Request Example Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories This example demonstrates how to send a PUT request to update an existing webhook subscription. You can modify properties like description, URL, secret, active status, and events. ```bash curl --request PUT \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/hooks/{uid}' \ --header 'Authorization: Bearer ' --header 'Content-Type: application/json' --data '{ "description": "Updated description", "url": "https://new-example.com/", "active": false, "secret": null, "events": [ "repo:push" ] }' ``` -------------------------------- ### Example Response: Explicit User Permissions Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories This JSON structure represents a paginated list of user permissions for a repository, including user details and their assigned permission level. ```json { "pagelen": 10, "values": [ { "type": "repository_user_permission", "user": { "type": "user", "display_name": "Colin Cameron", "uuid": "{d301aafa-d676-4ee0-88be-962be7417567}", "account_id": "557058:ba8948b2-49da-43a9-9e8b-e7249b8e324a" }, "permission": "admin", "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/atlassian_tutorial/geordi/permissions-config/users/557058:ba8948b2-49da-43a9-9e8b-e7249b8e324a" } } }, { "type": "repository_user_permission", "user": { "type": "user", "display_name": "Sean Conaty", "uuid": "{504c3b62-8120-4f0c-a7bc-87800b9d6f70}", "account_id": "557058:ba8948b2-49da-43a9-9e8b-e7249b8e324c" }, "permission": "write", "links": { "self": { "href": "https://api.bitbucket.org/2.0//repositories/atlassian_tutorial/geordi/permissions-config/users/557058:ba8948b2-49da-43a9-9e8b-e7249b8e324c" } } } ], "page": 1, "size": 2 } ``` -------------------------------- ### Example Response: Single Explicit User Permission Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories This JSON object details a single user's explicit permission for a repository, including their user information and permission level. ```json { "type": "repository_user_permission", "user": { "type": "user", "display_name": "Colin Cameron", "uuid": "{d301aafa-d676-4ee0-88be-962be7417567}", "account_id": "557058:ba8948b2-49da-43a9-9e8b-e7249b8e324a", "nickname": "Colin Cameron" }, "permission": "admin", "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/atlassian_tutorial/geordi/permissions-config/users/557058:ba8948b2-49da-43a9-9e8b-e7249b8e324a" } } } ``` -------------------------------- ### Get Forks of a Repository Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Retrieves a paginated list of all forks for a given repository. Requires an access token for authorization. ```curl curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/forks' \ --header 'Authorization: Bearer ' \ --header 'Accept: application/json' ``` -------------------------------- ### Get Repository Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Retrieves the details of a specific repository. This includes information such as the repository's name, description, owner, creation date, and more. ```APIDOC ## GET /repositories/{workspace}/{repo_slug} ### Description Retrieves the details of a specific repository. ### Method GET ### Endpoint /repositories/{workspace}/{repo_slug} ### Parameters #### Path Parameters - **workspace** (string) - Required - The workspace ID or un-slugified name of the repository. - **repo_slug** (string) - Required - The repository's name or un-slugified name. ### Response #### Success Response (200) - **type** (string) - **links** (object) - **uuid** (string) - **full_name** (string) - **is_private** (boolean) - **scm** (string) - **owner** (object) - **name** (string) - **description** (string) - **created_on** (string) - **updated_on** (string) - **size** (integer) - **language** (string) - **has_issues** (boolean) - **has_wiki** (boolean) - **fork_policy** (string) - **project** (object) - **mainbranch** (object) ### Response Example ```json { "type": "repository", "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/my-workspace/my-repo" }, "html": { "href": "https://bitbucket.org/my-workspace/my-repo" }, "avatar": { "href": "https://bytebucket.org/users/my-workspace/avatar/32" }, "pullrequests": { "href": "https://api.bitbucket.org/2.0/repositories/my-workspace/my-repo/pullrequests" }, "commits": { "href": "https://api.bitbucket.org/2.0/repositories/my-workspace/my-repo/commits" }, "forks": { "href": "https://api.bitbucket.org/2.0/repositories/my-workspace/my-repo/forks" }, "watchers": { "href": "https://api.bitbucket.org/2.0/repositories/my-workspace/my-repo/watchers" }, "downloads": { "href": "https://api.bitbucket.org/2.0/repositories/my-workspace/my-repo/downloads" }, "clone": [ { "href": "https://bitbucket.org/my-workspace/my-repo.git", "name": "https" }, { "href": "git@bitbucket.org:my-workspace/my-repo.git", "name": "ssh" } ], "hooks": { "href": "https://api.bitbucket.org/2.0/repositories/my-workspace/my-repo/webhooks" } }, "uuid": "", "full_name": "my-workspace/my-repo", "is_private": true, "scm": "git", "owner": { "type": "workspace", "display_name": "My Workspace", "uuid": "" }, "name": "my-repo", "description": "A sample repository.", "created_on": "2023-01-01T12:00:00.000000+00:00", "updated_on": "2023-01-01T12:00:00.000000+00:00", "size": 2154, "language": "python", "has_issues": true, "has_wiki": true, "fork_policy": "allow_forks", "project": { "type": "project", "key": "PROJ", "name": "My Project" }, "mainbranch": { "type": "branch", "name": "main" } } ``` ``` -------------------------------- ### Example JSON Response for Workspace Repository Permissions Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories This JSON structure represents the response for listing repository permissions within a specific workspace for a user. It details the user, repository, and their granted permission. ```json { "pagelen": 10, "values": [ { "type": "repository_permission", "user": { "type": "user", "nickname": "jessyeh", "display_name": "Jessica Yeh", "uuid": "{d301abfa-d676-4ee0-88be-962ce7443567}" }, "repository": { "type": "repository", "name": "bits", "full_name": "bitbucket/bits", "uuid": "{85d67b4e-571d-44e9-a507-fa476935aa98}" }, "permission": "admin" } ], "page": 1, "size": 1 } ``` -------------------------------- ### Get Repository Details (cURL) Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Retrieve detailed information about a specific repository using its workspace and slug. Replace `{workspace}`, `{repo_slug}`, and `` with your specific values. ```curl curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}' \ --header 'Authorization: Bearer ' ``` -------------------------------- ### List Repository Webhooks Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Retrieves a paginated list of all webhooks installed on a specific repository. This is useful for monitoring events and integrations. ```APIDOC ## GET /repositories/{workspace}/{repo_slug}/hooks ### Description Returns a paginated list of webhooks installed on this repository. ### Method GET ### Endpoint /repositories/{workspace}/{repo_slug}/hooks ### Parameters #### Path Parameters - **repo_slug** (string) - Required - The repository's slug. - **workspace** (string) - Required - The repository's workspace. ### Responses #### Success Response (200) - **size** (integer) - The total number of webhooks. - **page** (integer) - The current page number. - **pagelen** (integer) - The number of webhooks per page. - **next** (string) - The URL for the next page of results. - **previous** (string) - The URL for the previous page of results. - **values** (array) - A list of webhook subscription objects. - **type** (string) - The type of the webhook subscription. - **uuid** (string) - The unique identifier for the webhook subscription. - **url** (string) - The URL to which the webhook events are sent. - **description** (string) - A description of the webhook. - **subject_type** (string) - The type of the subject the webhook is attached to (e.g., 'repository'). - **active** (boolean) - Indicates if the webhook is active. - **created_at** (string) - The timestamp when the webhook was created. - **events** (array) - A list of event types that trigger the webhook. - **secret_set** (boolean) - Indicates if a secret has been set for the webhook. - **secret** (string) - The secret used for webhook authentication (if set). #### Error Response (403) Forbidden: Indicates insufficient permissions. #### Error Response (404) Not Found: Indicates the repository or workspace was not found. ### Request Example ```curl curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/hooks' \ --header 'Authorization: Bearer ' \ --header 'Accept: application/json' ``` ### Response Example ```json { "size": 142, "page": 102, "pagelen": 159, "next": "", "previous": "", "values": [ { "type": "", "uuid": "", "url": "", "description": "", "subject_type": "repository", "active": true, "created_at": "", "events": [ "issue:comment_created" ], "secret_set": true, "secret": "" } ] } ``` ``` -------------------------------- ### Get a Repository - cURL Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Use this cURL command to retrieve details for a specific Bitbucket repository. Ensure you replace `{workspace}` and `{repo_slug}` with your actual workspace and repository slug, and provide a valid ``. ```curl curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}' \ --header 'Authorization: Bearer ' \ --header 'Accept: application/json' ``` -------------------------------- ### List Repository Webhooks using cURL Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Retrieve a paginated list of webhooks installed on a repository. Requires `webhook` scope for OAuth 2.0 or `read:webhook:bitbucket` for API Tokens. ```curl curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/hooks' \ --header 'Authorization: Bearer ' \ --header 'Accept: application/json' ``` -------------------------------- ### Get Paginated Repository Permissions (curl) Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Use this endpoint to retrieve a paginated list of repository permissions for the authenticated user. Requires the `access_token`. ```curl curl --request GET \ --url 'https://api.bitbucket.org/2.0/user/permissions/repositories' \ --header 'Authorization: Bearer ' \ --header 'Accept: application/json' ``` -------------------------------- ### Get Repository Permissions in a Workspace (curl) Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Retrieve a list of repository permissions for the authenticated user within a specific workspace. This endpoint requires the `workspace` path parameter and an `access_token`. ```curl curl --request GET \ --url 'https://api.bitbucket.org/2.0/user/workspaces/{workspace}/permissions/repositories' \ --header 'Authorization: Bearer ' \ --header 'Accept: application/json' ``` -------------------------------- ### Get Explicit User Permission for a Repository Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Fetches the explicit permission details for a specific user on a repository. Only users with admin permission for the repository can access this. Requires `repository:admin` scope for OAuth/Connect apps or `read:repository:bitbucket` for Forge apps and API Tokens. ```curl curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/permissions-config/users/{selected_user_id}' \ --header 'Authorization: Bearer ' \ --header 'Accept: application/json' ``` -------------------------------- ### List All Repositories (cURL) Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Use this cURL command to fetch a paginated list of all repositories accessible via the Bitbucket API. Ensure you replace `` with your valid authentication token. ```curl curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories' \ --header 'Authorization: Bearer ' \ --header 'Accept: application/json' ``` -------------------------------- ### Create a Repository Webhook Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Use this endpoint to create a new webhook for a repository. Provide a URL, description, and specify the events the webhook should listen for. An optional secret can be provided for HMAC signature generation. ```bash $ curl -X POST -u credentials -H 'Content-Type: application/json' https://api.bitbucket.org/2.0/repositories/my-workspace/my-repo-slug/hooks -d ' { "description": "Webhook Description", "url": "https://example.com/", "active": true, "secret": "this is a really bad secret", "events": [ "repo:push", "issue:created", "issue:updated" ] }' ``` -------------------------------- ### Get User Permission Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Returns the explicit user permission for a given user and repository. ```APIDOC ## GET /repositories/{workspace}/{repo_slug}/permissions-config/users/{selected_user_id} ### Description Returns the explicit user permission for a given user and repository. Only users with admin permission for the repository may access this resource. Permissions can be: `admin`, `write`, `read`, `none`. ### Method GET ### Endpoint /repositories/{workspace}/{repo_slug}/permissions-config/users/{selected_user_id} ### Parameters #### Path Parameters - **repo_slug** (string) - Required - The repository's slug. - **selected_user_id** (string) - Required - The user's ID. - **workspace** (string) - Required - The workspace ID. ### Responses #### Success Response (200) Explicit user permission for user and repository ##### application/json Repository User Permission ```json { "type": "repository_user_permission", "user": { "type": "user", "display_name": "Colin Cameron", "uuid": "{d301aafa-d676-4ee0-88be-962be7417567}", "account_id": "557058:ba8948b2-49da-43a9-9e8b-e7249b8e324a", "nickname": "Colin Cameron" }, "permission": "admin", "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/atlassian_tutorial/geordi/permissions-config/users/557058:ba8948b2-49da-43a9-9e8b-e7249b8e324a" } } } ``` #### Error Responses - **401** Unauthorized - **403** Forbidden - **404** Not Found ``` -------------------------------- ### Get Repository Group Permission Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Retrieves a specific group permission for a given repository and group slug. ```APIDOC ## GET /repositories/{workspace}/{repo_slug}/permissions-config/groups/{group_slug} ### Description Returns the group permission for a given group slug and repository. Only users with admin permission for the repository may access this resource. ### Method GET ### Endpoint /repositories/{workspace}/{repo_slug}/permissions-config/groups/{group_slug} ### Parameters #### Path Parameters - **group_slug** (string) - Required - The slug of the group. - **repo_slug** (string) - Required - The slug of the repository. - **workspace** (string) - Required - The workspace ID. ### Responses #### Success Response (200) ##### application/json Repository Group Permission ### Request Example ```curl curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/permissions-config/groups/{group_slug}' \ --header 'Authorization: Bearer ' \ --header 'Accept: application/json' ``` ### Response Example ```json { "type": "repository_group_permission", "group": { "type": "group", "name": "Developers", "slug": "developers", "full_slug": "atlassian_tutorial:developers" }, "permission": "read", "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/atlassian_tutorial/geordi/permissions-config/groups/developers" } } } ``` ``` -------------------------------- ### List Repositories in a Workspace (cURL) Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories This cURL command lists repositories within a specific workspace. Replace `{workspace}` with the actual workspace ID and `` with your authentication token. ```curl curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}' \ --header 'Authorization: Bearer ' \ --header 'Accept: application/json' ``` -------------------------------- ### Get a webhook for a repository Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Retrieves a specific webhook subscription by its UID on the given repository. Requires `webhook` scope. ```APIDOC ## Get a webhook for a repository ### Description Returns the webhook with the specified id installed on the specified repository. ##### Scopes **OAuth 2.0 and Connect app scopes required:** `webhook` **API Token scopes required:** `read:webhook:bitbucket` ### Method GET ### Endpoint `/repositories/{workspace}/{repo_slug}/hooks/{uid}` ### Parameters #### Path Parameters - **repo_slug** (string) - Required - **uid** (string) - Required - **workspace** (string) - Required ### Responses #### Success Response (200 OK) The webhook subscription object. #### application/json (Webhook Subscription object) #### Error Response (404 Not Found) ``` -------------------------------- ### Create a Repository using cURL Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Use this snippet to create a new Bitbucket repository. Ensure you replace placeholders like , , and with your actual values. The request body includes optional fields for repository configuration. ```curl curl --request POST \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}' \ --header 'Authorization: Bearer ' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --data '{ \ "type": "", \ "links": { \ "self": { \ "href": "", \ "name": "" \ }, \ "html": { \ "href": "", \ "name": "" \ }, \ "avatar": { \ "href": "", \ "name": "" \ }, \ "pullrequests": { \ "href": "", \ "name": "" \ }, \ "commits": { \ "href": "", \ "name": "" \ }, \ "forks": { \ "href": "", \ "name": "" \ }, \ "watchers": { \ "href": "", \ "name": "" \ }, \ "downloads": { \ "href": "", \ "name": "" \ }, \ "clone": [ \ { \ "href": "", \ "name": "" \ } \ ], \ "hooks": { \ "href": "", \ "name": "" \ } \ }, \ "uuid": "", \ "full_name": "", \ "is_private": true, \ "parent": { \ "type": "" \ }, \ "scm": "git", \ "owner": { \ "type": "" \ }, \ "name": "", \ "description": "", \ "created_on": "", \ "updated_on": "", \ "size": 2154, \ "language": "", \ "has_issues": true, \ "has_wiki": true, \ "fork_policy": "allow_forks", \ "project": { \ "type": "" \ }, \ "mainbranch": { \ "type": "" \ } \ }' ``` -------------------------------- ### Create Repository Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Creates a new repository. The project must be assigned for all repositories. ```APIDOC ## Create a repository ### Description Creates a new repository. Note: In order to set the project for the newly created repository, pass in either the project key or the project UUID as part of the request body as shown in the examples below: ### Method POST ### Endpoint `/repositories/{workspace}` ### Parameters #### Path Parameters - **workspace** (string) - Required #### Request Body - **scm** (string) - Required - **project** (object) - Required - **key** (string) - Required ### Request Example ```json { "scm": "git", "project": { "key": "MARS" } } ``` ### Scopes **OAuth 2.0 and Connect app scopes required:** `repository:admin` **Forge app and API Token scopes required:** `admin:repository:bitbucket` ``` -------------------------------- ### Create Repository Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Creates a new Bitbucket repository. The `owner` and `full_name` elements in the request body are ignored as they are implied by the URL. Most object elements are optional. ```APIDOC ## POST /repositories/{workspace}/{repo_slug} ### Description Creates a new Bitbucket repository. ### Method POST ### Endpoint /repositories/{workspace}/{repo_slug} ### Request Body application/json ```json { "type": "", "links": { "self": { "href": "", "name": "" }, "html": { "href": "", "name": "" }, "avatar": { "href": "", "name": "" }, "pullrequests": { "href": "", "name": "" }, "commits": { "href": "", "name": "" }, "forks": { "href": "", "name": "" }, "watchers": { "href": "", "name": "" }, "downloads": { "href": "", "name": "" }, "clone": [ { "href": "", "name": "" } ], "hooks": { "href": "", "name": "" } }, "uuid": "", "full_name": "", "is_private": true, "parent": { "type": "" }, "scm": "git", "owner": { "type": "" }, "name": "", "description": "", "created_on": "", "updated_on": "", "size": 2154, "language": "", "has_issues": true, "has_wiki": true, "fork_policy": "allow_forks", "project": { "type": "" }, "mainbranch": { "type": "" } } ``` ### Responses #### Success Response (200 OK) application/json ```json { "type": "", "links": { "self": { "href": "", "name": "" }, "html": { "href": "", "name": "" }, "avatar": { "href": "", "name": "" }, "pullrequests": { "href": "", "name": "" }, "commits": { "href": "", "name": "" }, "forks": { "href": "", "name": "" }, "watchers": { "href": "", "name": "" }, "downloads": { "href": "", "name": "" }, "clone": [ { "href": "", "name": "" } ], "hooks": { "href": "", "name": "" } }, "uuid": "", "full_name": "", "is_private": true, "scm": "git", "owner": { "type": "" }, "name": "", "description": "", "created_on": "", "updated_on": "", "size": 2154, "language": "", "has_issues": true, "has_wiki": true, "fork_policy": "allow_forks", "project": { "type": "" }, "mainbranch": { "type": "" } } ``` ``` -------------------------------- ### List Repository Forks using cURL Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Use this cURL command to retrieve a paginated list of all forks for a specified Bitbucket repository. Replace {workspace} and {repo_slug} with your repository's details and ensure your access token has the required 'repository' scope. ```curl curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/forks' \ --header 'Authorization: Bearer ' ``` -------------------------------- ### List repositories in a workspace Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Returns a paginated list of all repositories owned by the specified workspace. The result can be narrowed down based on the authenticated user's role. ```APIDOC ## GET /repositories/{workspace} ### Description Returns a paginated list of all repositories owned by the specified workspace. The result can be narrowed down based on the authenticated user's role. E.g. with `?role=contributor`, only those repositories that the authenticated user has write access to are returned (this includes any repo the user is an admin on, as that implies write access). This endpoint also supports filtering and sorting of the results. See filtering and sorting for more details. ##### Scopes **OAuth 2.0 and Connect app scopes required:** `repository` **Forge app and API Token scopes required:** `read:repository:bitbucket` ### Request #### Path parameters **workspace** (string) - Required #### Query parameters **role** (string) - Optional **q** (string) - Optional **sort** (string) - Optional ### Responses #### Success Response (200 OK) - **size** (integer) - The total number of items in the result set. - **page** (integer) - The page number of the results. - **pagelen** (integer) - The number of items per page. - **next** (string) - The URL to the next page of results. - **previous** (string) - The URL to the previous page of results. - **values** (array) - A list of repository objects. #### Response Example (200 OK) ```json { "size": 142, "page": 102, "pagelen": 159, "next": "", "previous": "", "values": [ { "type": "", "links": { "self": {"href": "", "name": ""}, "html": {"href": "", "name": ""}, "avatar": {"href": "", "name": ""}, "pullrequests": {"href": "", "name": ""}, "commits": {"href": "", "name": ""}, "forks": {"href": "", "name": ""}, "watchers": {"href": "", "name": ""}, "downloads": {"href": "", "name": ""}, "clone": [{"href": "", "name": ""}], "hooks": {"href": "", "name": ""} }, "uuid": "", "full_name": "", "is_private": true, "scm": "git", "owner": {"type": ""}, "name": "", "description": "", "created_on": "", "updated_on": "", "size": 2154, "language": "", "has_issues": true, "has_wiki": true, "fork_policy": "allow_forks", "project": {"type": ""}, "mainbranch": {"type": ""} } ] } ``` ``` -------------------------------- ### List Explicit User Permissions for a Repository Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Retrieves a paginated list of explicit user permissions for a given repository. Requires `repository:admin` scope for OAuth/Connect apps or `read:repository:bitbucket` for Forge apps and API Tokens. This endpoint does not support BBQL features. ```curl curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/permissions-config/users' \ --header 'Authorization: Bearer ' \ --header 'Accept: application/json' ``` -------------------------------- ### Get Explicit Repository Group Permission Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Retrieves the specific permission for a given group and repository. Only users with admin permission for the repository can access this resource. Permissions can be 'admin', 'write', 'read', or 'none'. ```curl curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/permissions-config/groups/{group_slug}' \ --header 'Authorization: Bearer ' \ --header 'Accept: application/json' ``` -------------------------------- ### Repository Fork Response Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories This is a sample JSON response for a successful repository fork operation. It details the properties of the newly created fork. ```json { "type": "", "links": { "self": { "href": "", "name": "" }, "html": { "href": "", "name": "" }, "avatar": { "href": "", "name": "" }, "pullrequests": { "href": "", "name": "" }, "commits": { "href": "", "name": "" }, "forks": { "href": "", "name": "" }, "watchers": { "href": "", "name": "" }, "downloads": { "href": "", "name": "" }, "clone": [ { "href": "", "name": "" } ], "hooks": { "href": "", "name": "" } }, "uuid": "", "full_name": "", "is_private": true, "scm": "git", "owner": { "type": "" }, "name": "", "description": "", "created_on": "", "updated_on": "", "size": 2154, "language": "", "has_issues": true, "has_wiki": true, "fork_policy": "allow_forks", "project": { "type": "" }, "mainbranch": { "type": "" } } ``` -------------------------------- ### Paginated Repositories JSON Response Source: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories Example JSON structure for a paginated response when listing repositories. It includes metadata like page size and links to next/previous pages, along with an array of repository objects. ```json { "size": 142, "page": 102, "pagelen": 159, "next": "", "previous": "", "values": [ { "type": "", "links": { "self": { "href": "", "name": "" }, "html": { "href": "", "name": "" }, "avatar": { "href": "", "name": "" }, "pullrequests": { "href": "", "name": "" }, "commits": { "href": "", "name": "" }, "forks": { "href": "", "name": "" }, "watchers": { "href": "", "name": "" }, "downloads": { "href": "", "name": "" }, "clone": [ { "href": "", "name": "" } ], "hooks": { "href": "", "name": "" } }, "uuid": "", "full_name": "", "is_private": true, "scm": "git", "owner": { "type": "" }, "name": "", "description": "", "created_on": "", "updated_on": "", "size": 2154, "language": "", "has_issues": true, "has_wiki": true, "fork_policy": "allow_forks", "project": { "type": "" }, "mainbranch": { "type": "" } } ] } ```