Get an API Key
-
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.
Your calls tell people apart with a per-person
uservalue. See End User Identity 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 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 ishttps://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, 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:
- Scoped key: Copy the ID from Dify for a knowledge base in its scope, then call Get Knowledge Base.
- Key with access to all knowledge bases: Call List Knowledge Bases.
Find Your App Type’s Endpoints
See each app type’s own overview page for its full API surface:- Chatflow (
advanced-chat) - Workflow (
workflow) - Agent (
agent) - Chatbot and Legacy Agent (
chat,agent-chat) - Text Generator (
completion) - Knowledge