Skip to main content
To hand the work over to your coding agent, set it up with the difyctl skill and point it to this page.
External SSO users are people who open Dify web apps through single sign-on (SSO) and have no Dify account. If you have a Dify account, follow Get Started instead.

Sign In

  1. Install difyctl.
  2. Sign in with the address of the Dify console. A web app’s address won’t work.
    If no browser opens, for example over SSH, open the URL difyctl prints on any device.
  3. On the Authorize difyctl page, enter the code difyctl printed and click Continue.
  4. Choose Sign in with SSO, and sign in the same way you do for your web apps.
  5. When the page shows your email, click Authorize.
Your sign-in lasts 14 days. After that, every command fails with auth_expired until you sign in again. When you’re done with a machine, run difyctl logout to delete your sign-in from it.
When you sign out or sign in again, difyctl reports server revoke failed: …. That’s expected for an SSO sign-in, and the command still works.

Find the Apps You Can Run

Run difyctl get console_app external to list the apps you can run. Only web apps with Service API access turned on are listed.
Use an app’s id as --app-id in other commands. Its mode is the app’s type, which decides the command that runs it:

Check an App’s Inputs

Run difyctl describe console_app external to show an app’s variables: their names, their types, and which are required.

Run a Workflow

Pass the app’s variables to difyctl run console_app workflow in --inputs, as JSON keyed by name. The answer is the result’s outputs.
A misspelled required variable fails the run with an error such as topic is required in input form. A misspelled optional one is silently left out. Check the variable names with describe console_app external.

Send a Message or Generate Text

Use the run console_app command that matches the app’s type in Find the Apps You Can Run. Put the message in --query and any variables in --inputs. A Text Generator app usually takes only --inputs. The response is the result’s text.answer.
With an SSO sign-in, every message starts a new conversation, so put everything the app needs into each message. A run with --conversation-id fails, even when it follows a result’s hint to reply in the same conversation.

Send Files

With any run command, map each file variable to a local path in --files. A file-list variable takes a list of paths. A file on the web goes in --inputs instead. Pass each file variable in either --files or --inputs, not both.

Follow a Long Run

To watch a run as it goes, add --stream. It prints each event as it happens, one JSON object per line. In a Workflow run, the last event, workflow_finished, carries the result in data.outputs. To print only the events you want, name each one with --only.

Stop a Run

To stop a Workflow or Chatflow run that’s still going or paused at a Human Input form, pass its run ID to difyctl stop run. Pressing Ctrl+C stops only difyctl, not the run on the server. The run ID is the run_id in a suspended or incomplete result, such as the one you get after Ctrl+C. With --stream, take workflow_run_id from the workflow_started event. For a Chatbot, legacy Agent, or Text Generator reply, use stop task instead.
To see how a run ends instead of stopping it, pass its run ID to difyctl get run event with --include-state-snapshot. The command follows the run until it ends or pauses at a form, then prints its result. For a Chatflow, the reply is in outputs.answer, not text.answer.
Keep the run ID. Without it you can’t find the run again, because listing runs needs a Dify account.

Stop a Chatbot, Legacy Agent, or Text Generator Reply

To be able to stop a reply, start it with --stream. Then pass the task_id from its first event to difyctl stop task.
A stopped reply looks finished: its stream ends with message_end, and the command that started it exits with code 0. The answer holds only what arrived before the stop. If your script uses the answer, have it record that it called stop task.

Answer a Human Input Form

A run that pauses at a form returns a result whose status is suspended. When you can answer the form, the result has one hint per action button, each a submit run form command with the form token filled in. When the form went only to other recipients, hints is [], and the run resumes once one of them answers. To answer, run the hint for your action, replacing each null in its inputs with your answer. To see the form’s fields first, take form_token from any hint and run difyctl describe run form. Whoever answers, follow the resumed run with get run event, passing the paused result’s run_id as --run-id. Keep --include-state-snapshot, or the command can sit silent for up to 5 minutes.

Find Why a Run Failed

A failed run’s result has status: failed, and its error.message says why. difyctl exits with code 1. A Workflow or Chatflow run that was stopped shows as failed too. To see which node of a Workflow or Chatflow run failed, run the app again with --stream. Each node_finished event carries that node’s status and error. A run’s nodes can’t be inspected after it ends, because run history needs a Dify account.

Troubleshooting

For other sign-in errors, see Troubleshooting on Get Started. For errors any command can raise, see Troubleshooting on Results, Errors, and Exit Codes.