> ## Documentation Index
> Fetch the complete documentation index at: https://apidocs.glideapps.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Table

> Creates a new Big Table

Create a new Big Table, define its structure, and (optionally) populate it with data.

Row IDs for any added rows are returned in the response in the same order as the input row data is passed in the request. Row data may be passed in JSON, CSV, or TSV format.

When using a CSV or TSV request body, the name of the table must be passed as a query parameter and the schema of the table is always inferred from the content. Alternatively, the CSV/TSV content may be [stashed](/api-reference/v2/stashing/introduction), and then the schema and name may be passed in the regular JSON payload.

If a schema is passed in the payload, any passed row data must match that schema. If a column is not included in the passed row data, it will be empty in the added row. If a column is passed that does not exist in the schema, or with a value that does not match the column's type, the default behavior is for the table to not be created and the API call to [return an error](/api-reference/v2/general/errors#invalid-row-data). However, you can control this behavior with the `onSchemaError` query parameter.

## Examples

<AccordionGroup>
  <Accordion title="Create Table w/ Row Data">
    If you want to create a table and populate it with an initial dataset, you can do so by providing the data inline in the `rows` field (being sure that row object structure matches the table schema):

    ```json theme={null}
    {
        "name": "Employees",
        "schema": { ... },
        "rows": [
            {
                "fullName": "Alex Bard",
                "ageInYears": 30,
                "hiredOn": "2021-07-03"
            }
        ]
    }
    ```

    However, this is only appropriate for relatively small initial datasets (around a few hundred rows or less, depending on schema complexity). If you need to work with a larger dataset you should utilize stashing.
  </Accordion>

  <Accordion title="Create Table from Stash">
    [Stashing](/api-reference/v2/stashing/introduction) is our process for handling the upload of large datasets. Break down your dataset into smaller, more manageable, pieces and [upload them to a single stash ID](/api-reference/v2/stashing/put-stashes-serial).

    Then, to create a table from a stash, you can use the `$stashID` reference in the `rows` field instead of providing the data inline:

    ```json theme={null}
    {
        "name": "Employees",
        "schema": { ... },
        "rows": {
            "$stashID": "20240215-job32"
        }
    }
    ```
  </Accordion>
</AccordionGroup>


## OpenAPI

````yaml post /tables
openapi: 3.0.0
info:
  title: ''
  version: 0.0.1
servers:
  - description: Production
    url: https://api.glideapps.com
security:
  - BearerAuth: []
tags: []
paths:
  /tables:
    post:
      description: Creates a new Big Table
      parameters:
        - name: x-glide-asynchronous
          in: header
          schema:
            type: string
            enum:
              - 'true'
              - 'false'
            description: >-
              Allow asynchronous processing, which will return a job ID. Note
              that this does not force asynchronouys processing. The caller must
              handle both synchronous and asynchronous responses.
          required: false
        - name: name
          in: query
          schema:
            type: string
            description: >-
              Name of the table. Required when the name is not passed in the
              request body. It is an error to pass a name in both this query
              parameter and the request body.
            example: Invoices
          required: false
        - name: appsToLink
          in: query
          schema:
            type: array
            items:
              type: string
            description: An array of app IDs to link the new table to.
          required: false
        - name: onSchemaError
          in: query
          schema:
            type: string
            enum:
              - abort
              - dropColumns
              - updateSchema
            description: >-
              The action to take when the passed data does not match the table
              schema:


              - `abort`: Abort the entire operation and return an error.

              - `dropColumns`: Ignore the data that caused the error, and do not
              import those columns in the affected rows.

              - `updateSchema`: Update the schema as needed to add any missing
              columns or widen the data types of existing columns, and then
              import the data from them.
            example: updateSchema
          required: false
      requestBody:
        content:
          application/json:
            schema:
              anyOf:
                - type: object
                  properties:
                    name:
                      type: string
                      description: Name of the table, e.g., `Invoices`
                      example: Invoices
                    schema:
                      type: object
                      properties:
                        columns:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: string
                                description: >-
                                  Internal ID of the column, e.g., `fullName`.
                                  This value cannot be changed once created.
                                example: fullName
                              displayName:
                                type: string
                                description: >-
                                  Human-readable display name of the column,
                                  e.g., `Full Name`. Can be modified once
                                  created.
                                example: Full Name
                              type:
                                anyOf:
                                  - type: string
                                    enum:
                                      - string
                                      - uri
                                      - imageURI
                                      - audioURI
                                      - markdown
                                      - phoneNumber
                                      - emailAddress
                                      - emoji
                                      - date
                                      - time
                                      - dateTime
                                      - duration
                                      - number
                                      - boolean
                                      - json
                                  - anyOf:
                                      - type: object
                                        properties:
                                          kind:
                                            type: string
                                            enum:
                                              - string
                                              - uri
                                              - imageURI
                                              - audioURI
                                              - markdown
                                              - phoneNumber
                                              - emailAddress
                                              - emoji
                                              - date
                                              - time
                                              - dateTime
                                              - duration
                                              - number
                                              - boolean
                                              - json
                                        required:
                                          - kind
                                        additionalProperties: false
                                      - type: object
                                        properties:
                                          kind:
                                            type: string
                                            enum:
                                              - array
                                          items:
                                            type: object
                                            properties:
                                              kind:
                                                type: string
                                                enum:
                                                  - string
                                                  - uri
                                                  - imageURI
                                                  - audioURI
                                                  - markdown
                                                  - phoneNumber
                                                  - emailAddress
                                                  - emoji
                                                  - date
                                                  - time
                                                  - dateTime
                                                  - duration
                                                  - number
                                                  - boolean
                                                  - json
                                            required:
                                              - kind
                                            additionalProperties: false
                                        required:
                                          - kind
                                          - items
                                        additionalProperties: false
                                description: The type of the column.
                            required:
                              - id
                              - type
                            additionalProperties: false
                          description: >-
                            A collection of column definitions, in the order
                            that they are to be displayed in the table.
                      required:
                        - columns
                      additionalProperties: false
                      description: >-
                        The schema of the table as a collection of column
                        definitions. If this is not provided, the schema will be
                        inferred from the data.
                      example:
                        columns:
                          - id: fullName
                            displayName: Full Name
                            type: string
                          - id: invoiceDate
                            displayName: Invoice Date
                            type: dateTime
                          - id: totalAmount
                            displayName: Total
                            type: number
                          - id: amountPaid
                            displayName: Paid
                            type: number
                    rows:
                      anyOf:
                        - $ref: '#/components/schemas/A_collection_of_row_objects'
                        - type: object
                          properties:
                            $stashID:
                              type: string
                              pattern: ^[a-zA-Z0-9][a-zA-Z0-9_-]{0,255}$
                              description: ID of the stash, e.g., `20240215-job32`
                              example: 20240215-job32
                          required:
                            - $stashID
                          additionalProperties: false
                          description: >-
                            A single reference to a
                            [stash](/api-reference/v2/stashing) whose data
                            should be used.
                    appsToLink:
                      type: array
                      items:
                        type: string
                      description: An array of app IDs to link the new table to.
                  required:
                    - name
                    - rows
                  additionalProperties: false
                - $ref: '#/components/schemas/A_collection_of_row_objects'
          text/csv:
            schema:
              type: string
              description: >-
                A CSV string. The first line is column IDs, and each subsequent
                line is a row of data. The schema will be inferred from the
                data. The name of the table must be passed in the query
                parameter `name`.
              example: |-
                Name,Age,Birthday
                Alice,25,2024-08-29T09:46:16.722Z
                Bob,30,2020-01-15T09:00:16.722Z
          text/tab-separated-values:
            schema:
              type: string
              description: >-
                A TSV string. The first line is column IDs, and each subsequent
                line is a row of data. The schema will be inferred from the
                data. The name of the table must be passed in the query
                parameter `name`.
              example: "Name\tAge\tBirthday\nAlice\t25\t2024-08-29T09:46:16.722Z\nBob\t30\t2020-01-15T09:00:16.722Z"
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      tableID:
                        type: string
                        description: >-
                          ID of the table, e.g.,
                          `2a1bad8b-cf7c-44437-b8c1-e3782df6`
                        example: 2a1bad8b-cf7c-44437-b8c1-e3782df6
                      rowIDs:
                        type: array
                        items:
                          type: string
                          description: ID of the row, e.g., `zcJWnyI8Tbam21V34K8MNA`
                          example: zcJWnyI8Tbam21V34K8MNA
                        description: "Row IDs of added rows, returned in the same order as the input rows, e.g., \n\n```json\n[\n\t\"zcJWnyI8Tbam21V34K8MNA\",\n\t\"93a19-cf7c-44437-b8c1-e9acbbb\"\n]\n```"
                        example:
                          - zcJWnyI8Tbam21V34K8MNA
                          - 93a19-cf7c-44437-b8c1-e9acbbb
                      linkedAppIDs:
                        type: array
                        items:
                          type: string
                        description: An array of appIDs which were successfully linked.
                    required:
                      - tableID
                      - rowIDs
                    additionalProperties: false
                required:
                  - data
                additionalProperties: false
        '202':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      tableID:
                        type: string
                        description: >-
                          ID of the table, e.g.,
                          `2a1bad8b-cf7c-44437-b8c1-e3782df6`
                        example: 2a1bad8b-cf7c-44437-b8c1-e3782df6
                      jobID:
                        type: string
                        description: The ID of the asynchronous job
                    required:
                      - tableID
                      - jobID
                    additionalProperties: false
                required:
                  - data
                additionalProperties: false
        '400':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      message:
                        type: string
                    required:
                      - type
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        '402':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - payment_required
                      message:
                        type: string
                    required:
                      - type
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        '422':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - column_id_reserved
                          - column_id_not_unique
                          - column_has_invalid_value
                          - column_id_not_found
                      message:
                        type: string
                    required:
                      - type
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
components:
  schemas:
    A_collection_of_row_objects:
      type: array
      items:
        type: object
        additionalProperties: {}
        description: "A row object conforming to the schema of the table, where keys are the column IDs and values are the column values:\n\n```json\n{\n\t\"fullName\": \"Alex Bard\",\n\t\"invoiceDate\": \"2024-07-29T14:04:15.561Z\",\n\t\"totalAmount\": 34.50,\n\t\"amountPaid\": 0\n}\n```"
        example:
          fullName: Alex Bard
          invoiceDate: '2024-07-29T14:04:15.561Z'
          totalAmount: 34.5
          amountPaid: 0
      description: "A collection of row objects conforming to the schema of the table where keys are the column IDs and values are the column values:\n\n```json\n[\n\t{\n\t\t\"fullName\": \"Alex Bard\",\n\t\t\"invoiceDate\": \"2024-07-29T14:04:15.561Z\",\n\t\t\"totalAmount\": 34.50,\n\t\t\"amountPaid\": 0\n\t},\n\t{\n\t\t\"fullName\": \"Alicia Hines\",\n\t\t\"invoiceDate\": \"2023-06-15T10:30:00.000Z\",\n\t\t\"totalAmount\": 50.75,\n\t\t\"amountPaid\": 20\n\t}\n]\n```"
      example:
        - fullName: Alex Bard
          invoiceDate: '2024-07-29T14:04:15.561Z'
          totalAmount: 34.5
          amountPaid: 0
        - fullName: Alicia Hines
          invoiceDate: '2023-06-15T10:30:00.000Z'
          totalAmount: 50.75
          amountPaid: 20
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer authentication header of the form Bearer `<token>`, where
        `<token>` is your [auth
        token](/api-reference/v2/general/authentication).

````