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

# Interact

> Keep working on the screen a scrape or agent task ended on. Send the next instruction in plain words, then read the answer.

Interact continues a task you already ran. A [Scrape](https://docs.lusor.ai/app-data/scrape.md) or [Agent](https://docs.lusor.ai/app-data/agent.md) task ends on a screen of an app. Interact sends the next instruction for that screen in plain words, an AI agent carries it out on the same phone, and you read its answer as text. Send as many turns as you need, then stop.

Use interact when one call gets you to the right place and you want to go one step further: open the most recent order after scraping the order list, or read a field on the screen an agent left open.

Interact needs an earlier task. There is no interact call on an address. To start at a screen, scrape that screen first and continue its task.

> [!NOTE]
>
> Interact methods aren't in the published SDKs yet. The examples here use the REST API.

## Send a turn

Send the next instruction with `POST /v1/interact/{id}`, where `{id}` is the id the scrape or agent task returned:

```bash theme={null}
curl "https://api.lusor.ai/v1/interact/$TASK_ID" \
  -H "X-Api-Key: $LUSOR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "prompt": "Open the most recent order and read its status." }'
```

The request returns `202` at once. The turn continues the task's own session, so the id it answers is the task's id:

```json theme={null}
{
  "id": "8b2d4f71-…"
}
```

Read the turn while its `status` is `processing`. If it reads `awaiting_human`, see [Status](#status) before you read again.

```bash theme={null}
curl "https://api.lusor.ai/v1/interact/$TASK_ID" \
  -H "X-Api-Key: $LUSOR_API_KEY"
```

### Response

```json theme={null}
{
  "success": true,
  "status": "completed",
  "output": "Order #1042 is out for delivery.",
  "recordingUrl": "https://api.lusor.ai/v1/sessions/8b2d4f71-…/recording",
  "error": null,
  "creditsUsed": 8
}
```

| Field | What it is |
| - | - |
| `success` | `false` once the turn failed or was cancelled. |
| `status` | Where the latest turn is. See [Status](#status). |
| `output` | The completed turn's answer as text, or `null` when the turn wrote no answer. A task that ran with a `schema` answers that object as JSON text. |
| `recordingUrl` | The task's recording. Turns themselves aren't recorded yet. |
| `error` | Why the latest turn failed, when it did. |
| `creditsUsed` | Credits the task has been charged so far: the scrape or agent run that started it and every turn. A turn's charge is written when it ends. |

## Status

| Status | Meaning |
| - | - |
| `processing` | The turn is waiting for its phone or working. Keep reading. |
| `awaiting_human` | The agent stopped to ask a question. Answer it with the task id, on a Scrape or an Agent task; see [Answer the agent](https://docs.lusor.ai/agents/answer-the-agent.md). The turn then carries on. |
| `completed` | The turn ended. `output` holds its answer, or `null` when it wrote none. |
| `failed` | `error` says why. |
| `cancelled` | The turn was stopped. |

While the scrape is within your plan's history window, `GET /v1/scrape/{id}` still returns the scrape's own document, during a turn and after it. A turn's answer is read through interact.

## Stop

`POST /v1/interact/{id}/stop` stops the turn running on the task's phone:

```bash theme={null}
curl -X POST "https://api.lusor.ai/v1/interact/$TASK_ID/stop" \
  -H "X-Api-Key: $LUSOR_API_KEY"
```

```json theme={null}
{
  "success": true,
  "id": "8b2d4f71-…",
  "status": "stopping",
  "sessionDurationMs": 41250,
  "creditsBilled": 8
}
```

A `200` acknowledges the stop. `status` says what it did:

| `status` | Meaning |
| - | - |
| `stopping` | Cancellation was requested. Keep reading the turn until it ends before you send the next one. |
| `cancelled` | A turn that was waiting for a reply is now ended. |
| `noop` | The stop found no run it could cancel. A scrape or agent task still waiting for its phone also answers `noop` and can still start. Each stop acts on the task's latest run, so a later stop can cancel a turn you sent after the first one. |

`sessionDurationMs` is the time since the stopped run took the phone, or `0` when it never took the phone or the stop answered `noop`. A turn the stop ended is charged as its run winds down, so read the turn again for the final `creditsUsed`.

## The phone between turns

The phone is not held between calls. Each turn takes the phone again, and no phone time is charged in between. A later turn on the same id still works, as long as the screen the task left is still there: another task on the same phone in between can change it.

* A phone busy with another task answers `429` `device_busy`. Try again when it frees.
* A turn sent while the task's own run, or an earlier turn, is still going answers `409` `task_running`. Wait for it to end. If you asked it to stop, keep reading the turn until it ends.

### Retry safely

Use a new `Idempotency-Key` for each new turn. If you can't tell whether a turn was accepted, retry with the same key. The request is checked again (body, credits, billing), and if it reaches the phone while the first result is still kept, it answers that result instead of starting a second turn. After `409` `task_running` or `429` `device_busy`, wait for the task or the phone to free up, then send the turn with a new key.

## Options

| Field | Required | Meaning |
| - | - | - |
| `prompt` | Yes | The next instruction, in plain words. Up to 8,192 characters. |
| `workspaceId` | No | The workspace, for a credential that can reach several. An API key is bound to one workspace and can leave it out. |

## Errors

Errors are JSON with an `error` code, and a `message` when there is one. See [Errors](https://docs.lusor.ai/billing/errors.md).

| Status | `error` | Meaning |
| - | - | - |
| `400` | `bad_request` | The body is invalid: `prompt` is missing, blank or too long, or `workspaceId` is not a UUID. |
| `400` | `code_not_supported` | The body is otherwise valid but sent `code`. Running a script isn't available yet; send a `prompt` without `code`. |
| `401` | `unauthenticated`, `invalid_api_key` | The API key is missing, wrong or revoked. |
| `402` | `credits_exhausted` | The workspace is out of credits. The body also has `balance`, `tier` and `upgradeTo`. No turn started. |
| `402` | `billing_required` | The Lusor Phone isn't covered by an active paid plan or by the plan's phone count. No turn started. |
| `403` | `tenant_paused` | The account is paused and can't start runs. Contact support. |
| `404` | `not_found` | No scrape or agent task with this id in the key's workspace. |
| `409` | `task_running` | The task's own run or an earlier turn is still going. |
| `429` | `device_busy` | The phone is running another task. |
| `503` | `interact_unavailable` | Interact isn't available right now. |
| `503` | `cancel_unconfirmed` | On stop: the stop couldn't be confirmed. Read the turn before you send another. |

## Known limits

* **Prompts only.** A turn takes a plain-words `prompt`. Scripts with `code` aren't available yet.
* **Turns aren't recorded yet.** `recordingUrl` is the recording of the task that started it.
* **No live view link for a turn.**
* **Text answers only.** A turn doesn't return the screen as a document yet. To read a screen in a set format, use [Scrape](https://docs.lusor.ai/app-data/scrape.md).

## Related

> [card] [Scrape](https://docs.lusor.ai/app-data/scrape.md)
>
> Read a screen you already know, with no agent.

> [card] [Agent](https://docs.lusor.ai/app-data/agent.md)
>
> Describe a task in plain words and get the answer.


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