---
title: Custom metadata
description: "Your own keys on a built-in module's articles, categories, collections and authors, returned by the API alongside everything else."
---

A built-in module publishes a fixed shape. An article has a title, an excerpt,
a body, authors, categories, tags, dates and resolved SEO, and that fixedness
is the point: a blog renders without anybody modelling one first.

It is also, eventually, a wall. You want one more thing alongside each
article and the module has no field for it.

`metadata` is that room. Keys you choose, values that are any JSON, stored as
sent and returned with the entity everywhere it is served.

```json
{
  "id": "art_6cRpCYFMCnAqFyCMpM4LF",
  "title": "How we deploy",
  "metadata": {
    "layout": "wide",
    "legacy_id": 4120,
    "hide_from_homepage": false
  }
}
```

## What it is for

Four shapes come up again and again.

**A rendering hint.** `"layout": "wide"` or `"hero": "video"`. Your template
reads it and picks a component. The CMS does not need to know what a layout
is, and you do not need a content type to hold one string.

**An id from somewhere else.** `"legacy_id": 4120`, `"shopify_handle":
"blue-mug"`, `"notion_page": "a1b2…"`. A migration keeps the old key so links,
redirects and analytics still line up, and a sync job has something to match
on.

**A flag your own site filters on.** `"hide_from_homepage": true`,
`"members_only": true`. Rules that belong to your site rather than to the
content.

**A small piece of structure.** `"reading_level": {"grade": 8, "label":
"Plain"}`. Up to five levels deep, so a nested object is fine when the thing
genuinely is one.

## Where it exists

| | |
|---|---|
| Blog articles | `GET /v1/blog/articles`, `/v1/blog/articles/{slug}` |
| Blog categories | `GET /v1/blog/categories`, `/v1/blog/categories/{slug}` |
| Knowledge base articles | `GET /v1/kb/articles`, `/v1/kb/articles/{slug}` |
| Collections and sections | `GET /v1/kb/tree` |
| Authors | `GET /v1/authors`, `/v1/authors/{slug}` |

It is served in **listings as well as single reads**, so a card can carry a
badge without fetching each article to find out. That is affordable only
because it is capped; see the limits below.

Custom content types do not have it, and do not need it: there you declare
the fields you want and they are validated, typed and introspectable.

## Writing it

Set it over the API with any write that already exists.

```bash
curl -X PATCH https://api.zevcontent.net/v1/blog/articles/how-we-deploy \
  -H "Authorization: Bearer $ZEVCONTENT_SECRET_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"metadata": {"layout": "wide", "legacy_id": 4120}}'
```

Or in the dashboard, under **Custom metadata** at the bottom of an article's
sidebar. A value that looks like JSON is stored as JSON, so `3` is a number
and `wide` is a string, and the field says which it decided before you save.

> **WARNING: Sending it replaces the whole object**
>
> `metadata` behaves like `tags`: what you send is what is stored. Omit the
> field to leave it alone, and send `{}` to clear it.
>
> There is no merge, because a merge gives you no way to delete a key. To change
> one key, read the object, change it, and send it back.

## Limits

| | |
|---|---|
| Keys | 50 |
| Size | 16KB serialized |
| Nesting | 5 levels |
| Key length | 64 characters |

Keys are stored trimmed, so `" layout "` is read back as `layout`. Values are
whatever JSON you sent.

A few names cannot be used as keys, because they mean something to JavaScript
itself and do not survive the trip: `__proto__`, `constructor` and
`prototype`. They are dropped rather than stored. If you are importing from a
system that used one, rename it on the way in.

The caps are what keep it a sidecar rather than the content. Long text belongs
in the body, files belong in [media](/concepts/media), and anything with a
shape worth enforcing belongs in a
[custom content type](/concepts/content-model).

## Filtering

Articles can be filtered on their own keys. Nothing else can.

```bash
curl "https://api.zevcontent.net/v1/blog/articles?metadata[layout]=wide" \
  -H "Authorization: Bearer $ZEVCONTENT_KEY"
```

It works on `GET /v1/blog/articles` and `GET /v1/kb/articles`. Up to five
conditions per request, ANDed, exact match:

```bash
?metadata[layout]=wide&metadata[featured]=true
```

A number or a boolean matches whether it was stored typed or as text, so
`?metadata[legacy_id]=4120` finds `4120` and `"4120"` alike. A query string
cannot say which you meant, so it asks for both.

> **INFO: Why only articles**
>
> Those two lists are the ones that grow. Categories, authors, collections and
> sections are tens of rows, and the index that makes filtering fast would be
> paid on every save to serve a search that was never slow. They take no
> `metadata` filter at all rather than offering one that quietly degrades as
> you grow.

There is no `contains`, no greater-than and no ordering by a metadata value.
An unindexed operator on a column whose shape nobody declared is the kind of
query that is quick on your test data and slow on your real data. If you need
those, the thing deserves to be a
[custom content type](/concepts/content-model), where the fields are declared
and filtering is part of the contract.

## What it does not do

**It is not validated.** A typo in a key is stored as written, and so is a
number you meant to be a string. This is deliberate: the product that
validates declared fields is custom content types, and a second, weaker
version of it bolted to the blog would be two things to learn.

**It is not searchable, and filtering is exact match only.** There is no
`contains`, no range and no sort. See Filtering below for what is supported
and why it stops there.

**It is not described by introspection.** `GET /v1/introspection` tells an
agent that `metadata` exists on these entities; it cannot tell it which keys
you use, because only you know that. If a key matters to someone else's code,
write it down where they will look.