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

# API

> Interact with Qontext via API

## Overview

The Qontext API provides programmatic access to your context repository.

Use it to build custom applications, workflows, agents, and internal tools that retrieve, search, create, and update context.

All API requests are authenticated using API keys.

***

## Creating an API key

Please refer to the [API reference](/api-reference/introduction) for all available endpoints and examples.

<Steps>
  <Step title="Go to Clients">
    In the [Qontext app](https://app.qontext.ai), go to the **Clients** tab. To add an API key, click on **+ Create  API key** in the top right corner.

    <img src="https://mintcdn.com/qontext/ij80IpzZhIk9hRMP/images/Qontext_add-API-key.png?fit=max&auto=format&n=ij80IpzZhIk9hRMP&q=85&s=6e5df589299ffdb59464e67720d36486" alt="Qontext Add API Key" title="Qontext Add API Key" style={{ width:"91%" }} width="1286" height="357" data-path="images/Qontext_add-API-key.png" />
  </Step>

  <Step title="Create API key">
    In the **Create an API key** window, give your key a name and add an expiration date if required.

    <img src="https://mintcdn.com/qontext/ij80IpzZhIk9hRMP/images/Qontext_API-key-creation-1.png?fit=max&auto=format&n=ij80IpzZhIk9hRMP&q=85&s=845966d318c52ac5ea1d6651435bf0be" alt="Qontext API Key Creation 1" title="Qontext API Key Creation 1" style={{ width:"44%" }} width="520" height="538" data-path="images/Qontext_API-key-creation-1.png" />
  </Step>

  <Step title="Copy API key">
    Copy the API key and store it safely. You will not be able to view it again later.
  </Step>

  <Step title="Access Qontext">
    You can now access the context repository from any application, workflow, or script by passing the key as the `X-API-Key` header in API requests.
  </Step>
</Steps>

***

## Authentication

Pass the API key as the `X-API-Key` header:

```text theme={null}
--header 'X-API-Key: q_sk_***************'
```

***

## Available operations

The API can be used to:

* Read files and folders
* Search the context repository
* Create files and folders
* Update files and folders
* Manage clients
* Manage sources
* Retrieve logs

Please refer to the [API reference](/api-reference/introduction) for endpoint documentation and examples.

***

## Best practices

<Info>
  **One API key per use case or environment.**

  Use separate keys per workflow, agent, or environment. That enables easy revocation of access and makes the origin of retrieval logs clearly identifiable.
</Info>

***

## FAQ

<AccordionGroup>
  <Accordion title="What do I do if I lost my API key?">
    In the [Qontext app](https://app.qontext.ai), open the **Clients** tab. Click the three dots next to the key and choose **Revoke**. Once revoked, the key is automatically disabled and removed from the list. Create a new key for the same use case and update the client using it.

    <img src="https://mintcdn.com/qontext/ij80IpzZhIk9hRMP/images/Qontext_revoke-API-key.png?fit=max&auto=format&n=ij80IpzZhIk9hRMP&q=85&s=c8aff4da22654aa522b572ba7fe443fa" alt="Qontext Revoke API Key" width="1034" height="649" data-path="images/Qontext_revoke-API-key.png" />
  </Accordion>
</AccordionGroup>
