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

# Get Started with the Dify API

> Get an API key, make your first call, and find the endpoints for your app type

Every app you publish in Dify doubles as a REST API, and so do your knowledge bases. You call the same app your end users interact with, from your own backend, with an API key.

## Get an API Key

> [!WARNING]
>
> Call the API from your backend only. A key embedded in frontend code or a client app can be extracted and abused.

* For an app, create an API key from inside the app itself. The key is scoped to that one app, and one key serves all your end users.

  > [!NOTE]
  >
  > Your calls tell people apart with a per-person `user` value. See [End User Identity](https://docs.dify.ai/en/api-reference/guides/end-user-identity.md) for details.

* For knowledge bases, go to **Knowledge**, click **Service API** in the top-right corner and create an API key there.

  You can [scope the key](https://docs.dify.ai/en/api-reference/guides/knowledge.md#scoped-api-keys) to only the knowledge bases the integration needs access to.

## Make Your First Call

Every request carries the key as a Bearer token. For Dify Cloud, the base URL is `https://api.dify.ai/v1`; for self-hosted deployments, use your own instance's API base URL.

The fastest first call needs no code: open [Get App Info](https://docs.dify.ai/en/api-reference/applications/get-app-info.md), click **Try it**, paste your key into the **Authorization** field, and press **Send**. It works for every app type.

The same call from a terminal:

```bash theme={null}
curl https://api.dify.ai/v1/info \
  -H "Authorization: Bearer $DIFY_API_KEY"
```

A response like this confirms the key works and shows which app it belongs to:

```json theme={null}
{
  "name": "My Chat App",
  "description": "A helpful assistant",
  "tags": ["assistant"],
  "mode": "chat",
  "author_name": "Dify Team"
}
```

Using a knowledge API key?

* **Scoped key**: [Copy the ID from Dify](https://docs.dify.ai/en/api-reference/guides/knowledge.md#knowledge-base-id) for a knowledge base in its scope, then call [Get Knowledge Base](https://docs.dify.ai/en/api-reference/knowledge-bases/get-knowledge-base.md).
* **Key with access to all knowledge bases**: Call [List Knowledge Bases](https://docs.dify.ai/en/api-reference/knowledge-bases/list-knowledge-bases.md).

## Find Your App Type's Endpoints

See each app type's own overview page for its full API surface:

* [Chatflow](https://docs.dify.ai/en/api-reference/guides/chatflow.md) (`advanced-chat`)
* [Workflow](https://docs.dify.ai/en/api-reference/guides/workflow.md) (`workflow`)
* [Agent](https://docs.dify.ai/en/api-reference/guides/agent.md) (`agent`)
* [Chatbot and Legacy Agent](https://docs.dify.ai/en/api-reference/guides/chat.md) (`chat`, `agent-chat`)
* [Text Generator](https://docs.dify.ai/en/api-reference/guides/completion.md) (`completion`)
* [Knowledge](https://docs.dify.ai/en/api-reference/guides/knowledge.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.