> ## Documentation Index
> Fetch the complete documentation index at: https://docs.smooth.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# API Overview

> Complete guide to the Smooth REST API

> [!WARNING]
>
> **We recommend using one of our SDKs instead of calling the API directly.** The SDKs handle authentication, polling, and error handling automatically, making integration much simpler.
>
> If we don't support your language yet, reach out at **[support@circlemind.co](mailto:support@circlemind.co)** and we'll be happy to support your implementation.

The Smooth API enables programmatic browser automation through REST endpoints. You can run AI-powered tasks, create interactive browser sessions, and extend agent capabilities with custom tools.

## Quick Start

Get your API key and start running tasks in minutes.

> [card] [Get your free API key](https://app.smooth.sh)
>
> Unlock your free welcome credits. No credit card required.

## Authentication

All API endpoints require authentication via the `apikey` header:

```bash theme={null}
curl -X POST "https://api.smooth.sh/api/v1/task" \
     -H "apikey: YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{"task": "Go to hacker news and get the top story"}'
```

## Two Ways to Use the API

### 1. Simple Tasks

Run one-shot tasks that execute and return results:

```bash theme={null}
# Submit a task
curl -X POST "https://api.smooth.sh/api/v1/task" \
     -H "apikey: YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{"task": "Go to hacker news and get the top 5 stories"}'

# Response: {"r": {"id": "task_abc123", "status": "running", ...}}

# Poll for results
curl -X GET "https://api.smooth.sh/api/v1/task/task_abc123" \
     -H "apikey: YOUR_API_KEY"

# Response: {"r": {"id": "task_abc123", "status": "done", "output": "..."}}
```

### 2. Session Workflows

For multi-step workflows, create a session and send actions:

```bash theme={null}
# Create a session (task=null)
curl -X POST "https://api.smooth.sh/api/v1/task" \
     -H "apikey: YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{"task": null, "url": "https://example.com"}'

# Response: {"r": {"id": "task_abc123", "status": "running", "live_url": "..."}}

# Send actions via the Event endpoint
curl -X POST "https://api.smooth.sh/api/v1/task/task_abc123/event" \
     -H "apikey: YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "name": "session_action",
       "payload": {"name": "run_task", "input": {"task": "Click the login button"}},
       "id": "evt_001"
     }'

# Poll for the result
curl -X GET "https://api.smooth.sh/api/v1/task/task_abc123?event_t=0" \
     -H "apikey: YOUR_API_KEY"
```

> [card] [Session Workflow](https://docs.smooth.sh/api-reference/sessions.md)
>
> Learn how to create sessions, send actions, and poll for results

> [card] [Polling Mechanism](https://docs.smooth.sh/api-reference/polling.md)
>
> Understand how to efficiently poll for task results and events

## Core Endpoints

| Endpoint | Method | Description |
| - | - | - |
| `/task` | POST | Submit a task or create a session (`task=null`) |
| `/task` | GET | List all tasks |
| `/task/{id}` | GET | Get task status and results |
| `/task/{id}` | DELETE | Cancel a running task |
| `/task/{id}/event` | POST | Send an event to a running task/session |

## Session Actions

When using sessions, send actions via `POST /task/{id}/event`:

| Action | Event Type | Description |
| - | - | - |
| Navigate | `browser_action` | Go to a URL |
| Extract | `browser_action` | Extract structured data from the page |
| JavaScript | `browser_action` | Execute JavaScript in the browser |
| Run Task | `session_action` | Run an AI-powered task within the session |
| Close | `session_action` | Close the session |

> [card] [Session Actions Reference](https://docs.smooth.sh/api-reference/sessions.md#action-reference)
>
> See complete examples of all session actions

## Custom Tools

Extend agent capabilities by registering custom tools:

```bash theme={null}
curl -X POST "https://api.smooth.sh/api/v1/task" \
     -H "apikey: YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "task": "Look up the weather and send it to Slack",
       "custom_tools": [
         {
           "name": "get_weather",
           "description": "Get weather for a city",
           "inputs": {"type": "object", "properties": {"city": {"type": "string"}}},
           "output": "Weather data"
         },
         {
           "name": "send_slack",
           "description": "Send a Slack message",
           "inputs": {"type": "object", "properties": {"message": {"type": "string"}}},
           "output": "Success boolean"
         }
       ]
     }'
```

When the agent calls a tool, you receive a `tool_call` event. Execute the tool locally and respond via the Event endpoint.

> [card] [Custom Tools Guide](https://docs.smooth.sh/api-reference/custom-tools.md)
>
> Complete guide to implementing custom tools with the API

## Additional Features

### Browser Profiles

Persist cookies and authentication across tasks:

```bash theme={null}
# Create a profile
curl -X POST "https://api.smooth.sh/api/v1/profile" \
     -H "apikey: YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{"id": "my-profile"}'

# Use the profile in a task
curl -X POST "https://api.smooth.sh/api/v1/task" \
     -H "apikey: YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{"task": "Check my account balance", "profile_id": "my-profile"}'
```

### Structured Output

Get structured data matching a JSON schema:

```bash theme={null}
curl -X POST "https://api.smooth.sh/api/v1/task" \
     -H "apikey: YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "task": "Get the top 3 stories from Hacker News",
       "response_model": {
         "type": "array",
         "items": {
           "type": "object",
           "properties": {
             "title": {"type": "string"},
             "url": {"type": "string"},
             "points": {"type": "number"}
           }
         }
       }
     }'
```

### File Uploads

Pass files to tasks:

```bash theme={null}
# Upload a file
curl -X POST "https://api.smooth.sh/api/v1/file" \
     -H "apikey: YOUR_API_KEY" \
     -F "file=@invoice.pdf"

# Response: {"r": {"id": "file_xyz789"}}

# Use in a task
curl -X POST "https://api.smooth.sh/api/v1/task" \
     -H "apikey: YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{"task": "Extract the total from this invoice", "files": ["file_xyz789"]}'
```

## Response Format

All responses are wrapped in an `r` field:

```json theme={null}
{
  "r": {
    "id": "task_abc123",
    "status": "done",
    "output": "...",
    "credits_used": 15
  }
}
```

### Task Status Values

| Status | Description |
| - | - |
| `waiting` | Task is queued |
| `running` | Task is executing |
| `done` | Task completed successfully |
| `failed` | Task failed |
| `cancelled` | Task was cancelled |

## Error Handling

| HTTP Code | Meaning |
| - | - |
| 400 | Invalid request parameters |
| 403 | Premium feature not available on your plan |
| 404 | Resource not found |
| 422 | Validation error |
| 429 | Rate limit exceeded or credits exhausted |

Error responses include a detail message:

```json theme={null}
{
  "detail": "API credits exhausted. Please upgrade your plan."
}
```

## Next Steps

> [card] [Session Workflow](https://docs.smooth.sh/api-reference/sessions.md)
>
> Create interactive sessions for multi-step workflows

> [card] [Custom Tools](https://docs.smooth.sh/api-reference/custom-tools.md)
>
> Extend agent capabilities with your own tools

> [card] [Polling Guide](https://docs.smooth.sh/api-reference/polling.md)
>
> Best practices for polling task results

> [card] [Python SDK](https://docs.smooth.sh/quickstart.md)
>
> Use the SDK for automatic polling and easier integration


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.