{"openapi":"3.1.0","info":{"title":"Draftify API","description":"\nDraftify is a Keep-style notes app with a rich-text editor. This API backs it.\n\n## Sessions\n\nSign up or log in and the server sets an **HTTP-only session cookie**\n(`draftify_session`, 7 days). Every endpoint outside `/auth` requires it and\nreturns `401` without it. In this UI, call **POST /auth/login** first and the\ncookie is kept for the other calls.\n\n## Ownership\n\nNotes and labels belong to the signed-in user. Another user's ids behave as if\nthey do not exist (`404`), including inside `label_ids` (`422`).\n\n## Ordering\n\n`GET /notes` returns every note (active, archived and trashed) sorted pinned\nfirst, then by `position`. Clients filter by `archived` / `deleted_at`.\nNew notes take the top slot; pinning moves a note to the top of its group;\n**POST /notes/reorder** persists a drag-and-drop order in one call.\n","version":"0.5.0"},"paths":{"/auth/signup":{"post":{"tags":["auth"],"summary":"Create an account","description":"Create an account and sign in (the session cookie is set on the response).\n\nEmails are unique regardless of case. Passwords need at least 8 characters\nand are stored as Argon2 hashes. The very first account adopts any notes\nand labels that predate accounts.","operationId":"signup_auth_signup_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Credentials"}}},"required":true},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}}},"409":{"description":"An account with this email already exists"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/auth/login":{"post":{"tags":["auth"],"summary":"Sign in","description":"Sign in and receive the session cookie. The error is the same whether the\nemail or the password is wrong, and attempts are rate-limited per client.","operationId":"login_auth_login_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Credentials"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}}},"401":{"description":"Incorrect email or password"},"429":{"description":"Too many failed attempts; wait a few minutes"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/auth/logout":{"post":{"tags":["auth"],"summary":"Sign out","description":"Clear the session cookie.","operationId":"logout_auth_logout_post","responses":{"204":{"description":"Successful Response"}}}},"/auth/me":{"get":{"tags":["auth"],"summary":"Current user","description":"The signed-in user, or 401 when there is no valid session.","operationId":"me_auth_me_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}}},"401":{"description":"No valid session cookie"}}}},"/labels":{"get":{"tags":["labels"],"summary":"List labels","operationId":"list_labels_labels_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/Label"},"type":"array","title":"Response List Labels Labels Get"}}}},"401":{"description":"No valid session cookie"}}},"post":{"tags":["labels"],"summary":"Create a label","operationId":"create_label_labels_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LabelIn"}}},"required":true},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Label"}}}},"401":{"description":"No valid session cookie"},"409":{"description":"You already have a label with this name"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/labels/{label_id}":{"put":{"tags":["labels"],"summary":"Rename a label","operationId":"rename_label_labels__label_id__put","parameters":[{"name":"label_id","in":"path","required":true,"schema":{"type":"integer","title":"Label Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LabelIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Label"}}}},"401":{"description":"No valid session cookie"},"404":{"description":"Not found, or owned by another user"},"409":{"description":"You already have a label with this name"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["labels"],"summary":"Delete a label","operationId":"delete_label_labels__label_id__delete","parameters":[{"name":"label_id","in":"path","required":true,"schema":{"type":"integer","title":"Label Id"}}],"responses":{"204":{"description":"Successful Response"},"401":{"description":"No valid session cookie"},"404":{"description":"Not found, or owned by another user"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/notes":{"get":{"tags":["notes"],"summary":"List notes","description":"Every note of the signed-in user, in display order (pinned first, then\n`position`). Archived and trashed notes are included with their flags set;\ntrashed notes older than seven days are purged first.","operationId":"list_notes_notes_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/Note"},"type":"array","title":"Response List Notes Notes Get"}}}},"401":{"description":"No valid session cookie"}}},"post":{"tags":["notes"],"summary":"Create a note","description":"Create a note at the top of the wall. `content` is HTML from the editor.","operationId":"create_note_notes_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NoteIn"}}},"required":true},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Note"}}}},"401":{"description":"No valid session cookie"},"422":{"description":"Invalid payload or a label id that is not yours"}}}},"/notes/reorder":{"post":{"tags":["notes"],"summary":"Reorder notes","description":"Persist a drag-and-drop order: the ids are assigned positions 0..n-1 in\nthe given order. Returns every note in the new display order.","operationId":"reorder_notes_notes_reorder_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReorderIn"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/Note"},"type":"array","title":"Response Reorder Notes Notes Reorder Post"}}}},"401":{"description":"No valid session cookie"},"404":{"description":"One or more ids are unknown or not yours"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/notes/trash":{"delete":{"tags":["notes"],"summary":"Empty the trash","description":"Permanently delete every note in the trash.","operationId":"empty_trash_notes_trash_delete","responses":{"204":{"description":"Successful Response"},"401":{"description":"No valid session cookie"}}}},"/notes/{note_id}":{"get":{"tags":["notes"],"summary":"Get a note","operationId":"get_note_notes__note_id__get","parameters":[{"name":"note_id","in":"path","required":true,"schema":{"type":"integer","title":"Note Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Note"}}}},"401":{"description":"No valid session cookie"},"404":{"description":"Not found, or owned by another user"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"put":{"tags":["notes"],"summary":"Replace a note","description":"Full replacement of the editable fields. Pinning or unpinning moves the\nnote to the top of its new group; archiving unpins it.","operationId":"update_note_notes__note_id__put","parameters":[{"name":"note_id","in":"path","required":true,"schema":{"type":"integer","title":"Note Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NoteIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Note"}}}},"401":{"description":"No valid session cookie"},"404":{"description":"Not found, or owned by another user"},"422":{"description":"Invalid payload or a label id that is not yours"}}},"delete":{"tags":["notes"],"summary":"Trash or delete a note","description":"Move a note to the trash (restorable for seven days), or delete it for\ngood with `?permanent=true`.","operationId":"delete_note_notes__note_id__delete","parameters":[{"name":"note_id","in":"path","required":true,"schema":{"type":"integer","title":"Note Id"}},{"name":"permanent","in":"query","required":false,"schema":{"type":"boolean","default":false,"title":"Permanent"}}],"responses":{"204":{"description":"Successful Response"},"401":{"description":"No valid session cookie"},"404":{"description":"Not found, or owned by another user"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/notes/{note_id}/restore":{"post":{"tags":["notes"],"summary":"Restore from trash","operationId":"restore_note_notes__note_id__restore_post","parameters":[{"name":"note_id","in":"path","required":true,"schema":{"type":"integer","title":"Note Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Note"}}}},"401":{"description":"No valid session cookie"},"404":{"description":"Not found, or owned by another user"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"Credentials":{"properties":{"email":{"type":"string","format":"email","title":"Email","description":"Case-insensitive; stored lower-cased."},"password":{"type":"string","maxLength":128,"minLength":8,"title":"Password","description":"At least 8 characters."}},"type":"object","required":["email","password"],"title":"Credentials","example":{"email":"you@example.com","password":"a-long-password"}},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"Label":{"properties":{"name":{"type":"string","maxLength":50,"minLength":1,"title":"Name","description":"Unique per user, case-insensitive."},"id":{"type":"integer","title":"Id"}},"type":"object","required":["name","id"],"title":"Label","example":{"name":"Work"}},"LabelIn":{"properties":{"name":{"type":"string","maxLength":50,"minLength":1,"title":"Name","description":"Unique per user, case-insensitive."}},"type":"object","required":["name"],"title":"LabelIn","example":{"name":"Work"}},"Note":{"properties":{"id":{"type":"integer","title":"Id"},"title":{"type":"string","title":"Title"},"content":{"type":"string","title":"Content"},"color":{"type":"string","enum":["default","red","orange","yellow","green","teal","blue","purple","pink","gray"],"title":"Color"},"pinned":{"type":"boolean","title":"Pinned"},"archived":{"type":"boolean","title":"Archived"},"position":{"type":"integer","title":"Position"},"updated_at":{"type":"string","format":"date-time","title":"Updated At"},"deleted_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Deleted At"},"labels":{"items":{"$ref":"#/components/schemas/Label"},"type":"array","title":"Labels"}},"type":"object","required":["id","title","content","color","pinned","archived","position","updated_at"],"title":"Note","description":"What the API returns."},"NoteIn":{"properties":{"title":{"type":"string","maxLength":200,"title":"Title","default":""},"content":{"type":"string","maxLength":200000,"title":"Content","description":"HTML produced by the editor.","default":""},"color":{"type":"string","enum":["default","red","orange","yellow","green","teal","blue","purple","pink","gray"],"title":"Color","description":"One of Keep's card colours.","default":"default"},"pinned":{"type":"boolean","title":"Pinned","description":"Pinned notes sort first. Ignored while archived.","default":false},"archived":{"type":"boolean","title":"Archived","default":false},"label_ids":{"items":{"type":"integer"},"type":"array","title":"Label Ids","description":"Ids of the user's labels to attach."}},"type":"object","title":"NoteIn","description":"Payload accepted on create and update. The server owns id, order and timestamps.","example":{"archived":false,"color":"red","content":"<ul data-type=\"taskList\"><li data-type=\"taskItem\" data-checked=\"false\"><label><input type=\"checkbox\"><span></span></label><div><p>Milk</p></div></li></ul>","label_ids":[1],"pinned":true,"title":"Weekly groceries"}},"ReorderIn":{"properties":{"ids":{"items":{"type":"integer"},"type":"array","title":"Ids","description":"Note ids in the order they should appear."}},"type":"object","required":["ids"],"title":"ReorderIn","description":"Full display order of notes, first item shown first.","example":{"ids":[12,7,3]}},"User":{"properties":{"id":{"type":"integer","title":"Id"},"email":{"type":"string","title":"Email"},"created_at":{"type":"string","format":"date-time","title":"Created At"}},"type":"object","required":["id","email","created_at"],"title":"User"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"tags":[{"name":"auth","description":"Sign up, sign in, sign out and the current session."},{"name":"notes","description":"Create, edit, order, archive and trash notes. All scoped to the signed-in user."},{"name":"labels","description":"Per-user labels that can be attached to notes."}],"servers":[{"url":"/api"}]}