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

# Define Your Schema

> Create a Pydantic schema to define your data structure

You start every workflow by defining the structure of the incoming event. A Pydantic schema becomes the single source of truth for validation, documentation, and serialization.

## Why Schemas Matter

Schemas give you automatic type validation, inline documentation through field descriptions, and straightforward JSON serialization, so you can accept reliable inputs and publish clear API docs without extra boilerplate.

## Customer Care Event Schema

For our customer care use case, we've defined the following schema:

```python theme={null}
from datetime import datetime, timezone
from pydantic import BaseModel, Field
from uuid import UUID, uuid4


class CustomerCareEventSchema(BaseModel):
    ticket_id: UUID = Field(
        default_factory=uuid4, 
        description="Unique identifier for the ticket"
    )
    timestamp: datetime = Field(
        default_factory=lambda: datetime.now(timezone.utc),
        description="Time when the ticket was created",
    )
    from_email: str = Field(
        ..., 
        description="Email address of the sender"
    )
    to_email: str = Field(
        ..., 
        description="Email address of the recipient"
    )
    sender: str = Field(
        ..., 
        description="Name or identifier of the sender"
    )
    subject: str = Field(
        ..., 
        description="Subject of the ticket"
    )
    body: str = Field(
        ..., 
        description="The body of the ticket"
    )
```

## Schema Components Explained

### Automatic ID Generation

The `ticket_id` field uses `default_factory=uuid4` to automatically generate a unique identifier for each ticket when created.

### Timestamp Management

The `timestamp` field automatically captures the creation time in UTC, ensuring consistent time tracking across different timezones.

### Required Fields

Fields marked with `...` (ellipsis) are required and must be provided when creating an event instance.

### Field Descriptions

Each field includes a description that serves as inline documentation and helps with API documentation generation.

## File Location

Colocate each workflow's schema in its own package (`app/launchpad/workflows/<name>/schema.py`) so the input model lives next to the workflow that validates against it. Truly cross-workflow schemas can go under `app/launchpad/schemas/`.
