Skip to content
  • Auto
  • Light
  • Dark
DiscordForumGitHubSign up
View as Markdown
Copy Markdown

Open in Claude
Open in ChatGPT

Create token (Cloud-only)

client.accessTokens.create(AccessTokenCreateParams { hostname, policy, expires_at } body, RequestOptionsoptions?): AccessTokenCreateResponse { token, expiresAt, hostname, policy }
post/v1/client-side-access-tokens

Create a new client side access token with the specified configuration.

ParametersExpand Collapse
body: AccessTokenCreateParams { hostname, policy, expires_at }
hostname: string

The hostname of the client side application. Please specify the full URL including the protocol (http or https).

formaturi
policy: Array<Policy>
id: string
access: Array<"read_messages" | "write_messages" | "read_agent" | "write_agent">
Accepts one of the following:
"read_messages"
"write_messages"
"read_agent"
"write_agent"
type: "agent"
Accepts one of the following:
"agent"
expires_at?: string

The expiration date of the token. If not provided, the token will expire in 5 minutes

ReturnsExpand Collapse
AccessTokenCreateResponse { token, expiresAt, hostname, policy }
token: string
expiresAt: string
hostname: string
policy: Policy { data, version }
data: Array<Data>
id: string
access: Array<"read_messages" | "write_messages" | "read_agent" | "write_agent">
Accepts one of the following:
"read_messages"
"write_messages"
"read_agent"
"write_agent"
type: "agent"
Accepts one of the following:
"agent"
version: "1"
Accepts one of the following:
"1"
Create token (Cloud-only)
import Letta from '@letta-ai/letta-client';

const client = new Letta({
  apiKey: 'My API Key',
});

const accessToken = await client.accessTokens.create({
  hostname: 'https://example.com',
  policy: [{ id: 'id', access: ['read_messages'], type: 'agent' }],
});

console.log(accessToken.token);
{
  "token": "token",
  "expiresAt": "expiresAt",
  "hostname": "hostname",
  "policy": {
    "data": [
      {
        "id": "id",
        "access": [
          "read_messages"
        ],
        "type": "agent"
      }
    ],
    "version": "1"
  }
}
Returns Examples
{
  "token": "token",
  "expiresAt": "expiresAt",
  "hostname": "hostname",
  "policy": {
    "data": [
      {
        "id": "id",
        "access": [
          "read_messages"
        ],
        "type": "agent"
      }
    ],
    "version": "1"
  }
}