Schema Editor
Schema Editor
The Schema Editor lets you define the shape of records in your collection — what fields exist, what type of data each field generates, and how many sample records to create. MockLab uses the schema to auto-generate realistic data using the field name and type as hints.
Opening the Schema Editor
- Go to Mock API and click on a collection name.
- In the collection detail view, click the Schema tab.
- You'll see a table of current fields with type and sample value columns.
Supported field types
| Type | Auto-generated value | Example output |
|---|---|---|
| id | Unique prefixed ID | "prod_4kX9z" |
| name | Full person or product name | "Wireless Headphones" |
| Valid email address | "[email protected]" | |
| phone | International phone number | "+1 555-234-5678" |
| url | Valid HTTPS URL | "https://example.com" |
| price | Decimal number (2dp) | 49.99 |
| integer | Random integer | 42 |
| boolean | true or false | true |
| date | ISO 8601 date | "2024-11-03" |
| datetime | ISO 8601 datetime | "2024-11-03T14:22:00Z" |
| uuid | RFC 4122 UUID v4 | "a3f2c1d0-..." |
| text | Short lorem-ipsum sentence | "Lorem ipsum..." |
| enum | Random value from your list | "active" |
| object | Nested object with child fields | {"key": "value"} |
| array | Array of 1–5 values of a type | ["tag1", "tag2"] |
Smart field name inference
MockLab infers the type from the field name automatically. You don't need to manually set types for common patterns:
// Field name → inferred type "id" → id "userId" → id "email" → email "createdAt" → datetime "updatedAt" → datetime "price" → price "amount" → price "isActive" → boolean "phoneNumber" → phone "imageUrl" → url "description" → text
Regenerating records
After modifying the schema, click Regenerate to create a fresh set of sample records using the new schema. The previous records are discarded.
Regenerate replaces all existing records including ones you created via POST. On the Pro plan, manually created records are permanent — regenerate only if you want to reset.
Custom enum values
For enum type fields,
you provide the list of possible values. MockLab picks randomly from this list for each generated record.
// Schema definition for a "status" enum field
{
"name": "status",
"type": "enum",
"values": ["active", "inactive", "pending", "suspended"]
}
// Generated records will have one of:
// "active", "inactive", "pending", or "suspended"