一键导入
dify-docs-api-reference
// Use when editing, auditing, or creating OpenAPI specs for the Dify documentation repo. Applies to files in en/api-reference/. Covers formatting rules, error code conventions, example standards, operationId patterns.
// Use when editing, auditing, or creating OpenAPI specs for the Dify documentation repo. Applies to files in en/api-reference/. Covers formatting rules, error code conventions, example standards, operationId patterns.
Use when writing, rewriting, or auditing environment variable documentation for Dify self-hosted deployment. Applies to en/self-host/configuration/environments.mdx. Covers the full process from codebase tracing to user-facing descriptions.
Use when preparing documentation updates for a Dify release. User provides two version references to compare (e.g., v1.13.2 and v1.13.3, or v1.13.2 and main). Covers API reference, help documentation, environment variable changes, and UI i18n glossary impact.
Check formatting compliance in changed Chinese and Japanese documentation against writing-guides/formatting-guide.md, tools/translate/formatting-zh.md, and tools/translate/formatting-ja.md. Use after finalizing a translation batch, or when the user says "check formatting (zh/ja)", "check CJK formatting", or "format audit" on translated content.
Check formatting compliance in changed English documentation against writing-guides/formatting-guide.md. Use after finalizing a draft, or when the user says "check formatting", "format audit", "format check" on English content.
Research a Dify feature before writing or optimizing documentation. Use when starting any doc task that requires understanding a feature's implementation, user pain points, or community feedback. Triggers: 'research this feature', 'investigate the code for', 'what do users say about', 'let's understand how X works before writing', or any documentation task where the current docs are being rewritten or significantly expanded.
Use when writing, improving, or reviewing Dify user guide documentation. Covers pages in en/use-dify/, en/develop-plugin/, and en/self-host/. Triggers: "write docs for [feature]", "improve this page", "review this documentation section".
| name | dify-docs-api-reference |
| description | Use when editing, auditing, or creating OpenAPI specs for the Dify documentation repo. Applies to files in en/api-reference/. Covers formatting rules, error code conventions, example standards, operationId patterns. |
Read these shared guides:
writing-guides/style-guide.mdwriting-guides/formatting-guide.mdwriting-guides/glossary.mdWhen auditing, also load:
references/audit-checklist.mdreferences/common-mistakes.mdWhen tracing code paths, also load:
references/codebase-paths.mdBackend developers integrating Dify apps or knowledge bases into their own applications via REST APIs. Assume strong coding ability, familiarity with HTTP, authentication patterns, and JSON. Focus on precision: exact parameter types, required vs optional, error codes, and realistic examples. Don't explain what a REST API is.
Pull the latest Dify code before auditing. In the Dify codebase directory:
git fetch origin && git checkout main && git pull origin main
Every detail in the spec MUST be verifiable against the codebase. When the spec disagrees with the code, the spec is wrong.
default, minimum/maximum, enum must exactly match Pydantic Field() arguments. E.g., le=101 -> "maximum": 101 -- not 100.Field(default=...) = optional, no default = required; FetchUserArg(required=True) = required.except -> raise -> exception class -> error_code and code attributes. See Error Responses.return ..., <status> value.enum against actual events yielded by the task pipeline. Each event type must have a corresponding discriminator mapping entry.description attribute or the string passed to werkzeug exceptions.request.args.get(), note Field() arguments.str, but the service layer may cast to StrEnum, Literal, or validate against a fixed list. Common patterns: SomeEnum(value) cast, Literal["a", "b"] downstream, explicit if field not in ALLOWED_VALUES checks. If any exist, the spec MUST have enum.except -> raise -> exception class -> error_code and code in error.py.return statement. Important: Response converters (e.g., convert_blocking_full_response) may flatten, restructure, or inject fields not present in the Pydantic entity. Always read the converter.The code is the source of truth, but the code itself may have bugs. When you encounter something irregular:
Common code smells: off-by-one in le/ge, response body with 204, inconsistent error handling across similar endpoints, missing error handlers that sibling endpoints have, required mismatches.
You are a professional API documentation writer. Beyond code fidelity:
| Spec File | App Type | AppMode values | Key Endpoints |
|---|---|---|---|
openapi_chat.json | Chat & Agent | CHAT, AGENT_CHAT | /chat-messages, conversations |
openapi_chatflow.json | Chatflow | ADVANCED_CHAT | Same as chat, mode advanced-chat |
openapi_workflow.json | Workflow | WORKFLOW | /workflows/run, workflow logs |
openapi_completion.json | Completion | COMPLETION | /completion-messages |
openapi_knowledge.json | Knowledge | (N/A) | datasets, documents, segments, metadata |
Shared endpoints (file upload, audio, feedback, app info, parameters, meta, site, end-user) appear in chat/chatflow/workflow/completion specs.
The codebase uses shared controllers and Pydantic models across app modes. The documentation separates these into per-app-type specs. You MUST filter through the app type lens:
retriever_from) -- omit from all specs.How to determine relevance: Check the controller's AppMode guard. For fields: "does this field have any effect in this mode?" For errors: "can this error be triggered in this mode?" When in doubt, trace through AppGenerateService.generate().
These rules are specific to API reference docs and override or extend the general style guide.
Must start with an imperative verb. Title Case. Standard vocabulary:
| Verb | Method | When to use |
|---|---|---|
Get | GET | Single JSON resource by ID or fixed path |
List | GET | Collection (paginated array) |
Download | GET | Binary file content |
Create | POST | New persistent resource |
Send | POST | Message or request dispatch |
Submit | POST | Feedback or input on existing resource |
Upload | POST | File upload |
Convert | POST | Format transformation |
Run | POST | Execute workflow or process |
Stop | POST | Halt running task |
Configure | POST | Enable/disable setting |
Rename | POST | Rename existing resource |
Update | PUT/PATCH | Modify fields on existing resource |
Delete | DELETE | Remove resource |
Do NOT use Retrieve -- use Get or List. Verb-object order: Upload File not File Upload.
Pattern: {verb}{AppType}{Resource}
| App Type | Prefix | Examples |
|---|---|---|
| Chat | Chat | createChatMessage, listChatConversations |
| Chatflow | Chatflow | createChatflowMessage |
| Workflow | Workflow | runWorkflow, getWorkflowLogs |
| Completion | Completion | createCompletionMessage |
| Knowledge | (none) | createDataset, listDocuments |
Legacy operationIds: Do NOT rename existing ones. Changing operationIds is a breaking change for SDK users. Apply this convention to new endpoints only.
"Session identifier." is a label, not a description. Instead: "The \user` identifier provided in API requests."`.null.| Field | Scope |
|---|---|
Endpoint description | What the endpoint does, plus any whole-API surprise (cascading delete, long-poll duration). One sentence when possible. |
Parameter description | Field meaning, valid values, deprecation, normalization, and rules about when to use it vs an alternative. |
If the endpoint description explains a parameter, move it down.
❌ "Remove one or more tag bindings from a knowledge base. Provide tag IDs in tag_ids. The legacy tag_id field is still accepted for single-tag requests and is normalized into tag_ids server-side; supply at least one of the two."
✅ Endpoint: "Remove one or more tags from a knowledge base."
tag_ids: "Tag IDs to unbind. Required unless the legacy tag_id is provided."
tag_id: "Legacy single-tag form. Normalized into tag_ids server-side. Use tag_ids for new integrations."
When a description mentions another endpoint, add a markdown link. Pattern: /api-reference/{category}/{endpoint-name} (kebab-case from endpoint summary).
description.Field() arguments verbatim.example field on parameters.default: 20 is in schema, don't repeat in description.required accurately based on code.enum for known value sets. Trace string fields through service layer for hidden enums.enum. Explain values in description instead (Mintlify renders duplicate "Available options" list).100 s, 15 MB -- not 100s, 15MB."Available options." is not acceptable.Only 200/201 as the primary response. For multiple response modes (blocking/streaming), use markdown bullets in the 200 description.
Every 200/201 JSON response MUST have at least one examples entry with realistic values.
Binary/file responses: Use content with appropriate media type and format: binary. Use audio/mpeg for audio, application/octet-stream for generic files. Put details in response description, not endpoint description.
Schema description duplication: When using $ref, the schema definition MUST NOT have a top-level description. Mintlify renders both, causing duplication.
Each endpoint MUST list its specific error codes, grouped by HTTP status.
BaseHTTPException subclasses (in error.py): Use error_code attribute as code name, code attribute as HTTP status.BadRequest, NotFound): Use generic codes -- bad_request, not_found. NOT the service-layer exception name.HTTPException subclasses (NOT BaseHTTPException): Global handler converts class name to snake_case via regex. E.g., FilenameNotExistsError -> filename_not_exists_error.@validate_app_token with no try/except, the only error is 401 (global auth). Do NOT add empty error sections.description attribute or werkzeug string argument.$ref schema in error responses -- omit "schema" entirely.$ref for simple objects.$ref for genuinely reused or complex schemas.properties -- no bare "type": "object".required arrays on request schemas only -- not response schemas.oneOf options: Each must have a title property. Parent schema must NOT have description."summary": "Request Example" (single) or "summary": "Request Example-Streaming mode" (multiple). Error examples: use error code as summary.Chats, Files, Conversations.Feedback, TTS.CRUD lifecycle: POST create -> GET list/detail -> PUT/PATCH update -> DELETE.
Exception: Tags without a create operation (e.g., Conversations). GET list comes first; non-create POST placed after GETs but before PUT/DELETE.
After completing the document, run the post-writing checks listed in writing-guides/index.md#post-writing-verification.