# Types

> Create a type such as Store, Trail or Event, choose its location rule, shapes and color, add subtypes, and turn a type off or delete it safely.

A type describes one kind of place or item in your project, such as "Store", "Trail" or "Event", and the details each one has. This page shows how to create and set up types. It is for project Owners, who are the only ones who can change the content model; Editors and Developers can look at it.

## What is a type?

A type is a template for entries: one kind of place or item, with a list of elements (fields) that every entry of that type fills in. "Store" might have a Description, Opening hours and Photos; "Event" might have Starts, Ends and Tickets. Every entry belongs to exactly one type.

A type also sets how its entries appear on the map: whether they need a location, which shapes they can be (point, line or area) and their color.

Types live in **Content model** on the **Types** tab, next to **Elements library** and **Map feature types**.

## Do I have to create a type before adding entries?

No. In a project with no types, click the map on **Entries** and add your first place: when it is saved, Spatibase creates a type called **Place** (identifier `place`) for it, which takes points, lines and areas and doesn't require a location. Fields you add from the entry editor with **Add field** go onto that type. Later you can rename it, change its rules here, or add more types. See [Create entries](https://spatibase.com/docs/content/entries/#the-first-entry-of-an-empty-project).

To start with a type of your own instead, choose **Set it up yourself** in the empty entry list: **What goes on your map?** suggests a type (Place, Store, Event, Trail, Area or Something else) with a shape and starter fields, and creates it with **Create type**.

## How do I create a type?

1. Open **Content model** and stay on the **Types** tab.
2. Click **Create your first type**, or **New type** if the project already has some. A **New type** window opens.
3. Fill in the form:
   - **Name**: what editors see, for example "Store Location".
   - **Identifier**: the name developers use in the API. It is suggested from the name; you can change it. See [What can an identifier look like?](https://spatibase.com/docs/model/change-the-model/#what-can-an-identifier-look-like).
   - **Description** (optional): helps other editors understand what belongs here.
   - **Parent type**: leave **None (top level)**, or choose a type to make this one a subtype (see [What are subtypes?](https://spatibase.com/docs/model/types/#what-are-subtypes)).
   - **Show in Entries and the API**: a switch, on by default.
   - **Location on the map**: **Required**, **Optional** or **No location** (see [Which location rule should I pick?](https://spatibase.com/docs/model/types/#which-location-rule-should-i-pick)).
   - **Allowed shapes**: tick **Point**, **Line**, **Area**, or any mix.
   - **Type color**: one of the ten preset colors, or **Custom** for a lighter or darker shade of one of them, or any hex code like `#1aa356`. Entries of this type are drawn in it.
4. Under **Assigned elements**, click **Assign element** to add fields. Click an assigned element's name to change its settings. See [Elements](https://spatibase.com/docs/model/elements/).
5. Click **Create type**.

To change a type later, select it in the list of types on the right, edit the form and click **Save changes**. The list shows each type's color and how many entries it has; subtypes hang under their parent on a dotted line.

> **Important:** Changing a type's **Identifier** after websites or apps use it breaks them: they stop finding the type under its old key. The form warns you before you save.

## Which location rule should I pick?

The location rule decides whether entries of a type have a place on the map. You choose it under **Location on the map**:

| Rule | What it means | Good for |
|---|---|---|
| **Required** | Every entry must be placed on the map before it can be marked ready to publish. Drafts can be saved without a location. | Stores, trails, events, anything that is a place |
| **Optional** | Entries can be placed on the map, but don't have to be. This is the default. | Things that sometimes have a place, such as news with an optional location |
| **No location** | Content without a place. The map tools are hidden for these entries, and they never appear in map data. | Articles, FAQs, regions you only link to |

The place an entry has on the map is its **main location**. It is what the map, map data (GeoJSON) and location filters in the API use.

### Which shapes should the main location be?

**Allowed shapes** limits what editors can draw: **Point** for a single spot (a store), **Line** for a route (a trail), **Area** for a space with a border (a park). Tick more than one if entries differ, for example a "Venue" that can be a point or an area. **Allowed shapes** is hidden when the rule is **No location**.

> **Tip:** Need more than one place per entry, such as a store with a delivery area and parking spots? Keep one main location and add a **Map shapes** element. See [Elements](https://spatibase.com/docs/model/elements/#what-kinds-of-elements-are-there).

## What are subtypes?

A subtype is a type with a **Parent type**, for example "National park" under "Park" or "Cafe" under "Venue". Use subtypes when several kinds of place share most of their details.

- **Elements are inherited.** A subtype gets all of its parent's elements, then its own. Inherited elements appear greyed out under **Assigned elements**, marked "from" and the name of the type they come from, and follow every change you make on the parent.
- **Settings are copied once.** A new subtype starts with its parent's location rule, shapes and color. You can then change them; later changes to the parent don't change them again.
- **Up to five levels.** A type can have subtypes, which can have their own subtypes, up to five levels deep.
- **The API includes subtypes.** When a website asks for the entries of a type, it gets the entries of its subtypes too, unless the request says `subtypes=false`. Asking for "Park" also returns national parks. Each entry still reports its own type.
- **No element twice.** If you assign an element to a parent that one of its subtypes already has of its own, the subtype keeps it only as an inherited element.

### How do I create a subtype?

On the **Types** tab, click **New type** and choose the parent under **Parent type**. The new subtype takes over the parent's location rule, shapes and color right away; change them on the same form if you like. You can also move an existing type: drag it in the list of types onto another type to make it a subtype, or onto the top or bottom edge of a type to place it before or after that one (with a mouse; on a touch screen, change **Parent type** on the form instead). Changing its **Parent type** on the form does the same.

## How do I turn a type off?

Switch off **Show in Entries and the API** on the type and click **Save changes**. Turning a type off:

- hides it, and all its subtypes, from the menu for new entries;
- leaves its entries, and its subtypes' entries, out of the API;
- keeps existing entries editable in the app.

The type list marks it **Disabled**, and its subtypes **Disabled via parent**. Switch it on again to bring everything back. This is useful for seasonal content or a type you are still preparing.

## How do I delete a type?

Open the type and click **Delete type**, then confirm. The type's elements stay in the **Elements library** for other types.

You can't delete a type that still has entries or subtypes, or that a **Reference** element links to (an archived Reference element counts too). Spatibase tells you which one is in the way. Delete the entries (entries in the trash don't count, but they can't be restored once the type is gone), move or delete the subtypes, and take the type off the Reference element's **Link to entries of type** list, or turn the type off instead. An entry can't be moved to another type.

> **Tip:** Owners can also create a type from a file: when you import a spreadsheet or map file, choose **A new type made from this file** and Spatibase creates the type and its elements. See [Import](https://spatibase.com/docs/content/import/).

## Related

- [Elements](https://spatibase.com/docs/model/elements/)
- [Map feature types](https://spatibase.com/docs/model/map-feature-types/)
- [Change the model safely](https://spatibase.com/docs/model/change-the-model/)
- [Concepts](https://spatibase.com/docs/build/concepts/)
