---
title: "CreateTokenBody"
description: "The `CreateTokenBody` entity."
section: "Reference"
group: "Types"
order: 56
---

## Definition

```ts
interface CreateTokenBody {
  workspaceId: string;
  scopes: {
    operations?: Array<string> | undefined;
    entityIds?: Array<string> | undefined;
  };
  expiresIn: string;
  metadata?: Record<string, unknown> | undefined;
}
```

## Fields

| Field         | Type                                                                                   | Notes                                                             |
| ------------- | -------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| `workspaceId` | `string`                                                                               | `required` — Workspace the new token should be scoped to.         |
| `scopes`      | `{ operations?: Array<string> \| undefined; entityIds?: Array<string> \| undefined; }` | `required` — Operation and entity scopes to enforce on the token. |
| `expiresIn`   | `string`                                                                               | `required` — Duration (e.g. '1h', '30m', '24h')                   |
| `metadata`    | `Record<string, unknown> \| undefined`                                                 | `optional` — User context passed to agents                        |
