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 /j/{ID}, where {ID} is a placeholder for the zettel identifier (14 digits). You must send a HTTP PUT request to that endpoint:

# curl -X PUT --data '{}'

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.

Alternatively, you can use the endpoint /z/{ID} to update a zettel. In this case, 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 Status codes

Update was successful, there is no body in the response.
Request was not valid. For example, the request body was not valid.
You are not allowed to delete the given zettel.
Zettel not found. You probably used a zettel identifier that is not used in the Zettelstore.