Prerequisites
- A Deck account (console.deck.co)
- A Deck API key
- Base URL:
https://api.deck.co/v2
Authorization header:
Set up your agent and tasks
Create an agent
Create an agent in the Dashboard or through the API. Scope it to a single use case, like hotel reservations.
Create a task
Tasks define what the agent does, what task input it needs, and what output it returns. Tasks can be created in the Dashboard with prompting or from a template. They can also be created through the API.Tasks start in
learning status. You can run tasks in any status, but success rates improve as the task progresses to testing and then live. See Tasks for details on task statuses.Open a connection
A connection authenticates one user to one source. Connections time out after a period of inactivity.| Method | Description |
|---|---|
username_password | Username and password |
google_sso | Google single sign-on |
none | No credentials needed |
connecting status.
Wait for the connection
Connection authentication is asynchronous. After creating a connection, Deck works through the login flow and the status transitions automatically:connecting → connected (or interaction_required if the source needs verification, or invalid if the credentials were rejected)
You have two options to track the transition:
- Events (recommended). Listen for
connection.connectedorconnection.interaction_requiredevents on your event destination. This is the most reliable approach. - Polling. Call
GET /v2/connections/{connection_id}untilstatuschanges fromconnecting.
connected.
Handle MFA
If the source requires additional verification during login, the connection status becomesinteraction_required instead of connected.
Your app receives the event
Deck sends an
interaction_required event to your webhook. The payload includes the prompt type, message, and fields to collect.Run a task
Once the connection status isconnected, you can run tasks against it. The input must match the task’s input schema.
Run the task
Send a task run request with a
connection_id and input. Deck returns a task run object and begins execution. If the source requires interaction during execution, the task run pauses with interaction_required status. Handle it the same way as connection interactions.Receive results
When the task completes, Deck sends a If a task run fails,
task_run.completed or task_run.failed event to your event destination. You can also poll GET /v2/task-runs/{task_run_id} until status changes from running. The output contains structured data matching the task’s output schema.status is failed and the errors array contains details.