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

# Sign Users In from a Native App

> Sign users in to a Komo hub from a native iOS or Android app by exchanging a JWT with the Komo session API, with request and response examples and no SDK required

# Sign Users In from a Native App

Exchange your user's JWT for a Komo session token, then open the hub in your app's web view with that token. No Komo SDK needed.

For other ways to embed Komo in an app, see [Mobile App Integration](https://knowledge.komo.tech/integrations-automation/mobile-app-integration/index.md).

## 1. Set up the Workspace App

In the Komo Portal, go to **Apps** > **Workspace Apps** and open your app.

* **General:** copy the **App ID** (for example `au1_<app-guid>` or `us1_<app-guid>`). Leave **Allowed origins** empty.
* **Authentication:** turn on **JWT**, choose **RS256** (JWKS URL or public key) or **HS256** (shared secret), and set **Issuer** and **Audience** if you use them.
* **Claim Mapping:** map your claims to contact fields, for example `email` to **Email**, `first_name` to **First name**, `last_name` to **Last name**.
* Paste a sample token into **JWT for testing** to check it.

## 2. Exchange the JWT for a session token

Call the session API from your backend or app.

Your JWT must have:

* `alg` RS256 or HS256, matching the Workspace App.
* `iss` and `aud` matching the app's **Issuer** and **Audience** (if set).
* `exp`. Keep it short-lived; the JWT is used once.
* At least one claim you mapped on **Claim Mapping** (for example `email`).
* `kid` only if you use a JWKS URL.

Your App ID starts with your region prefix (for example `au1_` or `us1_`). Call `https://api.{region}.komo.site` and send the App ID without the prefix as `appId`. Sending the full App ID returns HTTP 400. This applies only when you call the session API directly. Komo's web and React Native SDKs take the full App ID.

Request:

```bash theme={null}
curl -X POST "https://api.{region}.komo.site/api/v1/live/auth/sdk/session" \
  -H "Content-Type: application/json" \
  -d '{ "appId": "<app-guid>", "identity": { "type": "jwt", "token": "<your-jwt>" } }'
```

Success response:

```json theme={null}
{
  "success": true,
  "result": "Success",
  "failureReason": null,
  "errorMessage": null,
  "data": {
    "sessionToken": "<session-token>",
    "expiresAt": "2026-11-20T03:35:36+00:00",
    "expiresIn": 3600,
    "contactId": "<contact-guid>",
    "trustLevel": "Verified",
    "mergedFromContactId": null
  }
}
```

Failure response (also HTTP 200, so always check `success`):

```json theme={null}
{
  "success": false,
  "result": "Failed",
  "failureReason": "TokenInvalid",
  "errorMessage": "JWT verification failed",
  "data": null
}
```

| `failureReason` | What to do |
| - | - |
| `TokenInvalid` | Check the JWT's signing key, `iss`, `aud`, `exp` and mapped claims. On refresh: exchange a new JWT. |
| `TokenExpired` | Refresh only: exchange a new JWT. |
| `AppNotFound` | Check `appId` (GUID only, no region prefix). |
| `TypeNotPermitted` | Turn on **JWT** in the Workspace App. |
| `ContactResolutionFailed` | Retry. |

## 3. Open the hub

Open the hub home page or any page in your app's web view, with a fresh session token:

```text theme={null}
https://your-hub.komo.site/?komo_session=<session-token>
https://your-hub.komo.site/<page-slug>?komo_session=<session-token>
```

What happens:

* The hub recognises the user as a known contact, so everything on it knows who they are: cards, their profile, loyalty and more. Forms can be [prefilled](https://knowledge.komo.tech/getting-started/hub-setup/data-capture/index.md#prefill) or skipped using [auto submit](https://knowledge.komo.tech/getting-started/hub-setup/data-capture/index.md#auto-submit), and their profile is set up from your JWT claims.
* Komo removes `komo_session` from the address bar and history. Other URL parameters, such as `utm_source`, are kept.
* Opening the hub with a token for a different user switches it to that user.
* The hub keeps recognising the user after the token's 60 minutes. The token is used once; later opens without a token are still recognised through the hub's long-lived cookie, as long as the web view keeps its data.

## 4. Refresh the session token (optional)

Only needed if your app keeps a session token to reopen the hub later. If you exchange a fresh JWT right before each open, skip this step.

Request:

```bash theme={null}
curl -X POST "https://api.{region}.komo.site/api/v1/live/auth/sdk/session/refresh" \
  -H "Content-Type: application/json" \
  -d '{ "sessionToken": "<session-token>" }'
```

Response (a new token for the same contact):

```json theme={null}
{
  "success": true,
  "result": "Success",
  "failureReason": null,
  "errorMessage": null,
  "data": {
    "sessionToken": "<new-session-token>",
    "expiresAt": "2026-11-20T04:35:36+00:00",
    "expiresIn": 3600,
    "contactId": "<contact-guid>",
    "trustLevel": "Verified",
    "mergedFromContactId": null
  }
}
```

## 5. Sign out

When a user signs out of your app, clear the web view's cookies and website data for the hub domain.

> [!WARNING]
>
> If you don't clear them, the previous user stays recognised on the hub, even if the next person opens it without a token.

## Good to know

* **The user changes in your app:** exchange a token for the new user and open the hub with it.
* **Invalid or expired session token:** the hub loads with no error and keeps recognising whoever it already knew, which is why step 5 matters.
* **User agent:** keep the web view's default user agent, or append to it rather than replacing it.
* **Security:** keep signing keys on your servers, and don't log the session token or send it anywhere except the hub URL.

***

**Need Help?** Contact [support@komo.tech](mailto:support@komo.tech) for mobile integration assistance.


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