Skip to main content

List schemas

schemas = app_res.schemas.list()

Get by event name

schema = app_res.schemas.get_by_event_name("order.placed")

Create a schema

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

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

Field types

TypeDescriptionValidation options
stringText valuemin, max (length), pattern (regex)
numberNumeric valuemin, max
booleanTrue or False
dateISO-8601 date string
enumFixed set of stringsProvide enum_values list
objectNested dict
You can also manage schemas as code using the Vela CLI.