---
title: "Create Model"
method: POST
path: "/models"
---

# Create Model

`POST /models`

Create a new model

## Query parameters

- `skipColumnQuery` boolean

## Request body

- ModelCreate — The input for creating a Model
  - `name` string, required — The name of the model
  - `slug` string, required — The slug of the model
  - `queryType` string, required — The type of the query. Available options: custom, raw_sql, tabel, dbt and visual.
  - `sourceId` number, double, required — The id of the source that model is connected to
  - `isSchema` boolean, required — If is_schema is true, the model is just used to build other models. Either as part of visual querying, or as the root of a visual query.
  - `primaryKey` string, required — The primary key will be null if the query doesn't get directly synced (e.g. a relationship table for visual querying)
  - `visual` object — Visual query, used by audience
    - `secondaryLabel` string
    - `primaryLabel` string
    - `filter` unknown, required
    - `parentId` number, double, required — Parent id of the schema that visual query is based on
  - `custom` object — Custom query for sources that doesn't support sql. For example, Airtable.
    - `query` unknown, required
  - `table` object — Table-based query that fetches on a table instead of SQL
    - `name` string, required
  - `raw` object — Standard raw SQL query
    - `sql` string, required
  - `folderId` string
  - `dbt` object
    - `modelId` number, double, required — Model id that refers to a dbt model
  - `dbt_cloud` object
    - `modelId` number, double, required — Model id that refers to a dbt Cloud model

## Response `200`

Ok

- union
  - Model — The SQL query that pulls data from your source to send to your destination. We send your SQL query directly to your source so any SQL that is valid for your source (including functions) is valid in Hightouch.
    - `id` number, double, required — The id of the model
    - `name` string, required — The name of the model
    - `slug` string, required — The slug of the model
    - `description` string, required — The description of the model
    - `workspaceId` number, double, required — The id of the workspace where the model belongs to
    - `primaryKey` string, required — The primary key will be null if the query doesn't get directly synced (e.g. a relationship table for visual querying)
    - `createdAt` string, date-time, required — The timestamp when model was created
    - `updatedAt` string, date-time, required — The timestamp when model was lastly updated
    - `sourceId` number, double, required — The id of the source that model is connected to
    - `queryType` string, required — The type of the query. Available options: custom, raw_sql, tabel, dbt and visual.
    - `tags` object, required — The tags of the model
    - `isSchema` boolean, required — If is_schema is true, the model is just used to build other models. Either as part of visual querying, or as the root of a visual query.
    - `syncs` number[], required — The list of id of syncs that uses this model
    - `visual` object — Visual query, used by audience
      - `secondaryLabel` string
      - `primaryLabel` string
      - `filter` unknown, required
      - `parentId` number, double, required — Parent id of the schema that visual query is based on
    - `custom` object — Custom query for sources that doesn't support sql. For example, Airtable.
      - `query` unknown, required
    - `table` object — Table-based query that fetches on a table instead of SQL
      - `name` string, required
    - `dbt` object — Query that is based on a dbt model
      - `dbtUniqueId` string, required — Unique ID of the model assigned by dbt (usually some combination of the schema and table name)
      - `compiledSql` string, required — Compiled SQL in the dbt model
      - `rawSql` string, required — Raw SQL in the dbt model
      - `database` string, required — Name of the database containing the generated table
      - `schema` string, required — Name of the schema containing the generated table
      - `name` string, required — Name of the table generated by the dbt model
      - `modelId` number, double, required — Model id that refer to a dbt model
    - `dbt_cloud` object
      - `dbtUniqueId` string, required — Unique ID of the model assigned by dbt (usually some combination of the schema and table name)
      - `compiledSql` string, required — Compiled SQL in the dbt model
      - `rawSql` string, required
      - `name` string, required — Name of the table generated by the dbt model
      - `modelId` number, double, required — Model id that refer to a dbt model
    - `raw` object — Standard raw SQL query
      - `sql` string, required
    - `folderId` string
    - `lastRunSize` number, double, nullable, required — The number of rows returned by the most recent successful sync run of this model. Null if the model has never been synced successfully.
  - ValidateErrorJSON
    - `message` 'Validation failed', required
    - `details` object, required
  - 'Internal Server Error'

## Other responses

- `401` — Unauthorized
- `409` — Conflict
- `422` — Validation Failed
- `500` — Something went wrong

---

[API](https://skmtc.net/hightouch/apis/hightouch-api.md) · [All operations](https://skmtc.net/hightouch/apis/hightouch-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/hightouch/hightouch-api/revisions/24a8012aa8c8/schema)
