# Webhooks

MoreLogin sends JSON events by POST to your HTTPS endpoint for cloud phone and cloud browser operations and for supported Cloud Phone RPA execution results. Each team has one callback URL shared by the Local API and Open API.

## Configure the callback URL

Both surfaces expose the same operation. Open API:

```bash
curl -X POST "https://api.morelogin.com/webhook/config" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
    "callbackUrl": "https://example.com/morelogin/webhook",
    "enabled": true
  }'
```

Local API:

```bash
curl -X POST "http://127.0.0.1:40000/api/webhook/config" \
  -H "Content-Type: application/json" \
  -d '{
    "callbackUrl": "https://example.com/morelogin/webhook",
    "enabled": true
  }'
```

The Local API route is served by the desktop client, so it needs MoreLogin client v2.66.0 or higher. The Open API endpoint has no client dependency.

`teamId` is never read from the request. Each call configures the team of the server-side context, so you cannot point another team's events at your endpoint.

The URL must be HTTPS, 1 to 1024 characters, with a host, no user info, no fragment and a valid port. Every address it resolves to has to be publicly routable: localhost, private, link-local, CGNAT, cloud metadata, protocol-reserved, documentation and 6to4 ranges are rejected with [`41001`](/api-reference/getting-started/error-codes). The same check runs again when a delivery opens its connection, so a hostname that later resolves into a private range fails that delivery rather than reaching your network.

Saving is an upsert keyed by team, so sending the same body twice is harmless.

### Turning delivery off

`enabled: false` keeps the URL on file and stops new events from being created. Events already queued are cancelled one at a time, at the moment each would next be authorized, and only while the configuration is still disabled — so if you re-enable quickly, queued events continue instead of being dropped.

## What a delivery looks like

Each delivery is a `POST` with these headers:

| Header | Value |
|  --- | --- |
| `Content-Type` | `application/json` |
| `User-Agent` | `MoreLogin-Webhook/1.0` |
| `X-Webhook-Event-Id` | Same as `eventId` in the body |
| `X-Webhook-Event-Type` | Same as `eventType` in the body |


The two `X-Webhook-*` headers duplicate body fields on purpose, so a router or queue can dispatch on them without parsing JSON.

```json
{
  "eventId": "c7f3a2b10d8e4f6a9c1b2d3e4f5a6b7c",
  "eventType": "cloud_phone.power_off",
  "eventTime": "1787241600000",
  "data": {
    "teamId": "10001",
    "cloudPhoneId": "20001",
    "reason": "MONEY_SAVING"
  },
  "result": {
    "success": true,
    "code": "0",
    "message": null
  }
}
```

| Field | Description |
|  --- | --- |
| `eventId` | Unique event ID. Retries and internal replays of the same event reuse it, so it is the idempotency key |
| `eventType` | Stable event name, from the table below |
| `eventTime` | Lifecycle events use a Unix millisecond timestamp sent as a string. RPA events send a JSON integer. |
| `data.teamId` | Team that owns the resource. **Sent as a string** |
| `data.cloudPhoneId` | Cloud phone the event is about. **Sent as a string** |
| `data.cloudBrowserId` | Cloud browser profile the event is about. **Sent as a string** |
| `data.runId` | Cloud browser run instance the event is about |
| `data.reason` | Only on `cloud_phone.power_off` and `cloud_browser.stop` |
| `result.success` | Whether the operation ultimately succeeded |
| `result.code` | `0` on success; otherwise a stable business error code that does not depend on language |
| `result.message` | Null on success. Lifecycle failures use the team language with an en-US fallback. RPA failures use the original execution message. |


Numeric IDs are JSON strings. Keep them as strings to preserve the precision of 64-bit IDs. The lifecycle events shown here send `eventTime` as a string. The RPA event described below sends it as a JSON integer.

## Events

| `eventType` | Final result it reports |
|  --- | --- |
| `cloud_phone.power_on` | Power on succeeded or failed |
| `cloud_phone.power_off` | Power off succeeded. A failed shutdown produces no event |
| `cloud_phone.restart` | Restart succeeded or failed |
| `cloud_phone.reset` | Reset succeeded or failed |
| `cloud_phone.new_machine` | One-click new machine succeeded or failed |
| `cloud_browser.start` | Cloud browser start succeeded or failed |
| `cloud_browser.stop` | Each cloud browser stop attempt, successful or not |
| `rpa_task.complete` | Success or failure reported for one Cloud Phone RPA execution |


Cloud phone events carry `teamId` and `cloudPhoneId`. Cloud browser events carry `teamId`, `cloudBrowserId` and `runId`.

Power on, restart, reset and one-click new machine report `success: true` only once the completion callback succeeded and the local synchronisation committed. A billing failure, or an asynchronous proxy check that fails and finishes its cleanup, reports a failed power on and does **not** additionally emit a power off. Deferred work such as installing preset apps or clearing expired files does not change the result.

If a shutdown interrupts a boot, that attempt produces no power-on event; the later successful shutdown still produces its own `cloud_phone.power_off`.

### Stop reasons

`cloud_phone.power_off` adds `data.reason`:

| Value | Meaning |
|  --- | --- |
| `NORMAL` | Ordinary shutdown |
| `MONEY_SAVING` | Money-saving mode |
| `OTHER` | Arrears, expiry, maintenance or anything else |


`cloud_browser.stop` adds `data.reason`:

| Value | Meaning |
|  --- | --- |
| `NORMAL` | Ordinary close |
| `MONEY_SAVING` | Money-saving mode |
| `ENERGY_SAVING` | Energy-saving mode |
| `BROWSER_EXITED` | The browser exited unexpectedly |
| `OTHER` | Anything else |


An internal archiving failure changes only `result`; it never overwrites the `reason` captured when the stop began.

### RPA execution result

With team webhooks enabled, MoreLogin attempts to send a `rpa_task.complete` event to the configured URL after a Cloud Phone reports success or failure and the execution result is saved.

If a task runs on three phones, each phone's execution is reported separately. Recurring runs also produce separate events. Executions of the same task share a `taskId` and have distinct `executionId` values.

Check `result.success` for the outcome and use `data.executionId` to identify the execution. If you receive the same `eventId` more than once, process it once.

This example shows a failed execution. On success, `data.result` is `1`, `result.success` is `true`, the error code is `"0"`, and the error message is `null`.

```json
{
  "eventId": "90001",
  "eventType": "rpa_task.complete",
  "eventTime": 1793757618000,
  "data": {
    "taskId": "10001",
    "taskName": "Automation task",
    "executionId": "20001",
    "cloudPhoneId": "30001",
    "result": 0,
    "resultAttachment": "https://example.com/rpa/result-20001.png",
    "errorCode": "4002",
    "errorMsg": "Failed to launch the app",
    "startTime": 1793757600000,
    "endTime": 1793757618000,
    "duration": 18000
  },
  "result": {
    "success": false,
    "code": "4002",
    "message": "Failed to launch the app"
  }
}
```

All 11 fields in `data` are present. Nullable fields are sent as `null` when no value is available.

| Field | Type | Description |
|  --- | --- | --- |
| `eventId` | String | Unique event ID. Retries reuse it. Use it to deduplicate deliveries. |
| `eventType` | String | Always `rpa_task.complete`. |
| `eventTime` | Integer | Unix timestamp in milliseconds when the server processed the result, equal to `data.endTime`. |
| `data.taskId` | String | Parent task ID. Executions of the same task share this ID. |
| `data.taskName` | String or `null` | Saved task name when the event was created. It can be null for temporary tasks. |
| `data.executionId` | String | Execution record ID. Use it to query the execution detail. |
| `data.cloudPhoneId` | String | ID of the Cloud Phone that ran the task. |
| `data.result` | Integer | `0` for failure and `1` for success. |
| `data.resultAttachment` | String or `null` | URL of the first result screenshot from this execution. |
| `data.errorCode` | String | `"0"` on success. On failure, the execution error code or `"99000"` if none was reported. |
| `data.errorMsg` | String or `null` | Error message reported by the execution. Null on success or when no message was reported. |
| `data.startTime` | Integer or `null` | Unix timestamp in milliseconds when initialization began. Includes preparation time. |
| `data.endTime` | Integer | Unix timestamp in milliseconds when the server processed the execution result. |
| `data.duration` | Integer or `null` | `endTime - startTime` in milliseconds. Null when the start time is unavailable. |
| `result.success` | Boolean | Whether this execution succeeded. |
| `result.code` | String | Same as `data.errorCode`. |
| `result.message` | String or `null` | Same as `data.errorMsg`. Uses the original execution message. |


The event contains an execution summary. Query the execution detail for node-level results.

#### If you don't receive an event

Initialization failures, server-side timeouts, cancellations and interruptions do not trigger this event. If the team has no active webhook configuration, no event is created. If event creation fails, the saved RPA result remains available through the execution detail endpoint.

Created RPA events follow the delivery and retry rules below. There is no delivery order guarantee between executions or between RPA events and phone power events.

Pass `data.executionId` as `{id}` to query the execution detail. You can also use the execution record to check the status if no webhook arrives.

- Open API · `POST /cloudphone/rpa/subTask/detail/{id}`
- Local API · `POST /api/cloudphone/rpa/subTask/detail/{id}`


## Delivery, retries and ordering

Any `2xx` counts as delivered. Every other status, plus connect and read timeouts and network errors, counts as a failure. The connect timeout is 5 seconds and the read timeout is 30 seconds.

A failed delivery is retried at most 6 times, after 10 seconds, 30 seconds, 60 seconds, 3 minutes, 10 minutes and 30 minutes. That is at most 7 requests for one event. After the sixth retry fails the event stops being retried automatically.

Events for the same cloud phone, or the same cloud browser, are delivered in creation order, one at a time. Different resources are delivered in parallel, so do not assume any ordering between them.

Retries of one event always reuse the same `eventId`, `eventTime` and body. Under network or recovery edge cases the same event may be delivered more than once with those values unchanged, so **deduplicate on `eventId`**.

For cloud browser stops, one stop attempt yields exactly one event. A later manual retry, a manual forced release, or a system-initiated forced release is a new operation and gets a new `eventId`. Two attempts are never merged into one event.

Cloud phone operations are identified by the operation task ID, `traceId`, or a stable business timestamp. When none of those exists the service generates a UUID and treats the current final callback as a new operation, so you get a new `eventId` rather than two different operations collapsing into one.

## Writing the receiver

Return a `2xx` as soon as you have stored the event, and do the real work asynchronously. The response body is ignored, and a slow handler burns your 30-second read budget and pushes the event into the retry schedule even though you received it.

Deduplicate on `eventId`. Treat a repeat as already handled rather than replaying side effects.

Do not treat the payload as trusted input just because it arrived at your endpoint. This release does not sign callbacks, so anyone who learns your URL can post to it. Use a URL that is hard to guess, and before acting on anything expensive, confirm the state through the API — for example [`POST /cloudphone/info`](/api-reference/cloud-phone/open-api) for a cloud phone, or `POST /cloudbrowser/page` for a cloud browser run.

Lifecycle events use API business error codes. See [Error Codes](/api-reference/getting-started/error-codes) for those codes. RPA events use the execution error code and original execution message. Use `result.success` and `result.code` for decisions, and display `result.message` as text.

The machine-readable contract for every event, including schemas and per-event examples, is published with the shared resources spec under [Shared Resources Open API](/api-reference/shared-resources/open-api).