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

# Schemas

> Define and manage event schemas with Python

## List schemas

```python theme={null}
schemas = app_res.schemas.list()
```

## Get by event name

```python theme={null}
schema = app_res.schemas.get_by_event_name("order.placed")
```

## Create a schema

```python theme={null}
schema = app_res.schemas.create({
    "event_name": "order.placed",
    "description": "Emitted when a checkout completes",
    "fields": [
        {
            "id": "fld-order-id",
            "name": "orderId",
            "type": "string",
            "required": True,
            "validation": {"min": 1, "max": 128},
        },
        {
            "id": "fld-amount",
            "name": "amountCents",
            "type": "number",
            "required": True,
        },
        {
            "id": "fld-currency",
            "name": "currency",
            "type": "enum",
            "required": True,
            "enum_values": ["USD", "EUR", "GBP"],
        },
    ],
    "metadata_fields": [
        {"id": "meta-env", "name": "environment", "type": "string"},
    ],
})
```

## Update a schema

```python theme={null}
updated = app_res.schemas.update(schema.id, {"description": "Updated"})
```

## Field types

| Type      | Description          | Validation options                       |
| --------- | -------------------- | ---------------------------------------- |
| `string`  | Text value           | `min`, `max` (length), `pattern` (regex) |
| `number`  | Numeric value        | `min`, `max`                             |
| `boolean` | `True` or `False`    | --                                       |
| `date`    | ISO-8601 date string | --                                       |
| `enum`    | Fixed set of strings | Provide `enum_values` list               |
| `object`  | Nested dict          | --                                       |

<Tip>
  You can also manage schemas as code using the [Vela CLI](/cli/overview).
</Tip>
