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

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