---
updatedAt: 2026-06-19T01:27:32.000Z
agentTools:
  projectIndex: https://docs.getsmileapi.com/llms.txt
---

# Tokens

To provide authorized access for your user, your application should first obtain a user token (the **Link token**) by creating or retrieving a Smile User from the `/users` endpoint, which will include the token. This is a single use, short-lived token which is used to initialize our **Wink Widget**.

Time of expiry is included when a token is generated. You may also listen for events from the SDK when the token has expired (see below).

Your server or application should generate a new Link token for the user each time you wish to launch the widget.

## Refreshing a User's Token

After the initial token creation via the `/users` endpoint, you can refresh the user's token by calling the `/tokens` endpoint. Simply pass the `userId` of the user as a parameter in the query to give the user a new token.

## The Token object

| Attribute   | Type      | Description                                                     |
| :---------- | :-------- | :-------------------------------------------------------------- |
| expiresAt   | date-time | Date and time when the issued token will expire                 |
| mode        | string    | Valid mode for the Link token, either `SANDBOX` or `PRODUCTION` |
| accessToken | string    | Short-lived token to initiate link flow                         |

## Sample Token data

```json
{
    "expiresAt": "2022-11-01T09:00:00Z",
    "mode": "SANDBOX",
    "accessToken": "abcdefghijklmnopqrstuvwxyz.ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPPONMLKJIHGFEDCBA.0987654321abcdefghijklmnopqrstuvwxyz.ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPPONMLKJIHGFEDCBA.0987654321abcdefghijklmnopqrstuvwxyz.ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPPONMLKJIHGFEDCBA.0987654321abcdefghijklmnopqrstuvwxyz.ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPPONMLKJIHGFEDCBA.0987654321abcdefghijklmnopqrstuvwxyz.ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPPONMLKJIHGFEDCBA.0987654321abcdefghijklmnopqrstuvwxyz.ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPPONMLKJIHGFEDCBA.0987654321abcdefghijklmnopqrstuvwxyz.ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPPONMLKJIHGFED"
}
```

## Endpoints

| Endpoint                                   |                |
| :----------------------------------------- | :------------- |
| [Refresh token](https://docs.getsmileapi.com/reference/create-token-1) | `POST /tokens` |

## Webhooks

### `USER_CREATED`

Fired when a new user has been created in the Smile Network and their link token is available.

```json
{
    "id": "et-123abc456def789abc123def456abc78",
    "version": 1,
    "type": "USER_CREATED",
    "createdAt": "2021-04-14T09:30:24Z",
    "data": {
        "userId": "tenantId-123abc456def789abc123def456abc78"
    }
}
```

## Event Listeners

The SDK also emits events that can be caught by your native application to allow the application to react and perform functions as needed.

| Callback         | Data | Description                           |
| :--------------- | :--- | :------------------------------------ |
| `onTokenExpired` | -    | Fired when the Link token has expired |