> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getunblocked.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart for the Unblocked API

The Unblocked API is a REST API that allows you to retrieve context from your connected data sources, add documents to Unblocked, and ask questions about your codebase programmatically.

If you are deciding between the REST API, MCP, and the Unblocked CLI, see [Programmatic access to Unblocked](/programmatic-access).

## Create an API Token

Unblocked supports two types of API tokens for authentication:

<Tabs>
  <Tab title="Personal Access Token">
    Personal Access Tokens are scoped to your individual account and are ideal for personal automation, testing, and development workflows.

    <Note>
      Personal Access Tokens have a limit of **1,000 API calls per day**. See [Rate limits](/api-reference/rate-limits).
    </Note>

    <Steps>
      <Step title="Create the API Token">
        In the [Unblocked web app](/using-unblocked/on-the-web), click on **Settings** --> **API Tokens**.

        In the **Personal API Tokens** section, click on **Create Token**.

        <img src="https://mintcdn.com/unblocked/GOUKpQ80cNM-eQYm/img/personal-token-1.png?fit=max&auto=format&n=GOUKpQ80cNM-eQYm&q=85&s=2f8370f6a500750697cebbc6cc13a5ff" alt="Personal Token[]" width="2880" height="1820" data-path="img/personal-token-1.png" />
      </Step>

      <Step title="Configure the API Token">
        Fill out the token name.  You can also limit the data sources that the token will have access to in the list under **Data Sources**.

        <img src="https://mintcdn.com/unblocked/GOUKpQ80cNM-eQYm/img/personal-token-2.png?fit=max&auto=format&n=GOUKpQ80cNM-eQYm&q=85&s=ccaead6818c7c04278e9285082a76b3d" alt="Personal Token[]" width="2880" height="1820" data-path="img/personal-token-2.png" />
      </Step>

      <Step title="Copy the API Token">
        Copy the resulting API token.

        <img src="https://mintcdn.com/unblocked/GOUKpQ80cNM-eQYm/img/personal-token-3.png?fit=max&auto=format&n=GOUKpQ80cNM-eQYm&q=85&s=8ae7b033588bccf513409ad3f6254c6d" alt="Personal Token[]" width="2880" height="1820" data-path="img/personal-token-3.png" />
      </Step>
    </Steps>
  </Tab>

  <Tab title="Team Access Token">
    <Warning>
      Team Access Tokens can access every document in the data sources selected when the token is created. Select only the data sources this integration needs, store the token in a secret manager, and rotate it regularly.
    </Warning>

    <Steps>
      <Step title="Create the API Token">
        In the [Unblocked web app](/using-unblocked/on-the-web), click on **Settings** --> **API Tokens**.

        In the **Team API Tokens** section, click on **Create Token**.

        <img src="https://mintcdn.com/unblocked/UPT9O22gsEWNRiDD/img/team-token-1.png?fit=max&auto=format&n=UPT9O22gsEWNRiDD&q=85&s=6750d421f417fadac3731603312fc871" alt="Team Token[]" width="2880" height="1820" data-path="img/team-token-1.png" />
      </Step>

      <Step title="Configure the API Token">
        Fill out the token name.  You can also limit the data sources that the token will have access to in the list under **Data Sources**.

        <img src="https://mintcdn.com/unblocked/WrAe_ZzBHh_yDkhV/img/team-token-2.png?fit=max&auto=format&n=WrAe_ZzBHh_yDkhV&q=85&s=b67bd2f1736f215edc53401852eba6e8" alt="Team Token[]" width="2880" height="1820" data-path="img/team-token-2.png" />
      </Step>

      <Step title="Copy the API Token">
        Copy the resulting API token.

        <img src="https://mintcdn.com/unblocked/WrAe_ZzBHh_yDkhV/img/team-token-3.png?fit=max&auto=format&n=WrAe_ZzBHh_yDkhV&q=85&s=8553ab50e62f41cc68f7d0b6ab9d59d5" alt="Team Token[]" width="2880" height="1820" data-path="img/team-token-3.png" />
      </Step>
    </Steps>
  </Tab>
</Tabs>

<Info>
  All tokens should be provided with each request to the Unblocked API using the `Authorization: Bearer <token>` header to authenticate the request.
</Info>

## Retrieve Context

The Context API retrieves information from the code, pull requests, issues, messages, and documentation connected to Unblocked. Context requests are synchronous.

Use the research endpoint when you want a synthesized answer from several source types:

```bash theme={null}
curl --request POST \
  --url https://getunblocked.com/api/v1/context/research \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "query": "How does the user authentication system work?",
  "instruction": "Focus on the current implementation and the decisions behind it.",
  "effort": "medium"
}'
```

The response contains a Markdown summary and the sources that support it:

```json theme={null}
{
  "summary": "The authentication system uses short-lived access tokens...",
  "sources": [
    {
      "content": "The access token is validated before...",
      "title": "Add short-lived access tokens",
      "url": "https://github.com/yourorg/yourrepo/pull/123",
      "sourceType": "pull_request",
      "provider": "github"
    }
  ],
  "effort": "medium"
}
```

Choose a focused endpoint when you do not need a synthesized answer:

| Endpoint | Use it to |
| - | - |
| `POST /context/research` | Research across all connected source types and return a summary with supporting sources. |
| `POST /context/search/code` | Search connected source code. |
| `POST /context/search/documentation` | Search connected documentation and knowledge bases. |
| `POST /context/search/issues` | Search connected issue trackers. |
| `POST /context/search/messages` | Search connected messaging platforms. |
| `POST /context/search/prs` | Search pull requests. |
| `POST /context/query/issues` | Retrieve issues that match natural-language criteria and optional project or person filters. |
| `POST /context/query/prs` | Retrieve pull requests that match natural-language criteria and optional repository or person filters. |
| `POST /context/get/urls` | Retrieve content from known URLs. |

Search endpoints accept a `query` and optional `instruction`. Query endpoints accept a `query` plus optional `projects` and `userName` filters. The URL endpoint accepts a non-empty `urls` array.

## Create a Collection

To add your own documents, first create a collection. A collection in Unblocked is a group of related documents from various data sources, such as customer support tools, knowledge bases, and internal wikis.

Multiple collections can be created to manage documents from different sources.

```bash theme={null}
curl --request POST \
  --url https://getunblocked.com/api/v1/collections \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "Apollo",
  "description": "Documents from the Apollo customer support tool including support responses.",
  "iconUrl": "https://my.company.com/apollo/logo.svg"
}'
```

The Unblocked API will respond with the newly created collection along with an ID. This ID uniquely identifies the collection, and will be used for adding documents to Unblocked.

```json theme={null}
{
  "id": "12345678-abcd-123456789-123456789abc",
  "name": "Apollo",
  "description": "Documents from the Apollo customer support tool including support responses.",
  "iconUrl": "https://my.company.com/apollo/logo.svg"
}
```

Collections can also be created in the Unblocked web app. Once you've signed in, click **Data Sources** in the sidebar, and then the **Add Data Sources** section. Scroll to the Custom section and select **Public API Collection**.

## Add a Document

Add a document to the collection using the collection's ID. In addition to the collection ID, provide a title, a body (in plain text or Markdown), and a URI for the document.

A document is uniquely identified by its URI. The URI will be used to link to the source of a reference in an answer.

```bash theme={null}
curl --request PUT \
  --url https://getunblocked.com/api/v1/documents \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "collectionId": "12345678-abcd-123456789-123456789abc",
  "title": "Password Reset Guide",
  "body": "To reset your password, visit ...",
  "uri": "https://my.company.com/apollo/ticket/123456"
}'
```

## Get Answers

The Answers API allows you to programmatically ask questions about your codebase and receive answers from Unblocked. The API uses an asynchronous pattern where you submit a question and then poll for the response.

Responses are in Markdown format.

<Note>
  The Answers API is currently limited to 1,000 questions per day per team. See [Rate limits](/api-reference/rate-limits).
</Note>

### Submit a Question

First, submit your question using a unique `questionId` (must be a globally unique UUID):

```bash theme={null}
curl --request PUT \
  --url https://getunblocked.com/api/v1/answers/12345678-abcd-123456789-123456789abc \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "question": "How does the user authentication system work?"
}'
```

The API will respond with a `204 No Content` status, indicating the question has been queued for processing.

### Poll for the Answer

Use the same `questionId` to poll for the answer:

```bash theme={null}
curl --request GET \
  --url https://getunblocked.com/api/v1/answers/12345678-abcd-123456789-123456789abc \
  --header 'Authorization: Bearer <token>'
```

While processing, the API returns:

```json theme={null}
{
  "state": "processing"
}
```

Once complete, the API returns the answer with references:

```json theme={null}
{
  "state": "complete",
  "result": {
    "answer": "The user authentication system uses JWT tokens... ",
    "references": [
      {
        "htmlUrl": "https://github.com/yourorg/yourrepo/blob/main/src/auth/login.js#L42"
      }
    ]
  }
}
```
