PermuteDocs
Go to Permute

Databases · databaseTablesCreate

Add a table to the database schema draft

Requires admin permission. Save the table in a draft and publish the database definition to create it.

POST/v1/databases/{databaseId}/tables
betaapiKeyworkspace

When to use

Add a typed table to the database application draft.

For agents

Requires admin permission. Publish the database definition through client.revisions to create the live table. Primary keys must be non-nullable scalar columns.

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.createTable('dbas_crm123', {
  "name": "customers",
  "columns": [
    {
      "name": "id",
      "type": "text",
      "nullable": false
    },
    {
      "name": "name",
      "type": "text",
      "nullable": false
    }
  ],
  "primaryKey": [
    "id"
  ]
});

Request body

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

Response

json
{
  "data": {
    "name": "customers",
    "revisionId": "rvsn_database1"
  }
}