Database Table by Name
https://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/tables/table_name
This endpoint provides a way to mutate a specific table on a database.
Expected Parameters
Name | Description | In | Required | Schema |
---|---|---|---|---|
db_branch_name | The DBBranchName matches the pattern `{db_name}:{branch_name}`. | path | ✅ | string |
table_name | The Table name | path | ✅ | string |
Create Table
PUThttps://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/tables/table_name
Creates a new table with the given name. Returns 422 if a table with the same name already exists.
Status Code | Description | Example Response/Type Definition |
---|---|---|
201 | Created |
|
204 | No Content | |
400 | Bad Request |
|
401 | Authentication Error |
|
404 | Example response |
|
422 | Example response |
|
5XX | Unexpected Error |
Delete Table
DELETEhttps://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/tables/table_name
Deletes the table with the given name.
Status Code | Description | Example Response/Type Definition |
---|---|---|
200 | OK |
|
400 | Bad Request |
|
401 | Authentication Error |
|
404 | Not Found | |
5XX | Unexpected Error |
Update Table
PATCHhttps://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/tables/table_name
Update table. Currently there is only one update operation supported: renaming the table by providing a new name.
In the example below, we rename a table from “users” to “people”:
1 2 3 4 5
// PATCH /db/test:main/tables/users { "name": "people" }
Request Body Type Definition
1 2 3 4 5 6
type UpdateTable = { /* * @minLength 1 */ name: string; };
Status Code | Description | Example Response/Type Definition |
---|---|---|
200 | Schema migration response with ID and migration status. |
|
400 | Bad Request |
|
401 | Authentication Error |
|
404 | Example response |
|
422 | Example response |
|
5XX | Unexpected Error |