Addon
Branch restrictions
Branching model
Commit statuses
Commits
Deployments
Downloads
Issue tracker
Pipelines
Projects
Pullrequests
Refs
Reports
Repositories
Snippets
Source
Ssh
Users
Webhooks
Workspaces
Other operations

Rate this page:

Reports

Code insights provides reports, annotations, and metrics to help you and your team improve code quality in pull requests throughout the code review process. Some of the available code insights are static analysis reports, security scan results, artifact links, unit tests, and build status.

List reports

GET /2.0/repositories/{workspace}/{repo_slug}/commit/{commit}/reports

Returns a paginated list of Reports linked to this commit.

Request

Path parameters
workspace Required

string

This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example {workspace UUID}.

repo_slug Required

string

The repository.

commit Required

string

The commit for which to retrieve reports.

Example

1
2
3
curl --request GET \
  --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/commit/{commit}/reports' \
  --header 'Accept: application/json'

Responses

OK

Content typeValue
application/json

Paginated Reports

Get a report

GET /2.0/repositories/{workspace}/{repo_slug}/commit/{commit}/reports/{reportId}

Returns a single Report matching the provided ID.

Request

Path parameters
workspace Required

string

This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example {workspace UUID}.

repo_slug Required

string

The repository.

commit Required

string

The commit the report belongs to.

reportId Required

string

Either the uuid or external-id of the report.

Example

1
2
3
curl --request GET \
  --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/commit/{commit}/reports/{reportId}' \
  --header 'Accept: application/json'

Responses

OK

Content typeValue
application/json

allOf [object, Commit Report]

Create or update a report

PUT /2.0/repositories/{workspace}/{repo_slug}/commit/{commit}/reports/{reportId}

Creates or updates a report for the specified commit. To upload a report, make sure to generate an ID that is unique across all reports for that commit. If you want to use an existing id from your own system, we recommend prefixing it with your system's name to avoid collisions, for example, mySystem-001.

Sample cURL request:

1
2
curl --request PUT 'https://api.bitbucket.org/2.0/repositories/<username>/<reposity-name>/commit/<commit-hash>/reports/mysystem-001' \
--header 'Content-Type: application/json' \
--data-raw '{
    "title": "Security scan report",
    "details": "This pull request introduces 10 new dependency vulnerabilities.",
    "report_type": "SECURITY",
    "reporter": "mySystem",
    "link": "http://www.mysystem.com/reports/001",
    "result": "FAILED",
    "data": [
        {
            "title": "Duration (seconds)",
            "type": "DURATION",
            "value": 14
        },
        {
            "title": "Safe to merge?",
            "type": "BOOLEAN",
            "value": false
        }
    ]
}'

Possible field values:

report_type: SECURITY, COVERAGE, TEST, BUG result: PASSED, FAILED, PENDING data.type: BOOLEAN, DATE, DURATION, LINK, NUMBER, PERCENTAGE, TEXT

Data field formats

Type FieldValue Field TypeValue Field Display
None/ OmittedNumber, String or Boolean (not an array or object)Plain text
BOOLEANBooleanThe value will be read as a JSON boolean and displayed as 'Yes' or 'No'.
DATENumberThe value will be read as a JSON number in the form of a Unix timestamp (milliseconds) and will be displayed as a relative date if the date is less than one week ago, otherwise it will be displayed as an absolute date.
DURATIONNumberThe value will be read as a JSON number in milliseconds and will be displayed in a human readable duration format.
LINKObject: {"text": "Link text here", "href": "https://link.to.annotation/in/external/tool"}The value will be read as a JSON object containing the fields "text" and "href" and will be displayed as a clickable link on the report.
NUMBERNumberThe value will be read as a JSON number and large numbers will be displayed in a human readable format (e.g. 14.3k).
PERCENTAGENumber (between 0 and 100)The value will be read as a JSON number between 0 and 100 and will be displayed with a percentage sign.
TEXTStringThe value will be read as a JSON string and will be displayed as-is

Please refer to the Code Insights documentation for more information.

Request

Path parameters
workspace Required

string

This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example {workspace UUID}.

repo_slug Required

string

The repository.

commit Required

string

The commit the report belongs to.

reportId Required

string

Either the uuid or external-id of the report.

Body parameters
Content typeValue
application/json

allOf [object, Commit Report]

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
curl --request PUT \
  --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/commit/{commit}/reports/{reportId}' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "type": "<string>",
  "uuid": "<string>",
  "title": "<string>",
  "details": "<string>",
  "external_id": "<string>",
  "reporter": "<string>",
  "link": "<string>",
  "remote_link_enabled": true,
  "logo_url": "<string>",
  "report_type": "SECURITY",
  "result": "PASSED",
  "data": [
    {
      "type": "BOOLEAN",
      "title": "<string>",
      "value": {}
    }
  ],
  "created_on": "<string>",
  "updated_on": "<string>"
}'

Responses

OK

Content typeValue
application/json

allOf [object, Commit Report]

Delete a report

DELETE /2.0/repositories/{workspace}/{repo_slug}/commit/{commit}/reports/{reportId}

Deletes a single Report matching the provided ID.

Request

Path parameters
workspace Required

string

This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example {workspace UUID}.

repo_slug Required

string

The repository.

commit Required

string

The commit the report belongs to.

reportId Required

string

Either the uuid or external-id of the report.

Example

1
2
curl --request DELETE \
  --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/commit/{commit}/reports/{reportId}'

Responses

No content

List annotations

GET /2.0/repositories/{workspace}/{repo_slug}/commit/{commit}/reports/{reportId}/annotations

Returns a paginated list of Annotations for a specified report.

Request

Path parameters
workspace Required

string

This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example {workspace UUID}.

repo_slug Required

string

The repository.

commit Required

string

The commit for which to retrieve reports.

reportId Required

string

Uuid or external-if of the report for which to get annotations for.

Example

1
2
3
curl --request GET \
  --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/commit/{commit}/reports/{reportId}/annotations' \
  --header 'Accept: application/json'

Responses

OK

Content typeValue
application/json

Paginated Annotations

Bulk create or update annotations

POST /2.0/repositories/{workspace}/{repo_slug}/commit/{commit}/reports/{reportId}/annotations

Bulk upload of annotations. Annotations are individual findings that have been identified as part of a report, for example, a line of code that represents a vulnerability. These annotations can be attached to a specific file and even a specific line in that file, however, that is optional. Annotations are not mandatory and a report can contain up to 1000 annotations.

Add the annotations you want to upload as objects in a JSON array and make sure each annotation has the external_id field set to a unique value. If you want to use an existing id from your own system, we recommend prefixing it with your system's name to avoid collisions, for example, mySystem-annotation001. The external id can later be used to identify the report as an alternative to the generated UUID. You can upload up to 100 annotations per POST request.

Sample cURL request:

1
2
curl --location 'https://api.bitbucket.org/2.0/repositories/<username>/<reposity-name>/commit/<commit-hash>/reports/mysystem-001/annotations' \
--header 'Content-Type: application/json' \
--data-raw '[
  {
        "external_id": "mysystem-annotation001",
        "title": "Security scan report",
        "annotation_type": "VULNERABILITY",
        "summary": "This line represents a security threat.",
        "severity": "HIGH",
      "path": "my-service/src/main/java/com/myCompany/mysystem/logic/Main.java",
        "line": 42
  },
  {
        "external_id": "mySystem-annotation002",
        "title": "Bug report",
        "annotation_type": "BUG",
        "result": "FAILED",
        "summary": "This line might introduce a bug.",
        "severity": "MEDIUM",
      "path": "my-service/src/main/java/com/myCompany/mysystem/logic/Helper.java",
        "line": 13
  }
]'

Possible field values:

annotation_type: VULNERABILITY, CODE_SMELL, BUG result: PASSED, FAILED, IGNORED, SKIPPED severity: HIGH, MEDIUM, LOW, CRITICAL

Please refer to the Code Insights documentation for more information.

Request

Path parameters
workspace Required

string

This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example {workspace UUID}.

repo_slug Required

string

The repository.

commit Required

string

The commit for which to retrieve reports.

reportId