# Report an Embedded Signup Session Event

Canonical: https://docs.bluehola.com/docs/onboarding/post-v1-onboarding-es-events
OpenAPI: https://docs.bluehola.com/openapi.yaml

<div class="endpoint"><span class="endpoint-method endpoint-method--post">POST</span><code class="endpoint-path">/v1/onboarding/es-events</code></div>

Report one Embedded Signup session event (which screen the customer abandoned on, or a customer self-reported error). Always 202.

:::note[Authentication]

Send `Authorization: Bearer <API_KEY>` in the request headers, with scope `onboarding:write`. Which resources an API Key can reach is determined by its current authorization scope.

:::

## Request

Base URL: `https://api.bluehola.com`

### Request body
A request body is required.
### Request body fields

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `portfolioId` | string | No | The Business Portfolio this run is for, bm_... Use **exactly one** of this and `customerEntityId` |
| `customerEntityId` | string | No | Customer entity ID, cust_... when onboarding was started for a customer; before authorization there is no Portfolio yet. Use **exactly one** of this and `portfolioId` |
| `event` | string | Yes | The `event` value from the ES message event: FINISH* / CANCEL / ERROR |
| `esVersion` | v2 \| v3 \| v4 | No | The ES version used when starting |
| `currentStep` | string | No | The screen the customer was on when they abandoned, e.g. PHONE_NUMBER_SETUP |
| `errorCode` | string | No | The error code Meta gave when the customer self-reported an error during the flow |
| `errorMessage` | string | No | The corresponding error text shown to the customer |
| `metaSessionId` | string | No | Meta's session_id — **required when contacting Meta support** |
| `timestamp` | integer | No | The unix seconds Meta supplied (only present for error events) |

Content-Type: `application/json`
Example:

```json
{
  "customerEntityId": "cust_x",
  "event": "CANCEL",
  "currentStep": "PHONE_NUMBER_SETUP",
  "esVersion": "v4"
}
```

Schema:

```json
{
  "type": "object",
  "properties": {
    "portfolioId": {
      "type": "string",
      "description": "string · optional — the Business Portfolio this run is for, bm_... Use exactly one of this and customerEntityId"
    },
    "customerEntityId": {
      "type": "string",
      "description": "string · optional — customer entity ID, cust_... when onboarding was started for a customer; before authorization there is no Portfolio yet. Use exactly one of this and portfolioId"
    },
    "event": {
      "type": "string",
      "description": "string · required — the event value from the ES message event: FINISH* / CANCEL / ERROR"
    },
    "esVersion": {
      "type": "string",
      "description": "v2 | v3 | v4 · optional — the ES version used when starting"
    },
    "currentStep": {
      "type": "string",
      "description": "string · optional — the screen the customer was on when they abandoned, e.g. PHONE_NUMBER_SETUP"
    },
    "errorCode": {
      "type": "string",
      "description": "string · optional — the error code Meta gave when the customer self-reported an error during the flow"
    },
    "errorMessage": {
      "type": "string",
      "description": "string · optional — the corresponding error text shown to the customer"
    },
    "metaSessionId": {
      "type": "string",
      "description": "string · optional — Meta's session_id — required when contacting Meta support"
    },
    "timestamp": {
      "type": "string",
      "description": "integer · optional — the unix seconds Meta supplied (only present for error events)"
    }
  },
  "required": [
    "event"
  ],
  "example": {
    "customerEntityId": "cust_x",
    "event": "CANCEL",
    "currentStep": "PHONE_NUMBER_SETUP",
    "esVersion": "v4"
  }
}
```

## Response

| Status | Description |
| --- | --- |
| `202` | Accepted |
| `4xx` | Client error |

For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md).

## Notes

#### Why this endpoint exists
Embedded Signup's session info logging (on by default from ES v3) **appears only in a single browser `message` event** — it cannot be queried from the Graph API afterwards. Two things are gone for good if this is lost: which screen the customer abandoned on (the only funnel data for onboarding), and the `session_id` from a customer self-reported error (the credential needed for Meta support).

#### This is diagnostic data, not a business write
It always returns 202, does not validate business semantics, and a persistence failure is only logged. The front end should fire-and-forget: a failed report here must never surface as an error on the customer's screen. The request body is `.strict()`, so extra fields cause a 400 — **in particular, never pass `code` in here**, since that is a 30-second credential that does not belong in this table.
