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

# Vytvořit schéma

> Vytvoření nového produktového schématu s definicemi sloupců.

## Tělo požadavku

<ParamField body="name" type="string" required>
  Název schématu.
</ParamField>

<ParamField body="description" type="string">
  Popis, k čemu se toto schéma používá.
</ParamField>

<ParamField body="is_default" type="boolean" default="false">
  Zda by toto mělo být výchozí schéma.
</ParamField>

<ParamField body="columns" type="array" required>
  Pole definic sloupců. Nesmí být prázdné.

  <Expandable title="Objekt sloupce">
    <ParamField body="key" type="string" required>Strojově čitelný klíč (snake\_case).</ParamField>
    <ParamField body="label" type="string" required>Lidsky čitelný popisek.</ParamField>

    <ParamField body="type" type="string" required>
      Typ sloupce. Jeden z: `text`, `number`, `url`, `email`, `date`, `boolean`, `richtext`, `enum`, `tags`, `image`, `images`, `json`.
    </ParamField>

    <ParamField body="required" type="boolean">Zda je tento sloupec povinný.</ParamField>
    <ParamField body="description" type="string">Popis sloupce.</ParamField>
    <ParamField body="enum_values" type="string[]">Povolené hodnoty pro sloupce typu `enum`.</ParamField>
  </Expandable>
</ParamField>

## Odpověď

<ResponseField name="id" type="string">Jedinečný identifikátor schématu.</ResponseField>
<ResponseField name="name" type="string">Název schématu.</ResponseField>
<ResponseField name="description" type="string | null">Popis schématu.</ResponseField>
<ResponseField name="is_default" type="boolean">Zda je toto výchozí schéma.</ResponseField>
<ResponseField name="columns" type="array">Definice sloupců.</ResponseField>
<ResponseField name="created_at" type="string">Časové razítko ISO 8601.</ResponseField>
<ResponseField name="updated_at" type="string">Časové razítko ISO 8601.</ResponseField>

<RequestExample>
  ```typescript TypeScript theme={null}
  const schema = await client.schemas.create({
    name: "Electronics Catalog",
    description: "Schema for consumer electronics",
    columns: [
      { key: "product_name", label: "Product Name", type: "text", required: true },
      { key: "price", label: "Price", type: "number" },
      { key: "brand", label: "Brand", type: "text" },
      { key: "category", label: "Category", type: "enum", enum_values: ["phones", "laptops", "tablets"] },
      { key: "image_url", label: "Image", type: "image" },
      { key: "specs", label: "Specifications", type: "json" },
    ],
  });

  console.log(schema.id);
  ```

  ```python Python theme={null}
  schema = client.schemas.create(
      name="Electronics Catalog",
      description="Schema for consumer electronics",
      columns=[
          {"key": "product_name", "label": "Product Name", "type": "text", "required": True},
          {"key": "price", "label": "Price", "type": "number"},
          {"key": "brand", "label": "Brand", "type": "text"},
          {"key": "category", "label": "Category", "type": "enum", "enum_values": ["phones", "laptops", "tablets"]},
          {"key": "image_url", "label": "Image", "type": "image"},
          {"key": "specs", "label": "Specifications", "type": "json"},
      ],
  )

  print(schema["id"])
  ```

  ```bash cURL theme={null}
  curl -X POST "https://hub.banditshq.com/api/v1/schemas" \
    -H "Authorization: Bearer lasso_..." \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Electronics Catalog",
      "description": "Schema for consumer electronics",
      "columns": [
        {"key": "product_name", "label": "Product Name", "type": "text", "required": true},
        {"key": "price", "label": "Price", "type": "number"},
        {"key": "brand", "label": "Brand", "type": "text"},
        {"key": "category", "label": "Category", "type": "enum", "enum_values": ["phones", "laptops", "tablets"]},
        {"key": "image_url", "label": "Image", "type": "image"},
        {"key": "specs", "label": "Specifications", "type": "json"}
      ]
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "id": "schema_abc123",
    "name": "Electronics Catalog",
    "description": "Schema for consumer electronics",
    "is_default": false,
    "columns": [
      { "key": "product_name", "label": "Product Name", "type": "text", "required": true },
      { "key": "price", "label": "Price", "type": "number" }
    ],
    "created_at": "2025-03-01T10:00:00.000Z",
    "updated_at": "2025-03-01T10:00:00.000Z"
  }
  ```
</ResponseExample>

## Typy sloupců

| Typ        | Popis                                                   |
| ---------- | ------------------------------------------------------- |
| `text`     | Prostý textový řetězec.                                 |
| `number`   | Číselná hodnota (celé číslo nebo desetinné číslo).      |
| `url`      | Platná URL adresa.                                      |
| `email`    | E-mailová adresa.                                       |
| `date`     | Řetězec s datem nebo datem a časem.                     |
| `boolean`  | `true` nebo `false`.                                    |
| `richtext` | Text formátovaný v HTML nebo markdownu.                 |
| `enum`     | Jedna z předdefinované sady hodnot (viz `enum_values`). |
| `tags`     | Pole textových štítků.                                  |
| `image`    | Jedna URL adresa obrázku.                               |
| `images`   | Pole URL adres obrázků.                                 |
| `json`     | Libovolný JSON objekt.                                  |
