Content types
A content type is the shape of one kind of content: what fields a blog post, a product or a changelog entry has. You define it once in a visual builder, and the editor and the API follow from it.
Types and entries
A content type (for example "Posts") lists the fields. An entry is one piece of content of that type (one post). The editor form for an entry is generated from the type's fields, and the API returns entries with the same fields.
Start from a template
Pick a template when you create a type and adjust it afterwards:
- Blog posts (
posts): title, excerpt, body (rich text) and tags. - Changelog (
changelog): title, version, release date and what changed (rich text). - Pages (
pages): title and content (rich text), for About, terms and similar pages. - Products (
products): name, price, description and an available flag. - Newsletter issues (
newsletter): subject, send date and the issue (rich text).
A template is only a starting point. You can rename, reorder, add and remove its fields like any other type.
Field types
| Field | Use it for | Arrives in the API as |
|---|---|---|
| Short text | Titles, names, short labels | String |
| Long text | Summaries and plain paragraphs | String |
| Rich text | Article bodies with headings, lists, links and images | Sanitised HTML string |
| Number | Prices, ratings, order | Number |
| Yes / no | Flags such as "featured" | Boolean |
| Date | Event dates, release dates | String as YYYY-MM-DD |
| Choice list | A fixed set of options such as a category | String (one of your options) |
Mark a field required and an entry cannot be saved until it has a value. A value that does not fit the field (text in a number field, an option that is not in the list) is refused with a message that names the field.
API ids
Every type has an API id (for example posts) that appears in the URL of the API. Every field has one too, and it is the key in the returned JSON.
GET /api/public/v1/posts
{ "data": [ { "slug": "hello-world", "data": { "title": "Hello world", "body": "<p>…</p>" } } ] }A type's API id is locked after you create it. That is deliberate: a live website that reads /posts must never break because someone renamed a type. You can still change the display name at any time.
Slugs
Each entry has a slug, the part of its address after the type: /api/public/v1/posts/hello-world. SharpWrite fills it from the title and you can edit it. Slugs are unique within a type.
Changing a type later
- Adding a field is always safe. Older entries simply have no value for it yet; make it required only after you have filled it in.
- Reordering or renaming a field only changes the editor form. Check that your website does not depend on the field's API id before changing that.
- Removing a field hides it from the editor and the API. Your site must stop reading it first, or it will see it disappear.
- The API only returns fields that currently exist on the type.
Restoring an old version of an entry is refused when the old content no longer fits the type, for example because a required field was added since. See version history.
Who can change types
Owners and Admins can create and change content types. Editors can write entries but not change the structure. See Team and roles.