(zettel (meta (back "00001005000000 00001012054200") (backward "00001005000000 00001012000000 00001012054200 00001012920000") (box-number "1") (created "20210713150005") (forward "00001006000000 00001006010000 00001006020000 00001006050000 00001012000000 00001012053300 00001012920000 00001012921200 00001012930500") (modified "20230807170416") (published "20230807170416") (role "manual") (syntax "zmk") (tags "#api #manual #zettelstore") (title "API: Create a new zettel")) (rights 4) (encoding "") (content "A zettel is created by adding it to the [[list of zettel|00001012000000]].\nTherefore, the [[endpoint|00001012920000]] to create a new zettel is also ''/z'', but you must send the data of the new zettel via a HTTP POST request.\n\n\nThe zettel must be encoded in a [[plain|00001006000000]] format: first comes the [[metadata|00001006010000]] and the following content is separated by an empty line.\nThis is the same format as used by storing zettel within a [[directory box|00001006010000]].\n\n```\n# curl -X POST --data $'title: Note\\n\\nImportant content.' http://127.0.0.1:23123/z\n20210903211500\n```\n\nThe zettel identifier of the created zettel is returned.\nIn addition, the HTTP response header contains a key ''Location'' with a relative URL for the new zettel.\nA client must prepend the HTTP protocol scheme, the host name, and (optional, but often needed) the post number to make it an absolute URL.\n\n=== Data input\nAlternatively, you may encode the zettel as a parseable object / a [[symbolic expression|00001012930500]] by providing the query parameter ''enc=data''.\nThe encoding is the same as the data output encoding when you [[retrieve a zettel|00001012053300#data-output]].\n\nThe encoding for [[access rights|00001012921200]] must be given, but is ignored.\nYou may encode computed or property [[metadata keys|00001006020000]], but these are also ignored.\n\n=== HTTP Status codes\n; ''201''\n: Zettel creation was successful, the body contains its [[zettel identifier|00001006050000]] (data value or plain text).\n; ''400''\n: Request was not valid. \n There are several reasons for this.\n Most likely, the symbolic expression was not formed according to above rules.\n; ''403''\n: You are not allowed to create a new zettel."))