Client Tokens

Client tokens allows you to interact with the Metorial API on behalf of a user.

Client tokens should be generated by your server and then sent to the client. The client can then use the token to make requests to the Metorial API.

What you will learn

How to generate client tokens

How to use client tokens in requests

Before you begin

Generating Client Tokens

You can create client tokens by signing a JWT using the JWK provided in the Metorial dashboard or the GET /jwks endpoint. The JWT payload should include the following:

1{
2 "sub": "user_id",
3 "exp": 1609459200,
4 "iat": 1609455600
5}
  • sub: The unique user ID. A new user is created if the ID is not already registered.
  • exp: Expiration time (Unix epoch, seconds).
  • iat: Token issuance time (Unix epoch, seconds).

The JWT must be signed using the RSA algorithm with the JWK provided in the dashboard or GET /jwks endpoint.

Using Client Tokens

When using a client token, include the Publishable API Key in the Authorization header:

Authorization: Bearer metorial_pk_abc123

Add the client token as a query parameter in the request URL:

GET /threads?client_token=eyJhbGc...