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

# Dify - How do I link my account?

## Overview

To authenticate with Dify, you need:

1. **API Key** — an app API key (to call one Dify app) or a knowledge base API key (to call your workspace's knowledge bases).

This guide will show you how to create either one.

### Prerequisites

* A [Dify Cloud](https://cloud.dify.ai) account. The free Sandbox plan includes API access.
* For a knowledge base API key: the workspace owner or admin role. Only they can create, view, and delete knowledge base keys.

### Step 1: Create an API key

An app API key works only for the app you create it in. A knowledge base API key works for all knowledge bases in your workspace, or only the ones you pick when you create it.

**App API key**

1. Sign in to [Dify Cloud](https://cloud.dify.ai) and open your app in **Studio**.
2. If the app has never been published, click **Publish**, then **Publish** again. The app's API stays unavailable until the app is published.
3. In the app's sidebar, click **Access Point**. Under **Backend Service API**, click **API Key**.

![Dify app Access Point page with the API Key button under Backend Service API highlighted](https://mintcdn.com/nango/fwQMXhj-qnKX7b6v/api-integrations/dify/app_access_point_api_key.png?fit=max\&auto=format\&n=fwQMXhj-qnKX7b6v\&q=85\&s=663286f9fd9f79f9e917344cd8eff060)

4. Click **Create new Secret key**.
5. Copy the key (it starts with `app-`), then click **I have saved this key**. Dify shows the key only once.

![Dify API key created dialog with the copy button highlighted](https://mintcdn.com/nango/fwQMXhj-qnKX7b6v/api-integrations/dify/app_api_key_created.png?fit=max\&auto=format\&n=fwQMXhj-qnKX7b6v\&q=85\&s=b6f588b1c1306ae2b30d67230f45be57)

**Knowledge base API key**

1. In the Dify sidebar, click **Knowledge**.
2. Click **Service API** in the top-right corner, then **API Key**.

![Dify Knowledge page with the Service API menu and API Key button highlighted](https://mintcdn.com/nango/fwQMXhj-qnKX7b6v/api-integrations/dify/knowledge_service_api_key.png?fit=max\&auto=format\&n=fwQMXhj-qnKX7b6v\&q=85\&s=0fe2f17d8000d2829143559efdb75247)

3. Click **Create new Secret key**, choose **All Knowledge Bases** or **Specific Knowledge Bases** under **Knowledge Base Access**, then click **Create**.

![Dify Add API Key dialog with the Knowledge Base Access options and the Create button](https://mintcdn.com/nango/fwQMXhj-qnKX7b6v/api-integrations/dify/knowledge_api_key_scope.png?fit=max\&auto=format\&n=fwQMXhj-qnKX7b6v\&q=85\&s=8e065b7a6f7c444b9637f3085f86dcbc)

4. Copy the key (it starts with `dataset-`), then click **I have saved this key**. Dify shows the key only once.

### Step 2: Enter your API key in the Connect UI

1. Open the form where you need to authenticate with Dify.
2. Paste your app or knowledge base API key in the **API Key** field.
3. Submit the form. The connection is saved without checking the key: if the key is wrong, the first API request returns an authentication error.

![Dify Connect UI form with the API Key field](https://mintcdn.com/nango/fwQMXhj-qnKX7b6v/api-integrations/dify/form.png?fit=max\&auto=format\&n=fwQMXhj-qnKX7b6v\&q=85\&s=7a5ca13d0e2bc17cc0286ea54cb92846)

You are now connected to Dify.


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