> For the complete documentation index, see [llms.txt](https://docs.userlane.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.userlane.com/deployment/rollout/the-userlane-snippet/use-a-client-token.md). Agents can also search and read this documentation through its [MCP server](https://docs.userlane.com/~gitbook/mcp).

# Use a client token

How to turn on snippet authentication so Userlane only answers requests that carry your application's client token.

Turn on snippet authentication[^1] so Userlane loads content only for requests that carry your application's client token[^2].

{% hint style="info" %}
**Not the API token.** The client token secures the snippet. The [Userlane API token](https://docs.userlane.com/developer-reference/your-userlane-api-token.md) under Settings > API Token is a separate credential for exporting and importing data.
{% endhint %}

{% hint style="warning" %}
**Before you start.** You need admin rights in the Userlane Portal, the snippet installed in the application, and a developer who can change its code.
{% endhint %}

## How it works

Snippet authentication is optional and off by default. You turn it on per application, so each application can have its own token. You choose the token, save it in the Portal, and pass the same value in the snippet. Once it is on, Userlane checks the token before it loads content or processes user data, and rejects requests without a valid one. The token works alongside the property ID and confirms that a request comes from your application, but it doesn't identify individual users.

## Turn it on

The toggle goes on last, because from that moment Userlane rejects every request without the token.

{% stepper %}
{% step %}

#### Save a token (admin)

In **Settings > Application Settings > Snippet Setup**, enter a token in the authentication token section and save it.
{% endstep %}

{% step %}

#### Add the token to the snippet (developer)

```javascript
Userlane('init', 'property_ID', { clientToken: 'your_token' });
```

{% endstep %}

{% step %}

#### Deploy the change (developer)

Release the updated code to production.
{% endstep %}

{% step %}

#### Turn on authentication (admin)

In Snippet Setup, turn on snippet authentication.
{% endstep %}
{% endstepper %}

{% hint style="success" %}
**Result.** Userlane loads as before for your users, and requests without the token get no content.
{% endhint %}

## Keep the token safe

Store the token in a secure configuration store, not in a public code repository, and never write it to logs or other unsecured places. To change it, turn authentication off, save and deploy the new token, then turn authentication on again.

## Troubleshooting

| Problem                                                       | Cause                                                                                                 | Fix                                                                                                      |
| ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| Userlane stopped appearing after authentication was turned on | The token is missing from `init`, differs from the saved one, or the toggle went on before deployment | Turn authentication off, compare the token in the code with Snippet Setup, deploy, then turn it on again |
| Userlane works in one application but not another             | Tokens are set per application                                                                        | Use the token saved for that application                                                                 |

## Related articles

{% content-ref url="/pages/JxxDQNfBXhCBW2L8uKRW" %}
[Install the snippet](https://docs.userlane.com/deployment/rollout/the-userlane-snippet.md)
{% endcontent-ref %}

{% content-ref url="/pages/TcXdqgybeGLnS1EODhcN" %}
[Your Userlane API token](https://docs.userlane.com/developer-reference/your-userlane-api-token.md)
{% endcontent-ref %}

## FAQ

<details>

<summary>Is the client token required?</summary>

No. Snippet authentication is off by default.

</details>

<details>

<summary>Can each application have its own client token?</summary>

Yes. Client tokens are set per application.

</details>

<details>

<summary>Does the client token replace the property ID?</summary>

No. The client token works alongside the property ID.

</details>

<details>

<summary>Is the client token the same as the Userlane API token?</summary>

No. The Userlane API token authenticates data export and import requests, not the snippet.

</details>

[^1]: Snippet authentication is a per-application setting that makes Userlane reject snippet requests without a valid client token.

[^2]: A client token is a value you choose, save in the Userlane Portal, and pass in the snippet's `init` command.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.userlane.com/deployment/rollout/the-userlane-snippet/use-a-client-token.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
