> For the complete documentation index, see [llms.txt](https://api.circle.so/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api.circle.so/apis/circle-plus/custom-signup-api-reference.md).

# Custom Signup API reference

#### Overview

When the sign-up page is loaded inside the mobile app, the app injects a small bridge into it. The page can use the bridge to:

* Detect that it is running inside the mobile app
* Tell the app an account was created, so it can continue to email verification
* Tell the app the email is already registered, so it can send the user back to login
* Ask the app to open a paywall / checkout URL (Android only)

No setup is needed on the page. The bridge is injected by the app on every page load.

> The bridge becomes available **after** the page finishes loading. Do not read it during initial page script execution. Call it lazily (on user action or in a `load` handler) and feature-detect first.

***

#### Global Objects

**`window.webview`**

**Type:** `object`

Namespace for every bridge function.

| Property                        | Type       | Description              |
| ------------------------------- | ---------- | ------------------------ |
| `handleEmailAlreadyExistsError` | `function` | See below.               |
| `accountCreatedCallback`        | `function` | See below.               |
| `goToPaywallUrl`                | `function` | Android only. See below. |

***

#### Callback Functions

**`window.webview.accountCreatedCallback(data)`**

```js
window.webview.accountCreatedCallback(data)
```

Notifies the app that sign-up succeeded.

| Parameter | Type                | Required | Description                           |
| --------- | ------------------- | -------- | ------------------------------------- |
| `data`    | `{ email: string }` | Yes      | The address that was just registered. |

**Returns:** `undefined`

**Example:**

```js
window.webview?.accountCreatedCallback?.({ email: 'jane@example.com' })
```

**Notes:**

* With a valid `email`, the app sends a verification code to that address and shows the code entry screen.
* If sending the code fails, the app returns the user to the login screen to finish registration.
* If `data` has no `email` (or is `undefined`), the app returns the user to the login screen to finish registration.
* Call it exactly once per sign-up, and always with an email. Placeholder or empty payloads send the user to login.

***

**`window.webview.handleEmailAlreadyExistsError()`**

```js
window.webview.handleEmailAlreadyExistsError()
```

Call when the sign-up form reports that the email is already registered. After 1 second, the `#existing-account-error-link` element stops navigating to its `href`, and clicking it sends the user to the app's login screen.

**Parameters:** none

**Returns:** `undefined`

**Example:**

```js
window.webview?.handleEmailAlreadyExistsError?.()
```

**Notes:**

* The `#existing-account-error-link` element must be in the DOM within 1 second of the call.

***

**`window.webview.goToPaywallUrl(url)` / `window.goToPaywallUrl(url)`**

```js
window.webview.goToPaywallUrl(url)
```

Asks the app to open a paywall or checkout URL.

| Parameter | Type     | Required | Description              |
| --------- | -------- | -------- | ------------------------ |
| `url`     | `string` | Yes      | Absolute `https://` URL. |

**Returns:** `undefined`

**Example:**

```js
if (window.webview?.goToPaywallUrl) {
  window.webview.goToPaywallUrl('https://example.circle.so/checkout/my-plan')
} else {
  window.location.href = 'https://example.circle.so/checkout/my-plan'
}
```

**Notes:**

* **Android only.** On iOS the function is not defined; always feature-detect and fall back.
* Non-`https://` URLs are rejected by the app and nothing happens.
* `window.goToPaywallUrl` and `window.webview.goToPaywallUrl` are the same function.

***

#### Feature Detection

```js
const bridge = window.webview
const isInApp = Boolean(bridge?.isComingFromReactNativeWebview)
const canOpenPaywall = typeof bridge?.goToPaywallUrl === 'function'
```

***

#### Page Modifications

Once the page loads, the app hides these elements if present, so the page does not need to:

| Selector                | Effect          |
| ----------------------- | --------------- |
| `#back-link-container`  | `display: none` |
| `#login-link-container` | `display: none` |

***

#### Best Practices

**1. Always feature-detect**

The page also runs in a normal browser, and `goToPaywallUrl` is Android only.

```js
window.webview?.accountCreatedCallback?.({ email })
```

**2. Keep `#existing-account-error-link` in the DOM**

`handleEmailAlreadyExistsError` expects it to exist 1 second after the call.

***

#### API Summary

| API                                                                 | Type       | Platform     |
| ------------------------------------------------------------------- | ---------- | ------------ |
| `window.webview.accountCreatedCallback(data)`                       | Callback   | iOS, Android |
| `window.webview.handleEmailAlreadyExistsError()`                    | Callback   | iOS, Android |
| `window.webview.goToPaywallUrl(url)` / `window.goToPaywallUrl(url)` | Navigation | Android only |
