---
sidebar:
  hidden: true
title: roboto.domain.tokens.record
---
## Module Contents

### TokenContext

```python
class roboto.domain.tokens.record.TokenContext(/, **data: Any)
```

`from roboto.domain.tokens import TokenContext`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/tokens/record.py#L15-L47)

Bases: `pydantic.BaseModel`

Details of a personal access token other than its secret and owner: its name, lifetime, scopes, and state.

Carried in `TokenRecord.context`.

**Parameters**

- **data** (`Any`)

**Attributes**

- **TokenContext.api_scopes** (`set[roboto.auth.scope.ApiScope]`): API scopes the token holds, which limit the requests it can authenticate.

  A token created without scopes holds every scope.

- **TokenContext.description** (`str | None`) = `None`: Human-readable description of the token, or `None` if it has none.

- **TokenContext.enabled** (`bool`) = `True`: Whether the token can authenticate requests. Roboto rejects a request made with a disabled token.

- **TokenContext.expires** (`datetime.datetime`): Time the token expires, after which it no longer authenticates requests.

- **TokenContext.last_used** (`datetime.datetime | None`) = `None`: Time the token last authenticated a request, or `None` if it never has.

  Roboto records a use only when the recorded time is at least an hour old, so this can be up to an hour behind the token's latest use.

- **TokenContext.name** (`str`): Human-readable name of the token.

- **TokenContext.token_id** (`str`): Unique ID of the token, beginning with `to_`.

### TokenRecord

```python
class roboto.domain.tokens.record.TokenRecord(/, **data: Any)
```

`from roboto.domain.tokens import TokenRecord`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/tokens/record.py#L50-L70)

Bases: `pydantic.BaseModel`

Data record of a personal access token, as the Roboto API returns it.

A personal access token authenticates requests to Roboto as the user who owns it. [`Token`](/docs/reference/python-sdk/roboto/domain/tokens/token#roboto.domain.tokens.token.Token) wraps this record with methods that act on the token, and exposes it as [`record`](/docs/reference/python-sdk/roboto/domain/tokens/token#roboto.domain.tokens.token.Token.record).

**Parameters**

- **data** (`Any`)

**Attributes**

- **TokenRecord.context** (`TokenContext | None`) = `None`: Details of the token other than its secret and owner.

- **TokenRecord.secret** (`str | None`) = `None`: Secret value that authenticates requests, or `None` in every response except the one that creates the token.

  Roboto does not store the secret, so it returns it once: from [`create()`](/docs/reference/python-sdk/roboto/domain/tokens/token#roboto.domain.tokens.token.Token.create) or [`create_token()`](/docs/reference/python-sdk/roboto/domain/devices/device#roboto.domain.devices.device.Device.create_token). A lost secret cannot be recovered; delete the token and create another.

- **TokenRecord.user_id** (`str | None`) = `None`: ID of the user who owns the token, which for a person is their email address.
