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

# Verify External User

> Verify or create a user from an external auth system JWT

Accepts a JWT signed by your own auth system and returns Sublay tokens. If the user does not exist in the project, they are created. If they do exist, their profile is updated with any changed fields from the JWT payload.

A user who hasn't signed in this way before is matched by `email` to an existing user. Sublay trusts your auth system to have confirmed that email, so if the matched user never verified it, its password is removed, every provider linked to it is unlinked, and all of its sessions are signed out (an access token already issued stops working within 30 minutes and can't be used to add a password, a provider or a push device): whoever set that account up may not own the address.

The JWT must be signed with the RSA private key corresponding to the public key configured in your Sublay project settings.

## Body Parameters

**userJwt** `string` *required*

A JWT signed with your project's RSA private key (RS256 algorithm). The
payload must include `sub` (external user ID) and `iss` (your Sublay project
ID). The `userData` claim may contain optional profile fields.

## JWT Payload Structure

The `userJwt` must contain:

| Claim | Required | Description |
| - | - | - |
| `sub` | Yes | External user ID. Stored as `foreignId` on the Sublay user. |
| `iss` | Yes | Your Sublay project ID. Must match the request project. |
| `userData` | No | Object with optional profile fields (see below). |

### `userData` fields

| Field | Type | Description |
| - | - | - |
| `email` | `string` | Email address |
| `name` | `string` | Display name |
| `username` | `string` | Username |
| `avatar` | `string` | Avatar URL |
| `bio` | `string` | Bio text |
| `location` | object | `{ latitude, longitude }` |
| `birthdate` | `string` | ISO 8601 date |
| `metadata` | object | Public custom data |
| `secureMetadata` | object | Private custom data |

## Response

**success** `boolean`

`true` on success.

**accessToken** `string`

Short-lived JWT access token. Expires in 30 minutes.

**refreshToken** `string`

Long-lived JWT refresh token. Expires in 30 days.

**user** `object`

The verified or created user's profile.

**properties**

**id** `string`

Unique user ID (UUID).

**foreignId** `string | null`

External user ID (the `sub` claim).

**role** `string`

User role.

**email** `string | null`

Email address.

**name** `string | null`

Display name.

**username** `string | null`

Username.

**avatar** `string | null`

Avatar URL.

**bio** `string | null`

Bio text.

**metadata** `object | null`

Public custom data.

**reputation** `number | null`

Reputation score.

**isVerified** `boolean | null`

Whether the user is verified.

**isActive** `boolean | null`

Whether the account is active.

**lastActive** `string | null`

ISO timestamp of last activity.

**suspensions** `array`

Active suspensions on the account.

**avatarFile** `object | null`

Processed avatar file with variants.

**bannerFile** `object | null`

Processed banner file with variants.

**authMethods** `string[]`

List of auth methods (includes `"external"`).

**createdAt** `string`

ISO timestamp of account creation.

## Error Responses

> [accordion] Missing JWT Keys — 403
>
> ```json theme={null}
> {
>   "error": "Missing JWT keys",
>   "code": "auth/missing-keys"
> }
> ```
>
> The project does not have a public key configured.

> [accordion] Invalid Token — 403
>
> ```json theme={null}
> {
>   "error": "Invalid token",
>   "code": "auth/invalid-token"
> }
> ```
>
> The JWT signature is invalid or the token is expired.

> [accordion] Project ID Mismatch — 403
>
> ```json theme={null}
> {
>   "error": "Project ID mismatch",
>   "code": "auth/project-mismatch"
> }
> ```
>
> The `iss` claim in the JWT does not match the request project ID.

> [accordion] Username Already Taken — 409
>
> ```json theme={null}
> {
>   "error": "Username already taken",
>   "field": "username",
>   "code": "DUPLICATE_USERNAME"
> }
> ```

## See Also

* [External Auth guide](https://docs.sublay.io/v7/sdk/authentication/external.md)


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