Skip to main content
POST
https://api.usedari.com
/
public
/
single-actions
/
run-action
from dari import Dari

client = Dari(api_key="YOUR_API_KEY")

# Create a managed session first
session = client.create_session(
    screen_config={"width": 1440, "height": 900},
    ttl=3600  # 1 hour
)

# Use the session for multiple actions
result1 = client.run_single_action(
    action="Navigate to Google Calendar",
    session_id=session["session_id"],
    id="nav-to-calendar"
)

result2 = client.run_single_action(
    action="Create a meeting called {{meeting_title}} for tomorrow at 3pm",
    session_id=session["session_id"],
    id="calendar-meeting-step",
    variables={"meeting_title": "Internal sync"}
)

# With custom user agent
result3 = client.run_single_action(
    action="Navigate to the mobile version of the site",
    session_id=session["session_id"],
    id="mobile-nav-step",
    user_agent="Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15"
)

# Clean up when done
client.terminate_session(session["session_id"])
{
  "success": true,
  "result": "Meeting scheduled for tomorrow at 3:00 PM",
  "credits": 4,
  "used_cache": false,
  "set_cache": true,
  "cache_failed": false
}
This endpoint lets you trigger a single computer-use browser action. You must provide a session_id from a previously created session. The endpoint optionally reuses cached state for faster follow-up actions.

Headers

X-API-Key
string
required
Your API key for authentication
Content-Type
string
required
Must be application/json

Request Body

action
string
required
Natural language instruction describing the action to perform
session_id
string
required
Session ID to use for this browser action. Create a session first using the Sessions API.
id
string
Optional stable identifier that lets you reuse cached step instances across runs
variables
object
Optional mapping of variable names to values that can be referenced inside the action prompt using {{variable_name}} syntax
set_cache
boolean
Whether to refresh the cached step instance for this action; defaults to true
user_agent
string
Custom user agent string for the browser session. If not specified, the default browser user agent will be used.

Response Fields

success
boolean
Indicates whether the action completed without errors
result
string
Textual outcome returned by the computer-use agent, if available
credits
integer
Number of credits consumed by this execution, when applicable
error
string
Error message when the action fails
used_cache
boolean
true when a previously cached step instance was reused
set_cache
boolean
true when the cache was stored or updated during this run
cache_failed
boolean
true if cached data existed but could not be applied, forcing a fresh run
from dari import Dari

client = Dari(api_key="YOUR_API_KEY")

# Create a managed session first
session = client.create_session(
    screen_config={"width": 1440, "height": 900},
    ttl=3600  # 1 hour
)

# Use the session for multiple actions
result1 = client.run_single_action(
    action="Navigate to Google Calendar",
    session_id=session["session_id"],
    id="nav-to-calendar"
)

result2 = client.run_single_action(
    action="Create a meeting called {{meeting_title}} for tomorrow at 3pm",
    session_id=session["session_id"],
    id="calendar-meeting-step",
    variables={"meeting_title": "Internal sync"}
)

# With custom user agent
result3 = client.run_single_action(
    action="Navigate to the mobile version of the site",
    session_id=session["session_id"],
    id="mobile-nav-step",
    user_agent="Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15"
)

# Clean up when done
client.terminate_session(session["session_id"])
{
  "success": true,
  "result": "Meeting scheduled for tomorrow at 3:00 PM",
  "credits": 4,
  "used_cache": false,
  "set_cache": true,
  "cache_failed": false
}

Usage Notes

Session Management

  • You must create a session first using the Create Session endpoint before running actions.
  • Pass the session_id to reuse the same browser context across multiple actions.
  • Remember to clean up sessions with the Terminate Session endpoint when done.

Caching

  • Reuse the same id parameter to cache step instances and speed up future runs; the used_cache response field shows when cached data was applied.
  • Set set_cache to false to bypass cache updates when testing or replaying an action.

Variables

  • Use {{variable_name}} syntax in your action prompt to reference values from the variables object.
  • Variables are interpolated before the action is executed.

User Agent

  • Set a custom user_agent string to control the browser’s user agent for this action.
  • Useful for testing mobile-specific layouts, bypassing user agent restrictions, or simulating different browsers.
  • If not specified, the default browser user agent is used.

Error Responses

{
  "detail": "Invalid API key"
}
{
  "detail": "Failed to run single action: internal error"
}