(zettel (meta (back "00001012000000 00001012080100 00001018000000") (backward "00001012000000 00001012051400 00001012080100 00001018000000") (box-number "1") (created "20211230230441") (forward "00001004011200 00001004020000 00001004051100 00001010040100 00001012050600 00001012051400 00001012920000") (modified "20220923104836") (published "20220923104836") (role "manual") (syntax "zmk") (tags "#api #manual #zettelstore") (title "API: Refresh internal data")) (rights 4) (encoding "") (content "Zettelstore maintains some internal data to allow faster operations.\n\nOne example is the [[content search|00001012051400]] for a term: Zettelstore does not need to scan all zettel to find all occurrences for the term.\nInstead, all word are stored internally, with a list of zettel where they occur.\n\nAnother example is the way to determine which zettel are stored in a [[ZIP file|00001004011200]].\nScanning a ZIP file is a lengthy operation, therefore Zettelstore maintains a directory of zettel for each ZIP file.\n\nAll these internal data may become stale.\nThis should not happen, but when it comes e.g. to file handling, every operating systems behaves differently in very subtle ways.\n\nTo avoid stopping and re-starting Zettelstore, you can use the API to force Zettelstore to refresh its internal data if you think it is needed.\nTo do this, you must send a HTTP POST request to the [[endpoint|00001012920000]] ''/x'' and you must specify the query parameter ''cmd=refresh''.\n\n```sh\n# curl -X POST 'http://127.0.0.1:23123/x?cmd=refresh'\n```\n\nIf successful, you will get a HTTP status code 204 (No Content) with an empty HTTP body.\n\nThe request will be successful if either:\n* [[Authentication is enabled|00001010040100]] and you [[provide a valid access token|00001012050600]],\n* Authentication is not enabled and you started Zettelstore with the [[run-simple|00001004051100]] command or [[expert-mode|00001004020000#expert-mode]] is set to \"\"true\"\".\n\n=== HTTP Status codes\n; ''204''\n: Operation was successful, the body is empty.\n; ''400''\n: Request was not valid. \n There are several reasons for this.\n Most likely, no query parameter ''cmd'' was given, or it did not contain the value \"\"refresh\"\".\n; ''403''\n: You are not allowed to perform this operation."))