Skip to main content
Build your own credential collection UI instead of using the hosted page. Poll for login fields, then submit credentials via the API. Use the Programmatic flow when:
  • You need a custom credential collection UI that matches your app’s design
  • You’re building headless/automated authentication
  • You have credentials stored and want to authenticate without user interaction

How It Works

1

Create Auth Agent and Start Authentication

Same as Hosted UI
2

Poll and Submit

Poll until step becomes awaiting_input, then submit credentials
3

Handle 2FA

If more fields appear (2FA code), submit again—same loop handles it

Getting started

1. Create an Auth Agent

2. Start Authentication

To save credentials for automatic re-authentication:

3. Poll and Submit Credentials

A single loop handles everything—initial login, 2FA, and completion:
The pending_fields array tells you what the login form needs:

Complete Example

Handling Different Input Types

The basic polling loop handles pending_fields, but login pages can require other input types too.

SSO Buttons

When the login page has “Sign in with Google/GitHub/Microsoft” buttons, they appear in pending_sso_buttons:
Remember to set allowed_domains on the agent to include the OAuth provider’s domain (e.g., accounts.google.com).

MFA Selection

When the site offers multiple MFA methods, they appear in mfa_options:
After selecting an MFA method, the flow continues—poll for pending_fields to submit the code, or handle external actions for push/security key.

External Actions (Push, Security Key)

When the site requires an action outside the browser (push notification, security key tap), the step becomes awaiting_external_action:

Step Reference

The step field indicates what the flow is waiting for:

Status Reference

The status field indicates the overall invocation state: