API: Update a zettel

00001012054200 · Info · (manual) · #api #manual #zettelstore

Updating metadata and content of a zettel is technically quite similar to creating a new zettel. In both cases you must provide the data for the new or updated zettel in the body of the HTTP request.

One difference is the endpoint. The endpoint to update a zettel is /z/{ID}, where {ID} is a placeholder for the zettel identifier. You must send a HTTP PUT request to that endpoint.

The zettel must be encoded in a plain format: first comes the metadata and the following content is separated by an empty line. This is the same format as used by storing zettel within a directory box.

# curl -X POST --data 'title: Updated Note\n\nUpdated content.' http://127.0.0.1:23123/z/00001012054200

Alternatively, you can use the JSON encoding by using the query parameter enc=json.

# curl -X PUT --data '{}' 'http://127.0.0.1:23123/z/00001012054200?enc=json'

This will put some empty content and metadata to the zettel you are currently reading. As usual, some metadata will be calculated if it is empty.

The body of the HTTP response is empty, if the request was successful.

HTTP Status codes

204

Update was successful, there is no body in the response.

400

Request was not valid. For example, the request body was not valid.

403

You are not allowed to delete the given zettel.

404

Zettel not found. You probably used a zettel identifier that is not used in the Zettelstore.