> For the complete documentation index, see [llms.txt](https://docs.amigo.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.amigo.ai/api-reference/readme/platform/workspace-tables.md).

# Workspace Tables

## GET /v1/{workspace\_id}/tables

> List Workspace Tables

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"servers":[{"url":"https://api.platform.amigo.ai","description":"Production"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"src__routes__workspace_tables__list_workspace_tables__Response":{"properties":{"items":{"items":{"$ref":"#/components/schemas/src__routes__workspace_tables__list_workspace_tables__Response__Item"},"type":"array","title":"Items"}},"type":"object","required":["items"],"title":"Response"},"src__routes__workspace_tables__list_workspace_tables__Response__Item":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"workspace_id":{"type":"string","format":"uuid","title":"Workspace Id"},"table_name":{"type":"string","title":"Table Name"},"physical_name":{"type":"string","title":"Physical Name"},"created_at":{"type":"string","format":"date-time","title":"Created At"}},"type":"object","required":["id","workspace_id","table_name","physical_name","created_at"],"title":"Item"}}},"paths":{"/v1/{workspace_id}/tables":{"get":{"tags":["Workspace Tables"],"summary":"List Workspace Tables","operationId":"list-workspace-tables","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/src__routes__workspace_tables__list_workspace_tables__Response"}}}}},"parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}}]}}}}
```

## POST /v1/{workspace\_id}/tables

> Create Workspace Table

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"servers":[{"url":"https://api.platform.amigo.ai","description":"Production"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"src__routes__workspace_tables__create_workspace_table__Request":{"properties":{"table_name":{"$ref":"#/components/schemas/IdentifierString"},"columns":{"items":{"$ref":"#/components/schemas/Column-Input"},"type":"array","maxItems":100,"minItems":1,"title":"Columns"},"primary_key":{"anyOf":[{"items":{"$ref":"#/components/schemas/IdentifierString"},"type":"array"},{"type":"null"}],"title":"Primary Key"},"unique":{"items":{"items":{"$ref":"#/components/schemas/IdentifierString"},"type":"array","maxItems":32,"minItems":1},"type":"array","title":"Unique"},"indexes":{"items":{"$ref":"#/components/schemas/Index-Input"},"type":"array","title":"Indexes"}},"type":"object","required":["table_name","columns"],"title":"Request"},"IdentifierString":{"type":"string","maxLength":63,"minLength":1,"pattern":"^[a-z][a-z0-9_]{0,62}$"},"Column-Input":{"properties":{"name":{"$ref":"#/components/schemas/IdentifierString"},"type":{"$ref":"#/components/schemas/ColumnType"},"nullable":{"type":"boolean","title":"Nullable","default":true},"default":{"anyOf":[{"$ref":"#/components/schemas/Default"},{"type":"null"}]}},"type":"object","required":["name","type"],"title":"Column"},"ColumnType":{"type":"string","enum":["text","int","bigint","numeric","boolean","uuid","timestamptz","date","time","jsonb","bytea"]},"Default":{"properties":{"kind":{"type":"string","enum":["literal","uuid_v4","now","current_date"],"title":"Kind"},"value":{"anyOf":[{"type":"string"},{"type":"integer"},{"type":"number"},{"type":"boolean"},{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Value","description":"Only meaningful for ``kind=\"literal\"``. Other kinds ignore it.\nA ``dict`` value is rendered as a JSONB literal — pair it with a\n``jsonb`` column."}},"type":"object","required":["kind"],"title":"Default"},"Index-Input":{"properties":{"columns":{"items":{"$ref":"#/components/schemas/IdentifierString"},"type":"array","maxItems":32,"minItems":1,"title":"Columns"}},"type":"object","required":["columns"],"title":"Index"},"src__routes__workspace_tables__create_workspace_table__Response":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"workspace_id":{"type":"string","format":"uuid","title":"Workspace Id"},"table_name":{"type":"string","title":"Table Name"},"physical_name":{"type":"string","title":"Physical Name"}},"type":"object","required":["id","workspace_id","table_name","physical_name"],"title":"Response"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v1/{workspace_id}/tables":{"post":{"tags":["Workspace Tables"],"summary":"Create Workspace Table","operationId":"create-workspace-table","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/src__routes__workspace_tables__create_workspace_table__Request"}}},"required":true},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/src__routes__workspace_tables__create_workspace_table__Response"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}}]}}}}
```

## GET /v1/{workspace\_id}/tables/{table\_id}

> Get Workspace Table

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"servers":[{"url":"https://api.platform.amigo.ai","description":"Production"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"src__routes__workspace_tables__get_workspace_table__Response":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"workspace_id":{"type":"string","format":"uuid","title":"Workspace Id"},"table_name":{"type":"string","title":"Table Name"},"physical_name":{"type":"string","title":"Physical Name"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"columns":{"items":{"$ref":"#/components/schemas/Column-Output"},"type":"array","title":"Columns"},"indexes":{"items":{"$ref":"#/components/schemas/Index-Output"},"type":"array","title":"Indexes"},"constraints":{"items":{"$ref":"#/components/schemas/Constraint"},"type":"array","title":"Constraints"}},"type":"object","required":["id","workspace_id","table_name","physical_name","created_at","columns","indexes","constraints"],"title":"Response"},"Column-Output":{"properties":{"name":{"type":"string","title":"Name"},"data_type":{"type":"string","title":"Data Type","description":"Postgres-side type as reported by ``information_schema.columns``\n(e.g. ``uuid``, ``text``, ``timestamp with time zone``)."},"is_nullable":{"type":"boolean","title":"Is Nullable"},"default":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Default","description":"Postgres-side default expression text, or NULL if no DEFAULT."}},"type":"object","required":["name","data_type","is_nullable","default"],"title":"Column"},"Index-Output":{"properties":{"name":{"type":"string","title":"Name"},"definition":{"type":"string","title":"Definition","description":"``pg_indexes.indexdef`` — the full CREATE INDEX statement."}},"type":"object","required":["name","definition"],"title":"Index"},"Constraint":{"properties":{"name":{"type":"string","title":"Name"},"definition":{"type":"string","title":"Definition","description":"``pg_get_constraintdef(oid)`` — the postgres-rendered definition."}},"type":"object","required":["name","definition"],"title":"Constraint"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v1/{workspace_id}/tables/{table_id}":{"get":{"tags":["Workspace Tables"],"summary":"Get Workspace Table","operationId":"get-workspace-table","parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}},{"name":"table_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Table Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/src__routes__workspace_tables__get_workspace_table__Response"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## DELETE /v1/{workspace\_id}/tables/{table\_id}

> Delete Workspace Table

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"servers":[{"url":"https://api.platform.amigo.ai","description":"Production"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v1/{workspace_id}/tables/{table_id}":{"delete":{"tags":["Workspace Tables"],"summary":"Delete Workspace Table","operationId":"delete-workspace-table","parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}},{"name":"table_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Table Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## PATCH /v1/{workspace\_id}/tables/{table\_id}

> Update Workspace Table

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"servers":[{"url":"https://api.platform.amigo.ai","description":"Production"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"src__routes__workspace_tables__update_workspace_table__Request":{"properties":{"actions":{"items":{"oneOf":[{"$ref":"#/components/schemas/AlterAction"}],"discriminator":{"propertyName":"op","mapping":{"add_column":"#/components/schemas/AlterAction","add_index":"#/components/schemas/AlterAction","add_unique":"#/components/schemas/AlterAction","change_column_type":"#/components/schemas/AlterAction","drop_column":"#/components/schemas/AlterAction","drop_column_default":"#/components/schemas/AlterAction","drop_constraint":"#/components/schemas/AlterAction","drop_index":"#/components/schemas/AlterAction","rename_column":"#/components/schemas/AlterAction","set_column_default":"#/components/schemas/AlterAction","set_column_nullable":"#/components/schemas/AlterAction"}}},"type":"array","maxItems":50,"minItems":1,"title":"Actions"}},"type":"object","required":["actions"],"title":"Request"},"AlterAction":{"anyOf":[{"$ref":"#/components/schemas/AddColumnAction"},{"$ref":"#/components/schemas/DropColumnAction"},{"$ref":"#/components/schemas/RenameColumnAction"},{"$ref":"#/components/schemas/ChangeColumnTypeAction"},{"$ref":"#/components/schemas/SetColumnNullableAction"},{"$ref":"#/components/schemas/SetColumnDefaultAction"},{"$ref":"#/components/schemas/DropColumnDefaultAction"},{"$ref":"#/components/schemas/AddUniqueAction"},{"$ref":"#/components/schemas/DropConstraintAction"},{"$ref":"#/components/schemas/AddIndexAction"},{"$ref":"#/components/schemas/DropIndexAction"}]},"AddColumnAction":{"properties":{"op":{"type":"string","const":"add_column","title":"Op"},"column":{"$ref":"#/components/schemas/Column-Input"}},"type":"object","required":["op","column"],"title":"AddColumnAction"},"Column-Input":{"properties":{"name":{"$ref":"#/components/schemas/IdentifierString"},"type":{"$ref":"#/components/schemas/ColumnType"},"nullable":{"type":"boolean","title":"Nullable","default":true},"default":{"anyOf":[{"$ref":"#/components/schemas/Default"},{"type":"null"}]}},"type":"object","required":["name","type"],"title":"Column"},"IdentifierString":{"type":"string","maxLength":63,"minLength":1,"pattern":"^[a-z][a-z0-9_]{0,62}$"},"ColumnType":{"type":"string","enum":["text","int","bigint","numeric","boolean","uuid","timestamptz","date","time","jsonb","bytea"]},"Default":{"properties":{"kind":{"type":"string","enum":["literal","uuid_v4","now","current_date"],"title":"Kind"},"value":{"anyOf":[{"type":"string"},{"type":"integer"},{"type":"number"},{"type":"boolean"},{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Value","description":"Only meaningful for ``kind=\"literal\"``. Other kinds ignore it.\nA ``dict`` value is rendered as a JSONB literal — pair it with a\n``jsonb`` column."}},"type":"object","required":["kind"],"title":"Default"},"DropColumnAction":{"properties":{"op":{"type":"string","const":"drop_column","title":"Op"},"name":{"$ref":"#/components/schemas/IdentifierString"}},"type":"object","required":["op","name"],"title":"DropColumnAction"},"RenameColumnAction":{"properties":{"op":{"type":"string","const":"rename_column","title":"Op"},"from":{"$ref":"#/components/schemas/IdentifierString"},"to":{"$ref":"#/components/schemas/IdentifierString"}},"type":"object","required":["op","from","to"],"title":"RenameColumnAction"},"ChangeColumnTypeAction":{"properties":{"op":{"type":"string","const":"change_column_type","title":"Op"},"name":{"$ref":"#/components/schemas/IdentifierString"},"new_type":{"$ref":"#/components/schemas/ColumnType"}},"type":"object","required":["op","name","new_type"],"title":"ChangeColumnTypeAction"},"SetColumnNullableAction":{"properties":{"op":{"type":"string","const":"set_column_nullable","title":"Op"},"name":{"$ref":"#/components/schemas/IdentifierString"},"nullable":{"type":"boolean","title":"Nullable"}},"type":"object","required":["op","name","nullable"],"title":"SetColumnNullableAction"},"SetColumnDefaultAction":{"properties":{"op":{"type":"string","const":"set_column_default","title":"Op"},"name":{"$ref":"#/components/schemas/IdentifierString"},"default":{"$ref":"#/components/schemas/Default"}},"type":"object","required":["op","name","default"],"title":"SetColumnDefaultAction"},"DropColumnDefaultAction":{"properties":{"op":{"type":"string","const":"drop_column_default","title":"Op"},"name":{"$ref":"#/components/schemas/IdentifierString"}},"type":"object","required":["op","name"],"title":"DropColumnDefaultAction"},"AddUniqueAction":{"properties":{"op":{"type":"string","const":"add_unique","title":"Op"},"columns":{"items":{"$ref":"#/components/schemas/IdentifierString"},"type":"array","maxItems":32,"minItems":1,"title":"Columns"},"constraint_name":{"anyOf":[{"$ref":"#/components/schemas/IdentifierString"},{"type":"null"}]}},"type":"object","required":["op","columns"],"title":"AddUniqueAction"},"DropConstraintAction":{"properties":{"op":{"type":"string","const":"drop_constraint","title":"Op"},"name":{"$ref":"#/components/schemas/IdentifierString"}},"type":"object","required":["op","name"],"title":"DropConstraintAction"},"AddIndexAction":{"properties":{"op":{"type":"string","const":"add_index","title":"Op"},"index_name":{"$ref":"#/components/schemas/IdentifierString"},"columns":{"items":{"$ref":"#/components/schemas/IdentifierString"},"type":"array","maxItems":32,"minItems":1,"title":"Columns"}},"type":"object","required":["op","index_name","columns"],"title":"AddIndexAction"},"DropIndexAction":{"properties":{"op":{"type":"string","const":"drop_index","title":"Op"},"index_name":{"$ref":"#/components/schemas/IdentifierString"}},"type":"object","required":["op","index_name"],"title":"DropIndexAction"},"src__routes__workspace_tables__update_workspace_table__Response":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"workspace_id":{"type":"string","format":"uuid","title":"Workspace Id"},"table_name":{"type":"string","title":"Table Name"},"physical_name":{"type":"string","title":"Physical Name"}},"type":"object","required":["id","workspace_id","table_name","physical_name"],"title":"Response"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v1/{workspace_id}/tables/{table_id}":{"patch":{"tags":["Workspace Tables"],"summary":"Update Workspace Table","operationId":"update-workspace-table","parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}},{"name":"table_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Table Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/src__routes__workspace_tables__update_workspace_table__Request"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/src__routes__workspace_tables__update_workspace_table__Response"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## POST /v1/{workspace\_id}/query

> Execute Workspace Query

```json
{"openapi":"3.1.0","info":{"title":"Platform API","version":"1.0.0"},"servers":[{"url":"https://api.platform.amigo.ai","description":"Production"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key issued via `POST /v1/{workspace_id}/api-keys`. Pass the returned `api_key` value as a Bearer token."}},"schemas":{"src__routes__workspace_tables__execute_workspace_query__Request":{"properties":{"sql":{"type":"string","maxLength":16384,"minLength":1,"title":"Sql","description":"One SQL statement: SELECT / WITH ... SELECT / INSERT / UPDATE /\nDELETE. Multi-statement, DDL, and session-state commands (SET ROLE,\nRESET, SET SESSION AUTHORIZATION) reject with 422 at the Pydantic\nboundary. ``pg_*`` function calls reject with 400 at execute time\n(no grant)."}},"type":"object","required":["sql"],"title":"Request"},"src__routes__workspace_tables__execute_workspace_query__Response":{"properties":{"columns":{"items":{"type":"string"},"type":"array","title":"Columns"},"rows":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Rows"},"row_count":{"type":"integer","title":"Row Count"}},"type":"object","required":["columns","rows","row_count"],"title":"Response"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v1/{workspace_id}/query":{"post":{"tags":["Workspace Tables"],"summary":"Execute Workspace Query","operationId":"execute-workspace-query","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/src__routes__workspace_tables__execute_workspace_query__Request"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/src__routes__workspace_tables__execute_workspace_query__Response"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Workspace Id"}}]}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.amigo.ai/api-reference/readme/platform/workspace-tables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
