# drive_save

Create or Update Drive

## Beschreibung

Linear-style upsert. Omit `id` to create a new drive in a
workspace (the workspace is the mandatory outer access boundary) in this
account. Access is inherited immediately from that workspace; the drive
creates no separate grant. Pass `id` (drv_…) to rename or re-describe an
existing drive. Account admins may pass `workspace_id` while updating
to move the complete drive. Toggle `archive: true` / `false` to soft-hide
or restore a drive.

Name is unique per workspace (case-insensitive) among active
drives; the DB has a `WHERE archived_at IS NULL` unique index
that enforces it, so trying to reuse a live drive's name
returns a validation error.

Access (DrivePolicy):
- Create: any member of the selected workspace.
- Update / archive: account admin or destination workspace manager.
- Move to another workspace: account admin only.

## Zugriff

Zugriffsprofil: `gated`. Module: `files`.
Die Freigabe im Profil ersetzt keine Account-, Workspace- oder Rollenberechtigung.

## Parameter

| Name | Typ | Pflicht | Beschreibung |
| --- | --- | --- | --- |
| `account_id` | string | Ja |  |
| `id` | string | Nein | Drive prefix ID (drv_…). Omit to create. |
| `workspace_id` | string | Nein | Workspace prefix ID (wsp_…) or key. Required on create; admin-only on update. |
| `name` | string | Nein |  |
| `description` | string / null | Nein |  |
| `archive` | boolean | Nein | true = archive (soft-hide from lists); false = un-archive. Omit to leave archive state unchanged. |

## Eingabeschema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "account_id": {
      "type": "string"
    },
    "id": {
      "type": "string",
      "description": "Drive prefix ID (drv_…). Omit to create."
    },
    "workspace_id": {
      "type": "string",
      "description": "Workspace prefix ID (wsp_…) or key. Required on create; admin-only on update."
    },
    "name": {
      "type": "string",
      "maxLength": 80
    },
    "description": {
      "type": [
        "string",
        "null"
      ]
    },
    "archive": {
      "type": "boolean",
      "description": "true = archive (soft-hide from lists); false = un-archive. Omit to leave archive state unchanged."
    }
  },
  "required": [
    "account_id"
  ],
  "type": "object"
}
```

## Ausgabeschema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "id": {
      "type": "string"
    },
    "workspace_id": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "description": {
      "type": [
        "string",
        "null"
      ]
    },
    "workspace_role": {
      "type": "string",
      "enum": [
        "member",
        "manager"
      ]
    },
    "archived": {
      "type": "boolean"
    },
    "created": {
      "type": "boolean",
      "description": "true iff this call inserted a fresh drive."
    },
    "created_by": {
      "type": "object"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "id",
    "workspace_id",
    "name",
    "description",
    "workspace_role",
    "archived",
    "created",
    "created_by",
    "created_at",
    "updated_at"
  ],
  "type": "object"
}
```
