title: Data Encoding
role: manual
tags: #api #manual #reference #zettelstore
syntax: zmk
back: 00001012920500
backward: 00001012920500
box-number: 1
copyright: (c) 2020-present by Detlef Stern <ds@zettelstore.de>
created: 20260303142542
forward: 00001012920516 00001012921200 00001012930000
lang: en
license: EUPL-1.2-or-later
modified: 20260612162702
published: 20260612162702
visibility: public

The data encoding represents the zettel as a special [symbolic expression](00001012930000).
In contrast to the similar-looking [sz encoding](00001012920516), a much simpler structure is used.

If transferred via HTTP, the content type will be `text/plain; charset=utf-8`.

A full zettel, both metadata and content, is encoded by the list

`(zettel` [*Metadata*](#metadata) [*Access rights*](#access-rights) [*Content encoding*](#content-encoding) [*Content*](#content) `)`.

If you only want to encode the metadata of a zettel, the following format will be used:

`(list` [*Metadata*](#metadata) [*Access rights*](#access-rights) `)`.

# Metadata

Metadata is basically a sequence of key / value pairs:

*Metadata* __=__ `(meta` `(` *Key* *Value* `)` … `)`.*Key* __=__ Symbol.*Value* __=__ String.

Each *Key* is a symbol, derived from the metadata key.
The *Value* is a string containing the value of the corresponding metadata entry.

# Access rights

This element encodes [access rights](00001012921200) of a zettel:

*Access rights* __=__ `(rights` Number `)`.

# Content encoding

The content encoding specifies, how the zettel content is encoded.
Currently, two values are supported: the empty string and the string `"base64"`.

*Content encoding* __=__ `(encoding "")` __|__ `(encoding "base64")`.

The empty string indicates that the content is not encoded and can be used as is.
`"base64"` indicates that the content string is Base64-encoded (typically used for binary content).

# Content

The content of a zettel is always encoded as a readable string.
For binary content, it is first encoded using Base64.

*Content* __=__ `(content` String `)`.