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 48KB

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