---
title: "Generate an app schema"
method: POST
path: "/v1/workspaces/{workspace_id}/helpers/generate-app-schema"
tags: ["App schema"]
---

# Generate an app schema

`POST /v1/workspaces/{workspace_id}/helpers/generate-app-schema`

## Request

- Base URL: `https://api.stacksync.com`
- URL: `https://api.stacksync.com/v1/workspaces/{workspace_id}/helpers/generate-app-schema`
- Auth: HTTP bearer

Read the tables of a connection and the columns of the tables named, so a sync can be built from exact table and column names. The credentials are read from the connection, never sent. Readable with a read-only key.

## Path parameters

- `workspace_id` integer, required

## Query parameters

- `region` 'besg' | 'usnv', required

## Request body

- GenerateAppSchemaBody: The connection to read, and the tables to read the columns of
  - `connection_id` string, uuid, required: The connection to read the schema through
  - `table_names` string[]: The tables to read the columns of, by `table_name` or `table_id` exactly as the schema lists them; the answer lists every table but fills `columns` for these only

## Response `200`

The tables of the app, with the columns of the tables named

- AppSchema: The tables and columns Stacksync can read through a connection
  - `app_type` string, required: The app of the connection, as shown in Stacksync
  - `can_create_tables` boolean, required: Whether a sync may create a new table in this app (`table_options.create_new_table: true`)
  - `tables` AppSchemaTable[], required: Every table of the app
    - `table_name` string, required: The name of the table in the app: the value to send as `table_name` when creating a sync (its id is accepted too)
    - `table_id` string, required: The id of the table in the app, when the app has one apart from the name (BigQuery: `project.dataset.table`)
    - `table_options` AppSchemaTableOptions, required: The options of a table of the app
      - `primary_key` AppSchemaPrimaryKey: The primary key of a table
        - `column_name` string: The name of the primary key column
        - `column_type` string: The Stacksync type of the column (for example `string`, `int`, `uuid`, `datetime`)
    - `columns` AppSchemaColumn[], required: The columns of the table; only filled for the tables named in `table_names`, empty for the others
      - `column_name` string, required: The name of the column in the app: the value to send as `column_name` when creating a sync
      - `column_type` string, required: The Stacksync type of the column (for example `string`, `int`, `number`, `boolean`, `datetime`, `uuid`, `json`)
      - `writable` boolean: Whether a sync can write to the column; absent when the app does not say

## Other responses

- `400`: The `region` is missing or not one of besg, usnv; the body is not a JSON object; `connection_id` is missing or not a UUID; `table_names` is not an array of strings; the app does not support syncs (`App Not Supported`); the app refused the credentials (`Connection Authorization Error`); Stacksync could not connect to the app (`Connection Error`); the schema could not be read (`Error generating app schema`)
- `403`: Forbidden: invalid API key, API key of another workspace, insufficient scope, workspace unavailable, or a non-GET request without `Content-Type: application/json`
- `404`: The connection does not exist in the workspace and region, or is not visible to the user of the API key (`Error retrieving connection`)

---

[API](https://skmtc.dev/stacksync/apis/stacksync-api.md) - [All operations](https://skmtc.dev/stacksync/apis/stacksync-api/llms.txt) - [OpenAPI document](https://skmtc.dev/stacksync/apis/stacksync-api/revisions/21f4ba4b214e?raw)
