# Public API

### How to create custom integrations with BugBug Public API?

BugBug Public API lets you run and manage tests from your own tools, scripts, CI/CD pipelines, and internal dashboards.

Use the Public API when you need more control than a simple webhook URL or CLI command can provide.

Keep in mind that Public API access is available on paid plans. More information about pricing can be found here: <https://bugbug.io/pricing/>

### Get your API token

1. Go to the **Integrations** page.
2. Open the **API** tab.
3. Copy the project API token.

The API token belongs to a project. Treat it as a secret.

### Authenticate API requests

Send the API token in the `Authorization` header with the `Token` prefix:

```http
Authorization: Token <api-token>
```

Example:

```bash
curl \
  -H "Authorization: Token <api-token>" \
  "https://api.bugbug.io/api/v2/tests/"
```

### API documentation

BugBug provides generated API documentation in two formats:

* [GitBook](/public-api-reference/config.md)
* [Swagger](https://app.bugbug.io/docs/swagger/?version=v2)
* [Redoc](https://app.bugbug.io/docs/redoc/?version=v2)

### What you can build with the Public API

The Public API can be used to create custom integrations for CI/CD systems, internal tools, dashboards, release workflows, and reporting automation.

Common API capabilities include:

* listing, creating, updating, and deleting tests
* listing, creating, updating, and deleting suites
* running tests and suites in the cloud
* checking test run and suite run status
* retrieving run results
* stopping running tests and suites
* downloading JUnit reports
* managing test groups, steps, and reusable components in API v2
* exporting and importing tests or projects as YAML or ZIP files
* reading and updating project settings
* managing visual regression reference screenshots

### Public API, CLI, and webhooks

Use the **Public API** when you are building a custom integration and need programmatic control.

Use the **Command Line Interface** when you want a ready-made command for CI/CD scripts.

Use **incoming webhooks** when another tool only needs to start a test or suite with one `POST` request.

Use **outgoing webhooks** when BugBug should send run events to another system.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bugbug.io/integrations/public-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
