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

# Notifications

> Receive platform alerts through channels and webhooks, or stream live task progress and agent replies into your app.

Notifications turn platform events into alerts in the places you work. Receive a message when a routine finishes, a task fails, an SMS arrives, or a card payment needs approval. Choose the moments you care about and the channels that receive them in Notifications.

## Push: channels and webhooks

### Channels

| Channel | What you receive | Setup |
| - | - | - |
| Mobilerun | Alerts in the bell icon and browser pop-ups for supported events. | Under **Notifications in Mobilerun**, choose **Notify me about** or **Choose individual events**. |
| Browser notifications | OS-level alerts for events that support pop-ups when the tab is not focused. | Enable **Browser notifications** and grant permission in this browser. On devices that require it, add Mobilerun to your home screen and open it from there first. |
| Slack | Formatted platform-event messages in a channel, posted by your connected account. | Connect your workspace, pick a channel, and choose moments under **Notifications in Slack or Teams**. |
| Microsoft Teams | Formatted platform-event messages in a channel, posted by your connected account. | Connect your account, pick a channel, and choose moments in the same section. |
| HTTP webhook | Signed JSON events for your server or automation tool. | Open Webhooks and follow [Webhooks](https://docs.mobilerun.ai/webhooks.md) for receiver setup. |

The dashboard lists the integrations available to your organization. In-app preferences and browser permission do not replace a Slack, Teams, or webhook destination's event filter. Not every event supports every surface: browser notifications use the pop-up event selection, while team channels and HTTP webhooks use the deliverable webhook catalog.

### Events and moments

The channel picker groups event types into **moments**. Selecting a moment subscribes the destination to its available event types. These are the groups and their events for Slack, Teams, and HTTP destinations:

| Moment | When it happens | Event types |
| - | - | - |
| Your agent needs you | A chat question or card-payment approval is waiting. | `chat.input.required`, `wallet.card.approval_requested` |
| Your agent is done | An interactive chat turn finishes successfully. | `chat.turn.completed` |
| Something failed | A chat, workflow, task, agent run, SMS send, number purchase, or card payment fails. | `chat.turn.failed`, `workflow.run.failed`, `workflow.run.invalid`, `task.run.failed`, `agent.run.failed`, `agent.run.timed_out`, `sms.send.failed`, `number.purchase.failed`, `wallet.transaction.declined` |
| Work is done | A workflow, task, or agent run completes. | `workflow.run.completed`, `task.run.completed`, `agent.run.completed` |
| Workflow notifications | A routine deliberately sends a notification. | `triggers.notification` |
| New messages | An SMS or mailbox message arrives. | `sms.received`, `mailbox.message.received` |
| Purchases and setup | A number, eSIM, or mailbox becomes ready. | `number.purchase.completed`, `esim.purchase.completed`, `esim.install.completed`, `mailbox.rent.activated` |
| Card activity | A payment is authorized, cleared, refunded, or voided, or a card changes. | `wallet.transaction.authorized`, `wallet.transaction.cleared`, `wallet.transaction.refunded`, `wallet.transaction.voided`, `wallet.card.updated` |

The agent moments also include `chat.away.completed` and `chat.away.failed` for in-app/browser alerts when you are away; those two events are not delivered to team channels or HTTP webhooks. For the full platform subscription catalog, including lifecycle events outside these moment groups, see [Webhooks](https://docs.mobilerun.ai/webhooks.md#event-catalog).

### Set up in the dashboard

Add a notification channel

1. Open Notifications. Under **Notifications in Slack or Teams**, click **Connect** for your provider and finish the connection flow.
2. Click **Add channel**. In **Add a channel**, select the destination under **Where to send it** and choose its **Channel**.
3. Choose the moments to receive and click **Add channel**. Leaving moments unselected subscribes the destination to all deliverable events; select moments for a narrower subscription.
4. Use **Send test message** in the confirmation to check the connection.

For an HTTP destination, open Webhooks and click **New webhook**; follow [Creating a webhook](https://docs.mobilerun.ai/webhooks.md#creating-a-webhook) to save the signing secret and send a test.

Change a channel's moments on its card later. If its connection expires, reconnect the provider; if its target no longer exists, set the channel up again. Use [Webhooks](https://docs.mobilerun.ai/webhooks.md#states-and-health) to inspect delivery health and failed attempts.

### Set up via API

Notification destinations use the same `/v1/webhooks` API as platform webhooks. Set `eventTypes` to the event identifiers you want; the API accepts event types, not moment names. The following creates an HTTP destination for successful and failed routine executions using the typed SDK methods available in version 6.2.1.

```typescript TypeScript theme={null}
import Mobilerun from '@mobilerun/sdk';

const client = new Mobilerun({ apiKey: process.env.MOBILERUN_API_KEY });
const result = await client.webhooks.create({
  kind: 'http',
  url: 'https://example.com/mobilerun',
  eventTypes: ['workflow.run.completed', 'workflow.run.failed'],
  description: 'Routine outcomes',
});
// Store result.data.secret securely: it is shown only once.
```

```python Python theme={null}
import os

from mobilerun_sdk import Mobilerun

client = Mobilerun(api_key=os.environ["MOBILERUN_API_KEY"])
result = client.webhooks.create(
    kind="http",
    url="https://example.com/mobilerun",
    event_types=["workflow.run.completed", "workflow.run.failed"],
    description="Routine outcomes",
)
# Store result.data.secret securely: it is shown only once.
```

```bash cURL theme={null}
curl --fail-with-body https://api.mobilerun.ai/v1/webhooks \
  -H "Authorization: Bearer $MOBILERUN_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"kind":"http","url":"https://example.com/mobilerun","eventTypes":["workflow.run.completed","workflow.run.failed"],"description":"Routine outcomes"}'
# Store the response's data.secret securely: it is shown only once.
```

For Slack or Teams, connect the account in the dashboard first. In an authenticated dashboard session, `GET /v1/webhooks/integrations` returns the offered capabilities and their connection state. `GET /v1/webhooks/integrations/{capabilityId}/targets?revision={revision}` returns the selectable channels. Create the destination with `POST /v1/webhooks`, `kind: "integration"`, the returned `capability` (`id` and `revision`), the chosen target's `args`, and your `eventTypes`. Use the returned values rather than inventing provider IDs or target arguments. Discovery of integrations and targets is session-only, unavailable to scoped API keys.

| Action | API |
| - | - |
| List destinations | `GET /v1/webhooks` |
| Read a destination | `GET /v1/webhooks/{id}` |
| Change events, description, or state | `PATCH /v1/webhooks/{id}` (dashboard session) |
| Send a test | `POST /v1/webhooks/{id}/test` (dashboard session) |
| Delete a destination | `DELETE /v1/webhooks/{id}` |

Creating a destination requires permission to disclose a secret. Personal notification preferences and browser permission are configured in the dashboard, separately from these destination subscriptions.

### Payload and verification

Slack and Teams receive a formatted message derived from the platform event, not a raw JSON request to a receiver you host. Integration destinations have no signing secret.

HTTP destinations receive the platform event envelope with `id`, `type`, `occurredAt`, and event-specific `data`. They use the same signing, deduplication, delivery log, and retry mechanism documented in [Webhooks](https://docs.mobilerun.ai/webhooks.md#what-your-receiver-gets). Follow [signature verification](https://docs.mobilerun.ai/webhooks.md#verifying-the-signature) before processing a request. Integration deliveries retry transient provider failures; an expired connection or invalid target can block delivery until you repair it.

## Live streams

Use push destinations above for alerts and backend automation. Use a live Server-Sent Events (SSE) connection for progress in your app while a task or agent turn runs. These streams are separate from webhook deliveries and their retry logs.

The examples run on your server with an API key authorized for the resource. Keep the key server-side and relay updates through your own authenticated endpoint for browser clients. TypeScript and Python examples use SDK 6.2.1; stream examples use raw-response helpers to preserve SSE framing, including named task events and chat completion markers. Raw chunks and lines are transport data: use an SSE parser to assemble complete events before updating your UI.

### Create a task and stream its events

`POST /v1/tasks/stream` creates a task and streams named events such as `QueuedEvent`, `CreatedEvent`, `StartEvent`, and `ResultEvent`. **Disconnecting before completion cancels the task.** Do not retry this POST to reconnect: it creates another task. For task lifecycle and outcomes, see [Tasks](https://docs.mobilerun.ai/tasks.md) and the [streaming task reference](https://docs.mobilerun.ai/api-reference/tasks/run-streamed-task.md).

```typescript TypeScript theme={null}
import Mobilerun from '@mobilerun/sdk';

const client = new Mobilerun({ apiKey: process.env.MOBILERUN_API_KEY });
const response = await client.tasks.runStreamed({
  deviceId: process.env.DEVICE_ID!,
  task: 'Open Settings',
}, { timeout: 0, maxRetries: 0 }).asResponse();
const reader = response.body!.getReader();
const decoder = new TextDecoder();
try {
  for (;;) {
    const { done, value } = await reader.read();
    if (done) break;
    process.stdout.write(decoder.decode(value, { stream: true }));
  }
} finally {
  await reader.cancel();
}
```

```python Python theme={null}
import os
from mobilerun_sdk import Mobilerun

client = Mobilerun(api_key=os.environ["MOBILERUN_API_KEY"], max_retries=0)
with client.tasks.with_streaming_response.run_streamed(
    device_id=os.environ["DEVICE_ID"], task="Open Settings", timeout=None,
) as response:
    for line in response.iter_lines():
        print(line)
```

```bash cURL theme={null}
curl -N --fail-with-body https://api.mobilerun.ai/v1/tasks/stream \
  -H "Authorization: Bearer $MOBILERUN_API_KEY" \
  -H 'Accept: text/event-stream' -H 'Content-Type: application/json' \
  -d "{\"deviceId\":\"$DEVICE_ID\",\"task\":\"Open Settings\"}"
```

### Attach to an existing task

`GET /v1/tasks/{task_id}/attach` streams the current task handshake followed by live task events. Attaching does not create a task, and disconnecting this GET does not cancel it. Use this when you create a task separately and need progress in a UI. See [Attach task](https://docs.mobilerun.ai/api-reference/tasks/attach-task.md).

```typescript TypeScript theme={null}
import Mobilerun from '@mobilerun/sdk';

const client = new Mobilerun({ apiKey: process.env.MOBILERUN_API_KEY });
const response = await client.tasks.attach(process.env.TASK_ID!, {
  timeout: 0,
}).asResponse();
const reader = response.body!.getReader();
const decoder = new TextDecoder();
try {
  for (;;) {
    const { done, value } = await reader.read();
    if (done) break;
    process.stdout.write(decoder.decode(value, { stream: true }));
  }
} finally {
  await reader.cancel();
}
```

```python Python theme={null}
import os
from mobilerun_sdk import Mobilerun

client = Mobilerun(api_key=os.environ["MOBILERUN_API_KEY"])
with client.tasks.with_streaming_response.attach(
    os.environ["TASK_ID"], timeout=None,
) as response:
    for line in response.iter_lines():
        print(line)
```

```bash cURL theme={null}
curl -N --fail-with-body "https://api.mobilerun.ai/v1/tasks/$TASK_ID/attach" \
  -H "Authorization: Bearer $MOBILERUN_API_KEY" \
  -H 'Accept: text/event-stream'
```

Task streams have no `id` cursor or `Last-Event-ID` replay. Reattach to obtain current state and new events; missed intermediate events are not replayed. A terminal task emits `StatusEvent` and closes. Read [task status and trajectory](https://docs.mobilerun.ai/tasks.md) when recovering after a disconnect.

### Send an agent message with a streamed reply

`POST /v1/assistant/chat/message` selects SSE with `Accept: text/event-stream`. Its `data:` frames contain AI SDK UI-message chunks with a `type`, such as `start` and `tool-input-available`; these are not named SSE events. An approval request uses `toolName: "hitl-approval"`. See [Send message](https://docs.mobilerun.ai/api-reference/chat/send-a-single-user-message.md) for the message and approval contracts. Use an existing chat session ID; the SSE response also returns it in `X-Chat-Session-Id`.

```typescript TypeScript theme={null}
import Mobilerun from '@mobilerun/sdk';

const client = new Mobilerun({ apiKey: process.env.MOBILERUN_API_KEY });
const response = await client.assistant.conversations.send({
  sessionId: process.env.SESSION_ID!,
  message: 'Summarize the current task',
}, {
  headers: { Accept: 'text/event-stream' }, timeout: 0, maxRetries: 0,
}).asResponse();
const reader = response.body!.getReader();
const decoder = new TextDecoder();
try {
  for (;;) {
    const { done, value } = await reader.read();
    if (done) break;
    process.stdout.write(decoder.decode(value, { stream: true }));
  }
} finally {
  await reader.cancel();
}
```

```python Python theme={null}
import os
from mobilerun_sdk import Mobilerun

client = Mobilerun(api_key=os.environ["MOBILERUN_API_KEY"], max_retries=0)
with client.assistant.conversations.with_streaming_response.send(
    session_id=os.environ["SESSION_ID"], message="Summarize the current task",
    extra_headers={"Accept": "text/event-stream"}, timeout=None,
) as response:
    for line in response.iter_lines():
        print(line)
```

```bash cURL theme={null}
curl -N --fail-with-body https://api.mobilerun.ai/v1/assistant/chat/message \
  -H "Authorization: Bearer $MOBILERUN_API_KEY" \
  -H 'Accept: text/event-stream' -H 'Content-Type: application/json' \
  -d "{\"sessionId\":\"$SESSION_ID\",\"message\":\"Summarize the current task\"}"
```

### Reconnect to the active agent turn

`GET /v1/assistant/chat/stream?sessionId=...` replays buffered chunks from the start of the active turn, then continues live. It does not start an inactive session. Use the published SDK stream method below; see [Re-attach to the active turn stream](https://docs.mobilerun.ai/api-reference/chat/re-attach-to-the-active-turn-stream.md).

```typescript TypeScript theme={null}
import Mobilerun from '@mobilerun/sdk';

const client = new Mobilerun({ apiKey: process.env.MOBILERUN_API_KEY });
const response = await client.assistant.conversations.stream({
  sessionId: process.env.SESSION_ID!,
}, { timeout: 0 }).asResponse();
if (response.status !== 204) {
  const reader = response.body!.getReader();
  const decoder = new TextDecoder();
  try {
    for (;;) {
      const { done, value } = await reader.read();
      if (done) break;
      process.stdout.write(decoder.decode(value, { stream: true }));
    }
  } finally {
    await reader.cancel();
  }
}
```

```python Python theme={null}
import os
from mobilerun_sdk import Mobilerun

client = Mobilerun(api_key=os.environ["MOBILERUN_API_KEY"])
with client.assistant.conversations.with_streaming_response.stream(
    session_id=os.environ["SESSION_ID"], timeout=None,
) as response:
    if response.status_code != 204:
        for line in response.iter_lines():
            print(line)
```

```bash cURL theme={null}
curl -N --fail-with-body --get https://api.mobilerun.ai/v1/assistant/chat/stream \
  -H "Authorization: Bearer $MOBILERUN_API_KEY" \
  -H 'Accept: text/event-stream' --data-urlencode "sessionId=$SESSION_ID"
```

Resume is best-effort, with no `Last-Event-ID` cursor. Reconcile replayed chunks with the current turn rather than appending them twice. `204` means there is no active turn; `503` is retryable using `Retry-After`. Reconnect with this GET instead of resending the message. For both task and chat connections, stop reconnecting once the work has finished and back off after failures; task execution remains bounded by its configured timeout (see [Tasks](https://docs.mobilerun.ai/tasks.md)).

### In a React app

`@mobilerun/react` 0.3.0 exports `useTaskApproval` and `TaskApproval`. Your verified webhook handler can signal your own authenticated SSE endpoint when an approval changes. Pass that source as `subscribe`; it triggers a refetch through `fetchApproval`, so the fetched approval remains the source of truth. The hook polls every three seconds without `subscribe`; supplying it disables polling by default. Keep a polling interval if you also want recovery while your SSE connection is unavailable.

```tsx React theme={null}
import { TaskApproval, useTaskApproval, type UseTaskApprovalOptions } from '@mobilerun/react';
import '@mobilerun/react/styles.css';

// Your backend implements fetchApproval and decide with caller/task authorization.
export function Approval({ taskId, fetchApproval, decide: sendDecision }: Pick<
  UseTaskApprovalOptions, 'taskId' | 'fetchApproval' | 'decide'
>) {
  const { approval, decide, isDeciding, decision, error } = useTaskApproval({
    taskId,
    fetchApproval,
    decide: sendDecision,
    pollIntervalMs: 3000,
    subscribe: (id, onChange) => {
      // Your endpoint sends unnamed SSE messages for this task's approval changes.
      const source = new EventSource(`/api/events?taskId=${encodeURIComponent(id)}`);
      source.onmessage = onChange;
      return () => source.close();
    },
  });
  return <TaskApproval approval={approval} onDecide={decide}
    isPending={isDeciding} decision={decision} error={error} />;
}
```

`/api/events` is an endpoint you build, not a Mobilerun API route. Authenticate the browser and authorize its task subscription before sending signals. Follow [webhook verification](https://docs.mobilerun.ai/webhooks.md#verifying-the-signature) on the receiver and the [React task-approval example](https://github.com/droidrun/mobilerun-react#-task-approvals) for backend adapters. The separate organization feed at `/v1/webhooks/stream` is dashboard-session-only and cannot be used with a scoped API key; it is not the SSE source used by this example.

## Related pages

* [Webhooks](https://docs.mobilerun.ai/webhooks.md): full event catalog, payloads, signing, retries, and receiver implementation.
* [Get notified by your agent](https://docs.mobilerun.ai/agents/notifications.md): agent-turn events, their payloads, and asking your agent to configure notifications.


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