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

Open in Claude
Open in ChatGPT

Create token (Cloud-only)

access_tokens.create(AccessTokenCreateParams**kwargs) -> AccessTokenCreateResponse
post/v1/client-side-access-tokens

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

ParametersExpand Collapse
hostname: str

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

formaturi
policy: Iterable[Policy]
id: str
access: List[Literal["read_messages", "write_messages", "read_agent", "write_agent"]]
Accepts one of the following:
"read_messages"
"write_messages"
"read_agent"
"write_agent"
type: Literal["agent"]
Accepts one of the following:
"agent"
expires_at: Optional[str]

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

ReturnsExpand Collapse
class AccessTokenCreateResponse:
token: str
expires_at: str
hostname: str
policy: Policy
data: List[PolicyData]
id: str
access: List[Literal["read_messages", "write_messages", "read_agent", "write_agent"]]
Accepts one of the following:
"read_messages"
"write_messages"
"read_agent"
"write_agent"
type: Literal["agent"]
Accepts one of the following:
"agent"
version: Literal["1"]
Accepts one of the following:
"1"
Create token (Cloud-only)
from letta_client import Letta

client = Letta(
    api_key="My API Key",
)
access_token = client.access_tokens.create(
    hostname="https://example.com",
    policy=[{
        "id": "id",
        "access": ["read_messages"],
        "type": "agent",
    }],
)
print(access_token.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"
  }
}