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

# Create Table

Create a table by uploading a CSV file. Table contents are updated by replacing
the whole CSV, not by row, column, or cell mutations.

<RequestExample>
  ```python Python theme={null}
  from pathlib import Path

  from retab import Retab

  client = Retab()

  tables = client.tables.create(
      name="Carriers",
      file=Path("carriers.csv").read_bytes(),
  )
  print(tables)
  ```

  ```typescript TypeScript theme={null}
  import { readFileSync } from "node:fs";

  import { Retab } from "@retab/node";

  const client = new Retab({ apiKey: process.env.RETAB_API_KEY });

  const tables = await client.tables.create("Carriers", readFileSync("carriers.csv"));
  console.log(tables);
  ```

  ```go Go theme={null}
  package main

  import (
  	"context"
  	"fmt"
  	"log"
  	"os"

  	retab "github.com/retab-dev/retab/clients/go"
  )

  func main() {
  	ctx := context.Background()

  	client, err := retab.NewClient("")
  	if err != nil {
  		log.Fatal(err)
  	}

  	file, err := os.ReadFile("carriers.csv")
  	if err != nil {
  		log.Fatal(err)
  	}

  	tables, err := client.Tables.Create(ctx, &retab.TablesCreateParams{
  		Name: "Carriers",
  		File: file,
  	})
  	if err != nil {
  		log.Fatal(err)
  	}
  	fmt.Println(*tables)
  }
  ```

  ```ruby Ruby theme={null}
  require 'retab'

  client = Retab::Client.new(api_key: ENV['RETAB_API_KEY'])

  tables = client.tables.create(
    name: 'Carriers',
    file: File.binread('carriers.csv'),
  )
  puts tables
  ```

  ```rust Rust theme={null}
  use retab::models::CreateWorkflowTableUploadRequest;
  use retab::resources::tables::CreateParams;
  use retab::Retab;

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      let client = Retab::new(std::env::var("RETAB_API_KEY")?);

      let file = std::fs::read("carriers.csv")?;
      let tables = client
          .tables()
          .create(CreateParams::new(CreateWorkflowTableUploadRequest::new(
              "Carriers", file,
          )))
          .await?;
      println!("{:?}", tables);
      Ok(())
  }
  ```

  ```php PHP theme={null}
  <?php
  require 'vendor/autoload.php';

  use Retab\Client;

  $client = new Client(apiKey: getenv('RETAB_API_KEY'));

  $result = $client->tables()->create(
      name: 'Carriers',
      file: file_get_contents('carriers.csv'),
  );
  print_r($result);
  ```

  ```csharp C# theme={null}
  using Retab;
  using RetabClient = Retab.Retab;

  var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;
  var client = new RetabClient(apiKey);

  var result = await client.Tables.CreateAsync(new TablesCreateOptions
  {
      Name = "Carriers",
      File = System.IO.File.ReadAllBytes("carriers.csv"),
  });
  Console.WriteLine(result);
  ```

  ```java Java theme={null}
  import com.retab.RetabClient;
  import java.nio.file.Files;
  import java.nio.file.Path;

  public final class Example {
    public static void main(String[] args) throws Exception {
      RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY"));

      byte[] file = Files.readAllBytes(Path.of("carriers.csv"));
      var result = client.tables().create("Carriers", file, null, null);
      System.out.println(result);
    }
  }
  ```

  ```bash cURL theme={null}
  curl https://api.retab.com/v1/tables \
    -H "Authorization: Bearer $RETAB_API_KEY" \
    -F "name=Carriers" \
    -F "file=@./carriers.csv"
  ```
</RequestExample>


## OpenAPI

````yaml POST /v1/tables
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.retab.com
security: []
paths:
  /v1/tables:
    post:
      tags:
        - Tables
      summary: Table.Create
      operationId: create_table
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/CreateWorkflowTableUploadRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowTableListResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    CreateWorkflowTableUploadRequest:
      properties:
        name:
          type: string
          title: Name
        file:
          type: string
          contentMediaType: application/octet-stream
          title: File
        column_schema_overrides:
          anyOf:
            - type: string
            - type: 'null'
          title: Column Schema Overrides
        project_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Project Id
      type: object
      required:
        - file
        - name
      title: CreateWorkflowTableUploadRequest
    WorkflowTableListResponse:
      properties:
        tables:
          items:
            $ref: '#/components/schemas/WorkflowTable'
          type: array
          title: Tables
          default: []
      type: object
      title: WorkflowTableListResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          default: []
      type: object
      title: HTTPValidationError
    WorkflowTable:
      properties:
        id:
          type: string
          title: Id
        name:
          type: string
          title: Name
        filename:
          type: string
          title: Filename
        project_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Project Id
          description: >-
            Project that owns this table. Null only on legacy rows that predate
            the project backfill.
        source_file_id:
          type: string
          title: Source File Id
          default: ''
        snapshot_file_id:
          type: string
          title: Snapshot File Id
          default: ''
        row_count:
          type: integer
          title: Row Count
        columns:
          items:
            $ref: '#/components/schemas/WorkflowTableColumn'
          type: array
          title: Columns
          default: []
        sample_rows:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Sample Rows
          default: []
        metadata:
          additionalProperties: true
          type: object
          title: Metadata
          default: {}
        uploaded_by_user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Uploaded By User Id
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
      type: object
      required:
        - filename
        - id
        - name
        - row_count
      title: WorkflowTable
    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
          default: null
        ctx:
          type: object
          title: Context
          default: {}
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    WorkflowTableColumn:
      properties:
        name:
          type: string
          title: Name
        json_schema:
          additionalProperties: true
          type: object
          title: Json Schema
          default: {}
        sample_values:
          items:
            type: string
          type: array
          title: Sample Values
          default: []
        required:
          type: boolean
          title: Required
          default: false
        unique:
          type: boolean
          title: Unique
          default: false
      type: object
      required:
        - name
      title: WorkflowTableColumn
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````