import dsl by api #16233

Closed
opened 2026-02-21 19:25:14 -05:00 by yindo · 3 comments
Owner

Originally created by @liuxingbo12138 on GitHub (Aug 18, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

I need to upload the dsl file through the API request method. I also found the relevant API interfaces in the dify source code, but when I tried to call them, it failed.

2. Additional context or comments

Upload DSL files via API

  1. Core service code --- D:\AYINDUN\dify\api\services\app_dsl_service.py
  • import_app() (Lines 118-321): Main entry method
  • confirm_import() (Lines 322-381): Confirmation import method
  • export_dsl() (Lines 535-564): Export DSL method
  1. API controller code --- D:\AYINDUN\dify\api\controllers\console\app\app_import.py
  • AppImportApi (Lines 24-75): Handles POST /console/api/apps/import
  • AppImportConfirmApi (Lines 77-99): Handles POST /console/api/apps/import/{import_id}/confirm
  • AppImportCheckDependenciesApi (Lines 101-116): Checks dependencies
  1. Route registration code --- D:\AYINDUN\dify\api\controllers\console_init_.py - api.add_resource(AppImportApi, "/apps/imports")
  • api.add_resource(AppImportConfirmApi, "/apps/imports/string:import_id/confirm")
  • api.add_resource(AppImportCheckDependenciesApi, "/apps/imports/string:app_id/check-dependencies")
  1. Workflow Synchronization Code - D:\AYINDUN\dify\api\controllers\console\app\workflow.py
  • DraftWorkflowApi.post() (Lines 87-161): Synchronize draft workflow
    Specific call chain
  1. API Entry: app_import.py: AppImportApi.post() → Lines 30-74
  2. Core Logic: app_dsl_service.py: AppDslService.import_app() → Lines 118-321
  3. Workflow Creation: app_dsl_service.py: _create_or_update_app() → Lines 406-532

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @liuxingbo12138 on GitHub (Aug 18, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. I need to upload the dsl file through the API request method. I also found the relevant API interfaces in the dify source code, but when I tried to call them, it failed. ### 2. Additional context or comments Upload DSL files via API 1. Core service code --- D:\AYINDUN\dify\api\services\app_dsl_service.py - import_app() (Lines 118-321): Main entry method - confirm_import() (Lines 322-381): Confirmation import method - export_dsl() (Lines 535-564): Export DSL method 2. API controller code --- D:\AYINDUN\dify\api\controllers\console\app\app_import.py - AppImportApi (Lines 24-75): Handles POST /console/api/apps/import - AppImportConfirmApi (Lines 77-99): Handles POST /console/api/apps/import/{import_id}/confirm - AppImportCheckDependenciesApi (Lines 101-116): Checks dependencies 3. Route registration code --- D:\AYINDUN\dify\api\controllers\console\__init__.py - api.add_resource(AppImportApi, "/apps/imports") - api.add_resource(AppImportConfirmApi, "/apps/imports/<string:import_id>/confirm") - api.add_resource(AppImportCheckDependenciesApi, "/apps/imports/<string:app_id>/check-dependencies") 4. Workflow Synchronization Code - D:\AYINDUN\dify\api\controllers\console\app\workflow.py - DraftWorkflowApi.post() (Lines 87-161): Synchronize draft workflow Specific call chain 1. API Entry: app_import.py: AppImportApi.post() → Lines 30-74 2. Core Logic: app_dsl_service.py: AppDslService.import_app() → Lines 118-321 3. Workflow Creation: app_dsl_service.py: _create_or_update_app() → Lines 406-532 ### 3. Can you help us with this feature? - [x] I am interested in contributing to this feature.
yindo closed this issue 2026-02-21 19:25:14 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 18, 2025):

Hi @liuxingbo12138! I'm Dosu and I’m helping the dify team.

To import a DSL file via the Dify API, use the POST endpoint /console/api/apps/import with authentication (your token must be valid and not expired). The request should be JSON with at least these fields:

{
  "mode": "yaml-content",
  "yaml_content": "<your DSL YAML as a string>"
}

If you want to import from a URL, use "mode": "yaml-url" and provide "yaml_url": "<link to your YAML file>" instead.

Common reasons for failure:

  • Missing yaml_content when using yaml-content mode will return an error: "yaml_content is required when import_mode is yaml-content" (source).
  • Expired or missing authentication token returns 401 Unauthorized. Log in again to refresh your token (source).
  • The API only supports a single YAML file, not folders or multiple files. If you try to upload a folder, the request will fail (source).
  • The DSL YAML must be valid and under 10MB. Missing required fields (like version, kind: app, or app data) or invalid YAML will cause the import to fail (source).
  • If the DSL version is newer than supported, the import will be pending and you must confirm it via POST /console/api/apps/import/{import_id}/confirm.

Example cURL request:

curl -X POST "https://<your-dify-host>/console/api/apps/import" \
  -H "Authorization: Bearer <your-token>" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "yaml-content",
    "yaml_content": "<paste your YAML file content here>"
  }'

If you get an error, check the error field in the response for details. If you need more help, share your exact error message and payload (with sensitive info removed) for more targeted troubleshooting.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Aug 18, 2025): <!-- Greeting --> Hi @liuxingbo12138! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> To import a DSL file via the Dify API, use the POST endpoint `/console/api/apps/import` with authentication (your token must be valid and not expired). The request should be JSON with at least these fields: ```json { "mode": "yaml-content", "yaml_content": "<your DSL YAML as a string>" } ``` If you want to import from a URL, use `"mode": "yaml-url"` and provide `"yaml_url": "<link to your YAML file>"` instead. Common reasons for failure: - Missing `yaml_content` when using `yaml-content` mode will return an error: `"yaml_content is required when import_mode is yaml-content"` [(source)](https://github.com/langgenius/dify/issues/20370#issuecomment-2916126968). - Expired or missing authentication token returns 401 Unauthorized. Log in again to refresh your token [(source)](https://github.com/langgenius/dify/issues/20370#issuecomment-2915816386). - The API only supports a single YAML file, not folders or multiple files. If you try to upload a folder, the request will fail [(source)](https://github.com/langgenius/dify/issues/23492). - The DSL YAML must be valid and under 10MB. Missing required fields (like `version`, `kind: app`, or `app` data) or invalid YAML will cause the import to fail [(source)](https://github.com/langgenius/dify/blob/f5033c5a0e26408fc1bc3af8344704c157783954/api/services/app_dsl_service.py). - If the DSL version is newer than supported, the import will be `pending` and you must confirm it via `POST /console/api/apps/import/{import_id}/confirm`. Example cURL request: ```bash curl -X POST "https://<your-dify-host>/console/api/apps/import" \ -H "Authorization: Bearer <your-token>" \ -H "Content-Type: application/json" \ -d '{ "mode": "yaml-content", "yaml_content": "<paste your YAML file content here>" }' ``` If you get an error, check the `error` field in the response for details. If you need more help, share your exact error message and payload (with sensitive info removed) for more targeted troubleshooting. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/8ecc45d5-1fdc-4fe9-a90a-8abed3d25248?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/8ecc45d5-1fdc-4fe9-a90a-8abed3d25248?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/8ecc45d5-1fdc-4fe9-a90a-8abed3d25248?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/8ecc45d5-1fdc-4fe9-a90a-8abed3d25248?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/8ecc45d5-1fdc-4fe9-a90a-8abed3d25248?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/8ecc45d5-1fdc-4fe9-a90a-8abed3d25248?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/8ecc45d5-1fdc-4fe9-a90a-8abed3d25248?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/24087)
Author
Owner

@liugddx commented on GitHub (Aug 18, 2025):

Can you provide error logs

@liugddx commented on GitHub (Aug 18, 2025): Can you provide error logs
Author
Owner

@crazywoola commented on GitHub (Aug 18, 2025):

It seems you are using the wrong template to open an issue. Please provide some logs if you have encountered some errors.

@crazywoola commented on GitHub (Aug 18, 2025): It seems you are using the wrong template to open an issue. Please provide some logs if you have encountered some errors.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#16233