PermuteDocs
Go to Permute

Databases · databaseDefinitionSave

Save a database schema draft

Requires database admin permission. Table schemas are one revision; actions are independent resources. History, restore, and publish use the existing resource versioning routes.

PUT/v1/databases/{databaseId}/definition
betaapiKeyworkspace

When to use

Save managed table schemas as one draft revision.

For agents

Requires database admin permission. Publish through client.revisions after reading its current version token. Author business actions separately through client.actions and bind them to the published schema revision.

Example

typescript
import { PermuteClient } from '@permute/sdk';

const orgClient = new PermuteClient({
  apiKey: process.env.PERMUTE_API_KEY!,
});

const client = orgClient.withWorkspace(process.env.PERMUTE_WORKSPACE_ID!);

const result = await client.databases.saveDefinition('dbas_crm123', {
  "expectedDraft": null,
  "definition": {
    "tables": [
      {
        "name": "customers",
        "columns": [
          {
            "name": "id",
            "type": "text",
            "nullable": false
          },
          {
            "name": "name",
            "type": "text",
            "nullable": false
          }
        ],
        "primaryKey": [
          "id"
        ]
      }
    ]
  }
});

Request body

json
{
  "expectedDraft": null,
  "definition": {
    "tables": [
      {
        "name": "customers",
        "columns": [
          {
            "name": "id",
            "type": "text",
            "nullable": false
          },
          {
            "name": "name",
            "type": "text",
            "nullable": false
          }
        ],
        "primaryKey": [
          "id"
        ]
      }
    ]
  }
}

Response

json
{
  "data": {
    "revisionId": "rvsn_database1"
  }
}