You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

template_workflow.en.mdx 50KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132
  1. import { CodeGroup } from '../code.tsx'
  2. import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from '../md.tsx'
  3. # Workflow App API
  4. Workflow applications offers non-session support and is ideal for translation, article writing, summarization AI, and more.
  5. <div>
  6. ### Base URL
  7. <CodeGroup title="Code" targetCode={props.appDetail.api_base_url} />
  8. ### Authentication
  9. The Service API uses `API-Key` authentication.
  10. <i>**Strongly recommend storing your API Key on the server-side, not shared or stored on the client-side, to avoid possible API-Key leakage that can lead to serious consequences.**</i>
  11. For all API requests, include your API Key in the `Authorization` HTTP Header, as shown below:
  12. <CodeGroup title="Code" targetCode='Authorization: Bearer {API_KEY}' />
  13. </div>
  14. ---
  15. <Heading
  16. url='/workflows/run'
  17. method='POST'
  18. title='Execute Workflow'
  19. name='#Execute-Workflow'
  20. />
  21. <Row>
  22. <Col>
  23. Execute workflow, cannot be executed without a published workflow.
  24. ### Request Body
  25. - `inputs` (object) Required
  26. Allows the entry of various variable values defined by the App.
  27. The `inputs` parameter contains multiple key/value pairs, with each key corresponding to a specific variable and each value being the specific value for that variable.
  28. The workflow application requires at least one key/value pair to be inputted. The variable can be of File Array type.
  29. File Array type variable is suitable for inputting files combined with text understanding and answering questions, available only when the model supports file parsing and understanding capability.
  30. If the variable is of File Array type, the corresponding value should be a list whose elements contain following attributions:
  31. - `type` (string) Supported type:
  32. - `document` Supported types include: 'TXT', 'MD', 'MARKDOWN', 'MDX', 'PDF', 'HTML', 'XLSX', 'XLS', 'VTT', 'PROPERTIES', 'DOC', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB'
  33. - `image` Supported types include: 'JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG'
  34. - `audio` Supported types include: 'MP3', 'M4A', 'WAV', 'WEBM', 'MPGA'
  35. - `video` Supported types include: 'MP4', 'MOV', 'MPEG', 'WEBM'
  36. - `custom` Supported types include: other file types
  37. - `transfer_method` (string) Transfer method:
  38. - `remote_url`: File URL.
  39. - `local_file`: Upload file.
  40. - `url` File URL. (Only when transfer method is `remote_url`).
  41. - `upload_file_id` Upload file ID. (Only when transfer method is `local_file`).
  42. </Property>
  43. - `response_mode` (string) Required
  44. The mode of response return, supporting:
  45. - `streaming` Streaming mode (recommended), implements a typewriter-like output through SSE ([Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)).
  46. - `blocking` Blocking mode, returns result after execution is complete. (Requests may be interrupted if the process is long)
  47. <i>Due to Cloudflare restrictions, the request will be interrupted without a return after 100 seconds.</i>
  48. - `user` (string) Required
  49. User identifier, used to define the identity of the end-user for retrieval and statistics.
  50. Should be uniquely defined by the developer within the application.
  51. <br/>
  52. <i>The user identifier should be consistent with the user passed in the message sending interface. The Service API does not share conversations created by the WebApp.</i>
  53. - `files` (array[object]) Optional
  54. - `trace_id` (string) Optional
  55. Trace ID. Used for integration with existing business trace components to achieve end-to-end distributed tracing. If not provided, the system will automatically generate a trace_id. Supports the following three ways to pass, in order of priority:
  56. 1. Header: via HTTP Header `X-Trace-Id`, highest priority.
  57. 2. Query parameter: via URL query parameter `trace_id`.
  58. 3. Request Body: via request body field `trace_id` (i.e., this field).
  59. ### Response
  60. When `response_mode` is `blocking`, return a CompletionResponse object.
  61. When `response_mode` is `streaming`, return a ChunkCompletionResponse stream.
  62. ### CompletionResponse
  63. Returns the App result, `Content-Type` is `application/json`.
  64. - `workflow_run_id` (string) Unique ID of workflow execution
  65. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  66. - `data` (object) detail of result
  67. - `id` (string) ID of workflow execution
  68. - `workflow_id` (string) ID of related workflow
  69. - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
  70. - `outputs` (json) Optional content of output
  71. - `error` (string) Optional reason of error
  72. - `elapsed_time` (float) Optional total seconds to be used
  73. - `total_tokens` (int) Optional tokens to be used
  74. - `total_steps` (int) default 0
  75. - `created_at` (timestamp) start time
  76. - `finished_at` (timestamp) end time
  77. ### ChunkCompletionResponse
  78. Returns the stream chunks outputted by the App, `Content-Type` is `text/event-stream`.
  79. Each streaming chunk starts with `data:`, separated by two newline characters `\n\n`, as shown below:
  80. <CodeGroup>
  81. ```streaming {{ title: 'Response' }}
  82. data: {"event": "text_chunk", "workflow_run_id": "b85e5fc5-751b-454d-b14e-dc5f240b0a31", "task_id": "bd029338-b068-4d34-a331-fc85478922c2", "data": {"text": "\u4e3a\u4e86", "from_variable_selector": ["1745912968134", "text"]}}\n\n
  83. ```
  84. </CodeGroup>
  85. The structure of the streaming chunks varies depending on the `event`:
  86. - `event: workflow_started` workflow starts execution
  87. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  88. - `workflow_run_id` (string) Unique ID of workflow execution
  89. - `event` (string) fixed to `workflow_started`
  90. - `data` (object) detail
  91. - `id` (string) Unique ID of workflow execution
  92. - `workflow_id` (string) ID of related workflow
  93. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  94. - `event: node_started` node execution started
  95. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  96. - `workflow_run_id` (string) Unique ID of workflow execution
  97. - `event` (string) fixed to `node_started`
  98. - `data` (object) detail
  99. - `id` (string) Unique ID of workflow execution
  100. - `node_id` (string) ID of node
  101. - `node_type` (string) type of node
  102. - `title` (string) name of node
  103. - `index` (int) Execution sequence number, used to display Tracing Node sequence
  104. - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path
  105. - `inputs` (object) Contents of all preceding node variables used in the node
  106. - `created_at` (timestamp) timestamp of start, e.g., 1705395332
  107. - `event: text_chunk` Text fragment
  108. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  109. - `workflow_run_id` (string) Unique ID of workflow execution
  110. - `event` (string) fixed to `text_chunk`
  111. - `data` (object) detail
  112. - `text` (string) Text content
  113. - `from_variable_selector` (array) Text source path, helping developers understand which node and variable generated the text
  114. - `event: node_finished` node execution ends, success or failure in different states in the same event
  115. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  116. - `workflow_run_id` (string) Unique ID of workflow execution
  117. - `event` (string) fixed to `node_finished`
  118. - `data` (object) detail
  119. - `id` (string) Unique ID of workflow execution
  120. - `node_id` (string) ID of node
  121. - `node_type` (string) type of node
  122. - `title` (string) name of node
  123. - `index` (int) Execution sequence number, used to display Tracing Node sequence
  124. - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path
  125. - `inputs` (object) Contents of all preceding node variables used in the node
  126. - `process_data` (json) Optional node process data
  127. - `outputs` (json) Optional content of output
  128. - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
  129. - `error` (string) Optional reason of error
  130. - `elapsed_time` (float) Optional total seconds to be used
  131. - `execution_metadata` (json) meta data
  132. - `total_tokens` (int) optional tokens to be used
  133. - `total_price` (decimal) optional Total cost
  134. - `currency` (string) optional e.g. `USD` / `RMB`
  135. - `created_at` (timestamp) timestamp of start, e.g., 1705395332
  136. - `event: workflow_finished` workflow execution ends, success or failure in different states in the same event
  137. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  138. - `workflow_run_id` (string) Unique ID of workflow execution
  139. - `event` (string) fixed to `workflow_finished`
  140. - `data` (object) detail
  141. - `id` (string) ID of workflow execution
  142. - `workflow_id` (string) ID of related workflow
  143. - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
  144. - `outputs` (json) Optional content of output
  145. - `error` (string) Optional reason of error
  146. - `elapsed_time` (float) Optional total seconds to be used
  147. - `total_tokens` (int) Optional tokens to be used
  148. - `total_steps` (int) default 0
  149. - `created_at` (timestamp) start time
  150. - `finished_at` (timestamp) end time
  151. - `event: tts_message` TTS audio stream event, that is, speech synthesis output. The content is an audio block in Mp3 format, encoded as a base64 string. When playing, simply decode the base64 and feed it into the player. (This message is available only when auto-play is enabled)
  152. - `task_id` (string) Task ID, used for request tracking and the stop response interface below
  153. - `message_id` (string) Unique message ID
  154. - `audio` (string) The audio after speech synthesis, encoded in base64 text content, when playing, simply decode the base64 and feed it into the player
  155. - `created_at` (int) Creation timestamp, e.g.: 1705395332
  156. - `event: tts_message_end` TTS audio stream end event, receiving this event indicates the end of the audio stream.
  157. - `task_id` (string) Task ID, used for request tracking and the stop response interface below
  158. - `message_id` (string) Unique message ID
  159. - `audio` (string) The end event has no audio, so this is an empty string
  160. - `created_at` (int) Creation timestamp, e.g.: 1705395332
  161. - `event: ping` Ping event every 10 seconds to keep the connection alive.
  162. ### Errors
  163. - 400, `invalid_param`, abnormal parameter input
  164. - 400, `app_unavailable`, App configuration unavailable
  165. - 400, `provider_not_initialize`, no available model credential configuration
  166. - 400, `provider_quota_exceeded`, model invocation quota insufficient
  167. - 400, `model_currently_not_support`, current model unavailable
  168. - 400, `workflow_request_error`, workflow execution failed
  169. - 500, internal server error
  170. </Col>
  171. <Col sticky>
  172. <CodeGroup
  173. title="Request"
  174. tag="POST"
  175. label="/workflows/run"
  176. targetCode={`curl -X POST '${props.appDetail.api_base_url}/workflows/run' \\
  177. --header 'Authorization: Bearer {api_key}' \\
  178. --header 'Content-Type: application/json' \\
  179. --data-raw '{
  180. "inputs": ${JSON.stringify(props.inputs)},
  181. "response_mode": "streaming",
  182. "user": "abc-123"
  183. }'`}
  184. />
  185. <CodeGroup title="Example: file array as an input variable">
  186. ```json {{ title: 'File variable example' }}
  187. {
  188. "inputs": {
  189. "{variable_name}":
  190. [
  191. {
  192. "transfer_method": "local_file",
  193. "upload_file_id": "{upload_file_id}",
  194. "type": "{document_type}"
  195. }
  196. ]
  197. }
  198. }
  199. ```
  200. </CodeGroup>
  201. ### Blocking Mode
  202. <CodeGroup title="Response">
  203. ```json {{ title: 'Response' }}
  204. {
  205. "workflow_run_id": "djflajgkldjgd",
  206. "task_id": "9da23599-e713-473b-982c-4328d4f5c78a",
  207. "data": {
  208. "id": "fdlsjfjejkghjda",
  209. "workflow_id": "fldjaslkfjlsda",
  210. "status": "succeeded",
  211. "outputs": {
  212. "text": "Nice to meet you."
  213. },
  214. "error": null,
  215. "elapsed_time": 0.875,
  216. "total_tokens": 3562,
  217. "total_steps": 8,
  218. "created_at": 1705407629,
  219. "finished_at": 1727807631
  220. }
  221. }
  222. ```
  223. </CodeGroup>
  224. ### Streaming Mode
  225. <CodeGroup title="Response">
  226. ```streaming {{ title: 'Response' }}
  227. data: {"event": "workflow_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "created_at": 1679586595}}
  228. data: {"event": "node_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "created_at": 1679586595}}
  229. data: {"event": "node_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "execution_metadata": {"total_tokens": 63127864, "total_price": 2.378, "currency": "USD"}, "created_at": 1679586595}}
  230. data: {"event": "workflow_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "total_tokens": 63127864, "total_steps": "1", "created_at": 1679586595, "finished_at": 1679976595}}
  231. data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}
  232. data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}
  233. ```
  234. </CodeGroup>
  235. <CodeGroup title="File upload sample code">
  236. ```json {{ title: 'File upload sample code' }}
  237. import requests
  238. import json
  239. def upload_file(file_path, user):
  240. upload_url = "https://api.dify.ai/v1/files/upload"
  241. headers = {
  242. "Authorization": "Bearer app-xxxxxxxx",
  243. }
  244. try:
  245. print("Upload file...")
  246. with open(file_path, 'rb') as file:
  247. files = {
  248. 'file': (file_path, file, 'text/plain') # Make sure the file is uploaded with the appropriate MIME type
  249. }
  250. data = {
  251. "user": user,
  252. "type": "TXT" # Set the file type to TXT
  253. }
  254. response = requests.post(upload_url, headers=headers, files=files, data=data)
  255. if response.status_code == 201: # 201 means creation is successful
  256. print("File uploaded successfully")
  257. return response.json().get("id") # Get the uploaded file ID
  258. else:
  259. print(f"File upload failed, status code: {response.status_code}")
  260. return None
  261. except Exception as e:
  262. print(f"Error occurred: {str(e)}")
  263. return None
  264. def run_workflow(file_id, user, response_mode="blocking"):
  265. workflow_url = "https://api.dify.ai/v1/workflows/run"
  266. headers = {
  267. "Authorization": "Bearer app-xxxxxxxxx",
  268. "Content-Type": "application/json"
  269. }
  270. data = {
  271. "inputs": {
  272. "orig_mail": [{
  273. "transfer_method": "local_file",
  274. "upload_file_id": file_id,
  275. "type": "document"
  276. }]
  277. },
  278. "response_mode": response_mode,
  279. "user": user
  280. }
  281. try:
  282. print("Run Workflow...")
  283. response = requests.post(workflow_url, headers=headers, json=data)
  284. if response.status_code == 200:
  285. print("Workflow execution successful")
  286. return response.json()
  287. else:
  288. print(f"Workflow execution failed, status code: {response.status_code}")
  289. return {"status": "error", "message": f"Failed to execute workflow, status code: {response.status_code}"}
  290. except Exception as e:
  291. print(f"Error occurred: {str(e)}")
  292. return {"status": "error", "message": str(e)}
  293. # Usage Examples
  294. file_path = "{your_file_path}"
  295. user = "difyuser"
  296. # Upload files
  297. file_id = upload_file(file_path, user)
  298. if file_id:
  299. # The file was uploaded successfully, and the workflow continues to run
  300. result = run_workflow(file_id, user)
  301. print(result)
  302. else:
  303. print("File upload failed and workflow cannot be executed")
  304. ```
  305. </CodeGroup>
  306. </Col>
  307. </Row>
  308. ---
  309. <Heading
  310. url='/workflows/:workflow_id/run'
  311. method='POST'
  312. title='Execute Specific Workflow'
  313. name='#Execute-Specific-Workflow'
  314. />
  315. <Row>
  316. <Col>
  317. Execute a specific version of workflow by specifying the workflow ID in the path parameter.
  318. ### Path
  319. - `workflow_id` (string) Required Workflow ID to specify a specific version of workflow
  320. How to obtain: In the version history interface, click the copy icon on the right side of each version entry to copy the complete workflow ID. Each version entry contains a copyable ID field.
  321. ### Request Body
  322. - `inputs` (object) Required
  323. Allows the entry of various variable values defined by the App.
  324. The `inputs` parameter contains multiple key/value pairs, with each key corresponding to a specific variable and each value being the specific value for that variable.
  325. The workflow application requires at least one key/value pair to be inputted. The variable can be of File Array type.
  326. File Array type variable is suitable for inputting files combined with text understanding and answering questions, available only when the model supports file parsing and understanding capability.
  327. If the variable is of File Array type, the corresponding value should be a list whose elements contain following attributions:
  328. - `type` (string) Supported type:
  329. - `document` ('TXT', 'MD', 'MARKDOWN', 'PDF', 'HTML', 'XLSX', 'XLS', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB')
  330. - `image` ('JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG')
  331. - `audio` ('MP3', 'M4A', 'WAV', 'WEBM', 'AMR')
  332. - `video` ('MP4', 'MOV', 'MPEG', 'MPGA')
  333. - `custom` (Other file types)
  334. - `transfer_method` (string) Transfer method, `remote_url` for image URL / `local_file` for file upload
  335. - `url` (string) Image URL (when the transfer method is `remote_url`)
  336. - `upload_file_id` (string) Uploaded file ID, which must be obtained by uploading through the File Upload API in advance (when the transfer method is `local_file`)
  337. - `response_mode` (string) Required
  338. The mode of response return, supporting:
  339. - `streaming` Streaming mode (recommended), implements a typewriter-like output through SSE ([Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)).
  340. - `blocking` Blocking mode, returns result after execution is complete. (Requests may be interrupted if the process is long)
  341. <i>Due to Cloudflare restrictions, the request will be interrupted without a return after 100 seconds.</i>
  342. - `user` (string) Required
  343. User identifier, used to define the identity of the end-user for retrieval and statistics.
  344. Should be uniquely defined by the developer within the application.
  345. <br/>
  346. <i>The user identifier should be consistent with the user passed in the message sending interface. The Service API does not share conversations created by the WebApp.</i>
  347. - `files` (array[object]) Optional
  348. - `trace_id` (string) Optional
  349. Trace ID. Used for integration with existing business trace components to achieve end-to-end distributed tracing. If not provided, the system will automatically generate a trace_id. Supports the following three ways to pass, in order of priority:
  350. 1. Header: via HTTP Header `X-Trace-Id`, highest priority.
  351. 2. Query parameter: via URL query parameter `trace_id`.
  352. 3. Request Body: via request body field `trace_id` (i.e., this field).
  353. ### Response
  354. When `response_mode` is `blocking`, return a CompletionResponse object.
  355. When `response_mode` is `streaming`, return a ChunkCompletionResponse stream.
  356. ### CompletionResponse
  357. Returns the App result, `Content-Type` is `application/json`.
  358. - `workflow_run_id` (string) Unique ID of workflow execution
  359. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  360. - `data` (object) detail of result
  361. - `id` (string) ID of workflow execution
  362. - `workflow_id` (string) ID of related workflow
  363. - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
  364. - `outputs` (json) Optional content of output
  365. - `error` (string) Optional reason of error
  366. - `elapsed_time` (float) Optional total seconds to be used
  367. - `total_tokens` (int) Optional tokens to be used
  368. - `total_steps` (int) default 0
  369. - `created_at` (timestamp) start time
  370. - `finished_at` (timestamp) end time
  371. ### ChunkCompletionResponse
  372. Returns the stream chunks outputted by the App, `Content-Type` is `text/event-stream`.
  373. Each streaming chunk starts with `data:`, separated by two newline characters `\n\n`, as shown below:
  374. <CodeGroup>
  375. ```streaming {{ title: 'Response' }}
  376. data: {"event": "text_chunk", "workflow_run_id": "b85e5fc5-751b-454d-b14e-dc5f240b0a31", "task_id": "bd029338-b068-4d34-a331-fc85478922c2", "data": {"text": "\u4e3a\u4e86", "from_variable_selector": ["1745912968134", "text"]}}\n\n
  377. ```
  378. </CodeGroup>
  379. The structure of the streaming chunks varies depending on the `event`:
  380. - `event: workflow_started` workflow starts execution
  381. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  382. - `workflow_run_id` (string) Unique ID of workflow execution
  383. - `event` (string) fixed to `workflow_started`
  384. - `data` (object) detail
  385. - `id` (string) Unique ID of workflow execution
  386. - `workflow_id` (string) ID of related workflow
  387. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  388. - `event: node_started` node execution started
  389. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  390. - `workflow_run_id` (string) Unique ID of workflow execution
  391. - `event` (string) fixed to `node_started`
  392. - `data` (object) detail
  393. - `id` (string) Unique ID of workflow execution
  394. - `node_id` (string) ID of node
  395. - `node_type` (string) type of node
  396. - `title` (string) name of node
  397. - `index` (int) Execution sequence number, used to display Tracing Node sequence
  398. - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path
  399. - `inputs` (object) Contents of all preceding node variables used in the node
  400. - `created_at` (timestamp) timestamp of start, e.g., 1705395332
  401. - `event: text_chunk` Text fragment
  402. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  403. - `workflow_run_id` (string) Unique ID of workflow execution
  404. - `event` (string) fixed to `text_chunk`
  405. - `data` (object) detail
  406. - `text` (string) Text content
  407. - `from_variable_selector` (array) Text source path, helps developers understand which variable of which node the text is generated from
  408. - `event: node_finished` node execution finished, success and failure are different states in the same event
  409. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  410. - `workflow_run_id` (string) Unique ID of workflow execution
  411. - `event` (string) fixed to `node_finished`
  412. - `data` (object) detail
  413. - `id` (string) Unique ID of node execution
  414. - `node_id` (string) ID of node
  415. - `index` (int) Execution sequence number, used to display Tracing Node sequence
  416. - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path
  417. - `inputs` (object) Contents of all preceding node variables used in the node
  418. - `process_data` (json) Optional Process data of node
  419. - `outputs` (json) Optional content of output
  420. - `status` (string) status of execution `running` / `succeeded` / `failed` / `stopped`
  421. - `error` (string) Optional reason of error
  422. - `elapsed_time` (float) Optional total seconds to be used
  423. - `execution_metadata` (json) metadata
  424. - `total_tokens` (int) optional tokens to be used
  425. - `total_price` (decimal) optional total cost
  426. - `currency` (string) optional currency, such as `USD` / `RMB`
  427. - `created_at` (timestamp) timestamp of start, e.g., 1705395332
  428. - `event: workflow_finished` workflow execution finished, success and failure are different states in the same event
  429. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  430. - `workflow_run_id` (string) Unique ID of workflow execution
  431. - `event` (string) fixed to `workflow_finished`
  432. - `data` (object) detail
  433. - `id` (string) Unique ID of workflow execution
  434. - `workflow_id` (string) ID of related workflow
  435. - `status` (string) status of execution `running` / `succeeded` / `failed` / `stopped`
  436. - `outputs` (json) Optional content of output
  437. - `error` (string) Optional reason of error
  438. - `elapsed_time` (float) Optional total seconds to be used
  439. - `total_tokens` (int) Optional tokens to be used
  440. - `total_steps` (int) default 0
  441. - `created_at` (timestamp) start time
  442. - `finished_at` (timestamp) end time
  443. - `event: tts_message` TTS audio stream event, i.e., speech synthesis output. The content is an audio block in Mp3 format, encoded as a base64 string, which can be decoded directly when playing. (Only available when auto-play is enabled)
  444. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  445. - `message_id` (string) Unique message ID
  446. - `audio` (string) The audio block after speech synthesis is encoded as base64 text content, which can be directly base64 decoded and sent to the player when playing
  447. - `created_at` (int) Creation timestamp, e.g., 1705395332
  448. - `event: tts_message_end` TTS audio stream end event, receiving this event indicates the end of audio stream return.
  449. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  450. - `message_id` (string) Unique message ID
  451. - `audio` (string) The end event has no audio, so this is an empty string
  452. - `created_at` (int) Creation timestamp, e.g., 1705395332
  453. - `event: ping` Ping event every 10s to keep the connection alive.
  454. ### Errors
  455. - 400, `invalid_param`, Invalid input parameters
  456. - 400, `app_unavailable`, App configuration unavailable
  457. - 400, `provider_not_initialize`, No available model credentials configured
  458. - 400, `provider_quota_exceeded`, Insufficient model call quota
  459. - 400, `model_currently_not_support`, Current model unavailable
  460. - 400, `workflow_not_found`, Specified workflow version not found
  461. - 400, `draft_workflow_error`, Cannot use draft workflow version
  462. - 400, `workflow_id_format_error`, Workflow ID format error, UUID format required
  463. - 400, `workflow_request_error`, Workflow execution failed
  464. - 500, Internal service error
  465. </Col>
  466. <Col sticky>
  467. <CodeGroup
  468. title="Request"
  469. tag="POST"
  470. label="/workflows/:workflow_id/run"
  471. targetCode={`curl -X POST '${props.appDetail.api_base_url}/workflows/{workflow_id}/run' \\
  472. --header 'Authorization: Bearer {api_key}' \\
  473. --header 'Content-Type: application/json' \\
  474. --data-raw '{
  475. "inputs": ${JSON.stringify(props.inputs)},
  476. "response_mode": "streaming",
  477. "user": "abc-123"
  478. }'`}
  479. />
  480. <CodeGroup title="Example: file array as an input variable">
  481. ```json {{ title: 'File variable example' }}
  482. {
  483. "inputs": {
  484. "{variable_name}":
  485. [
  486. {
  487. "transfer_method": "local_file",
  488. "upload_file_id": "{upload_file_id}",
  489. "type": "{document_type}"
  490. }
  491. ]
  492. }
  493. }
  494. ```
  495. </CodeGroup>
  496. ### Blocking Mode
  497. <CodeGroup title="Response">
  498. ```json {{ title: 'Response' }}
  499. {
  500. "workflow_run_id": "djflajgkldjgd",
  501. "task_id": "9da23599-e713-473b-982c-4328d4f5c78a",
  502. "data": {
  503. "id": "fdlsjfjejkghjda",
  504. "workflow_id": "fldjaslkfjlsda",
  505. "status": "succeeded",
  506. "outputs": {
  507. "text": "Nice to meet you."
  508. },
  509. "error": null,
  510. "elapsed_time": 0.875,
  511. "total_tokens": 3562,
  512. "total_steps": 8,
  513. "created_at": 1705407629,
  514. "finished_at": 1727807631
  515. }
  516. }
  517. ```
  518. </CodeGroup>
  519. ### Streaming Mode
  520. <CodeGroup title="Response">
  521. ```streaming {{ title: 'Response' }}
  522. data: {"event": "workflow_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "created_at": 1679586595}}
  523. data: {"event": "node_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "created_at": 1679586595}}
  524. data: {"event": "node_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "execution_metadata": {"total_tokens": 63127864, "total_price": 2.378, "currency": "USD"}, "created_at": 1679586595}}
  525. data: {"event": "workflow_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "total_tokens": 63127864, "total_steps": "1", "created_at": 1679586595, "finished_at": 1679976595}}
  526. data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}
  527. data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}
  528. ```
  529. </CodeGroup>
  530. </Col>
  531. </Row>
  532. ---
  533. <Heading
  534. url='/workflows/run/:workflow_run_id'
  535. method='GET'
  536. title='Get Workflow Run Detail'
  537. name='#get-workflow-run-detail'
  538. />
  539. <Row>
  540. <Col>
  541. Retrieve the current execution results of a workflow task based on the workflow execution ID.
  542. ### Path
  543. - `workflow_run_id` (string) Workflow run ID, can be obtained from the streaming chunk return
  544. ### Response
  545. - `id` (string) ID of workflow execution
  546. - `workflow_id` (string) ID of related workflow
  547. - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
  548. - `inputs` (json) content of input
  549. - `outputs` (json) content of output
  550. - `error` (string) reason of error
  551. - `total_steps` (int) total steps of task
  552. - `total_tokens` (int) total tokens to be used
  553. - `created_at` (timestamp) start time
  554. - `finished_at` (timestamp) end time
  555. - `elapsed_time` (float) total seconds to be used
  556. </Col>
  557. <Col sticky>
  558. ### Request Example
  559. <CodeGroup
  560. title="Request"
  561. tag="GET"
  562. label="/workflows/run/:workflow_run_id"
  563. targetCode={`curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_run_id' \\
  564. -H 'Authorization: Bearer {api_key}' \\
  565. -H 'Content-Type: application/json'`}
  566. />
  567. ### Response Example
  568. <CodeGroup title="Response">
  569. ```json {{ title: 'Response' }}
  570. {
  571. "id": "b1ad3277-089e-42c6-9dff-6820d94fbc76",
  572. "workflow_id": "19eff89f-ec03-4f75-b0fc-897e7effea02",
  573. "status": "succeeded",
  574. "inputs": "{\"sys.files\": [], \"sys.user_id\": \"abc-123\"}",
  575. "outputs": null,
  576. "error": null,
  577. "total_steps": 3,
  578. "total_tokens": 0,
  579. "created_at": 1705407629,
  580. "finished_at": 1727807631,
  581. "elapsed_time": 30.098514399956912
  582. }
  583. ```
  584. </CodeGroup>
  585. </Col>
  586. </Row>
  587. ---
  588. <Heading
  589. url='/workflows/tasks/:task_id/stop'
  590. method='POST'
  591. title='Stop Generate'
  592. name='#stop-generatebacks'
  593. />
  594. <Row>
  595. <Col>
  596. Only supported in streaming mode.
  597. ### Path
  598. - `task_id` (string) Task ID, can be obtained from the streaming chunk return
  599. ### Request Body
  600. - `user` (string) Required
  601. User identifier, used to define the identity of the end-user, must be consistent with the user passed in the message sending interface. The Service API does not share conversations created by the WebApp.
  602. ### Response
  603. - `result` (string) Always returns "success"
  604. </Col>
  605. <Col sticky>
  606. ### Request Example
  607. <CodeGroup
  608. title="Request"
  609. tag="POST"
  610. label="/workflows/tasks/:task_id/stop"
  611. targetCode={`curl -X POST '${props.appDetail.api_base_url}/workflows/tasks/:task_id/stop' \\
  612. -H 'Authorization: Bearer {api_key}' \\
  613. -H 'Content-Type: application/json' \\
  614. --data-raw '{"user": "abc-123"}'`}
  615. />
  616. ### Response Example
  617. <CodeGroup title="Response">
  618. ```json {{ title: 'Response' }}
  619. {
  620. "result": "success"
  621. }
  622. ```
  623. </CodeGroup>
  624. </Col>
  625. </Row>
  626. ---
  627. <Heading
  628. url='/files/upload'
  629. method='POST'
  630. title='File Upload'
  631. name='#file-upload'
  632. />
  633. <Row>
  634. <Col>
  635. Upload a file for use when sending messages, enabling multimodal understanding of images and text.
  636. Supports any formats that are supported by your workflow.
  637. Uploaded files are for use by the current end-user only.
  638. ### Request Body
  639. This interface requires a `multipart/form-data` request.
  640. - `file` (File) Required
  641. The file to be uploaded.
  642. - `user` (string) Required
  643. User identifier, defined by the developer's rules, must be unique within the application. The Service API does not share conversations created by the WebApp.
  644. ### Response
  645. After a successful upload, the server will return the file's ID and related information.
  646. - `id` (uuid) ID
  647. - `name` (string) File name
  648. - `size` (int) File size (bytes)
  649. - `extension` (string) File extension
  650. - `mime_type` (string) File mime-type
  651. - `created_by` (uuid) End-user ID
  652. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  653. ### Errors
  654. - 400, `no_file_uploaded`, a file must be provided
  655. - 400, `too_many_files`, currently only one file is accepted
  656. - 400, `unsupported_preview`, the file does not support preview
  657. - 400, `unsupported_estimate`, the file does not support estimation
  658. - 413, `file_too_large`, the file is too large
  659. - 415, `unsupported_file_type`, unsupported extension, currently only document files are accepted
  660. - 503, `s3_connection_failed`, unable to connect to S3 service
  661. - 503, `s3_permission_denied`, no permission to upload files to S3
  662. - 503, `s3_file_too_large`, file exceeds S3 size limit
  663. - 500, internal server error
  664. </Col>
  665. <Col sticky>
  666. ### Request Example
  667. <CodeGroup
  668. title="Request"
  669. tag="POST"
  670. label="/files/upload"
  671. targetCode={`curl -X POST '${props.appDetail.api_base_url}/files/upload' \\
  672. --header 'Authorization: Bearer {api_key}' \\
  673. --form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif]' \\
  674. --form 'user=abc-123'`}
  675. />
  676. ### Response Example
  677. <CodeGroup title="Response">
  678. ```json {{ title: 'Response' }}
  679. {
  680. "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",
  681. "name": "example.png",
  682. "size": 1024,
  683. "extension": "png",
  684. "mime_type": "image/png",
  685. "created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",
  686. "created_at": 1577836800,
  687. }
  688. ```
  689. </CodeGroup>
  690. </Col>
  691. </Row>
  692. ---
  693. <Heading
  694. url='/files/:file_id/preview'
  695. method='GET'
  696. title='File Preview'
  697. name='#file-preview'
  698. />
  699. <Row>
  700. <Col>
  701. Preview or download uploaded files. This endpoint allows you to access files that have been previously uploaded via the File Upload API.
  702. <i>Files can only be accessed if they belong to messages within the requesting application.</i>
  703. ### Path Parameters
  704. - `file_id` (string) Required
  705. The unique identifier of the file to preview, obtained from the File Upload API response.
  706. ### Query Parameters
  707. - `as_attachment` (boolean) Optional
  708. Whether to force download the file as an attachment. Default is `false` (preview in browser).
  709. ### Response
  710. Returns the file content with appropriate headers for browser display or download.
  711. - `Content-Type` Set based on file mime type
  712. - `Content-Length` File size in bytes (if available)
  713. - `Content-Disposition` Set to "attachment" if `as_attachment=true`
  714. - `Cache-Control` Caching headers for performance
  715. - `Accept-Ranges` Set to "bytes" for audio/video files
  716. ### Errors
  717. - 400, `invalid_param`, abnormal parameter input
  718. - 403, `file_access_denied`, file access denied or file does not belong to current application
  719. - 404, `file_not_found`, file not found or has been deleted
  720. - 500, internal server error
  721. </Col>
  722. <Col sticky>
  723. ### Request Example
  724. <CodeGroup
  725. title="Request"
  726. tag="GET"
  727. label="/files/:file_id/preview"
  728. targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \\
  729. --header 'Authorization: Bearer {api_key}'`}
  730. />
  731. ### Download as Attachment
  732. <CodeGroup
  733. title="Download Request"
  734. tag="GET"
  735. label="/files/:file_id/preview?as_attachment=true"
  736. targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview?as_attachment=true' \\
  737. --header 'Authorization: Bearer {api_key}' \\
  738. --output downloaded_file.png`}
  739. />
  740. ### Response Headers Example
  741. <CodeGroup title="Response Headers">
  742. ```http {{ title: 'Headers - Image Preview' }}
  743. Content-Type: image/png
  744. Content-Length: 1024
  745. Cache-Control: public, max-age=3600
  746. ```
  747. </CodeGroup>
  748. ### Download Response Headers
  749. <CodeGroup title="Download Response Headers">
  750. ```http {{ title: 'Headers - File Download' }}
  751. Content-Type: image/png
  752. Content-Length: 1024
  753. Content-Disposition: attachment; filename*=UTF-8''example.png
  754. Cache-Control: public, max-age=3600
  755. ```
  756. </CodeGroup>
  757. </Col>
  758. </Row>
  759. ---
  760. <Heading
  761. url='/workflows/logs'
  762. method='GET'
  763. title='Get Workflow Logs'
  764. name='#Get-Workflow-Logs'
  765. />
  766. <Row>
  767. <Col>
  768. Returns workflow logs, with the first page returning the latest `{limit}` messages, i.e., in reverse order.
  769. ### Query
  770. <Properties>
  771. <Property name='keyword' type='string' key='keyword'>
  772. Keyword to search
  773. </Property>
  774. <Property name='status' type='string' key='status'>
  775. succeeded/failed/stopped
  776. </Property>
  777. <Property name='page' type='int' key='page'>
  778. current page, default is 1.
  779. </Property>
  780. <Property name='limit' type='int' key='limit'>
  781. How many chat history messages to return in one request, default is 20.
  782. </Property>
  783. <Property name='created_by_end_user_session_id' type='str' key='created_by_end_user_session_id'>
  784. Created by which endUser, for example, `abc-123`.
  785. </Property>
  786. <Property name='created_by_account' type='str' key='created_by_account'>
  787. Created by which email account, for example, lizb@test.com.
  788. </Property>
  789. </Properties>
  790. ### Response
  791. - `page` (int) Current page
  792. - `limit` (int) Number of returned items, if input exceeds system limit, returns system limit amount
  793. - `total` (int) Number of total items
  794. - `has_more` (bool) Whether there is a next page
  795. - `data` (array[object]) Log list
  796. - `id` (string) ID
  797. - `workflow_run` (object) Workflow run
  798. - `id` (string) ID
  799. - `version` (string) Version
  800. - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
  801. - `error` (string) Optional reason of error
  802. - `elapsed_time` (float) total seconds to be used
  803. - `total_tokens` (int) tokens to be used
  804. - `total_steps` (int) default 0
  805. - `created_at` (timestamp) start time
  806. - `finished_at` (timestamp) end time
  807. - `created_from` (string) Created from
  808. - `created_by_role` (string) Created by role
  809. - `created_by_account` (string) Optional Created by account
  810. - `created_by_end_user` (object) Created by end user
  811. - `id` (string) ID
  812. - `type` (string) Type
  813. - `is_anonymous` (bool) Is anonymous
  814. - `session_id` (string) Session ID
  815. - `created_at` (timestamp) create time
  816. </Col>
  817. <Col sticky>
  818. <CodeGroup
  819. title="Request"
  820. tag="GET"
  821. label="/workflows/logs"
  822. targetCode={`curl -X GET '${props.appDetail.api_base_url}/workflows/logs'\\
  823. --header 'Authorization: Bearer {api_key}'`}
  824. />
  825. ### Response Example
  826. <CodeGroup title="Response">
  827. ```json {{ title: 'Response' }}
  828. {
  829. "page": 1,
  830. "limit": 1,
  831. "total": 7,
  832. "has_more": true,
  833. "data": [
  834. {
  835. "id": "e41b93f1-7ca2-40fd-b3a8-999aeb499cc0",
  836. "workflow_run": {
  837. "id": "c0640fc8-03ef-4481-a96c-8a13b732a36e",
  838. "version": "2024-08-01 12:17:09.771832",
  839. "status": "succeeded",
  840. "error": null,
  841. "elapsed_time": 1.3588523610014818,
  842. "total_tokens": 0,
  843. "total_steps": 3,
  844. "created_at": 1726139643,
  845. "finished_at": 1726139644
  846. },
  847. "created_from": "service-api",
  848. "created_by_role": "end_user",
  849. "created_by_account": null,
  850. "created_by_end_user": {
  851. "id": "7f7d9117-dd9d-441d-8970-87e5e7e687a3",
  852. "type": "service_api",
  853. "is_anonymous": false,
  854. "session_id": "abc-123"
  855. },
  856. "created_at": 1726139644
  857. }
  858. ]
  859. }
  860. ```
  861. </CodeGroup>
  862. </Col>
  863. </Row>
  864. ---
  865. <Heading
  866. url='/info'
  867. method='GET'
  868. title='Get Application Basic Information'
  869. name='#info'
  870. />
  871. <Row>
  872. <Col>
  873. Used to get basic information about this application
  874. ### Response
  875. - `name` (string) application name
  876. - `description` (string) application description
  877. - `tags` (array[string]) application tags
  878. - `mode` (string) application mode
  879. - `author_name` (string) application author name
  880. </Col>
  881. <Col>
  882. <CodeGroup
  883. title="Request"
  884. tag="GET"
  885. label="/info"
  886. targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\
  887. -H 'Authorization: Bearer {api_key}'`}
  888. />
  889. <CodeGroup title="Response">
  890. ```json {{ title: 'Response' }}
  891. {
  892. "name": "My App",
  893. "description": "This is my app.",
  894. "tags": [
  895. "tag1",
  896. "tag2"
  897. ],
  898. "mode": "workflow",
  899. "author_name": "Dify"
  900. }
  901. ```
  902. </CodeGroup>
  903. </Col>
  904. </Row>
  905. ---
  906. <Heading
  907. url='/parameters'
  908. method='GET'
  909. title='Get Application Parameters Information'
  910. name='#parameters'
  911. />
  912. <Row>
  913. <Col>
  914. Used at the start of entering the page to obtain information such as features, input parameter names, types, and default values.
  915. ### Response
  916. - `user_input_form` (array[object]) User input form configuration
  917. - `text-input` (object) Text input control
  918. - `label` (string) Variable display label name
  919. - `variable` (string) Variable ID
  920. - `required` (bool) Whether it is required
  921. - `default` (string) Default value
  922. - `paragraph` (object) Paragraph text input control
  923. - `label` (string) Variable display label name
  924. - `variable` (string) Variable ID
  925. - `required` (bool) Whether it is required
  926. - `default` (string) Default value
  927. - `select` (object) Dropdown control
  928. - `label` (string) Variable display label name
  929. - `variable` (string) Variable ID
  930. - `required` (bool) Whether it is required
  931. - `default` (string) Default value
  932. - `options` (array[string]) Option values
  933. - `file_upload` (object) File upload configuration
  934. - `document` (object) Document settings
  935. Currently only supports document types: `txt`, `md`, `markdown`, `pdf`, `html`, `xlsx`, `xls`, `docx`, `csv`, `eml`, `msg`, `pptx`, `ppt`, `xml`, `epub`.
  936. - `enabled` (bool) Whether it is enabled
  937. - `number_limits` (int) Document number limit, default is 3
  938. - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
  939. - `image` (object) Image settings
  940. Currently only supports image types: `png`, `jpg`, `jpeg`, `webp`, `gif`.
  941. - `enabled` (bool) Whether it is enabled
  942. - `number_limits` (int) Image number limit, default is 3
  943. - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
  944. - `audio` (object) Audio settings
  945. Currently only supports audio types: `mp3`, `m4a`, `wav`, `webm`, `amr`.
  946. - `enabled` (bool) Whether it is enabled
  947. - `number_limits` (int) Audio number limit, default is 3
  948. - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
  949. - `video` (object) Video settings
  950. Currently only supports video types: `mp4`, `mov`, `mpeg`, `mpga`.
  951. - `enabled` (bool) Whether it is enabled
  952. - `number_limits` (int) Video number limit, default is 3
  953. - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
  954. - `custom` (object) Custom settings
  955. - `enabled` (bool) Whether it is enabled
  956. - `number_limits` (int) Custom number limit, default is 3
  957. - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
  958. - `system_parameters` (object) System parameters
  959. - `file_size_limit` (int) Document upload size limit (MB)
  960. - `image_file_size_limit` (int) Image file upload size limit (MB)
  961. - `audio_file_size_limit` (int) Audio file upload size limit (MB)
  962. - `video_file_size_limit` (int) Video file upload size limit (MB)
  963. </Col>
  964. <Col sticky>
  965. <CodeGroup
  966. title="Request"
  967. tag="GET"
  968. label="/parameters"
  969. targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters'`}
  970. />
  971. <CodeGroup title="Response">
  972. ```json {{ title: 'Response' }}
  973. {
  974. "user_input_form": [
  975. {
  976. "paragraph": {
  977. "label": "Query",
  978. "variable": "query",
  979. "required": true,
  980. "default": ""
  981. }
  982. }
  983. ],
  984. "file_upload": {
  985. "image": {
  986. "enabled": false,
  987. "number_limits": 3,
  988. "detail": "high",
  989. "transfer_methods": [
  990. "remote_url",
  991. "local_file"
  992. ]
  993. }
  994. },
  995. "system_parameters": {
  996. "file_size_limit": 15,
  997. "image_file_size_limit": 10,
  998. "audio_file_size_limit": 50,
  999. "video_file_size_limit": 100
  1000. }
  1001. }
  1002. ```
  1003. </CodeGroup>
  1004. </Col>
  1005. </Row>
  1006. ---
  1007. <Heading
  1008. url='/site'
  1009. method='GET'
  1010. title='Get Application WebApp Settings'
  1011. name='#site'
  1012. />
  1013. <Row>
  1014. <Col>
  1015. Used to get the WebApp settings of the application.
  1016. ### Response
  1017. - `title` (string) WebApp name
  1018. - `icon_type` (string) Icon type, `emoji` - emoji, `image` - picture
  1019. - `icon` (string) Icon. If it's `emoji` type, it's an emoji symbol; if it's `image` type, it's an image URL.
  1020. - `icon_background` (string) Background color in hex format
  1021. - `icon_url` (string) Icon URL
  1022. - `description` (string) Description
  1023. - `copyright` (string) Copyright information
  1024. - `privacy_policy` (string) Privacy policy link
  1025. - `custom_disclaimer` (string) Custom disclaimer
  1026. - `default_language` (string) Default language
  1027. - `show_workflow_steps` (bool) Whether to show workflow details
  1028. </Col>
  1029. <Col>
  1030. <CodeGroup
  1031. title="Request"
  1032. tag="POST"
  1033. label="/meta"
  1034. targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\
  1035. -H 'Authorization: Bearer {api_key}'`}
  1036. />
  1037. <CodeGroup title="Response">
  1038. ```json {{ title: 'Response' }}
  1039. {
  1040. "title": "My App",
  1041. "icon_type": "emoji",
  1042. "icon": "😄",
  1043. "icon_background": "#FFEAD5",
  1044. "icon_url": null,
  1045. "description": "This is my app.",
  1046. "copyright": "all rights reserved",
  1047. "privacy_policy": "",
  1048. "custom_disclaimer": "All generated by AI",
  1049. "default_language": "en-US",
  1050. "show_workflow_steps": false,
  1051. }
  1052. ```
  1053. </CodeGroup>
  1054. </Col>
  1055. </Row>
  1056. ___