Cookie Notice

REST Resources Provided By: Bitbucket Server - REST

This is the reference document for the Atlassian Bitbucket REST API. The REST API is for developers who want to:

You can read more about developing Bitbucket plugins in the Bitbucket Developer Documentation.

Getting started

Because the REST API is based on open standards, you can use any web development language or command line tool capable of generating an HTTP request to access the API. See the developer documentation for a basic usage example.

If you're already working with the Atlassian SDK, the REST API Browser is a great tool for exploring and experimenting with the Bitbucket REST API.

Structure of the REST URIs

Bitbucket's REST APIs provide access to resources (data entities) via URI paths. To use a REST API, your application will make an HTTP request and parse the response. The Bitbucket REST API uses JSON as its communication format, and the standard HTTP methods like GET, PUT, POST and DELETE. URIs for Bitbucket's REST API resource have the following structure:

    http://host:port/context/rest/api-name/api-version/path/to/resource

For example, the following URI would retrieve a page of the latest commits to the jira repository in the Jira project on https://stash.atlassian.com.

    https://stash.atlassian.com/rest/api/1.0/projects/JIRA/repos/jira/commits

See the API descriptions below for a full list of available resources.

Alternatively we also publish a list of resources in WADL format. It is available here.

Paged APIs

Bitbucket uses paging to conserve server resources and limit response size for resources that return potentially large collections of items. A request to a paged API will result in a values array wrapped in a JSON object with some paging metadata, like this:

    {
        "size": 3,
        "limit": 3,
        "isLastPage": false,
        "values": [
            { /* result 0 */ },
            { /* result 1 */ },
            { /* result 2 */ }
        ],
        "start": 0,
        "filter": null,
        "nextPageStart": 3
    }

Clients can use the limit and start query parameters to retrieve the desired number of results.

The limit parameter indicates how many results to return per page. Most APIs default to returning 25 if the limit is left unspecified. This number can be increased, but note that a resource-specific hard limit will apply. These hard limits can be configured by server administrators, so it's always best practice to check the limit attribute on the response to see what limit has been applied. The request to get a larger page should look like this:

    http://host:port/context/rest/api-name/api-version/path/to/resource?limit={desired size of page}

For example:

    https://stash.atlassian.com/rest/api/1.0/projects/JIRA/repos/jira/commits?limit=1000

The start parameter indicates which item should be used as the first item in the page of results. All paged responses contain an isLastPage attribute indicating whether another page of items exists.

Important: If more than one page exists (i.e. the response contains "isLastPage": false), the response object will also contain a nextPageStart attribute which must be used by the client as the start parameter on the next request. Identifiers of adjacent objects in a page may not be contiguous, so the start of the next page is not necessarily the start of the last page plus the last page's size. A client should always use nextPageStart to avoid unexpected results from a paged API. The request to get a subsequent page should look like this:

    http://host:port/context/rest/api-name/api-version/path/to/resource?start={nextPageStart from previous response}

For example:

    https://stash.atlassian.com/rest/api/1.0/projects/JIRA/repos/jira/commits?start=25

Authentication

Any authentication that works against Bitbucket will work against the REST API. The preferred authentication methods are HTTP Basic (when using SSL) and OAuth. Other supported methods include: HTTP Cookies and Trusted Applications.

You can find OAuth code samples in several programming languages at bitbucket.org/atlassian_tutorial/atlassian-oauth-examples.

The log-in page uses cookie-based authentication, so if you are using Bitbucket in a browser you can call REST from JavaScript on the page and rely on the authentication that the browser has established.

Errors & Validation

If a request fails due to client error, the resource will return an HTTP response code in the 40x range. These can be broadly categorised into:

HTTP Code Description
400 (Bad Request) One or more of the required parameters or attributes:
  • were missing from the request;
  • incorrectly formatted; or
  • inappropriate in the given context.
401 (Unauthorized) Either:
  • Authentication is required but was not attempted.
  • Authentication was attempted but failed.
  • Authentication was successful but the authenticated user does not have the requisite permission for the resource.
See the individual resource documentation for details of required permissions.
403 (Forbidden) Actions are usually "forbidden" if they involve breaching the licensed user limit of the server, or degrading the authenticated user's permission level. See the individual resource documentation for more details.
404 (Not Found) The entity you are attempting to access, or the project or repository containing it, does not exist.
405 (Method Not Allowed) The request HTTP method is not appropriate for the targeted resource. For example an HTTP GET to a resource that only accepts an HTTP POST will result in a 405.
409 (Conflict) The attempted update failed due to some conflict with an existing resource. For example:
  • Creating a project with a key that already exists
  • Merging an out-of-date pull request
  • Deleting a comment that has replies
  • etc.
See the individual resource documentation for more details.
415 (Unsupported Media Type) The request entity has a Content-Type that the server does not support. Almost all of the Bitbucket REST API accepts application/json format, but check the individual resource documentation for more details. Additionally, double-check that you are setting the Content-Type header correctly on your request (e.g. using -H "Content-Type: application/json" in cURL).

For 400 HTTP codes the response will typically contain one or more validation error messages, for example:

    {
        "errors": [
            {
                "context": "name",
                "message": "The name should be between 1 and 255 characters.",
                "exceptionName": null
            },
            {
                "context": "email",
                "message": "The email should be a valid email address.",
                "exceptionName": null
            }
        ]
    }
    

The context attribute indicates which parameter or request entity attribute failed validation. Note that the context may be null.

For 401, 403, 404 and 409 HTTP codes, the response will contain one or more descriptive error messages:

    {
        "errors": [
            {
                "context": null,
                "message": "A detailed error message.",
                "exceptionName": null
            }
        ]
    }
    

A 500 (Server Error) HTTP code indicates an incorrect resource url or an unexpected server error. Double-check the URL you are trying to access, then report the issue to your server administrator or Atlassian Support if problems persist.

Personal Repositories

Bitbucket allows users to manage their own repositories, called personal repositories. These are repositories associated with the user and to which they always have REPO_ADMIN permission.

Accessing personal repositories via REST is achieved through the normal project-centric REST URLs using the user's slug prefixed by tilde as the project key. E.g. to list personal repositories for a user with slug "johnsmith" you would make a GET to:

http://example.com/rest/api/1.0/projects/~johnsmith/repos

In addition to this, Bitbucket allows access to these repositories through an alternate set of user-centric REST URLs beginning with:

http://example.com/rest/api/1.0/users/~{userSlug}/repos
E.g. to list the forks of the repository with slug "nodejs" in the personal project of user with slug "johnsmith" using the regular REST URL you would make a GET to:
http://example.com/rest/api/1.0/projects/~johnsmith/repos/nodejs/forks
Using the alternate URL, you would make a GET to:
http://example.com/rest/api/1.0/users/johnsmith/repos/nodejs/forks

Index

Provides REST resources

Resources

Rest resource for retrieving, creating and deleting users or groups

/rest/api/1.0/admin/users

Methods

POST

/rest/api/1.0/admin/users?name&password&displayName&emailAddress&addToDefaultGroup&notify

Creates a new user from the assembled query parameters.

The default group can be used to control initial permissions for new users, such as granting users the ability to login or providing read access to certain projects or repositories. If the user is not added to the default group, they may not be able to login after their account is created until explicit permissions are configured.

The authenticated user must have the ADMIN permission to call this resource.

request query parameters
parametervaluedescription

name

string

the username for the new user

password

string

the password for the new user

displayName

string

the display name for the new user

emailAddress

string

the e-mail address for the new user

addToDefaultGroup

boolean

Default: true

true to add the user to the default group, which can be used to grant them a set of initial permissions; otherwise, false to not add them to a group

notify

string

if present and not false instead of requiring a password, the create user will be notified via email their account has been created and requires a password to be reset. This option can only be used if a mail server has been configured

Example response representations:

  • 204 [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 403 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

DELETE

/rest/api/1.0/admin/users?name

Deletes the specified user, removing them from the system. This also removes any permissions that may have been granted to the user.

A user may not delete themselves, and a user with ADMIN permissions may not delete a user with SYS_ADMINpermissions.

The authenticated user must have the ADMIN permission to call this resource.

request query parameters
parametervaluedescription

name

string

the username identifying the user to delete

Example response representations:

  • 200 - application/json (detailedUser) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 403 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

PUT

Update a user's details.

The authenticated user must have the ADMIN permission to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (detailedUser) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

/rest/api/1.0/admin/users?filter

This is a paged API.

Retrieve a page of users.

The authenticated user must have the LICENSED_USER permission to call this resource.

request query parameters
parametervaluedescription

filter

string

if specified only users with usernames, display name or email addresses containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/admin/users/erasure

Methods

GET

/rest/api/1.0/admin/users/erasure?name

Validate if a user can be erased.

A username is only valid for erasure if it exists as the username of a deleted user. This endpoint will return an appropriate error response if the supplied username is invalid for erasure.

This endpoint does not perform the actual user erasure, and will not modify the application in any way.

The authenticated user must have the ADMIN permission to call this resource.

request query parameters
parametervaluedescription

name

string

the username of the user to validate erasability for.

Example response representations:

  • 204 - application/json [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

POST

/rest/api/1.0/admin/users/erasure?name

Erases personally identifying user data for a deleted user.

References in the application to the original username will be either removed or updated to a new non-identifying username. Refer to the support guide for details about what data is and isn't erased.

User erasure can only be performed on a deleted user. If the user has not been deleted first then this endpoint will return a bad request and no erasure will be performed.

Erasing user data is irreversible and may lead to a degraded user experience. This method should not be used as part of a standard user deletion and cleanup process.

Plugins can participate in user erasure by defining a <user-erasure-handler> module. If one or more plugin modules fail, an error summary of the failing modules is returned.

The authenticated user must have the ADMIN permission to call this resource.

request query parameters
parametervaluedescription

name

string

the username identifying the user to erase

Example response representations:

  • 200 - application/json (detailedUser) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

/rest/api/1.0/admin/groups/remove-user

Methods

POST

Deprecated since 2.10. Use /rest/users/remove-groups instead.

Remove a user from a group.

The authenticated user must have the ADMIN permission to call this resource.

In the request entity, the context attribute is the group and the itemName is the user.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 [expand]
  • 401 - application/json (errors) [expand]
  • 403 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/admin/users/remove-group

Methods

POST

Remove a user from a group. This is very similar to groups/remove-user, but with the context and itemName attributes of the supplied request entity reversed. On the face of it this may appear redundant, but it facilitates a specific UI component in Stash.

In the request entity, the context attribute is the user and the itemName is the group.

The authenticated user must have the ADMIN permission to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 [expand]
  • 401 - application/json (errors) [expand]
  • 403 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/admin/groups/more-members

Methods

GET

/rest/api/1.0/admin/groups/more-members?context&filter

This is a paged API.

Retrieves a list of users that are members of a specified group.

The authenticated user must have the LICENSED_USER permission to call this resource.

request query parameters
parametervaluedescription

context

string

the group which should be used to locate members

filter

string

Default:

if specified only users with usernames, display names or email addresses containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/admin/groups/more-non-members

Methods

GET

/rest/api/1.0/admin/groups/more-non-members?context&filter

This is a paged API.

Retrieves a list of users that are not members of a specified group.

The authenticated user must have the LICENSED_USER permission to call this resource.

request query parameters
parametervaluedescription

context

string

the group which should be used to locate non-members

filter

string

Default:

if specified only users with usernames, display names or email addresses containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/admin/users/more-members

Methods

GET

/rest/api/1.0/admin/users/more-members?context&filter

This is a paged API.

Retrieves a list of groups the specified user is a member of.

The authenticated user must have the LICENSED_USER permission to call this resource.

request query parameters
parametervaluedescription

context

string

the user which should be used to locate groups

filter

string

Default:

if specified only groups with names containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/admin/users/more-non-members

Methods

GET

/rest/api/1.0/admin/users/more-non-members?context&filter

This is a paged API.

Retrieves a list of groups the specified user is not a member of.

The authenticated user must have the LICENSED_USER permission to call this resource.

request query parameters
parametervaluedescription

context

string

the user which should be used to locate groups

filter

string

Default:

if specified only groups with names containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/admin/users/rename

Methods

POST

Rename a user.

The authenticated user must have the ADMIN permission to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (detailedUser) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/admin/users/captcha

Methods

DELETE

/rest/api/1.0/admin/users/captcha?name

Clears any CAPTCHA challenge that may constrain the user with the supplied username when they authenticate. Additionally any counter or metric that contributed towards the user being issued the CAPTCHA challenge (for instance too many consecutive failed logins) will also be reset.

The authenticated user must have the ADMIN permission to call this resource, and may not clear the CAPTCHA of a user with greater permissions than themselves.

request query parameters
parametervaluedescription

name

string

the username

Example response representations:

  • 204 - application/json [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 403 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/admin/groups

Methods

DELETE

/rest/api/1.0/admin/groups?name

Deletes the specified group, removing them from the system. This also removes any permissions that may have been granted to the group.

A user may not delete the last group that is granting them administrative permissions, or a group with greater permissions than themselves.

The authenticated user must have the ADMIN permission to call this resource.

request query parameters
parametervaluedescription

name

string

the name identifying the group to delete

Example response representations:

  • 200 - application/json (detailedGroup) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 403 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

POST

/rest/api/1.0/admin/groups?name

Create a new group.

The authenticated user must have ADMIN permission or higher to call this resource.

request query parameters
parametervaluedescription

name

string

Name of the group.

Example response representations:

  • 200 - application/json (restDetailedGroup) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

GET

/rest/api/1.0/admin/groups?filter

This is a paged API.

Retrieve a page of groups.

The authenticated user must have LICENSED_USER permission or higher to call this resource.

request query parameters
parametervaluedescription

filter

string

if specified only group names containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/admin/users/credentials

Methods

PUT

Update a user's password.

The authenticated user must have the ADMIN permission to call this resource, and may not update the password of a user with greater permissions than themselves.

Example request representations:

  • application/json [expand]

Example response representations:

  • 204 [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/admin/groups/add-user

Methods

POST

Deprecated since 2.10. Use /rest/users/add-groups instead.

Add a user to a group.

In the request entity, the context attribute is the group and the itemName is the user.

The authenticated user must have the ADMIN permission to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 [expand]
  • 401 - application/json (errors) [expand]
  • 403 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/admin/users/add-group

Methods

POST

Deprecated since 2.10. Use /rest/users/add-groups instead.

Add a user to a group. This is very similar to groups/add-user, but with the context and itemName attributes of the supplied request entity reversed. On the face of it this may appear redundant, but it facilitates a specific UI component in Stash.

In the request entity, the context attribute is the user and the itemName is the group.

The authenticated user must have the ADMIN permission to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 [expand]
  • 401 - application/json (errors) [expand]
  • 403 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/admin/groups/add-users

Methods

POST

Add multiple users to a group.

The authenticated user must have the ADMIN permission to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 [expand]
  • 401 - application/json (errors) [expand]
  • 403 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/admin/users/add-groups

Methods

POST

Add a user to one or more groups.

The authenticated user must have the ADMIN permission to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 [expand]
  • 401 - application/json (errors) [expand]
  • 403 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/admin/banner

Methods

PUT

Sets the announcement banner with the provided JSON. Only users authenticated as Admins may call this resource

Example request representations:

Example response representations:

  • 204 [expand]
  • 400 [expand]
  • 401 [expand]

DELETE

Deletes a banner, if one is present in the database.

Example response representations:

  • 204 [expand]
  • 401 [expand]

GET

Gets the announcement banner, if one exists and is available to the user

Example response representations:

  • 200 - application/json (banner) [expand]
  • 204 [expand]
  • 401 [expand]

/rest/api/1.0/admin/cluster

Methods

GET

Gets information about the nodes that currently make up the stash cluster.

The authenticated user must have the SYS_ADMIN permission to call this resource.

Example response representations:

  • 200 - application/json [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/admin/license

A REST endpoint for retrieving or updating the license.

Methods

GET

Retrieves details about the current license, as well as the current status of the system with regards to the installed license. The status includes the current number of users applied toward the license limit, as well as any status messages about the license (warnings about expiry or user counts exceeding license limits).

The authenticated user must have ADMIN permission. Unauthenticated users, and non-administrators, are not permitted to access license details.

Example response representations:

  • 200 - application/json (license) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

POST

Decodes the provided encoded license and sets it as the active license. If no license was provided, a 400 is returned. If the license cannot be decoded, or cannot be applied, a 409 is returned. Some possible reasons a license may not be applied include:

  • It is for a different product
  • It is already expired
Otherwise, if the license is updated successfully, details for the new license are returned with a 200 response.

Warning: It is possible to downgrade the license during update, applying a license with a lower number of permitted users. If the number of currently-licensed users exceeds the limits of the new license, pushing will be disabled until the licensed user count is brought into compliance with the new license.

The authenticated user must have SYS_ADMIN permission. ADMIN users may view the current license details, but they may not update the license.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (license) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

/rest/api/1.0/admin/mail-server

Methods

DELETE

Deletes the current mail configuration.

The authenticated user must have the SYS_ADMIN permission to call this resource.

Example response representations:

  • 204 - application/json [expand]
  • 401 - application/json (errors) [expand]

PUT

Updates the mail configuration The authenticated user must have the SYS_ADMIN permission to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (mailConfiguration) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]

GET

Retrieves the current mail configuration. The authenticated user must have the SYS_ADMIN permission to call this resource.

Example response representations:

  • 200 - application/json (mailHostConfiguration) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json [expand]

/rest/api/1.0/admin/mail-server/sender-address

Methods

PUT

Updates the server email address The authenticated user must have the ADMIN permission to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (senderAddress) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]

GET

Retrieves the server email address

Example response representations:

  • 200 - application/json (server email address) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json [expand]

DELETE

Clears the server email address.

The authenticated user must have the ADMIN permission to call this resource.

Example response representations:

  • 204 - application/json [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/admin/permissions/users/none

Methods

GET

/rest/api/1.0/admin/permissions/users/none?filter

This is a paged API.

Retrieve a page of users that have no granted global permissions.

The authenticated user must have ADMIN permission or higher to call this resource.

request query parameters
parametervaluedescription

filter

string

Default:

if specified only user names containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/admin/permissions/groups

Methods

PUT

/rest/api/1.0/admin/permissions/groups?permission&name

Promote or demote a user's global permission level. Available global permissions are:

  • LICENSED_USER
  • PROJECT_CREATE
  • ADMIN
  • SYS_ADMIN
See the Bitbucket Server documentation for a detailed explanation of what each permission entails.

The authenticated user must have:

  • ADMIN permission or higher; and
  • the permission they are attempting to grant or higher; and
  • greater or equal permissions than the current permission level of the group (a user may not demote the permission level of a group with higher permissions than them)
to call this resource. In addition, a user may not demote a group's permission level if their own permission level would be reduced as a result.

request query parameters
parametervaluedescription

permission

string

the permission to grant

name

string

the names of the groups

Example response representations:

  • 204 [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 403 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

DELETE

/rest/api/1.0/admin/permissions/groups?name

Revoke all global permissions for a group.

The authenticated user must have:

  • ADMIN permission or higher; and
  • greater or equal permissions than the current permission level of the group (a user may not demote the permission level of a group with higher permissions than them)
to call this resource. In addition, a user may not revoke a group's permissions if their own permission level would be reduced as a result.

request query parameters
parametervaluedescription

name

string

the name of the group

Example response representations:

  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

GET

/rest/api/1.0/admin/permissions/groups?filter

This is a paged API.

Retrieve a page of groups that have been granted at least one global permission.

The authenticated user must have ADMIN permission or higher to call this resource.

request query parameters
parametervaluedescription

filter

string

Default:

if specified only group names containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/admin/permissions/users

Methods

PUT

/rest/api/1.0/admin/permissions/users?name&permission

Promote or demote the global permission level of a user. Available global permissions are:

  • LICENSED_USER
  • PROJECT_CREATE
  • ADMIN
  • SYS_ADMIN
See the Bitbucket Server documentation for a detailed explanation of what each permission entails.

The authenticated user must have:

  • ADMIN permission or higher; and
  • the permission they are attempting to grant; and
  • greater or equal permissions than the current permission level of the user (a user may not demote the permission level of a user with higher permissions than them)
to call this resource. In addition, a user may not demote their own permission level.

request query parameters
parametervaluedescription

name

string

the names of the users

permission

string

the permission to grant

Example response representations:

  • 204 [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 403 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

DELETE

/rest/api/1.0/admin/permissions/users?name

Revoke all global permissions for a user.

The authenticated user must have:

  • ADMIN permission or higher; and
  • greater or equal permissions than the current permission level of the user (a user may not demote the permission level of a user with higher permissions than them)
to call this resource. In addition, a user may not demote their own permission level.

request query parameters
parametervaluedescription

name

string

the name of the user

Example response representations:

  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

GET

/rest/api/1.0/admin/permissions/users?filter

This is a paged API.

Retrieve a page of users that have been granted at least one global permission.

The authenticated user must have ADMIN permission or higher to call this resource.

request query parameters
parametervaluedescription

filter

string

Default:

if specified only user names containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/admin/permissions/groups/none

Methods

GET

/rest/api/1.0/admin/permissions/groups/none?filter

This is a paged API.

Retrieve a page of groups that have no granted global permissions.

The authenticated user must have ADMIN permission or higher to call this resource.

request query parameters
parametervaluedescription

filter

string

Default:

if specified only group names containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/admin/pull-requests/{scmId}

resource-wide template parameters
parametervaluedescription

scmId

string

the id of the scm to get strategies for

Methods

GET

This is a paged API.

Retrieve the merge strategies available for this instance.

The user must be authenticated to call this resource.

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

POST

Update the pull request merge strategies for the context repository.

The authenticated user must have ADMIN permission for the context repository to call this resource.

Only the strategies provided will be enabled, only one may be set to default

An explicitly set pull request merge strategy configuration can be deleted by POSTing a document with an empty "mergeConfig" attribute. i.e:

 {
     "mergeConfig": {
     }
 }
 
Upon completion of this request, the effective configuration will be the default configuration.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (strategies) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/admin/rate-limit/history

Methods

GET

/rest/api/1.0/admin/rate-limit/history?order

Retrieves the recent rate limit history for the instance.

The authenticated user must have the ADMIN permission to call this resource.

request query parameters
parametervaluedescription

order

string

an optional sort category to arrange the results in descending order by either {@link AggregateRejectCounterOrder#NEWEST} or {@link AggregateRejectCounterOrder#FREQUENCY}

Example response representations:

  • 200 - application/json [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/admin/rate-limit/settings

Methods

PUT

Sets the rate limit settings for the instance.

The authenticated user must have ADMIN permission to call this resource.

Example request representations:

Example response representations:

  • 200 - application/json [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]

GET

Retrieves the rate limit settings for the instance.

The user must be authenticated to call this resource.

Example response representations:

  • 200 - application/json [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/admin/rate-limit/settings/users

Methods

GET

/rest/api/1.0/admin/rate-limit/settings/users?filter

Retrieves the user-specific rate limit settings for the given user.

The authenticated user must have ADMIN permission to call this resource.

request query parameters
parametervaluedescription

filter

string

Example response representations:

  • 200 - application/json [expand]
  • 401 - application/json (errors) [expand]

POST

Sets the given rate limit settings for the given user.

The authenticated user must have ADMIN permission to call this resource.

Example request representations:

Example response representations:

  • 200 - application/json [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/admin/rate-limit/settings/users/{userSlug}

Methods

GET

Retrieves the user-specific rate limit settings for the given user.

To call this resource, the user must be authenticated and either have ADMIN permission or be the same user as the one whose settings are requested. A user with ADMIN permission cannot get the settings of a user with SYS_ADMIN permission.

Example response representations:

  • 200 - application/json [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

DELETE

Deletes the user-specific rate limit settings for the given user.

The authenticated user must have ADMIN permission to call this resource.

Example response representations:

  • 204 - application/json [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

PUT

Sets the given rate limit settings for the given user.

The authenticated user must have ADMIN permission to call this resource.

Example request representations:

Example response representations:

  • 200 - application/json [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/application-properties

Methods

GET

Retrieve version information and other application properties.

No authentication is required to call this resource.

Example response representations:

  • 200 - application/json (applicationProperties) [expand]

/rest/api/1.0/build/capabilities

Methods

GET

This is a paged API.

Returns the build capabilities of this instance

Example response representations:

  • 200 - application/json (page) [expand]
REST Resource for personal dashboards

/rest/api/1.0/dashboard/pull-request-suggestions

Methods

GET

/rest/api/1.0/dashboard/pull-request-suggestions?changesSince&limit

This is a paged API.

Retrieves a page of suggestions for pull requests that the currently authenticated user may wish to raise. Such suggestions are based on ref changes occurring and so contain the ref change that prompted the suggestion plus the time the change event occurred. Changes will be returned in descending order based on the time the change that prompted the suggestion occurred.

Note that although the response is a page object, the interface does not support paging, however a limit can be applied to the size of the returned page.

request query parameters
parametervaluedescription

changesSince

string

Default: 172800

restrict pull request suggestions to be based on events that occurred since some time in the past. This is expressed in seconds since "now". So to return suggestions based only on activity within the past 48 hours, pass a value of 172800.

limit

int

Default: 3

restricts the result set to return at most this many suggestions.

Example response representations:

  • 200 - application/json (page) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/dashboard/pull-requests

Methods

GET

/rest/api/1.0/dashboard/pull-requests?state&role&participantStatus&order&closedSince

This is a paged API.

Retrieve a page of pull requests where the current authenticated user is involved as either a reviewer, author or a participant. The request may be filtered by pull request state, role or participant status.

request query parameters
parametervaluedescription

state

string

(optional, defaults to returning pull requests in any state). If a state is supplied only pull requests in the specified state will be returned. Either OPEN, DECLINED or MERGED. Omit this parameter to return pull request in any state.

role

string

(optional, defaults to returning pull requests for any role). If a role is supplied only pull requests where the authenticated user is a participant in the given role will be returned. Either REVIEWER, AUTHOR or PARTICIPANT.

participantStatus

string

(optional, defaults to returning pull requests with any participant status). A comma separated list of participant status. That is, one or more of UNAPPROVED, NEEDS_WORK, or APPROVED.

order

string

(optional, defaults to NEWEST) the order to return pull requests in, either OLDEST (as in: "oldest first"), NEWEST, PARTICIPANT_STATUS, or CLOSED_DATE. Where CLOSED_DATE is specified and the result set includes pull requests that are not in the closed state, these pull requests will appear first in the result set, followed by most recently closed pull requests.

closedSince

string

(optional, defaults to returning pull requests regardless of closed since date). Permits returning only pull requests with a closed timestamp set more recently that (now - closedSince). Units are in seconds. So for example if closed since 86400 is set only pull requests closed in the previous 24 hours will be returned.

Example response representations:

  • 200 - application/json (page) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/groups

Methods

GET

/rest/api/1.0/groups?filter

This is a paged API.

Retrieve a page of group names.

The authenticated user must have PROJECT_ADMIN permission or higher to call this resource.

request query parameters
parametervaluedescription

filter

string

if specified only group names containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/hooks/{hookKey}/avatar

resource-wide template parameters
parametervaluedescription

hookKey

string

the complete module key of the hook module

Methods

GET

/rest/api/1.0/hooks/{hookKey}/avatar?version

Retrieve the avatar for the project matching the supplied moduleKey.

request query parameters
parametervaluedescription

version

string

optional version used for HTTP caching only - any non-blank version will result in a large max-age Cache-Control header. Note that this does not affect the Last-Modified header.

Example response representations:

  • 200 - image/png [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/inbox/pull-requests

Methods

GET

/rest/api/1.0/inbox/pull-requests?start&limit&role
request query parameters
parametervaluedescription

start

int

Default: 0

limit

int

Default: 25

role

string

Default: reviewer

Example response representations:

  • application/json; charset=UTF-8 [expand]

/rest/api/1.0/inbox/pull-requests/count

Methods

GET

Example response representations:

  • application/json; charset=UTF-8 [expand]

/rest/api/1.0/labels

Methods

GET

/rest/api/1.0/labels?prefix

Returns a paged response of all the labels in the system.

The user needs to be authenticated to use this resource.

request query parameters
parametervaluedescription

prefix

string

(optional) prefix to filter the labels on.

Example response representations:

  • 201 - application/json (label) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/labels/{labelName}

resource-wide template parameters
parametervaluedescription

labelName

string

the label name

Methods

GET

Returns a label.

The user needs to be authenticated to use this resource.

Example response representations:

  • 200 - application/json (label) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/labels/{labelName}/labeled

resource-wide template parameters
parametervaluedescription

labelName

string

the label name, provided on the path

Methods

GET

/rest/api/1.0/labels/{labelName}/labeled?type

Returns a page of labelables for a given label.

The authenticated user must have REPO_ADMIN permission for the specified repository.

request query parameters
parametervaluedescription

type

string

the type of labelables to be returned. Supported values: REPOSITORY

Example response representations:

  • 200 - application/json (labelables) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/logs/rootLogger/{levelName}

resource-wide template parameters
parametervaluedescription

levelName

string

the level to set the logger to. Either TRACE, DEBUG, INFO, WARN or ERROR

Methods

PUT

Set the current log level for the root logger.

The authenticated user must have ADMIN permission or higher to call this resource.

Example response representations:

  • 204 - application/json [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/logs/rootLogger

Methods

GET

Retrieve the current log level for the root logger.

The authenticated user must have ADMIN permission or higher to call this resource.

Example response representations:

  • 200 - application/json (logLevel) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/logs/logger/{loggerName}/{levelName}

resource-wide template parameters
parametervaluedescription

levelName

string

the level to set the logger to. Either TRACE, DEBUG, INFO, WARN or ERROR

loggerName

string

the name of the logger.

Methods

PUT

Set the current log level for a given logger.

The authenticated user must have ADMIN permission or higher to call this resource.

Example response representations:

  • 204 - application/json [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/logs/logger/{loggerName}

resource-wide template parameters
parametervaluedescription

loggerName

string

the name of the logger.

Methods

GET

Retrieve the current log level for a given logger.

The authenticated user must have ADMIN permission or higher to call this resource.

Example response representations:

  • 200 - application/json (logLevel) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/markup/preview

Methods

POST

/rest/api/1.0/markup/preview?hardwrap&htmlEscape&includeHeadingId&urlMode

Preview generated HTML for the given markdown content.

Only authenticated users may call this resource.

request query parameters
parametervaluedescription

hardwrap

boolean

(Optional) Whether the markup implementation should convert newlines to breaks. By default this is false which reflects the standard markdown specification.

htmlEscape

boolean

(Optional) true if HTML should be escaped in the input markup, false otherwise.

includeHeadingId

boolean

(Optional) true if headers should contain an ID based on the heading content.

urlMode

string

(Optional) The mode to use when building URLs. One of: ABSOLUTE, RELATIVE or CONFIGURED. By default this is RELATIVE.

Example request representations:

  • */* [expand]

Example response representations:

  • 200 - application/json (markup) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/migration/imports/{jobId}/messages

resource-wide template parameters
parametervaluedescription

jobId

long

the ID of the job

Methods

GET

/rest/api/1.0/migration/imports/{jobId}/messages?severity&subject

This is a paged API.

Gets the messages generated by the job.

Without any filter, all messages will be returned, but the response can optionally be filtered for the following severities. The severity parameter can be repeated to include multiple severities in one response.

  • INFO
  • WARN
  • ERROR

The authenticated user must have ADMIN permission or higher to call this resource.

request query parameters
parametervaluedescription

severity

string

the severity to include in the results

subject

string

the subject

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/migration/exports/preview

Methods

POST

Enumerates the projects and repositories that would be exported for a given export request.

All affected repositories will be enumerated explicitly, and while projects are listed as individual items in responses from this endpoint, their presence does not imply that all their repositories are included.

While this endpoint can be used to verify that all selectors in the request apply as intended, it should be noted that a subsequent, actual export might contain a different set of repositories, as they might have been added or deleted in the meantime.

Note that the overall response from this endpoint can become very large when a lot of repositories end up in the selection. This is why the server is streaming the response while it is being generated (as opposed to creating it in memory and then sending it all at once) and it can be consumed in a streaming way, too.

Also, due to the potential size of the response, projects and repositories are listed with fewer details than in other REST responses.

For a more detailed description of selectors, see the endpoint documentation for starting an export.

The authenticated user must have ADMIN permission or higher to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (scopes) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/migration/exports

Methods

POST

Starts a background job that exports the selected repositories.

Only 2 concurrent exports are supported per cluster node. If a request ends up on a node that is already running that many export jobs, the request will be rejected and an error returned.

The response includes a description of the job that has been started, and its ID can be used to query these details again, including the current progress, warnings and errors that occurred while processing the job, and to interrupt and cancel the execution of this job.

The request to start an export is similar to the one for previewing an export. Additionally, it accepts an optional parameter, exportLocation, which can be used to specify a relative path within data/migration/export in the shared home directory. No locations outside of that directory will be accepted for exports.

There are essentially three ways to select repositories for export. Regardless of which you use, a few general rules apply:

  • You can supply a list of selectors. The selection will be additive.
  • Repositories that are selected more than once due to overlapping selectors will be de-duplicated and effectively exported only once.
  • For every selected repository, its full fork hierarchy will be considered selected, even if parts of that hierarchy would otherwise not be matched by the provided selectors. For example, when you explicitly select a single repository only, but that repository is a fork, then its origin will be exported (and eventually imported), too.

Now, a single repository can be selected like this:

     {
        "projectKey": "PRJ",
        "slug": "my-repo"
     }
     

Second, all repositories in a specific project can be selected like this:

     {
        "projectKey": "PRJ",
        "slug": *"
     }
     

And third, all projects and repositories in the system would be selected like this:

     {
        "projectKey": "*",
        "slug": *"
     }
     

The authenticated user must have ADMIN permission or higher to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (job) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 503 - application/json (errors) [expand]

/rest/api/1.0/migration/imports

Methods

POST

Starts a background job that imports the specified archive.

Only 1 import at a time is supported per cluster. If another request is made while an import is already running, the request will be rejected and an error returned.

The path in the request must point to a valid archive file. The file must be located within the data/migration/import directory in the shared home directory.

The authenticated user must have ADMIN permission or higher to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (job) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 503 - application/json (errors) [expand]

/rest/api/1.0/migration/imports/{jobId}/cancel

resource-wide template parameters
parametervaluedescription

jobId

long

the ID of the job to cancel

Methods

POST

Requests the cancellation of an import job.

The request to cancel a job will be processed successfully if the job is actually still running. If it has already finished (successfully or with errors) or if it has already been canceled before, then an error will be returned.

Note that import jobs are not canceled as instantaneously as export jobs. Rather, once the request has been accepted, there are a number of checkpoints at which the job will actually apply it and stop. This is to keep the system in a reasonably consistent state:

  • After the current fork hierarchy has been imported and verified.
  • Before the next repository is imported.
  • Before the next pull request is imported.

A client should always actively query the job status to confirm that a job has been successfully canceled.

The authenticated user must have ADMIN permission or higher to call this resource.

Example response representations:

  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

/rest/api/1.0/migration/imports/{jobId}

resource-wide template parameters
parametervaluedescription

jobId

long

the ID of the job

Methods

GET

Gets the details, including the current status and progress, of the import job identified by the given ID.

The authenticated user must have ADMIN permission or higher to call this resource.

Example response representations:

  • 200 - application/json (job) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/migration/exports/{jobId}

resource-wide template parameters
parametervaluedescription

jobId

long

the ID of the job

Methods

GET

Gets the details, including the current status and progress, of the export job identified by the given ID.

The authenticated user must have ADMIN permission or higher to call this resource.

Example response representations:

  • 200 - application/json (job) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/migration/exports/{jobId}/cancel

resource-wide template parameters
parametervaluedescription

jobId

long

the ID of the job to cancel

Methods

POST

Requests the cancellation of an export job.

The request to cancel a job will be processed successfully if the job is actually still running. If it has already finished (successfully or with errors) or if it has already been canceled before, then an error will be returned.

There might be a small delay between accepting the request and actually cancelling the job. In most cases, the delay will be close to instantaneously. In the unlikely case of communication issues across a cluster, it can however take a few seconds to cancel a job.

A client should always actively query the job status to confirm that a job has been successfully canceled.

The authenticated user must have ADMIN permission or higher to call this resource.

Example response representations:

  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

/rest/api/1.0/migration/exports/{jobId}/messages

resource-wide template parameters
parametervaluedescription

jobId

long

the ID of the job

Methods

GET

/rest/api/1.0/migration/exports/{jobId}/messages?severity&subject

This is a paged API.

Gets the messages generated by the job.

Without any filter, all messages will be returned, but the response can optionally be filtered for the following severities. The severity parameter can be repeated to include multiple severities in one response.

  • INFO
  • WARN
  • ERROR

The authenticated user must have ADMIN permission or higher to call this resource.

request query parameters
parametervaluedescription

severity

string

the severity to include in the results

subject

string

the subject

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/profile/recent/repos

Methods

GET

/rest/api/1.0/profile/recent/repos?permission

This is a paged API.

Retrieve a page of recently accessed repositories for the currently authenticated user.

Repositories are ordered from most recently to least recently accessed.

Only authenticated users may call this resource.

request query parameters
parametervaluedescription

permission

string

(optional) if specified, it must be a valid repository permission level name and will limit the resulting repository list to ones that the requesting user has the specified permission level to. If not specified, the default REPO_READ permission level will be assumed.

Example response representations:

  • 200 - application/json (page) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/projects

Methods

POST

Create a new project.

To include a custom avatar for the project, the project definition should contain an additional attribute with the key avatar and the value a data URI containing Base64-encoded image data. The URI should be in the following format:

     data:(content type, e.g. image/png);base64,(data)
 
If the data is not Base64-encoded, or if a character set is defined in the URI, or the URI is otherwise invalid, project creation will fail.

The authenticated user must have PROJECT_CREATE permission to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 201 - application/json (project) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

GET

/rest/api/1.0/projects?name&permission

This is a paged API.

Retrieve a page of projects.

Only projects for which the authenticated user has the PROJECT_VIEW permission will be returned.

request query parameters
parametervaluedescription

name

string

name to filter by

permission

string

permission to filter by

Example response representations:

  • 200 - application/json (page) [expand]
  • 400 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}

Methods

DELETE

Delete the project matching the supplied projectKey.

The authenticated user must have PROJECT_ADMIN permission for the specified project to call this resource.

Example response representations:

  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

PUT

Update the project matching the projectKey supplied in the resource path.

To include a custom avatar for the updated project, the project definition should contain an additional attribute with the key avatar and the value a data URI containing Base64-encoded image data. The URI should be in the following format: data:(content type, e.g. image/png);base64,(data) If the data is not Base64-encoded, or if a character set is defined in the URI, or the URI is otherwise invalid, project creation will fail.

The authenticated user must have PROJECT_ADMIN permission for the specified project to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (project) [expand]
  • 201 - application/json (project) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

Retrieve the project matching the supplied projectKey.

The authenticated user must have PROJECT_VIEW permission for the specified project to call this resource.

Example response representations:

  • 200 - application/json (project) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/avatar.png

Methods

POST

Update the avatar for the project matching the supplied projectKey.

This resource accepts POST multipart form data, containing a single image in a form-field named 'avatar'.

There are configurable server limits on both the dimensions (1024x1024 pixels by default) and uploaded file size (1MB by default). Several different image formats are supported, but PNG and JPEG are preferred due to the file size limit.

This resource has Cross-Site Request Forgery (XSRF) protection. To allow the request to pass the XSRF check the caller needs to send an X-Atlassian-Token HTTP header with the value no-check.

An example curl request to upload an image name 'avatar.png' would be:

 curl -X POST -u username:password -H "X-Atlassian-Token: no-check" http://example.com/rest/api/1.0/projects/STASH/avatar.png -F avatar=@avatar.png
 

The authenticated user must have PROJECT_ADMIN permission for the specified project to call this resource.

Example response representations:

  • 201 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

/rest/api/1.0/projects/{projectKey}/avatar.png?s

Retrieve the avatar for the project matching the supplied projectKey.

The authenticated user must have PROJECT_VIEW permission for the specified project to call this resource.

request query parameters
parametervaluedescription

s

int

Default: 0

The desired size of the image. The server will return an image as close as possible to the specified size.

Example response representations:

  • 200 - image/png [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/permissions/groups

Methods

PUT

/rest/api/1.0/projects/{projectKey}/permissions/groups?permission&name

Promote or demote a group's permission level for the specified project.

The authenticated user must have PROJECT_ADMIN permission for the specified project or a higher global permission to call this resource. In addition, a user may not demote a group's permission level if their own permission level would be reduced as a result.

request query parameters
parametervaluedescription

permission

string

The permission to grant. See the [permissions documentation](https://confluence.atlassian.com/display/BitbucketServer/Using+project+permissions) for a detailed explanation of what each permission entails. Available project permissions are:

  • PROJECT_READ
  • PROJECT_WRITE
  • PROJECT_ADMIN

name

string

the names of the groups

Example response representations:

  • 204 [expand]
  • 400 - application/json (errors) [expand]
  • 401 [expand]
  • 403 [expand]
  • 404 [expand]

DELETE

/rest/api/1.0/projects/{projectKey}/permissions/groups?name

Revoke all permissions for the specified project for a group.

The authenticated user must have PROJECT_ADMIN permission for the specified project or a higher global permission to call this resource.

In addition, a user may not revoke a group's permissions if it will reduce their own permission level.

request query parameters
parametervaluedescription

name

string

the name of the group

Example response representations:

  • 204 [expand]
  • 401 [expand]
  • 404 [expand]
  • 409 [expand]

GET

/rest/api/1.0/projects/{projectKey}/permissions/groups?filter

This is a paged API.

Retrieve a page of groups that have been granted at least one permission for the specified project.

The authenticated user must have PROJECT_ADMIN permission for the specified project or a higher global permission to call this resource.

request query parameters
parametervaluedescription

filter

string

if specified only group names containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 [expand]
  • 404 [expand]

/rest/api/1.0/projects/{projectKey}/permissions/users

Methods

PUT

/rest/api/1.0/projects/{projectKey}/permissions/users?name&permission

Promote or demote a user's permission level for the specified project.

The authenticated user must have PROJECT_ADMIN permission for the specified project or a higher global permission to call this resource. In addition, a user may not reduce their own permission level unless they have a global permission that already implies that permission.

request query parameters
parametervaluedescription

name

string

the names of the users

permission

string

the permission to grant. See the [permissions documentation](https://confluence.atlassian.com/display/BitbucketServer/Using+project+permissions) for a detailed explanation of what each permission entails. Available project permissions are:

  • PROJECT_READ
  • PROJECT_WRITE
  • PROJECT_ADMIN

Example response representations:

  • 204 [expand]
  • 400 [expand]
  • 401 [expand]
  • 403 [expand]
  • 404 [expand]

DELETE

/rest/api/1.0/projects/{projectKey}/permissions/users?name

Revoke all permissions for the specified project for a user.

The authenticated user must have PROJECT_ADMIN permission for the specified project or a higher global permission to call this resource.

In addition, a user may not revoke their own project permissions if they do not have a higher global permission.

request query parameters
parametervaluedescription

name

string

the name of the user

Example response representations:

  • 204 [expand]
  • 401 [expand]
  • 404 [expand]
  • 409 [expand]

GET

/rest/api/1.0/projects/{projectKey}/permissions/users?filter

This is a paged API.

Retrieve a page of users that have been granted at least one permission for the specified project.

The authenticated user must have PROJECT_ADMIN permission for the specified project or a higher global permission to call this resource.

request query parameters
parametervaluedescription

filter

string

if specified only user names containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 [expand]
  • 404 [expand]

/rest/api/1.0/projects/{projectKey}/permissions/users/none

Methods

GET

/rest/api/1.0/projects/{projectKey}/permissions/users/none?filter

This is a paged API.

Retrieve a page of licensed users that have no granted permissions for the specified project.

The authenticated user must have PROJECT_ADMIN permission for the specified project or a higher global permission to call this resource.

request query parameters
parametervaluedescription

filter

string

if specified only user names containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 [expand]
  • 404 [expand]

/rest/api/1.0/projects/{projectKey}/permissions/groups/none

Methods

GET

/rest/api/1.0/projects/{projectKey}/permissions/groups/none?filter

This is a paged API.

Retrieve a page of groups that have no granted permissions for the specified project.

The authenticated user must have PROJECT_ADMIN permission for the specified project or a higher global permission to call this resource.

request query parameters
parametervaluedescription

filter

string

if specified only group names containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 [expand]
  • 404 [expand]

/rest/api/1.0/projects/{projectKey}/permissions/{permission}/all

resource-wide template parameters
parametervaluedescription

permission

string

the permission to grant Available project permissions are:

  • PROJECT_READ
  • PROJECT_WRITE
  • PROJECT_ADMIN

Methods

GET

Check whether the specified permission is the default permission (granted to all users) for a project.

The authenticated user must have PROJECT_ADMIN permission for the specified project or a higher global permission to call this resource.

Example response representations:

  • 200 - application/json (permitted) [expand]
  • 400 [expand]
  • 401 [expand]
  • 404 [expand]

POST

/rest/api/1.0/projects/{projectKey}/permissions/{permission}/all?allow

Grant or revoke a project permission to all users, i.e. set the default permission.

The authenticated user must have PROJECT_ADMIN permission for the specified project or a higher global permission to call this resource.

request query parameters
parametervaluedescription

allow

boolean

true to grant the specified permission to all users, or false to revoke it

Example response representations:

  • 204 [expand]
  • 400 [expand]
  • 401 [expand]
  • 404 [expand]

/rest/api/1.0/projects/{projectKey}/repos

resource-wide template parameters
parametervaluedescription

projectKey

string

the parent project key

Methods

POST

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Create a new repository. Requires an existing project in which this repository will be created. The only parameters which will be used are name and scmId.

The authenticated user must have PROJECT_ADMIN permission for the context project to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 201 - application/json (repository) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

GET

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve repositories from the project corresponding to the supplied projectKey.

The authenticated user must have REPO_READ permission for the specified project to call this resource.

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}

resource-wide template parameters
parametervaluedescription

projectKey

string

the parent project key

projectKey

string

the parent project key

repositorySlug

string

the repository slug

Methods

DELETE

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Schedule the repository matching the supplied projectKey and repositorySlug to be deleted. If the request repository is not present

The authenticated user must have sufficient permissions specified by the repository delete policy to call this resource. The default permission required is REPO_ADMIN permission.

Example response representations:

  • 202 - application/json (message) [expand]
  • 204 [expand]
  • 401 - application/json (errors) [expand]

POST

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Create a new repository forked from an existing repository.

The JSON body for this POST is not required to contain any properties. Even the name may be omitted. The following properties will be used, if provided:

  • "name":"Fork name" - Specifies the forked repository's name
    • Defaults to the name of the origin repository if not specified
  • "project":{"key":"TARGET_KEY"} - Specifies the forked repository's target project by key
    • Defaults to the current user's personal project if not specified

The authenticated user must have REPO_READ permission for the specified repository and PROJECT_ADMIN on the target project to call this resource. Note that users always have PROJECT_ADMIN permission on their personal projects.

Example request representations:

  • application/json [expand]

Example response representations:

  • 201 - application/json (repository) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve the repository matching the supplied projectKey and repositorySlug.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

Example response representations:

  • 200 - application/json (repository) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

PUT

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Update the repository matching the repositorySlug supplied in the resource path.

The repository's slug is derived from its name. If the name changes the slug may also change.

This API can be used to move the repository to a different project by setting the new project in the request, example: {"project":{"key":"NEW_KEY"}} .

The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 201 - application/json (repository) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/contributing

resource-wide template parameters
parametervaluedescription

projectKey

string

the parent project key

Methods

HEAD

Example response representations:

  • application/json; charset=UTF-8 [expand]

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/contributing?at&hardwrap&htmlEscape&includeHeadingId&markup

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieves the contributing guidelines for the repository, if they've been defined.

This checks the repository for a

CONTRIBUTING
file, optionally with an
md
or
txt
extension, and, if found, streams it. By default, the raw content of the file is streamed. Appending
?markup
to the URL will stream an HTML-rendered version instead.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

at

string

a specific commit or ref to retrieve the guidelines at, or the default branch if not specified

hardwrap

string

(Optional) Whether the markup implementation should convert newlines to breaks. If not specified, the value of the markup.render.hardwrap property, which is true by default, will be used

htmlEscape

string

(Optional) true if HTML should be escaped in the input markup, false otherwise. If not specified, the value of the markup.render.html.escape property, which is true by default, will be used

includeHeadingId

string

(Optional) true if headings should contain an ID based on the heading content. If not specified, the value of the markup.render.headerids property, which is false by default, will be used

markup

string

if present or "true", triggers the raw content to be markup-rendered and returned as HTML; otherwise, if not specified, or any value other than "true", the content is streamed without markup

Example response representations:

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/forks

resource-wide template parameters
parametervaluedescription

projectKey

string

the parent project key

Methods

GET

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve repositories which have been forked from this one. Unlike {@link #getRelatedRepositories(Repository, PageRequest) related repositories}, this only looks at a given repository's direct forks. If those forks have themselves been the origin of more forks, such "grandchildren" repositories will not be retrieved.

Only repositories to which the authenticated user has REPO_READ permission will be included, even if other repositories have been forked from this one.

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/license

resource-wide template parameters
parametervaluedescription

projectKey

string

the parent project key

Methods

HEAD

Example response representations:

  • application/json; charset=UTF-8 [expand]

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/license?at&hardwrap&htmlEscape&includeHeadingId&markup

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieves the license for the repository, if it's been defined.

This checks the repository for a

LICENSE
file, optionally with an
md
or
txt
extension, and, if found, streams it. By default, the raw content of the file is streamed. Appending
?markup
to the URL will stream an HTML-rendered version instead.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

at

string

a specific commit or ref to retrieve the license at, or the default branch if not specified

hardwrap

string

(Optional) Whether the markup implementation should convert newlines to breaks. If not specified, the value of the markup.render.hardwrap property, which is true by default, will be used

htmlEscape

string

(Optional) true if HTML should be escaped in the input markup, false otherwise. If not specified, the value of the markup.render.html.escape property, which is true by default, will be used

includeHeadingId

string

(Optional) true if headings should contain an ID based on the heading content. If not specified, the value of the markup.render.headerids property, which is false by default, will be used

markup

string

if present or "true", triggers the raw content to be markup-rendered and returned as HTML; otherwise, if not specified, or any value other than "true", the content is streamed without markup

Example response representations:

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/readme

resource-wide template parameters
parametervaluedescription

projectKey

string

the parent project key

Methods

HEAD

Example response representations:

  • application/json; charset=UTF-8 [expand]

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/readme?at&hardwrap&htmlEscape&includeHeadingId&markup

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieves the README for the repository, if it's been defined.

This checks the repository for a

README
file, optionally with an
md
or
txt
extension, and, if found, streams it. By default, the raw content of the file is streamed. Appending
?markup
to the URL will stream an HTML-rendered version instead. Note that, when streaming HTML, relative URLs in the README will not work if applied relative to this URL.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

at

string

a specific commit or ref to retrieve the README at, or the default branch if not specified

hardwrap

string

(Optional) Whether the markup implementation should convert newlines to breaks. If not specified, the value of the markup.render.hardwrap property, which is true by default, will be used

htmlEscape

string

(Optional) true if HTML should be escaped in the input markup, false otherwise. If not specified, the value of the markup.render.html.escape property, which is true by default, will be used

includeHeadingId

string

(Optional) true if headings should contain an ID based on the heading content. If not specified, the value of the markup.render.headerids property, which is false by default, will be used

markup

string

if present or "true", triggers the raw content to be markup-rendered and returned as HTML; otherwise, if not specified, or any value other than "true", the content is streamed without markup

Example response representations:

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/recreate

resource-wide template parameters
parametervaluedescription

projectKey

string

the parent project key

Methods

POST

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

If a create or fork operation fails, calling this method will clean up the broken repository and try again. The repository must be in an INITIALISATION_FAILED state.

The authenticated user must have PROJECT_ADMIN permission for the specified project to call this resource.

Example response representations:

  • 201 - application/json (repository) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/related

resource-wide template parameters
parametervaluedescription

projectKey

string

the parent project key

Methods

GET

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve repositories which are related to this one. Related repositories are from the same {@link Repository#getHierarchyId() hierarchy} as this repository.

Only repositories to which the authenticated user has REPO_READ permission will be included, even if more repositories are part of this repository's hierarchy.

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/archive

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/archive?at&filename&format&path&prefix

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Streams an archive of the repository's contents at the requested commit. If no at= commit is requested, an archive of the default branch is streamed.

The filename= query parameter may be used to specify the exact filename to include in the "Content-Disposition" header. If an explicit filename is not provided, one will be automatically generated based on what is being archived. Its format depends on the at= value:

  • No at= commit: <slug>-<default-branch-name>@<commit>.<format>; e.g. example-master@43c2f8a0fe8.zip
  • at=sha: <slug>-<at>.<format>; e.g. example-09bcbb00100cfbb5310fb6834a1d5ce6cac253e9.tar.gz
  • at=branchOrTag: <slug>-<branchOrTag>@<commit>.<format>; e.g. example-feature@bbb225f16e1.tar
    • If the branch or tag is qualified (e.g. refs/heads/master, the short name (master) will be included in the filename
    • If the branch or tag's short name includes slashes (e.g. release/4.6), they will be converted to hyphens in the filename (release-4.5)

Archives may be requested in the following formats by adding the format= query parameter:

  • zip: A zip file using standard compression (Default)
  • tar: An uncompressed tarball
  • tar.gz or tgz: A GZip-compressed tarball
The contents of the archive may be filtered by using the path= query parameter to specify paths to include. path= may be specified multiple times to include multiple paths.

The prefix= query parameter may be used to define a directory (or multiple directories) where the archive's contents should be placed. If the prefix does not end with /, one will be added automatically. The prefix is always treated as a directory; it is not possible to use it to prepend characters to the entries in the archive.

Archives of public repositories may be streamed by any authenticated or anonymous user. Streaming archives for non-public repositories requires an authenticated user with at least REPO_READ permission.

request query parameters
parametervaluedescription

at

string

the commit to stream an archive of; if not supplied, an archive of the default branch is streamed

filename

string

a filename to include the "Content-Disposition" header

format

string

the format to stream the archive in; must be one of: zip, tar, tar.gz or tgz

path

string

paths to include in the streamed archive; may be repeated to include multiple paths

prefix

string

a prefix to apply to all entries in the streamed archive; if the supplied prefix does not end with a trailing /, one will be added automatically

Example response representations:

  • 200 - application/octet-stream; application/x-tar (archive) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/attachments/{attachmentId}

resource-wide template parameters
parametervaluedescription

attachmentId

long

the attachment ID

Methods

DELETE

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Delete an attachment.

The user must be authenticated and have REPO_ADMIN permission for the specified repository.

Example response representations:

  • 204 - application/json [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve the attachment.

The authenticated user must have REPO_READ permission for the specified repository that is associated to the attachment.

request header parameters
parametervaluedescription

User-Agent

string

the User-Agent header information

Example response representations:

  • 200 - specific attachment media type [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/attachments/{attachmentId}/metadata

resource-wide template parameters
parametervaluedescription

attachmentId

long

the attachment ID

Methods

DELETE

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Delete attachment metadata.

The user must be authenticated and have REPO_ADMIN permission for the specified repository.

Example response representations:

  • 204 - application/json [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve the attachment metadata.

The authenticated user must have REPO_READ permission for the specified repository that is associated to the attachment that has the attachment metadata.

Example response representations:

  • 200 - application/json (metadata) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

PUT

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Save attachment metadata.

The authenticated user must have REPO_READ permission for the specified repository that is associated to the attachment that has the attachment metadata.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (metadata) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/branches

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/branches?base&details&filterText&orderBy&boostMatches

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve the branches matching the supplied filterText param.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

base

string

base branch or tag to compare each branch to (for the metadata providers that uses that information)

details

boolean

whether to retrieve plugin-provided metadata about each branch

filterText

string

the text to match on

orderBy

string

ordering of refs either ALPHABETICAL (by name) or MODIFICATION (last updated)

boostMatches

boolean

controls whether exact and prefix matches will be boosted to the top

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

POST

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Creates a branch using the information provided in the {@link RestCreateBranchRequest request}

The authenticated user must have REPO_WRITE permission for the context repository to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (branch) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/branches/default

Methods

PUT

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Update the default branch of a repository.

The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Get the default branch of the repository.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

Example response representations:

  • 200 - application/json (page) [expand]
  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/browse

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/browse?at&type&blame&noContent

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a page of content for a file path at a specified revision.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

at

string

Default:

the commit ID or ref to retrieve the content for.

type

boolean

Default: false

if true only the type will be returned for the file path instead of the contents.

blame

string

if present and not equal to 'false', the blame will be returned for the file as well.

noContent

string

if present and not equal to 'false', and used with blame only the blame is retrieved instead of the contents.

Example response representations:

  • 200 - application/json (page) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/browse/{path:.*}

resource-wide template parameters
parametervaluedescription

path

string

Default:

the file path to retrieve content from

Methods

PUT

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Update the content of path, on the given repository and branch.

This resource accepts PUT multipart form data, containing the file in a form-field named content.

An example curl request to update 'README.md' would be:

 curl -X PUT -u username:password -F content=@README.md  -F 'message=Updated using file-edit REST API'
 -F branch=master -F  sourceCommitId=5636641a50b
  http://example.com/rest/api/latest/projects/PROJECT_1/repos/repo_1/browse/README.md
 
  • branch: the branch on which the path should be modified or created
  • content: the full content of the file at path
  • message: the message associated with this change, to be used as the commit message. Or null if the default message should be used.
  • sourceCommitId: the commit ID of the file before it was edited, used to identify if content has changed. Or null if this is a new file

The file can be updated or created on a new branch. In this case, the sourceBranch parameter should be provided to identify the starting point for the new branch and the branch parameter identifies the branch to create the new commit on.

Example response representations:

  • 200 - application/json [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/browse/{path:.*}?at&type&blame&noContent

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a page of content for a file path at a specified revision.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

at

string

Default:

the commit ID or ref to retrieve the content for.

type

boolean

Default: false

if true only the type will be returned for the file path instead of the contents.

blame

string

if present and not equal to 'false', the blame will be returned for the file as well.

noContent

string

if present and not equal to 'false', and used with blame only the blame is retrieved instead of the contents.

Example response representations:

  • 200 - application/json (page) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/changes

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/changes?since&until

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a page of changes made in a specified commit.

Note: The implementation will apply a hard cap (page.max.changes) and it is not possible to request subsequent content when that cap is exceeded.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

since

string

the commit to which until should be compared to produce a page of changes. If not specified the commit's first parent is assumed (if one exists)

until

string

the commit to retrieve changes for

Example response representations:

  • 200 - application/json (page) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits?followRenames&ignoreMissing&merges&path&since&until&withCounts&avatarSize&avatarScheme

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a page of commits from a given starting commit or "between" two commits. If no explicit commit is specified, the tip of the repository's default branch is assumed. commits may be identified by branch or tag name or by ID. A path may be supplied to restrict the returned commits to only those which affect that path.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

followRenames

boolean

Default: false

if true, the commit history of the specified file will be followed past renames. Only valid for a path to a single file.

ignoreMissing

boolean

Default: false

true to ignore missing commits, false otherwise

merges

string

if present, controls how merge commits should be filtered. Can be either exclude, to exclude merge commits, include, to include both merge commits and non-merge commits or only, to only return merge commits.

path

string

an optional path to filter commits by

since

string

the commit ID or ref (exclusively) to retrieve commits after

until

string

the commit ID (SHA1) or ref (inclusively) to retrieve commits before

withCounts

boolean

Default: false

optionally include the total number of commits and total number of unique authors

avatarSize

string

if present the service adds avatar URLs for commit authors. Should be an integer specifying the desired size in pixels. If the parameter is not present, avatar URLs will not be set

avatarScheme

string

the desired scheme for the avatar URL. If the parameter is not present URLs will use the same scheme as this request

Example response representations:

  • 200 - application/json (page) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}

resource-wide template parameters
parametervaluedescription

commitId

string

the commit ID to retrieve

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}?path

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a single commit identified by its ID. In general, that ID is a SHA1. From 2.11, ref names like "refs/heads/master" are no longer accepted by this resource.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

path

string

an optional path to filter the commit by. If supplied the details returned may not be for the specified commit. Instead, starting from the specified commit, they will be the details for the first commit affecting the specified path.

Example response representations:

  • 200 - application/json (commit) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/builds

resource-wide template parameters
parametervaluedescription

commitId

string

full SHA1 of the commit (ex: e00cf62997a027bbf785614a93e2e55bb331d268)

Methods

POST

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Store a build status.

The authenticated user must have REPO_READ permission for the repository that this build status is for. The request can also be made with anonymous 2-legged OAuth.

Example request representations:

  • */* [expand]

Example response representations:

  • 204 [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/changes

resource-wide template parameters
parametervaluedescription

commitId

string

the commit to retrieve changes for

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/changes?since&withComments

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a page of changes made in a specified commit.

Note: The implementation will apply a hard cap (page.max.changes) and it is not possible to request subsequent content when that cap is exceeded.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

since

string

the commit to which until should be compared to produce a page of changes. If not specified the commit's first parent is assumed (if one exists)

withComments

boolean

Default: true

true to apply comment counts in the changes (the default); otherwise, false to stream changes without comment counts

Example response representations:

  • 200 - application/json (page) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/comments

resource-wide template parameters
parametervaluedescription

commitId

string

the commit to which the comments must be anchored

Methods

POST

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/comments?since

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Add a new comment.

Comments can be added in a few places by setting different attributes:

General commit comment:

     {
         "text": "An insightful general comment on a commit."
     }
     
Reply to a comment:
     {
         "text": "A measured reply.",
         "parent": {
             "id": 1
         }
     }
     
General file comment:
     {
         "text": "An insightful general comment on a file.",
         "anchor": {
             "diffType": "COMMIT",
             "fromHash": "6df3858eeb9a53a911cd17e66a9174d44ffb02cd",
             "path": "path/to/file",
             "srcPath": "path/to/file",
             "toHash": "04c7c5c931b9418ca7b66f51fe934d0bd9b2ba4b"
         }
     }
     
File line comment:
     {
         "text": "A pithy comment on a particular line within a file.",
         "anchor": {
             "diffType": "COMMIT",
             "line": 1,
             "lineType": "CONTEXT",
             "fileType": "FROM",
             "fromHash": "6df3858eeb9a53a911cd17e66a9174d44ffb02cd",
             "path": "path/to/file",
             "srcPath": "path/to/file",
             "toHash": "04c7c5c931b9418ca7b66f51fe934d0bd9b2ba4b"
     }
     }
     
Note: general file comments are an experimental feature and may change in the near future!

For file and line comments, 'path' refers to the path of the file to which the comment should be applied and 'srcPath' refers to the path the that file used to have (only required for copies and moves). Also, fromHash and toHash refer to the sinceId / untilId (respectively) used to produce the diff on which the comment was added. Finally diffType refers to the type of diff the comment was added on.

For line comments, 'line' refers to the line in the diff that the comment should apply to. 'lineType' refers to the type of diff hunk, which can be:

  • 'ADDED' - for an added line;
  • 'REMOVED' - for a removed line; or
  • 'CONTEXT' - for a line that was unmodified but is in the vicinity of the diff.
'fileType' refers to the file of the diff to which the anchor should be attached - which is of relevance when displaying the diff in a side-by-side way. Currently the supported values are:
  • 'FROM' - the source file of the diff
  • 'TO' - the destination file of the diff
If the current user is not a participant the user is added as one and updated to watch the commit.

The authenticated user must have REPO_READ permission for the repository that the commit is in to call this resource.

request query parameters
parametervaluedescription

since

string

for a merge commit, a parent can be provided to specify which diff the comments should be on. For a commit range, a sinceId can be provided to specify where the comments should be anchored from.

Example request representations:

  • application/json [expand]

Example response representations:

  • 201 - application/json (comment) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/comments?path&since

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieves the commit discussion comments that match the specified search criteria.

It is possible to retrieve commit discussion comments that are anchored to a range of commits by providing the sinceId that the comments anchored from.

The authenticated user must have REPO_READ permission for the repository that the commit is in to call this resource.

request query parameters
parametervaluedescription

path

string

the path to the file on which comments were made

since

string

for a merge commit, a parent can be provided to specify which diff the comments are on. For a commit range, a sinceId can be provided to specify where the comments are anchored from.

Example response representations:

  • 200 - application/json (page) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/comments/{commentId}

resource-wide template parameters
parametervaluedescription

commitId

string

the commit to which the comments must be anchored

commentId

long

the ID of the comment to retrieve

commitId

string

the full {@link Commit#getId() ID} of the commit within the repository

Methods

DELETE

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/comments/{commentId}?version

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Delete a commit comment. Anyone can delete their own comment. Only users with REPO_ADMIN and above may delete comments created by other users. Comments which have replies may not be deleted, regardless of the user's granted permissions.

The authenticated user must have REPO_READ permission for the repository that the commit is in to call this resource.

request query parameters
parametervaluedescription

version

int

Default: -1

the expected version of the comment. This must match the server's version of the comment or the delete will fail. To determine the current version of the comment, the comment should be fetched from the server prior to the delete. Look for the 'version' attribute in the returned JSON structure.

Example response representations:

  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

PUT

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Update a comment, with the following restrictions:

  • only the author of the comment may update the text of the comment
  • only the author of the comment or repository admins and above may update the other fields of a comment

Note: the supplied supplied JSON object must contain a version that must match the server's version of the comment or the update will fail. To determine the current version of the comment, the comment should be fetched from the server prior to the update. Look for the 'version' attribute in the returned JSON structure.

The authenticated user must have REPO_READ permission for the repository that the commit is in to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 201 - application/json (comment) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

GET

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieves a commit discussion comment.

The authenticated user must have REPO_READ permission for the repository that the commit is in to call this resource.

Example response representations:

  • 200 - application/json (comment) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/diff

resource-wide template parameters
parametervaluedescription

commitId

string

the target revision to diff to (required)

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/diff?autoSrcPath&contextLines&since&srcPath&whitespace&withComments

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve the diff between two provided revisions.

Note: This resource is currently not paged. The server will internally apply a hard cap to the streamed lines, and it is not possible to request subsequent pages if that cap is exceeded. In the event that the cap is reached, the diff will be cut short and one or more truncated flags will be set to true on the "segments", "hunks" and "diffs" properties, as well as the top-level object, in the returned JSON response.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

autoSrcPath

boolean

Default: false

true to automatically try to find the source path when it's not provided, false otherwise. Requires the path to be provided.

contextLines

int

Default: -1

the number of context lines to include around added/removed lines in the diff

since

string

the base revision to diff from. If omitted the parent revision of the until revision is used

srcPath

string

the source path for the file, if it was copied, moved or renamed

whitespace

string

optional whitespace flag which can be set to ignore-all

withComments

boolean

Default: true

true to embed comments in the diff (the default); otherwise false to stream the diff without comments

Example response representations:

  • 200 - application/json (diff) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/diff?autoSrcPath&contextLines&since&srcPath&whitespace

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Stream the diff between two provided revisions.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

autoSrcPath

boolean

Default: false

true to automatically try to find the source path when it's not provided, false otherwise. Requires the path to be provided.

contextLines

int

Default: -1

the number of context lines to include around added/removed lines in the diff

since

string

the base revision to diff from. If omitted the parent revision of the until revision is used

srcPath

string

the source path for the file, if it was copied, moved or renamed

whitespace

string

optional whitespace flag which can be set to ignore-all

Example response representations:

  • 200 - text/plain [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/diff/{path:.*}

resource-wide template parameters
parametervaluedescription

commitId

string

the target revision to diff to (required)

path

string

the path to the file which should be diffed (optional)

commitId

string

the target revision to diff to (required)

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/diff/{path:.*}?autoSrcPath&contextLines&since&srcPath&whitespace&withComments&avatarSize&avatarScheme

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve the diff between two provided revisions.

Note: This resource is currently not paged. The server will internally apply a hard cap to the streamed lines, and it is not possible to request subsequent pages if that cap is exceeded. In the event that the cap is reached, the diff will be cut short and one or more truncated flags will be set to true on the "segments", "hunks" and "diffs" properties, as well as the top-level object, in the returned JSON response.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

autoSrcPath

boolean

Default: false

true to automatically try to find the source path when it's not provided, false otherwise. Requires the path to be provided.

contextLines

int

Default: -1

the number of context lines to include around added/removed lines in the diff

since

string

the base revision to diff from. If omitted the parent revision of the until revision is used

srcPath

string

the source path for the file, if it was copied, moved or renamed

whitespace

string

optional whitespace flag which can be set to ignore-all

withComments

boolean

Default: true

true to embed comments in the diff (the default); otherwise false to stream the diff without comments

avatarSize

string

if present the service adds avatar URLs for comment authors where the provided value specifies the desired avatar size in pixels

avatarScheme

string

the security scheme for avatar URLs. If the scheme is not present then it is inherited from the request. It can be set to "https" to force the use of secure URLs

Example response representations:

  • 200 - application/json (diff) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/diff/{path:.*}?autoSrcPath&contextLines&since&srcPath&whitespace

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Stream the diff between two provided revisions.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

autoSrcPath

boolean

Default: false

true to automatically try to find the source path when it's not provided, false otherwise. Requires the path to be provided.

contextLines

int

Default: -1

the number of context lines to include around added/removed lines in the diff

since

string

the base revision to diff from. If omitted the parent revision of the until revision is used

srcPath

string

the source path for the file, if it was copied, moved or renamed

whitespace

string

optional whitespace flag which can be set to ignore-all

Example response representations:

  • 200 - text/plain [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/pull-requests

resource-wide template parameters
parametervaluedescription

commitId

string

the commit ID

Methods

GET

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a page of pull requests in the current repository that contain the given commit.

The user must be authenticated and have access to the specified repository to call this resource.

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/watch

resource-wide template parameters
parametervaluedescription

commitId

string

the full {@link Commit#getId() ID} of the commit within the repository

Methods

DELETE

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Remove the authenticated user as a watcher for the specified commit.

The authenticated user must have REPO_READ permission for the repository containing the commit to call this resource.

Example response representations:

  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

POST

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Add the authenticated user as a watcher for the specified commit.

The authenticated user must have REPO_READ permission for the repository containing the commit to call this resource.

Example response representations:

  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
Compare two commits or refs. <p> Each commit can be specified using either a commit ID, a qualified ref name or a unqualified ref name (the latter should be non-ambiguous).

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/compare/commits

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/compare/commits?from&to&fromRepo

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Gets the commits accessible from the from commit but not in the to commit.

If either the from or to commit are not specified, they will be replaced by the default branch of their containing repository.

request query parameters
parametervaluedescription

from

string

the source commit (can be a partial/full commit ID or qualified/unqualified ref name)

to

string

the target commit (can be a partial/full commit ID or qualified/unqualified ref name)

fromRepo

string

Default:

an optional parameter specifying the source repository containing the source commit if that commit is not present in the current repository; the repository can be specified by either its ID fromRepo=42 or by its project key plus its repo slug separated by a slash: fromRepo=projectKey/repoSlug

Example response representations:

  • 200 - application/json (page) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/compare/diff{path:.*}

resource-wide template parameters
parametervaluedescription

path

string

the path to the file to diff (optional)

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/compare/diff{path:.*}?from&to&fromRepo&srcPath&contextLines&whitespace

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Gets a diff of the changes available in the from commit but not in the to commit.

If either the from or to commit are not specified, they will be replaced by the default branch of their containing repository.

request query parameters
parametervaluedescription

from

string

the source commit (can be a partial/full commit ID or qualified/unqualified ref name)

to

string

the target commit (can be a partial/full commit ID or qualified/unqualified ref name)

fromRepo

string

Default:

an optional parameter specifying the source repository containing the source commit if that commit is not present in the current repository; the repository can be specified by either its ID fromRepo=42 or by its project key plus its repo slug separated by a slash: fromRepo=projectKey/repoSlug

srcPath

string

source path

contextLines

int

Default: -1

an optional number of context lines to include around each added or removed lines in the diff

whitespace

string

an optional whitespace flag which can be set to ignore-all

Example response representations:

  • 200 - application/json (page) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/compare/changes

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/compare/changes?from&to&fromRepo

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Gets the file changes available in the from commit but not in the to commit.

If either the from or to commit are not specified, they will be replaced by the default branch of their containing repository.

request query parameters
parametervaluedescription

from

string

the source commit (can be a partial/full commit ID or qualified/unqualified ref name)

to

string

the target commit (can be a partial/full commit ID or qualified/unqualified ref name)

fromRepo

string

Default:

an optional parameter specifying the source repository containing the source commit if that commit is not present in the current repository; the repository can be specified by either its ID fromRepo=42 or by its project key plus its repo slug separated by a slash: fromRepo=projectKey/repoSlug

Example response representations:

  • 200 - application/json (page) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/diff

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/diff?contextLines&since&srcPath&until&whitespace

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve the diff for a specified file path between two provided revisions.

Note: This resource is currently not paged. The server will internally apply a hard cap to the streamed lines, and it is not possible to request subsequent pages if that cap is exceeded. In the event that the cap is reached, the diff will be cut short and one or more truncated flags will be set to true on the segments, hunks and diffs substructures in the returned JSON response.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

contextLines

int

Default: -1

the number of context lines to include around added/removed lines in the diff

since

string

the base revision to diff from. If omitted the parent revision of the until revision is used

srcPath

string

the source path for the file, if it was copied, moved or renamed

until

string

the target revision to diff to (required)

whitespace

string

optional whitespace flag which can be set to ignore-all

Example response representations:

  • 200 - application/json (diff) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/diff?contextLines&since&srcPath&until&whitespace

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Stream the raw diff between two provided revisions.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

contextLines

int

Default: -1

the number of context lines to include around added/removed lines in the diff

since

string

the base revision to diff from. If omitted the parent revision of the until revision is used

srcPath

string

the source path for the file, if it was copied, moved or renamed

until

string

the target revision to diff to (required)

whitespace

string

optional whitespace flag which can be set to ignore-all

Example response representations:

  • 200 - text/plain [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/diff/{path:.*}

resource-wide template parameters
parametervaluedescription

path

string

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/diff/{path:.*}?contextLines&since&srcPath&until&whitespace

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve the diff for a specified file path between two provided revisions.

Note: This resource is currently not paged. The server will internally apply a hard cap to the streamed lines, and it is not possible to request subsequent pages if that cap is exceeded. In the event that the cap is reached, the diff will be cut short and one or more truncated flags will be set to true on the segments, hunks and diffs substructures in the returned JSON response.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

contextLines

int

Default: -1

the number of context lines to include around added/removed lines in the diff

since

string

the base revision to diff from. If omitted the parent revision of the until revision is used

srcPath

string

the source path for the file, if it was copied, moved or renamed

until

string

the target revision to diff to (required)

whitespace

string

optional whitespace flag which can be set to ignore-all

Example response representations:

  • 200 - application/json (diff) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/diff/{path:.*}?contextLines&since&srcPath&until&whitespace

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Stream the raw diff between two provided revisions.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

contextLines

int

Default: -1

the number of context lines to include around added/removed lines in the diff

since

string

the base revision to diff from. If omitted the parent revision of the until revision is used

srcPath

string

the source path for the file, if it was copied, moved or renamed

until

string

the target revision to diff to (required)

whitespace

string

optional whitespace flag which can be set to ignore-all

Example response representations:

  • 200 - text/plain [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/files

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/files?at

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a page of files from particular directory of a repository. The search is done recursively, so all files from any sub-directory of the specified directory will be returned.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

at

string

the commit ID or ref (e.g. a branch or tag) to list the files at. If not specified the default branch will be used instead.

Example response representations:

  • 200 - application/json (page) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/files/{path:.*}

resource-wide template parameters
parametervaluedescription

path

string

Default:

the directory to list files for.

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/files/{path:.*}?at

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a page of files from particular directory of a repository. The search is done recursively, so all files from any sub-directory of the specified directory will be returned.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

at

string

the commit ID or ref (e.g. a branch or tag) to list the files at. If not specified the default branch will be used instead.

Example response representations:

  • 200 - application/json (page) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/labels

Methods

GET

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Get all labels applied to the given repository.

The authenticated user must have REPO_READ permission for the specified repository.

Example response representations:

  • 200 - application/json (label) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

POST

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Applies a label to the repository.

The authenticated user must have REPO_ADMIN permission for the specified repository.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (label) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/labels/{labelName}

resource-wide template parameters
parametervaluedescription

labelName

string

the label to remove

Methods

DELETE

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Remove label that is applied to the given repository.

The authenticated user must have REPO_ADMIN permission for the specified repository.

Example response representations:

  • 204 - application/json [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/last-modified

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/last-modified?at

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Streams files in the requested path with the last commit to modify each file. Commit modifications are traversed starting from the at commit or, if not specified, from the tip of the default branch.

Unless the repository is public, the authenticated user must have REPO_READ access to call this resource.

request query parameters
parametervaluedescription

at

string

the commit to use as the starting point when listing files and calculating modifications

Example response representations:

  • 200 - application/json (modifications) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/last-modified/{path:.*}

resource-wide template parameters
parametervaluedescription

path

string

the path within the repository whose files should be streamed

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/last-modified/{path:.*}?at

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Streams files in the requested path with the last commit to modify each file. Commit modifications are traversed starting from the at commit or, if not specified, from the tip of the default branch.

Unless the repository is public, the authenticated user must have REPO_READ access to call this resource.

request query parameters
parametervaluedescription

at

string

the commit to use as the starting point when listing files and calculating modifications

Example response representations:

  • 200 - application/json (modifications) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/participants

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/participants?direction&filter&role

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a page of participant users for all the pull requests to or from the specified repository.

Optionally clients can specify following filters.

request query parameters
parametervaluedescription

direction

string

Default: incoming

(optional, defaults to INCOMING) the direction relative to the specified repository. Either INCOMING or OUTGOING.

filter

string

(optional) return only users, whose username, name or email address contain the filter value

role

string

(optional) The role associated with the pull request participant. This must be one of AUTHOR, REVIEWER, orPARTICIPANT

Example response representations:

  • 200 - application/json (page) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/patch

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/patch?allAncestors&since&until

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve the patch content for a repository at a specified revision.

Cache headers are added to the response (only if full commit hashes are used, not in the case of short hashes).

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

allAncestors

boolean

indicates whether or not to generate a patch which includes all the ancestors of the until revision. If true, the value provided by since is ignored.

since

string

the base revision from which to generate the patch. This is only applicable when allAncestors is false. If omitted the patch will represent one single commit, the until.

until

string

the target revision from which to generate the patch (required)

Example response representations:

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/permissions/groups

Methods

DELETE

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/permissions/groups?name

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Revoke all permissions for the specified repository for a group.

The authenticated user must have REPO_ADMIN permission for the specified repository or a higher project or global permission to call this resource.

In addition, a user may not revoke a group's permissions if it will reduce their own permission level.

request query parameters
parametervaluedescription

name

string

the name of the group

Example response representations:

  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

PUT

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/permissions/groups?permission&name

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Promote or demote a group's permission level for the specified repository. Available repository permissions are:

  • REPO_READ
  • REPO_WRITE
  • REPO_ADMIN
See the Bitbucket Server documentation for a detailed explanation of what each permission entails.

The authenticated user must have REPO_ADMIN permission for the specified repository or a higher project or global permission to call this resource. In addition, a user may not demote a group's permission level if their own permission level would be reduced as a result.

request query parameters
parametervaluedescription

permission

string

the permission to grant

name

string

the names of the groups

Example response representations:

  • 204 [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 403 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/permissions/groups?filter

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a page of groups that have been granted at least one permission for the specified repository.

The authenticated user must have REPO_ADMIN permission for the specified repository or a higher project or global permission to call this resource.

request query parameters
parametervaluedescription

filter

string

if specified only group names containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/permissions/users

Methods

DELETE

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/permissions/users?name

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Revoke all permissions for the specified repository for a user.

The authenticated user must have REPO_ADMIN permission for the specified repository or a higher project or global permission to call this resource.

In addition, a user may not revoke their own repository permissions if they do not have a higher project or global permission.

request query parameters
parametervaluedescription

name

string

the name of the user

Example response representations:

  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

PUT

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/permissions/users?name&permission

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Promote or demote a user's permission level for the specified repository. Available repository permissions are:

  • REPO_READ
  • REPO_WRITE
  • REPO_ADMIN
See the Bitbucket Server documentation for a detailed explanation of what each permission entails.

The authenticated user must have REPO_ADMIN permission for the specified repository or a higher project or global permission to call this resource. In addition, a user may not reduce their own permission level unless they have a project or global permission that already implies that permission.

request query parameters
parametervaluedescription

name

string

the names of the users

permission

string

the permission to grant

Example response representations:

  • 204 [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 403 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/permissions/users?filter

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a page of users that have been granted at least one permission for the specified repository.

The authenticated user must have REPO_ADMIN permission for the specified repository or a higher project or global permission to call this resource.

request query parameters
parametervaluedescription

filter

string

if specified only user names containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/permissions/users/none

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/permissions/users/none?filter

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a page of licensed users that have no granted permissions for the specified repository.

The authenticated user must have REPO_ADMIN permission for the specified repository or a higher project or global permission to call this resource.

request query parameters
parametervaluedescription

filter

string

if specified only user names containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/permissions/groups/none

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/permissions/groups/none?filter

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a page of groups that have no granted permissions for the specified repository.

The authenticated user must have REPO_ADMIN permission for the specified repository or a higher project or global permission to call this resource.

request query parameters
parametervaluedescription

filter

string

if specified only group names containing the supplied string will be returned

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests?direction&at&state&order&withAttributes&withProperties&filterText

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a page of pull requests to or from the specified repository.

The authenticated user must have REPO_READ permission for the specified repository to call this resource. Optionally clients can specify PR participant filters. Each filter has a mandatory username.N parameter, and the optional role.N and approved.N parameters.

  • username.N - the "root" of a single participant filter, where "N" is a natural number starting from 1. This allows clients to specify multiple participant filters, by providing consecutive filters as username.1, username.2 etc. Note that the filters numbering has to start with 1 and be continuous for all filters to be processed. The total allowed number of participant filters is 10 and all filters exceeding that limit will be dropped.
  • role.N(optional) the role associated with username.N. This must be one of AUTHOR, REVIEWER, orPARTICIPANT
  • approved.N(optional) the approved status associated with username.N. That is whether username.N has approved the PR. Either true, or false

request query parameters
parametervaluedescription

direction

string

Default: incoming

(optional, defaults to INCOMING) the direction relative to the specified repository. Either INCOMING or OUTGOING.

at

string

(optional) a fully-qualified branch ID to find pull requests to or from, such as refs/heads/master

state

string

(optional, defaults to OPEN). Supply ALL to return pull request in any state. If a state is supplied only pull requests in the specified state will be returned. Either OPEN, DECLINED or MERGED.

order

string

(optional, defaults to NEWEST) the order to return pull requests in, either OLDEST (as in: "oldest first") or NEWEST.

withAttributes

boolean

Default: true

(optional) defaults to true, whether to return additional pull request attributes

withProperties

boolean

Default: true

(optional) defaults to true, whether to return additional pull request properties

filterText

string

(optional) If specified, only pull requests where the title or description contains the supplied string will be returned.

Example response representations:

  • 200 - application/json (page) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

POST

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Create a new pull request between two branches. The branches may be in the same repository, or different ones. When using different repositories, they must still be in the same {@link Repository#getHierarchyId() hierarchy}.

The authenticated user must have REPO_READ permission for the "from" and "to"repositories to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 201 - application/json (pullRequest) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}

resource-wide template parameters
parametervaluedescription

pullRequestId

long

the ID of the pull request within the repository

Methods

GET

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a pull request.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Example response representations:

  • 200 - application/json (pullRequest) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

PUT

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Update the title, description, reviewers or destination branch of an existing pull request.

Note: the reviewers list may be updated using this resource. However the author and participants list may not.

The authenticated user must either:

  • be the author of the pull request and have the REPO_READ permission for the repository that this pull request targets; or
  • have the REPO_WRITE permission for the repository that this pull request targets
to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (pullRequest) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

DELETE

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Deletes a pull request.

To call this resource, users must be authenticated and have permission to view the pull request. Additionally, they must:

  • be the pull request author, if the system is configured to allow authors to delete their own pull requests (this is the default) OR
  • have repository administrator permission for the repository the pull request is targeting
A body containing the version of the pull request must be provided with this request.
{
    "version": 1
}

Example request representations:

  • application/json [expand]

Example response representations:

  • 204 - application/json [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}.diff

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}.diff?contextLines&whitespace

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Streams the raw diff for a pull request.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

request query parameters
parametervaluedescription

contextLines

int

Default: -1

the number of context lines to include around added/removed lines in the diff

whitespace

string

optional whitespace flag which can be set to ignore-all

Example response representations:

  • 200 - text/plain [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}.patch

Methods

GET

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Streams a patch representing a pull request.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Example response representations:

  • 200 - text/plain [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/activities

resource-wide template parameters
parametervaluedescription

pullRequestId

long

the ID of the pull request within the repository

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/activities?fromId&fromType

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a page of activity associated with a pull request.

Activity items include comments, approvals, rescopes (i.e. adding and removing of commits), merges and more.

Different types of activity items may be introduced in newer versions of Stash or by user installed plugins, so clients should be flexible enough to handle unexpected entity shapes in the returned page.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

request query parameters
parametervaluedescription

fromId

long

(optional) the ID of the activity item to use as the first item in the returned page

fromType

string

(required if fromId is present) the type of the activity item specified by fromId (either COMMENT or ACTIVITY)

Example response representations:

  • 200 - application/json (page) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/decline

resource-wide template parameters
parametervaluedescription

pullRequestId

long

the pullrequest ID provided by the path

Methods

POST

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/decline?version

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Decline a pull request.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

request query parameters
parametervaluedescription

version

int

Default: -1

the current version of the pull request. If the server's version isn't the same as the specified version the operation will fail. To determine the current version of the pull request it should be fetched from the server prior to this operation. Look for the 'version' attribute in the returned JSON structure.

Example response representations:

  • 200 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/merge

resource-wide template parameters
parametervaluedescription

pullRequestId

long

the ID of the pull request within the repository

Methods

GET

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Test whether a pull request can be merged.

A pull request may not be merged if:

  • there are conflicts that need to be manually resolved before merging; and/or
  • one or more merge checks have vetoed the merge.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Example response representations:

  • 200 - application/json (pullRequest) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

POST

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/merge?version

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Merge the specified pull request.

The authenticated user must have REPO_WRITE permission for the repository that this pull request targets to call this resource.

request query parameters
parametervaluedescription

version

int

Default: -1

the current version of the pull request. If the server's version isn't the same as the specified version the operation will fail. To determine the current version of the pull request it should be fetched from the server prior to this operation. Look for the 'version' attribute in the returned JSON structure.

Example response representations:

  • 200 - application/json (pullRequest) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/reopen

resource-wide template parameters
parametervaluedescription

pullRequestId

long

the ID of the pull request within the repository

Methods

POST

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/reopen?version

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Re-open a declined pull request.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

request query parameters
parametervaluedescription

version

int

Default: -1

the current version of the pull request. If the server's version isn't the same as the specified version the operation will fail. To determine the current version of the pull request it should be fetched from the server prior to this operation. Look for the 'version' attribute in the returned JSON structure.

Example response representations:

  • 200 - application/json (pullRequest) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/approve

resource-wide template parameters
parametervaluedescription

pullRequestId

long

the ID of the pull request within the repository

Methods

DELETE

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Remove approval from a pull request as the current user. This does not remove the user as a participant.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Deprecated since 4.2. Use /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/participants/{userSlug} instead

Example response representations:

  • 201 - application/json (participant) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

POST

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Approve a pull request as the current user. Implicitly adds the user as a participant if they are not already.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Deprecated since 4.2. Use /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/participants/{userSlug} instead

Example response representations:

  • 201 - application/json (participant) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/blocker-comments

Resource for managing BLOCKER comments on pull requests.

Methods

POST

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Add a new blocker comment.

Comments can be added in a few places by setting different attributes:

General pull request blocker comment:

     {
         "text": "A task on a pull request."
     }
     
Blocker reply to a comment:
     {
         "text": "This reply is a task.",
         "parent": {
             "id": 1
         }
     }
     
General blocker file comment:
     {
         "text": "A blocker comment on a file.",
         "anchor": {
             "diffType": "RANGE",
             "fromHash": "6df3858eeb9a53a911cd17e66a9174d44ffb02cd",
             "path": "path/to/file",
             "srcPath": "path/to/file",
             "toHash": "04c7c5c931b9418ca7b66f51fe934d0bd9b2ba4b"
         }
     }
     
Blocker file line comment:
     {
         "text": "A task on a particular line within a file.",
         "anchor": {
             "diffType": "COMMIT",
             "line": 1,
             "lineType": "CONTEXT",
             "fileType": "FROM",
             "fromHash": "6df3858eeb9a53a911cd17e66a9174d44ffb02cd",
             "path": "path/to/file",
             "srcPath": "path/to/file",
             "toHash": "04c7c5c931b9418ca7b66f51fe934d0bd9b2ba4b"
         }
     }
     

For file and line comments, 'path' refers to the path of the file to which the comment should be applied and 'srcPath' refers to the path the that file used to have (only required for copies and moves). Also, fromHash and toHash refer to the sinceId / untilId (respectively) used to produce the diff on which the comment was added. Finally diffType refers to the type of diff the comment was added on. For backwards compatibility purposes if no diffType is provided and no fromHash/toHash pair is provided the diffType will be resolved to 'EFFECTIVE'. In any other cases the diffType is REQUIRED.

For line comments, 'line' refers to the line in the diff that the comment should apply to. 'lineType' refers to the type of diff hunk, which can be:

  • 'ADDED' - for an added line;
  • 'REMOVED' - for a removed line; or
  • 'CONTEXT' - for a line that was unmodified but is in the vicinity of the diff.
'fileType' refers to the file of the diff to which the anchor should be attached - which is of relevance when displaying the diff in a side-by-side way. Currently the supported values are:
  • 'FROM' - the source file of the diff
  • 'TO' - the destination file of the diff
If the current user is not a participant the user is added as a watcher of the pull request.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 201 - application/json (comment) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/blocker-comments?count&state

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Gets comments matching the given set of field values for the specified pull request. (Note this does not perform any kind of searching for comments by their text).

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

request query parameters
parametervaluedescription

count

boolean

Default: false

if true only the count of the comments by state will be returned (and not the body of the comments).

state

string

(optional). If supplied, only comments with a state in the given list will be returned. The state can be OPEN or RESOLVED.

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/blocker-comments/{commentId}

resource-wide template parameters
parametervaluedescription

commentId

long

the ID of the comment to retrieve

Methods

DELETE

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/blocker-comments/{commentId}?version

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Delete a pull request comment. Anyone can delete their own comment. Only users with REPO_ADMIN and above may delete comments created by other users.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

request query parameters
parametervaluedescription

version

int

Default: -1

The expected version of the comment. This must match the server's version of the comment or the delete will fail. To determine the current version of the comment, the comment should be fetched from the server prior to the delete. Look for the 'version' attribute in the returned JSON structure.

Example response representations:

  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

PUT

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Update a comment, with the following restrictions:

  • only the author of the comment may update the text of the comment
  • only the author of the comment, the author of the pull request or repository admins and above may update the other fields of a comment

Convert a comment to a task or vice versa.

Comments can be converted to tasks by setting the 'severity' attribute to 'BLOCKER':

     {
     "severity": "BLOCKER"
     }
     

Tasks can be converted to comments by setting the 'severity' attribute to 'NORMAL':

     {
     "severity": "NORMAL"
     }
     

Resolve a blocker comment.

Blocker comments can be resolved by setting the 'state' attribute to 'RESOLVED':

     {
     "state": "RESOLVED"
     }
     

Note: the supplied JSON object must contain a version that must match the server's version of the comment or the update will fail. To determine the current version of the comment, the comment should be fetched from the server prior to the update. Look for the 'version' attribute in the returned JSON structure.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (comment) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

GET

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieves a pull request comment.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Example response representations:

  • 200 - application/json (comment) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/changes

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/changes?changeScope&sinceId&untilId&withComments

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Gets changes for the specified PullRequest.

If the changeScope query parameter is set to unreviewed, the application will attempt to stream unreviewed changes based on the lastReviewedCommit of the current user, which are the changes between the lastReviewedCommit and the latest commit of the source branch. The current user is considered to not have any unreviewed changes for the pull request when the lastReviewedCommit is either null (everything is unreviewed, so all changes are streamed), equal to the latest commit of the source branch (everything is reviewed), or no longer on the source branch (the source branch has been rebased). In these cases, the application will fall back to streaming all changes (the default), which is the effective diff for the pull request. The type of changes streamed can be determined by the changeScope parameter included in the properties map of the response.

Note: This resource is currently not paged. The server will return at most one page. The server will truncate the number of changes to either the request's page limit or an internal maximum, whichever is smaller. The start parameter of the page request is also ignored.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

request query parameters
parametervaluedescription

changeScope

string

Default: ALL

UNREVIEWED to stream the unreviewed changes for the current user (if they exist); RANGE to stream changes between two arbitrary commits (requires sinceId and untilId); otherwise ALL to stream all changes (the default)

sinceId

string

the since commit hash to stream changes for a RANGE arbitrary change scope

untilId

string

the until commit hash to stream changes for a RANGE arbitrary change scope

withComments

boolean

Default: true

true to apply comment counts in the changes (the default); otherwise, false to stream changes without comment counts

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments

Methods

POST

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Add a new comment.

Comments can be added in a few places by setting different attributes:

General pull request comment:

     {
         "text": "An insightful general comment on a pull request."
     }
     
Reply to a comment:
     {
         "text": "A measured reply.",
         "parent": {
             "id": 1
         }
     }
     
General file comment:
     {
         "text": "An insightful general comment on a file.",
         "anchor": {
             "diffType": "RANGE",
             "fromHash": "6df3858eeb9a53a911cd17e66a9174d44ffb02cd",
             "path": "path/to/file",
             "srcPath": "path/to/file",
             "toHash": "04c7c5c931b9418ca7b66f51fe934d0bd9b2ba4b"
         }
     }
     
File line comment:
     {
         "text": "A pithy comment on a particular line within a file.",
         "anchor": {
             "diffType": "COMMIT",
             "line": 1,
             "lineType": "CONTEXT",
             "fileType": "FROM",
             "fromHash": "6df3858eeb9a53a911cd17e66a9174d44ffb02cd",
             "path": "path/to/file",
             "srcPath": "path/to/file",
             "toHash": "04c7c5c931b9418ca7b66f51fe934d0bd9b2ba4b"
         }
     }
     

Add a new task.

Tasks are just comments with the attribute 'severity' set to 'BLOCKER':

General pull request task:

     {
     "text": "A task on a pull request.",
     "severity": "BLOCKER"
     }
     

For file and line comments, 'path' refers to the path of the file to which the comment should be applied and 'srcPath' refers to the path the that file used to have (only required for copies and moves). Also, fromHash and toHash refer to the sinceId / untilId (respectively) used to produce the diff on which the comment was added. Finally diffType refers to the type of diff the comment was added on. For backwards compatibility purposes if no diffType is provided and no fromHash/toHash pair is provided the diffType will be resolved to 'EFFECTIVE'. In any other cases the diffType is REQUIRED.

For line comments, 'line' refers to the line in the diff that the comment should apply to. 'lineType' refers to the type of diff hunk, which can be:

  • 'ADDED' - for an added line;
  • 'REMOVED' - for a removed line; or
  • 'CONTEXT' - for a line that was unmodified but is in the vicinity of the diff.
'fileType' refers to the file of the diff to which the anchor should be attached - which is of relevance when displaying the diff in a side-by-side way. Currently the supported values are:
  • 'FROM' - the source file of the diff
  • 'TO' - the destination file of the diff
If the current user is not a participant the user is added as a watcher of the pull request.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 201 - application/json (comment) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments?anchorState&diffType&fromHash&path&toHash

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Gets comments for the specified pull request and path.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

request query parameters
parametervaluedescription

anchorState

string

Default: ACTIVE

ACTIVE to stream the active comments; ORPHANED to stream the orphaned comments; ALL to stream both the active and the orphaned comments;

diffType

string

EFFECTIVE to stream the comments related to the effective diff of the pull request; RANGE to stream comments related to a commit range between two arbitrary commits (requires fromHash and toHash); COMMIT to stream comments related to a commit between two arbitrary commits (requires fromHash and toHash)

fromHash

string

the from commit hash to stream comments for a RANGE or COMMIT arbitrary change scope

path

string

the path to stream comments for a given path

toHash

string

the to commit hash to stream comments for a RANGE or COMMIT arbitrary change scope

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId}

resource-wide template parameters
parametervaluedescription

commentId

long

the ID of the comment to retrieve

Methods

DELETE

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId}?version

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Delete a pull request comment. Anyone can delete their own comment. Only users with REPO_ADMIN and above may delete comments created by other users.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

request query parameters
parametervaluedescription

version

int

Default: -1

The expected version of the comment. This must match the server's version of the comment or the delete will fail. To determine the current version of the comment, the comment should be fetched from the server prior to the delete. Look for the 'version' attribute in the returned JSON structure.

Example response representations:

  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

PUT

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Update a comment, with the following restrictions:

  • only the author of the comment may update the text of the comment
  • only the author of the comment, the author of the pull request or repository admins and above may update the other fields of a comment

Convert a comment to a task or vice versa.

Comments can be converted to tasks by setting the 'severity' attribute to 'BLOCKER':

     {
     "severity": "BLOCKER"
     }
     

Tasks can be converted to comments by setting the 'severity' attribute to 'NORMAL':

     {
     "severity": "NORMAL"
     }
     

Resolve a task.

Tasks can be resolved by setting the 'state' attribute to 'RESOLVED':

     {
     "state": "RESOLVED"
     }
     

Note: the supplied JSON object must contain a version that must match the server's version of the comment or the update will fail. To determine the current version of the comment, the comment should be fetched from the server prior to the update. Look for the 'version' attribute in the returned JSON structure.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (comment) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

GET

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieves a pull request comment.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Example response representations:

  • 200 - application/json (comment) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId}/apply-suggestion

Methods

POST

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Apply a suggestion contained within a comment.

Example request representations:

  • application/json [expand]

Example response representations:

  • 204 [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/commits

resource-wide template parameters
parametervaluedescription

pullRequestId

long

ID of the pullrequest, part of the path

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/commits?withCounts&avatarSize&avatarScheme

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve commits for the specified pull request.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

request query parameters
parametervaluedescription

withCounts

boolean

if set to true, the service will add "authorCount" and "totalCount" at the end of the page. "authorCount" is the number of different authors and "totalCount" is the total number of commits.

avatarSize

string

if present the service adds avatar URLs for commit authors. Should be an integer specifying the desired size in pixels. If the parameter is not present, avatar URLs will not be set

avatarScheme

string

the desired scheme for the avatar URL. If the parameter is not present URLs will use the same scheme as this request

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/diff

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/diff?contextLines&diffType&sinceId&srcPath&untilId&whitespace&withComments

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Streams a diff within a pull request.

If the specified file has been copied, moved or renamed, the srcPath must also be specified to produce the correct diff.

Note: This RESTful endpoint is currently not paged. The server will internally apply a hard cap to the streamed lines, and it is not possible to request subsequent pages if that cap is exceeded.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

request query parameters
parametervaluedescription

contextLines

int

Default: -1

the number of context lines to include around added/removed lines in the diff

diffType

string

Default: EFFECTIVE

the type of diff being requested. When withComments is true this works as a hint to the system to attach the correct set of comments to the diff

sinceId

string

the since commit hash to stream a diff between two arbitrary hashes

srcPath

string

the previous path to the file, if the file has been copied, moved or renamed

untilId

string

the until commit hash to stream a diff between two arbitrary hashes

whitespace

string

optional whitespace flag which can be set to ignore-all

withComments

boolean

Default: true

true to embed comments in the diff (the default); otherwise, false to stream the diff without comments

Example response representations:

  • 200 - application/json (diffs) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/diff?contextLines&sinceId&srcPath&untilId&whitespace

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Streams the raw diff for a pull request.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

request query parameters
parametervaluedescription

contextLines

int

Default: -1

the number of context lines to include around added/removed lines in the diff

sinceId

string

srcPath

string

the previous path to the file, if the file has been copied, moved or renamed

untilId

string

whitespace

string

optional whitespace flag which can be set to ignore-all

Example response representations:

  • 200 - text/plain [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/diff/{path:.*}

resource-wide template parameters
parametervaluedescription

path

string

the path to the file which should be diffed (optional)

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/diff/{path:.*}?contextLines&diffType&sinceId&srcPath&untilId&whitespace&withComments&avatarSize&avatarScheme

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Streams a diff within a pull request.

If the specified file has been copied, moved or renamed, the srcPath must also be specified to produce the correct diff.

Note: This RESTful endpoint is currently not paged. The server will internally apply a hard cap to the streamed lines, and it is not possible to request subsequent pages if that cap is exceeded.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

request query parameters
parametervaluedescription

contextLines

int

Default: -1

the number of context lines to include around added/removed lines in the diff

diffType

string

Default: EFFECTIVE

the type of diff being requested. When withComments is true this works as a hint to the system to attach the correct set of comments to the diff

sinceId

string

the since commit hash to stream a diff between two arbitrary hashes

srcPath

string

the previous path to the file, if the file has been copied, moved or renamed

untilId

string

the until commit hash to stream a diff between two arbitrary hashes

whitespace

string

optional whitespace flag which can be set to ignore-all

withComments

boolean

Default: true

true to embed comments in the diff (the default); otherwise, false to stream the diff without comments

avatarSize

string

if present the service adds avatar URLs for comment authors where the provided value specifies the desired avatar size in pixels

avatarScheme

string

the security scheme for avatar URLs. If the scheme is not present then it is inherited from the request. It can be set to "https" to force the use of secure URLs

Example response representations:

  • 200 - application/json (diffs) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/diff/{path:.*}?contextLines&sinceId&srcPath&untilId&whitespace

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Streams the raw diff for a pull request.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

request query parameters
parametervaluedescription

contextLines

int

Default: -1

the number of context lines to include around added/removed lines in the diff

sinceId

string

srcPath

string

the previous path to the file, if the file has been copied, moved or renamed

untilId

string

whitespace

string

optional whitespace flag which can be set to ignore-all

Example response representations:

  • 200 - text/plain [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/participants

resource-wide template parameters
parametervaluedescription

pullRequestId

long

the id of the pull request within the repository

Methods

GET

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieves a page of the participants for a given pull request.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Example response representations:

  • 201 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

POST

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Assigns a participant to an explicit role in pull request. Currently only the REVIEWER role may be assigned.

If the user is not yet a participant in the pull request, they are made one and assigned the supplied role.

If the user is already a participant in the pull request, their previous role is replaced with the supplied role unless they are already assigned the AUTHOR role which cannot be changed and will result in a Bad Request (400) response code.

The authenticated user must have REPO_WRITE permission for the repository that this pull request targets to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 201 - application/json (participant) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

DELETE

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/participants?username

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Unassigns a participant from the REVIEWER role they may have been given in a pull request.

If the participant has no explicit role this method has no effect.

Afterwards, the user will still remain a participant in the pull request but their role will be reduced to PARTICIPANT. This is because once made a participant of a pull request, a user will forever remain a participant. Only their role may be altered.

The authenticated user must have REPO_WRITE permission for the repository that this pull request targets to call this resource.

Deprecated since 4.2. Use /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/participants/{userSlug} instead.

request query parameters
parametervaluedescription

username

string

the participant's user name

Example response representations:

  • 204 [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/participants/{userSlug}

resource-wide template parameters
parametervaluedescription

pullRequestId

long

the id of the pull request within the repository

userSlug

string

the slug for the user changing their status

pullRequestId

long

the id of the pull request within the repository

Methods

DELETE

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Unassigns a participant from the REVIEWER role they may have been given in a pull request.

If the participant has no explicit role this method has no effect.

Afterwards, the user will still remain a participant in the pull request but their role will be reduced to PARTICIPANT. This is because once made a participant of a pull request, a user will forever remain a participant. Only their role may be altered.

The authenticated user must have REPO_WRITE permission for the repository that this pull request targets to call this resource.

Deprecated since 4.2. Use /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/participants/{userSlug} instead.

Example response representations:

  • 204 [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

PUT

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Change the current user's status for a pull request. Implicitly adds the user as a participant if they are not already. If the current user is the author, this method will fail.

The possible values for status are UNAPPROVED, NEEDS_WORK, or APPROVED.

If the new status is NEEDS_WORK or APPROVED then the lastReviewedCommit for the participant will be updated to the latest commit of the source branch of the pull request.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 201 - application/json (participant) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/tasks

Methods

GET

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve the tasks associated with a pull request.

Deprecated since 7.2. Tasks are now managed using Comments with BLOCKER severity. Use /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/blocker-comments instead

Example response representations:

  • 200 - application/json (task) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/tasks/count

Methods

GET

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve the total number of OPEN and RESOLVED tasks associated with a pull request.

Deprecated since 7.2. Tasks are now managed using Comments with BLOCKER severity. Use /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/blocker-comments?count=true instead.

Example response representations:

  • 200 - application/json (taskCount) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/watch

Methods

DELETE

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Remove the authenticated user as a watcher for the specified pull request.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Example response representations:

  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

POST

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Add the authenticated user as a watcher for the specified pull request.

The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Example response representations:

  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/raw

Methods

GET

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve the raw content for a file path at a specified revision.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

Example response representations:

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/raw/{path:.*}

resource-wide template parameters
parametervaluedescription

path

string

the file path to retrieve content from

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/raw/{path:.*}?at&hardwrap&htmlEscape&includeHeadingId&markup

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve the raw content for a file path at a specified revision.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

at

string

a specific commit or ref to retrieve the raw content at, or the default branch if not specified

hardwrap

string

(Optional) Whether the markup implementation should convert newlines to breaks. If not specified, the value of the markup.render.hardwrap property, which is true by default, will be used

htmlEscape

string

(Optional) true if HTML should be escaped in the input markup, false otherwise. If not specified, the value of the markup.render.html.escape property, which is true by default, will be used

includeHeadingId

string

(Optional) true if headings should contain an ID based on the heading content. If not specified, the value of the markup.render.headerids property, which is false by default, will be used

markup

string

if present or "true", triggers the raw content to be markup-rendered and returned as HTML; otherwise, if not specified, or any value other than "true", the content is streamed without markup

Example response representations:

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/ref-change-activities

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/ref-change-activities?ref

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a page of repository ref change activity.

The authenticated user must have REPO_ADMIN permission to call this resource.

request query parameters
parametervaluedescription

ref

string

(optional) exact match for a ref ID to filter ref change activity for

Example response representations:

  • 200 - application/json (refChangeActivity) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/ref-change-activities/branches

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/ref-change-activities/branches?filterText

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a page of branches for a specific repository.

The authenticated user must have REPO_ADMIN permission to call this resource.

request query parameters
parametervaluedescription

filterText

string

(optional) partial match for a ref ID to filter minimal refs for

Example response representations:

  • 200 - application/json (minimalRef) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/pull-requests

Methods

POST

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Update the pull request settings for the context repository.

The authenticated user must have REPO_ADMIN permission for the context repository to call this resource.

This resource will call all RestFragments that are registered with the key bitbucket.repository.settings.pullRequests. If any fragment fails validations by returning a non-empty Map of errors, then no fragments will execute.

Only the settings that should be updated need to be included in the request.

The property keys for the settings that are bundled with the application are

  • mergeConfig - the merge strategy configuration for pull requests
  • requiredApprovers - (Deprecated, please use com.atlassian.bitbucket.server.bundled-hooks.requiredApproversMergeHook instead) the number of approvals required on a pull request for it to be mergeable, or 0 to disable the merge check
  • com.atlassian.bitbucket.server.bundled-hooks.requiredApproversMergeHook - a json map containing the keys 'enabled' (a boolean to enable or disable this merge check) and 'count' (an integer to set the number of required approvals)
  • requiredAllApprovers - whether or not all approvers must approve a pull request for it to be mergeable
  • requiredAllTasksComplete - whether or not all tasks on a pull request need to be completed for it to be mergeable
  • requiredSuccessfulBuilds - (Deprecated, please use com.atlassian.bitbucket.server.bitbucket-build.requiredBuildsMergeCheck instead) the number of successful builds on a pull request for it to be mergeable, or 0 to disable the merge check
  • com.atlassian.bitbucket.server.bitbucket-build.requiredBuildsMergeCheck - a json map containing the keys 'enabled' (a boolean to enable or disable this merge check) and 'count' (an integer to set the number of required builds)
Merge strategy configuration deletion:

An explicitly set pull request merge strategy configuration can be deleted by POSTing a document with an empty "mergeConfig" attribute. i.e:

 {
     "mergeConfig": {
     }
 }
 
Upon completion of this request, the effective configuration will be:
  • The configuration set for this repository's SCM type as set at the project level, if present, otherwise
  • the configuration set for this repository's SCM type as set at the instance level, if present, otherwise
  • the default configuration for this repository's SCM type

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (settings) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve the pull request settings for the context repository.

The authenticated user must have REPO_READ permission for the context repository to call this resource.

This resource will call all RestFragments that are registered with the key bitbucket.repository.settings.pullRequests. If any fragment fails validations by returning a non-empty Map of errors, then no fragments will execute.

The property keys for the settings that are bundled with the application are

  • mergeConfig - the merge strategy configuration for pull requests
  • requiredApprovers - (Deprecated, please use com.atlassian.bitbucket.server.bundled-hooks.requiredApproversMergeHook instead) the number of approvals required on a pull request for it to be mergeable, or 0 if the merge check is disabled
  • com.atlassian.bitbucket.server.bundled-hooks.requiredApproversMergeHook - the merge check configuration for required approvers
  • requiredAllApprovers - whether or not all approvers must approve a pull request for it to be mergeable
  • requiredAllTasksComplete - whether or not all tasks on a pull request need to be completed for it to be mergeable
  • requiredSuccessfulBuilds - (Deprecated, please use com.atlassian.bitbucket.server.bitbucket-build.requiredBuildsMergeCheck instead) the number of successful builds on a pull request for it to be mergeable, or 0 if the merge check is disabled
  • com.atlassian.bitbucket.server.bitbucket-build.requiredBuildsMergeCheck - the merge check configuration for required builds

Example response representations:

  • 200 - application/json [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks?type

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a page of repository hooks for this repository.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

type

string

Default:

the optional type to filter by. Valid values are PRE_RECEIVE or POST_RECEIVE

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks/{hookKey}

resource-wide template parameters
parametervaluedescription

hookKey

string

the hook key

Methods

GET

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a repository hook for this repository.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

Example response representations:

  • 200 - application/json [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

DELETE

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Delete repository hook configuration for the supplied hookKey and repositorySlug

The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource.

Example response representations:

  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks/{hookKey}/enabled

resource-wide template parameters
parametervaluedescription

hookKey

string

hook key

Methods

DELETE

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Disable a repository hook for this repository.

The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource.

Example response representations:

  • 200 - application/json [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

PUT

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Enable a repository hook for this repository and optionally apply new configuration.

The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource.

A JSON document may be provided to use as the settings for the hook. These structure and validity of the document is decided by the plugin providing the hook.

request header parameters
parametervaluedescription

Content-Length

int

Default: 0

the content length as generated by the client

Example response representations:

  • 200 - application/json [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks/{hookKey}/settings

resource-wide template parameters
parametervaluedescription

hookKey

string

the hook key

Methods

PUT

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Modify the settings for a repository hook for this repository.

The service will reject any settings which are too large, the current limit is 32KB once serialized.

The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource.

A JSON document can be provided to use as the settings for the hook. These structure and validity of the document is decided by the plugin providing the hook.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve the settings for a repository hook for this repository.

The authenticated user must have REPO_READ permission for the specified repository to call this resource.

Example response representations:

  • 200 - application/json [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/tags

Methods

POST

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Creates a tag using the information provided in the {@link RestCreateTagRequest request}

The authenticated user must have REPO_WRITE permission for the context repository to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (tag) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/tags?filterText&orderBy

This is a paged API. This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve the tags matching the supplied filterText param.

The authenticated user must have REPO_READ permission for the context repository to call this resource.

request query parameters
parametervaluedescription

filterText

string

the text to match on

orderBy

string

ordering of refs either ALPHABETICAL (by name) or MODIFICATION (last updated)

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/tags/{name:.*}

resource-wide template parameters
parametervaluedescription

name

string

the name of the tag to be retrieved

Methods

GET

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Retrieve a tag in the specified repository.

The authenticated user must have REPO_READ permission for the context repository to call this resource.

Example response representations:

  • 200 - application/json (tag) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/watch

Methods

DELETE

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Remove the authenticated user as a watcher for the specified repository.

The authenticated user must have REPO_READ permission for the repository to call this resource.

Example response representations:

  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

POST

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Add the authenticated user as a watcher for the specified repository.

The authenticated user must have REPO_READ permission for the repository to call this resource.

Example response representations:

  • 204 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/webhooks

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/webhooks?event&statistics

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Find webhooks in this repository.

The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

event

string

list of {@link com.atlassian.webhooks.WebhookEvent} ids to filter for

statistics

boolean

Default: false

true if statistics should be provided for all found webhooks

Example response representations:

  • 200 - application/json (webhook) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

POST

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Create a webhook for the repository specified via the URL.

The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (webhook) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/webhooks/test

Methods

POST

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/webhooks/test?url

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Test connectivity to a specific endpoint.

The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

url

string

the url in which to connect to

Example response representations:

  • 200 - application/json (webhook) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/webhooks/{webhookId}

resource-wide template parameters
parametervaluedescription

webhookId

int

the existing webhook id

Methods

DELETE

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Delete a webhook for the repository specified via the URL.

The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource.

Example response representations:

  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/webhooks/{webhookId}?statistics

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Get a webhook by id.

The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

statistics

boolean

Default: false

statistics

Example response representations:

  • 200 - application/json (webhook) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

PUT

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Update an existing webhook.

The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource.

Example request representations:

Example response representations:

  • 200 - application/json (webhook) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/webhooks/{webhookId}/latest

resource-wide template parameters
parametervaluedescription

webhookId

int

id of the webhook

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/webhooks/{webhookId}/latest?event&outcome

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Get the latest invocations for a specific webhook.

The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

event

string

the string id of a specific event to retrieve the last invocation for.

outcome

string

the outcome to filter for. Can be SUCCESS, FAILURE, ERROR. None specified means that the all will be considered

Example response representations:

  • 200 - application/json (webhookInvocation) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/webhooks/{webhookId}/statistics

resource-wide template parameters
parametervaluedescription

webhookId

int

id of the webhook

Methods

GET

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/webhooks/{webhookId}/statistics?event

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Get the statistics for a specific webhook.

The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource.

request query parameters
parametervaluedescription

event

string

the string id of a specific event to retrieve the last invocation for. May be empty, in which case all events are considered

Example response representations:

  • 200 - application/json (webhookInvocation) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/webhooks/{webhookId}/statistics/summary

resource-wide template parameters
parametervaluedescription

webhookId

int

id of the webhook

Methods

GET

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Get the statistics summary for a specific webhook.

The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource.

Example response representations:

  • 200 - application/json (webhookInvocation) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/settings/pull-requests/{scmId}

resource-wide template parameters
parametervaluedescription

scmId

string

the SCM to get strategies for

Methods

POST

Update the pull request merge strategy configuration for this project and SCM.

The authenticated user must have PROJECT_ADMIN permission for the context repository to call this resource.

Only the strategies provided will be enabled, the default must be set and included in the set of strategies.

An explicitly set pull request merge strategy configuration can be deleted by POSTing a document with an empty "mergeConfig" attribute. i.e:

 {
     "mergeConfig": {
     }
 }
 
Upon completion of this request, the effective configuration will be the configuration explicitly set for the SCM, or if no such explicit configuration is set then the default configuration will be used.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (strategies) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

This is a paged API.

Retrieve the merge strategy configuration for this project and SCM.

The authenticated user must have PROJECT_READ permission for the context repository to call this resource.

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/settings/hooks

Methods

GET

/rest/api/1.0/projects/{projectKey}/settings/hooks?type

This is a paged API.

Retrieve a page of repository hooks for this project.

The authenticated user must have PROJECT_READ permission for the specified project to call this resource.

request query parameters
parametervaluedescription

type

string

Default:

the optional type to filter by. Valid values are PRE_RECEIVE or POST_RECEIVE

Example response representations:

  • 200 - application/json (page) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/settings/hooks/{hookKey}

resource-wide template parameters
parametervaluedescription

hookKey

string

the hook key

Methods

GET

Retrieve a repository hook for this project.

The authenticated user must have PROJECT_READ permission for the specified project to call this resource.

Example response representations:

  • 200 - application/json [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/settings/hooks/{hookKey}/enabled

resource-wide template parameters
parametervaluedescription

hookKey

string

the hook key

Methods

DELETE

Disable a repository hook for this project.

The authenticated user must have PROJECT_ADMIN permission for the specified project to call this resource.

Example response representations:

  • 200 - application/json [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

PUT

Enable a repository hook for this project and optionally apply new configuration.

The authenticated user must have PROJECT_ADMIN permission for the specified project to call this resource.

A JSON document may be provided to use as the settings for the hook. These structure and validity of the document is decided by the plugin providing the hook.

request header parameters
parametervaluedescription

Content-Length

int

Default: 0

the content length

Example response representations:

  • 200 - application/json [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/projects/{projectKey}/settings/hooks/{hookKey}/settings

resource-wide template parameters
parametervaluedescription

hookKey

string

the hook key

Methods

PUT

Modify the settings for a repository hook for this project.

The service will reject any settings which are too large, the current limit is 32KB once serialized.

The authenticated user must have PROJECT_ADMIN permission for the specified project to call this resource.

A JSON document can be provided to use as the settings for the hook. These structure and validity of the document is decided by the plugin providing the hook.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

GET

Retrieve the settings for a repository hook for this project.

The authenticated user must have PROJECT_READ permission for the specified project to call this resource.

Example response representations:

  • 200 - application/json [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/repos

REST resource for searching through repositories

Methods

GET

/rest/api/1.0/repos?name&projectname&permission&state&visibility

This is a paged API.

Retrieve a page of repositories based on query parameters that control the search. See the documentation of the parameters for more details.

This resource is anonymously accessible.

Note on permissions. In absence of the permission query parameter the implicit 'read' permission is assumed. Please note that this permission is lower than the REPO_READ permission rather than being equal to it. The implicit 'read' permission for a given repository is assigned to any user that has any of the higher permissions, such as REPO_READ, as well as to anonymous users if the repository is marked as public. The important implication of the above is that an anonymous request to this resource with a permission level REPO_READ is guaranteed to receive an empty list of repositories as a result. For anonymous requests it is therefore recommended to not specify the permission parameter at all.

request query parameters
parametervaluedescription

name

string

(optional) if specified, this will limit the resulting repository list to ones whose name matches this parameter's value. The match will be done case-insensitive and any leading and/or trailing whitespace characters on the name parameter will be stripped.

projectname

string

(optional) if specified, this will limit the resulting repository list to ones whose project's name matches this parameter's value. The match will be done case-insensitive and any leading and/or trailing whitespace characters on the projectname parameter will be stripped.

permission

string

(optional) if specified, it must be a valid repository permission level name and will limit the resulting repository list to ones that the requesting user has the specified permission level to. If not specified, the default implicit 'read' permission level will be assumed. The currently supported explicit permission values are REPO_READ, REPO_WRITE and REPO_ADMIN.

state

string

(optional) if specified, it must be a valid repository state name and will limit the resulting repository list to ones that are in the specified state. The currently supported explicit state values are AVAILABLE, INITIALISING and INITIALISATION_FAILED.
Available since 5.13

visibility

string

(optional) if specified, this will limit the resulting repository list based on the repositories visibility. Valid values are public or private.

Example response representations:

  • 200 - application/json (page) [expand]
  • 400 - application/json (errors) [expand]

/rest/api/1.0/tasks

Methods

POST

Create a new task.

Deprecated since 7.2. Tasks are now managed using Comments with severity BLOCKER. Call POST /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments instead, passing the attribute 'severity' set to 'BLOCKER'.

Example request representations:

  • application/json [expand]

Example response representations:

  • 201 - application/json (task) [expand]
  • 400 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/tasks/{taskId}

resource-wide template parameters
parametervaluedescription

taskId

long

the id identifying the task to delete

Methods

DELETE

Delete a task.

Deprecated since 7.2. Tasks are now managed using Comments with BLOCKER severity. Call DELETE /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId} instead.

Example response representations:

  • 204 (task) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

PUT

Update an existing task.

Deprecated since 7.2. Tasks are now managed using Comments with BLOCKER severity. Call PUT /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId} instead. To resolve a task, pass the attribute 'state' set to 'RESOLVED'.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (task) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]
  • 409 - application/json (errors) [expand]

GET

Retrieve an existing task.

Deprecated since 7.2. Tasks are now managed using Comments with BLOCKER severity. Call GET /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId} instead.

Example response representations:

  • 200 - application/json (task) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/users

Methods

PUT

Update the currently authenticated user's details. The update will always be applied to the currently authenticated user.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 - application/json (detailedUser) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]

GET

This is a paged API.

Retrieve a page of users, optionally run through provided filters.

Only authenticated users may call this resource.

Supported Filters

Filters are provided in query parameters in a standard name=value fashion. The following filters are currently supported:

  • filter - return only users, whose username, name or email address contain the filter value
  • group - return only users who are members of the given group
  • permission - the "root" of a permission filter, whose value must be a valid global, project, or repository permission. Additional filter parameters referring to this filter that specify the resource (project or repository) to apply the filter to must be prefixed with permission.. See the section "Permission Filters" below for more details.
  • permission.N - the "root" of a single permission filter, similar to the permission parameter, where "N" is a natural number starting from 1. This allows clients to specify multiple permission filters, by providing consecutive filters as permission.1, permission.2 etc. Note that the filters numbering has to start with 1 and be continuous for all filters to be processed. The total allowed number of permission filters is 50 and all filters exceeding that limit will be dropped. See the section "Permission Filters" below for more details on how the permission filters are processed.

Permission Filters

The following three sub-sections list parameters supported for permission filters (where [root] is the root permission filter name, e.g. permission, permission.1 etc.) depending on the permission resource. The system determines which filter to apply (Global, Project or Repository permission) based on the [root] permission value. E.g. ADMIN is a global permission, PROJECT_ADMIN is a project permission and REPO_ADMIN is a repository permission. Note that the parameters for a given resource will be looked up in the order as they are listed below, that is e.g. for a project resource, if both projectId and projectKey are provided, the system will use projectId for the lookup.

Global permissions

The permission value under [root] is the only required and recognized parameter, as global permissions do not apply to a specific resource.

Example valid filter: permission=ADMIN.

Project permissions

  • [root]- specifies the project permission
  • [root].projectId - specifies the project ID to lookup the project by
  • [root].projectKey - specifies the project key to lookup the project by

Example valid filter: permission.1=PROJECT_ADMIN&permission.1.projectKey=TEST_PROJECT.

Repository permissions

  • [root]- specifies the repository permission
  • [root].projectId - specifies the repository ID to lookup the repository by
  • [root].projectKey and [root].repositorySlug- specifies the project key and repository slug to lookup the repository by; both values need to be provided for this look up to be triggered
Example valid filter: permission.2=REPO_ADMIN&permission.2.projectKey=TEST_PROJECT&permission.2.repositorySlug=test_repo.

Example response representations:

  • 200 - application/json (page) [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/users/credentials

Methods

PUT

Update the currently authenticated user's password.

Example request representations:

  • application/json [expand]

Example response representations:

  • 204 [expand]
  • 400 - application/json (errors) [expand]
  • 401 - application/json (errors) [expand]

/rest/api/1.0/users/{userSlug}

Methods

GET

Retrieve the user matching the supplied userSlug.

Example response representations:

  • 200 - application/json (userSlug) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/users/{userSlug}/avatar.png

Methods

DELETE

Delete the avatar associated to a user.

Users are always allowed to delete their own avatar. To delete someone else's avatar the authenticated user must have global ADMIN permission, or global SYS_ADMIN permission to update a SYS_ADMIN user's avatar.

Example response representations:

  • 200 - application/json (href) [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

POST

Update the avatar for the user with the supplied slug.

This resource accepts POST multipart form data, containing a single image in a form-field named 'avatar'.

There are configurable server limits on both the dimensions (1024x1024 pixels by default) and uploaded file size (1MB by default). Several different image formats are supported, but PNG and JPEG are preferred due to the file size limit.

This resource has Cross-Site Request Forgery (XSRF) protection. To allow the request to pass the XSRF check the caller needs to send an X-Atlassian-Token HTTP header with the value no-check.

An example curl request to upload an image name 'avatar.png' would be:

 curl -X POST -u username:password -H "X-Atlassian-Token: no-check" http://example.com/rest/api/latest/users/jdoe/avatar.png -F avatar=@avatar.png
 

Users are always allowed to update their own avatar. To update someone else's avatar the authenticated user must have global ADMIN permission, or global SYS_ADMIN permission to update a SYS_ADMIN user's avatar.

Example response representations:

  • 201 [expand]
  • 401 - application/json (errors) [expand]
  • 404 - application/json (errors) [expand]

/rest/api/1.0/users/{userSlug}/settings

Rest resource for retrieving, and updating user settings key/values

Methods

GET

Retrieve a map of user setting key values for a specific user identified by the user slug.

Example response representations:

  • 200 - application/json (settings) [expand]
  • 401 - application/json (errors) [expand]

POST

Update the entries of a map of user setting key/values for a specific user identified by the user slug.

Example request representations:

  • application/json [expand]

Example response representations:

  • 200 [expand]
  • 401 - application/json (errors) [expand]
Feedback?
Got Feedback?
View cookie preferences