> Source: https://wexa.ai/docs/data-tables/create-table

# create-table

[Can be held for approval](/docs/sdks-and-apis/how-every-tool-call-works#lifecycle-and-governance)

Create a Data Table with its columns in one call. Returns the `table_id`, and creates a connector backing the table. Needs the `fabric:table.write` grant.

**Create a table**

**Wexa MCP server**

```bash
curl -sS -X POST https://fabric.wexa.ai/mcp/$FABRIC_PROJECT_ID \
  -H "authorization: Bearer $FABRIC_API_KEY" \
  -H "Mcp-Session-Id: $MCP_SESSION_ID" \
  -H "content-type: application/json" -H "accept: application/json" \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"create-table","arguments":{"table_name":"docs_fixture_scratch_1790023297425","columns":[{"column_name":"c1","column_type":"String"}]}}}'
```

```json
{
  "content": [
    {
      "type": "text",
      "text": "{\"lifecycle_id\":\"qlc_000201\",\"result\":{\"table_id\":\"6ab196817566f41b5c28e31f\",\"table_name\":\"docs_fixture_scratch_1790023297425\",\"connector_id\":\"6ab196817566f41b5c28e320\",\"columns\":[{\"column_id\":\"6ab19681c1a2f4b14e62e635\",\"column_name\":\"c1\",\"column_type\":\"String\"}]}}"
    }
  ],
  "isError": false
}
```

**REST API**

```bash
curl -sS https://fabric.wexa.ai/v1/create-table \
  -H "authorization: Bearer $FABRIC_API_KEY" \
  -H "content-type: application/json" \
  -d '{"table_name":"docs_fixture_scratch_1790023297425","columns":[{"column_name":"c1","column_type":"String"}]}'
```

```json
{
  "lifecycle_id": "qlc_000201",
  "result": {
    "table_id": "6ab196817566f41b5c28e31f",
    "table_name": "docs_fixture_scratch_1790023297425",
    "connector_id": "6ab196817566f41b5c28e320",
    "columns": [
      {
        "column_id": "6ab19681c1a2f4b14e62e635",
        "column_name": "c1",
        "column_type": "String"
      }
    ]
  }
}
```

**TypeScript SDK**

```ts
import { Fabric } from '@wexa-fabric/sdk'

const fabric = new Fabric()
const result = await fabric.createTable({
  table_name: 'docs_fixture_scratch_1790023297425',
  columns: [{ column_name: 'c1', column_type: 'String' }]
})
```

```ts
// result is the payload itself, with no `.result` to read
{
  table_id: '6ab196817566f41b5c28e31f',
  table_name: 'docs_fixture_scratch_1790023297425',
  connector_id: '6ab196817566f41b5c28e320',
  columns: [
    {
      column_id: '6ab19681c1a2f4b14e62e635',
      column_name: 'c1',
      column_type: 'String'
    }
  ]
}
```

**Python SDK**

```python
from wexa import Fabric

fabric = Fabric()
out = fabric.create_table(
    table_name="docs_fixture_scratch_1790023297425",
    columns=[{"column_name": "c1", "column_type": "String"}],
)
```

```python
# out is the result, already unwrapped
{
    "table_id": "6ab196817566f41b5c28e31f",
    "table_name": "docs_fixture_scratch_1790023297425",
    "connector_id": "6ab196817566f41b5c28e320",
    "columns": [
        {
            "column_id": "6ab19681c1a2f4b14e62e635",
            "column_name": "c1",
            "column_type": "String"
        }
    ]
}
```

## Parameters

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `table_name` | string | Required | Name of the new table. Non-empty. |
| `columns` | array | Required | At least one column, each `{"column_name": "email", "column_type": "String"}`. `column_type` is e.g. String, Number, Boolean, Date, Array, Object or Enum. Array also needs `array_type`; Object needs `object_fields`. Optional per column: `default_value`, `enum_options`. |

**Show full response**

A real response, captured from a live call to `create-table`:

**Result of create-table**

**REST API**

```json
{
  "lifecycle_id": "qlc_000201",
  "result": {
    "columns": [
      {
        "array_type": null,
        "column_id": "_id",
        "column_name": "_id",
        "column_type": "string",
        "default_value": "",
        "enum_options": null,
        "has_triggers": false,
        "object_fields": null
      },
      {
        "array_type": null,
        "column_id": "row_id",
        "column_name": "Row ID",
        "column_type": "number",
        "default_value": 1,
        "enum_options": null,
        "has_triggers": false,
        "object_fields": null
      },
      {
        "array_type": null,
        "column_id": "coworker_user_id",
        "column_name": "User ID",
        "column_type": "string",
        "default_value": "",
        "enum_options": null,
        "has_triggers": false,
        "object_fields": null
      },
      {
        "array_type": null,
        "column_id": "6ab19681c1a2f4b14e62e635",
        "column_name": "c1",
        "column_type": "String",
        "default_value": null,
        "enum_options": null,
        "has_triggers": false,
        "object_fields": null
      }
    ],
    "connector_id": "6ab196817566f41b5c28e320",
    "table_id": "6ab196817566f41b5c28e31f",
    "table_name": "docs_fixture_scratch_1790023297425",
    "trigger_count": 0
  }
}
```

**TypeScript SDK**

```ts
// the object you get back IS the result — there is no `.result` to read
{
  columns: [
    {
      array_type: null,
      column_id: '_id',
      column_name: '_id',
      column_type: 'string',
      default_value: '',
      enum_options: null,
      has_triggers: false,
      object_fields: null
    },
    {
      array_type: null,
      column_id: 'row_id',
      column_name: 'Row ID',
      column_type: 'number',
      default_value: 1,
      enum_options: null,
      has_triggers: false,
      object_fields: null
    },
    {
      array_type: null,
      column_id: 'coworker_user_id',
      column_name: 'User ID',
      column_type: 'string',
      default_value: '',
      enum_options: null,
      has_triggers: false,
      object_fields: null
    },
    {
      array_type: null,
      column_id: '6ab19681c1a2f4b14e62e635',
      column_name: 'c1',
      column_type: 'String',
      default_value: null,
      enum_options: null,
      has_triggers: false,
      object_fields: null
    }
  ],
  connector_id: '6ab196817566f41b5c28e320',
  table_id: '6ab196817566f41b5c28e31f',
  table_name: 'docs_fixture_scratch_1790023297425',
  trigger_count: 0
}

// The TS SDK names these camelCase — lifecycleId, traceId — where Python uses
// lifecycle_id and trace_id. Both are non-enumerable: readable, but omitted by
// Object.keys() and JSON.stringify(). `result.lifecycleId` here is undefined.
result.lifecycleId // 'qlc_000201'
```

**Python SDK**

```python
# a dict subclass; `result` is already unwrapped
{
 "columns": [
  {
   "array_type": None,
   "column_id": "_id",
   "column_name": "_id",
   "column_type": "string",
   "default_value": "",
   "enum_options": None,
   "has_triggers": False,
   "object_fields": None
  },
  {
   "array_type": None,
   "column_id": "row_id",
   "column_name": "Row ID",
   "column_type": "number",
   "default_value": 1,
   "enum_options": None,
   "has_triggers": False,
   "object_fields": None
  },
  {
   "array_type": None,
   "column_id": "coworker_user_id",
   "column_name": "User ID",
   "column_type": "string",
   "default_value": "",
   "enum_options": None,
   "has_triggers": False,
   "object_fields": None
  },
  {
   "array_type": None,
   "column_id": "6ab19681c1a2f4b14e62e635",
   "column_name": "c1",
   "column_type": "String",
   "default_value": None,
   "enum_options": None,
   "has_triggers": False,
   "object_fields": None
  }
 ],
 "connector_id": "6ab196817566f41b5c28e320",
 "table_id": "6ab196817566f41b5c28e31f",
 "table_name": "docs_fixture_scratch_1790023297425",
 "trigger_count": 0
}

out.lifecycle_id  # 'qlc_000201' — an attribute, not a key
```

**More details**

The connector is created with the table, and `delete-table` removes it. See [Connectors](/docs/connectors/overview) for what a connector is.

`columns` in the result also lists the columns Wexa adds itself: `_id`, `row_id` and a user id column, each with a `column_id` equal to its name. `get-table` shows every column's `column_id`, so read it from your own call. Rows may be keyed by `column_id` or `column_name`.

Every tool call works the same way: [How every tool call works](/docs/sdks-and-apis/how-every-tool-call-works).
