Create your first collection

Define a collection schema with fields, validation, and default values using the dashboard or API.

#Create your first collection

By the end of this guide, you'll have a collection with typed fields and a working API endpoint.

#Prerequisites

  • An EmuView project with admin access
  • An API key or admin session token

#Steps

#1. Navigate to collections

Open the EmuView dashboard and click Collections in the sidebar. If this is a new project, the list is empty.

#2. Choose + Add → + Collection

Open the + Add button in the top-right corner and pick + Collection. This opens the collection editor. To put the new collection straight into a group, use that group's own + instead and pick Collection.

Tip

Use the prefill templates in the + Collection tooltip to start with a common schema like Blog Posts or Products.

#3. Name your collection

Enter a name for your collection. Collection names must:

  • Start with a lowercase letter
  • Contain only lowercase letters, numbers, and underscores
  • Be 1–50 characters long
  • Match the pattern /^[a-z][a-z0-9_]{0,49}$/
  • Not use a reserved name like users, auth, or roles

For this guide, enter products.

#4. Add fields

Add the following fields to your collection:

Field name Type Required Notes
title text Yes Set indexed: true for faster queries
price decimal Yes Set default value to 0
status enum Yes Values: draft, published, archived
description richtext No Stores HTML content
category relation No Points to a categories collection
#Using the dashboard

Click Add Field for each field. Select the type from the dropdown, enter the name, and configure options like required, indexed, and default value.

#Using the API
curl -X POST https://your-api.example.com/api/v1/collections \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "products",
    "storageType": "d1",
    "fields": [
      {
        "name": "title",
        "type": "text",
        "required": true,
        "indexed": true,
        "label": "Product Title"
      },
      {
        "name": "price",
        "type": "decimal",
        "required": true,
        "defaultValue": 0,
        "label": "Price (USD)"
      },
      {
        "name": "status",
        "type": "enum",
        "required": true,
        "enumValues": ["draft", "published", "archived"],
        "label": "Status"
      },
      {
        "name": "description",
        "type": "richtext",
        "required": false,
        "label": "Description"
      }
    ]
  }'
Warning

Use snake_case for field names. Cloudflare D1 (SQLite) is case-insensitive, and EmuView normalises names to lowercase. Using camelCase causes unexpected behaviour in queries. Also avoid SQL reserved words like order, group, or select — use sort_order or category_group instead.

#5. Save the collection

Click Save in the dashboard, or check the 201 Created response from the API. EmuView creates the physical database table and registers the schema.

The response includes the full collection definition:

{
	"id": "a1b2c3d4e5f6...",
	"name": "products",
	"storageType": "d1",
	"fields": [
		{ "name": "title", "type": "text", "required": true, "indexed": true },
		{ "name": "price", "type": "decimal", "required": true, "defaultValue": 0 },
		{
			"name": "status",
			"type": "enum",
			"required": true,
			"enumValues": ["draft", "published", "archived"]
		},
		{ "name": "description", "type": "richtext", "required": false }
	],
	"schemaVersion": 1,
	"createdAt": 1718900000
}

#6. Verify the API works

Your collection has a full CRUD API. Test it by listing records (the list is empty, but a 200 response confirms the endpoint works):

curl https://your-api.example.com/api/v1/collections/products/records \
  -H "Authorization: Bearer sk-your-api-key"
{
	"data": [],
	"total": 0,
	"page": 1,
	"limit": 25,
	"hasMore": false
}

#What you learned

  • How to create a collection through the dashboard and API
  • Naming rules for collections and fields
  • How to configure field types, required flags, and default values
  • That EmuView generates CRUD endpoints automatically for each collection

#Next steps