---
title: "Function"
description: "The `Function` entity."
section: "Reference"
group: "Types"
order: 98
---

## Definition

```ts
interface Function {
  id: string;
  workspaceId: string | null;
  name: string;
  description: string | null;
  defaultVersionId: string | null;
  source: "custom" | "system" | "openapi-op";
  system: boolean;
  createdBy: string | null;
  runtimeUserId: string | null;
  deletedAt: string | null;
  retentionTier: "short" | "medium" | "long" | "none" | null;
  createdAt: string;
  updatedAt: string;
}
```

## Fields

| Field              | Type                                              | Notes                                                                                                                                                                                                                                  |
| ------------------ | ------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`               | `string`                                          | `readonly` `required`                                                                                                                                                                                                                  |
| `workspaceId`      | `string \| null`                                  | `required` — Workspace that owns this function; null for system functions.                                                                                                                                                             |
| `name`             | `string`                                          | `required` — Human-readable function name.                                                                                                                                                                                             |
| `description`      | `string \| null`                                  | `required` — Optional longer-form description of what the function does.                                                                                                                                                               |
| `defaultVersionId` | `string \| null`                                  | `required` — Version served as the default for agent calls.                                                                                                                                                                            |
| `source`           | `"custom" \| "system" \| "openapi-op"`            | `required` — Where the function's implementation comes from (user-authored, built-in system).                                                                                                                                          |
| `system`           | `boolean`                                         | `required` — True for built-in system functions that cannot be edited or deleted.                                                                                                                                                      |
| `createdBy`        | `string \| null`                                  | `required` — User who created the function; null for system functions.                                                                                                                                                                 |
| `runtimeUserId`    | `string \| null`                                  | `required` — Override the workspace default service user as the runtime caller when this function is invoked headlessly. Null = inherit workspace default. Workspace-admin-only to set; target user must be a member of the workspace. |
| `deletedAt`        | `string \| null`                                  | `required` — ISO-8601 timestamp of soft-delete; null while active. Cleanup worker hard-deletes once `deletedAt + retentionTier.days` passes.                                                                                           |
| `retentionTier`    | `"short" \| "medium" \| "long" \| "none" \| null` | `required` — Retention tier snapshotted at delete time. `short`=7d, `medium`=30d, `long`=90d, `none`=never. Null while active.                                                                                                         |
| `createdAt`        | `string`                                          | `readonly` `required` — ISO-8601 timestamp of creation.                                                                                                                                                                                |
| `updatedAt`        | `string`                                          | `readonly` `required` — ISO-8601 timestamp of the last update.                                                                                                                                                                         |
