Defining a schema
A new Sanity Studio project has no schema types registered, so there is nothing to edit yet. Define your first document type and register it.
1
This step continues from Setting up your studio, which creates a studio in a studio-hello-world folder. The file paths in this article assume that folder.

2Create a new document type
Create a new file in your studio's schemaTypes folder called postType.ts with the following code, which defines a set of fields for a new post document type.
import {defineArrayMember, defineField, defineType} from 'sanity'
export const postType = defineType({
name: 'post',
type: 'document',
fields: [
defineField({
name: 'title',
type: 'string',
validation: (rule) => rule.required(),
}),
defineField({
name: 'slug',
type: 'slug',
options: {source: 'title'},
validation: (rule) => rule.required(),
}),
defineField({
name: 'publishedAt',
type: 'datetime',
initialValue: () => new Date().toISOString(),
validation: (rule) => rule.required(),
}),
defineField({
name: 'image',
type: 'image',
}),
defineField({
name: 'body',
type: 'array',
of: [defineArrayMember({type: 'block'})],
}),
],
})3Register the post type in your studio's schema
Import the type into the schemaTypes array in the index.ts file in the same folder.
import {postType} from './postType'
export const schemaTypes = [postType]4Publish your first document
When you save these two files, your studio reloads automatically and shows your first document type.
To create and publish your first post document:
- In the navbar, click Create new document, then select Post.
- Enter a value for Title.
- Click Generate beside the Slug field.
- Click Publish.
The title, slug, and publishedAt fields are all required. publishedAt is filled in for you by its initialValue, so enter a title and generate a slug before you publish. Otherwise Publish stays disabled and its tooltip reads There are validation errors that need to be fixed before this document can be published.