Trabajar con notas
Formatos
Los cuerpos son Markdown (content_markdown). Pide JSON de TipTap con ?format=json o ambos con ?format=both. Al escribir envía uno entre content_markdown y content_json.
Las notas en modo código ("mode": "code") llevan un arreglo files en lugar de un cuerpo.
Paginación y búsqueda
GET /notes devuelve primero lo más reciente y pagina por cursor:
curl "https://notes-api.palmcode.cl/api/v1/notes?limit=25&q=invoice&tag=work" \
-H "Authorization: Bearer $PALMNOTES_TOKEN"
# → { "data": [...], "meta": { "next_cursor": "…" } }
curl "https://notes-api.palmcode.cl/api/v1/notes?limit=25&cursor=<next_cursor>" \
-H "Authorization: Bearer $PALMNOTES_TOKEN"let cursor: string | null = null;
do {
const url = new URL('https://notes-api.palmcode.cl/api/v1/notes');
url.searchParams.set('limit', '25');
if (cursor) url.searchParams.set('cursor', cursor);
const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.PALMNOTES_TOKEN}` } });
const { data, meta } = await res.json();
for (const note of data) console.log(note.title);
cursor = meta.next_cursor;
} while (cursor);import os, requests
headers = {"Authorization": f"Bearer {os.environ['PALMNOTES_TOKEN']}"}
params = {"limit": 25}
while True:
body = requests.get("https://notes-api.palmcode.cl/api/v1/notes", params=params, headers=headers).json()
for note in body["data"]:
print(note["title"])
cursor = body["meta"]["next_cursor"]
if not cursor:
break
params["cursor"] = cursornext_cursor es null en la última página. Los listados devuelven un excerpt corto; agrega include=content para los cuerpos completos.
Evitar actualizaciones perdidas
Cada nota tiene un version opaco. Devuélvelo en If-Match al actualizar; un valor desactualizado responde 409 version_conflict.
curl -X PATCH https://notes-api.palmcode.cl/api/v1/notes/$ID \
-H "Authorization: Bearer $PALMNOTES_TOKEN" \
-H "If-Match: $VERSION" \
-H "Content-Type: application/json" \
-d '{"title":"New title"}'const res = await fetch(`https://notes-api.palmcode.cl/api/v1/notes/${id}`, {
method: 'PATCH',
headers: {
Authorization: `Bearer ${process.env.PALMNOTES_TOKEN}`,
'If-Match': version, // the `version` you last read
'Content-Type': 'application/json',
},
body: JSON.stringify({ title: 'New title' }),
});
if (res.status === 409) {
// version_conflict: re-read the note, merge, retry
}import os, requests
r = requests.patch(
f"https://notes-api.palmcode.cl/api/v1/notes/{note_id}",
headers={
"Authorization": f"Bearer {os.environ['PALMNOTES_TOKEN']}",
"If-Match": version, # the `version` you last read
},
json={"title": "New title"},
)
if r.status_code == 409:
pass # version_conflict: re-read the note, merge, retryEliminar e historial
DELETE /notes/{id} envía la nota a la papelera; agrega ?permanent=true para eliminarla definitivamente. Cada nota normal conserva sus últimas 10 versiones; lístalas en /notes/{id}/versions y restaura con POST …/versions/{vid}/restore (primero se guarda el estado actual, así que restaurar es reversible).