From 7c94a62d80b87388b1a1445601aa253c1ca75a23 Mon Sep 17 00:00:00 2001 From: Julien Riou Date: Tue, 26 Aug 2025 11:45:27 +0200 Subject: [PATCH] docs: Add API routes Signed-off-by: Julien Riou --- src/cmd/collerd/README.md | 42 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/cmd/collerd/README.md b/src/cmd/collerd/README.md index cfffda6..829fc37 100644 --- a/src/cmd/collerd/README.md +++ b/src/cmd/collerd/README.md @@ -32,4 +32,44 @@ The file format is **JSON**: * **prometheus_notes_metric** (string): Name of the notes count metric (default "collerd_notes") * **observation_internal** (int): Number of seconds to wait between two observations (default 60) -The configuration file is not required but the service might not be exposed to the public. \ No newline at end of file +The configuration file is not required but the service might not be exposed to the public. + +## API + +### GET /health + +Returns 200 OK. + +### POST /api/note + +Create a note. + +Body (JSON): +* **content** (string): base64 encoded content (required) +* **password** (string): user-provided password +* **encrypted** (bool): true if the note has been encrypted by the client +* **expiration** (int): lifetime of the note in seconds (must be supported by the server) +* **delete_after_read** (bool): delete the note after the first read + +Response (JSON): +* **id** (string): ID of the note + + +### GET // + +> [!IMPORTANT] +> Potential password leak + +Return content of a note encrypted by the given password. + +### GET / + +Return content of a note. + +If the note is encrypted, the encrypted value is returned (application/octet-stream). Otherwise, the text is returned (text/plain). + +### Errors + +Errors return **500 Server Internal Error** with the **JSON** payload: +* **message** (string): message of the response +* **error** (string): error if any \ No newline at end of file