Skip to content

Bookmarks

Bookmark endpoints provide CRUD operations for managing encrypted bookmarks.


GET /api/v1/bookmarks

Returns all bookmarks for the authenticated user.

Required (Cookie)

Terminal window
curl https://app.bitmarks.sh/api/v1/bookmarks \
-b "bitmarks_session=YOUR_TOKEN"

Status: 200 OK

{
"data": [
{
"id": "bm_abc123",
"encrypted_data": "eyJhbGciOi...",
"data_hash": "a1b2c3d4...",
"created_at": 1735430400000,
"updated_at": 1735430400000,
"deleted_at": null
}
],
"meta": {
"total": 150,
"page": 1,
"limit": 100
}
}
ParamTypeDefaultDescription
pageinteger1Page number
limitinteger100Items per page (max: 1000)

GET /api/v1/bookmarks/:id

Returns a single bookmark by ID.

Required (Cookie)

ParamTypeDescription
idstringBookmark ID
Terminal window
curl https://app.bitmarks.sh/api/v1/bookmarks/bm_abc123 \
-b "bitmarks_session=YOUR_TOKEN"

Status: 200 OK

{
"id": "bm_abc123",
"encrypted_data": "eyJhbGciOi...",
"data_hash": "a1b2c3d4...",
"created_at": 1735430400000,
"updated_at": 1735430400000,
"deleted_at": null
}

Status: 404 Not Found

{
"error": "Bookmark not found"
}

POST /api/v1/bookmarks

Creates a new bookmark with encrypted data.

Required (Cookie)

FieldTypeRequiredDescription
encrypted_datastringYesBase64-encoded encrypted bookmark JSON
data_hashstringYesSHA-256 hash of plaintext data
Terminal window
curl -X POST https://app.bitmarks.sh/api/v1/bookmarks \
-H "Content-Type: application/json" \
-b "bitmarks_session=YOUR_TOKEN" \
-d '{
"encrypted_data": "eyJhbGciOi...",
"data_hash": "a1b2c3d4e5f6..."
}'

Status: 201 Created

{
"id": "bm_abc123",
"encrypted_data": "eyJhbGciOi...",
"data_hash": "a1b2c3d4...",
"created_at": 1735430400000,
"updated_at": 1735430400000,
"deleted_at": null
}

Status: 400 Bad Request

{
"error": "Invalid request body"
}

PUT /api/v1/bookmarks/:id

Updates an existing bookmark with new encrypted data.

Required (Cookie)

ParamTypeDescription
idstringBookmark ID
FieldTypeRequiredDescription
encrypted_datastringYesBase64-encoded encrypted bookmark JSON
data_hashstringYesSHA-256 hash of plaintext data
Terminal window
curl -X PUT https://app.bitmarks.sh/api/v1/bookmarks/bm_abc123 \
-H "Content-Type: application/json" \
-b "bitmarks_session=YOUR_TOKEN" \
-d '{
"encrypted_data": "eyJuZXdEYXRh...",
"data_hash": "newHash123..."
}'

Status: 200 OK

{
"id": "bm_abc123",
"encrypted_data": "eyJuZXdEYXRh...",
"data_hash": "newHash123...",
"created_at": 1735430400000,
"updated_at": 1735430500000,
"deleted_at": null
}

Status: 400 Bad Request

{
"error": "Invalid request body"
}

Status: 404 Not Found

{
"error": "Bookmark not found"
}

DELETE /api/v1/bookmarks/:id

Soft deletes a bookmark (sets deleted_at timestamp).

Required (Cookie)

ParamTypeDescription
idstringBookmark ID
Terminal window
curl -X DELETE https://app.bitmarks.sh/api/v1/bookmarks/bm_abc123 \
-b "bitmarks_session=YOUR_TOKEN"

Status: 200 OK

{
"success": true
}

Status: 404 Not Found

{
"error": "Bookmark not found"
}

interface Bookmark {
id: string; // Unique identifier
title: string; // Bookmark title
url?: string; // URL (optional for folders)
parentId?: string; // Parent folder ID
dateAdded?: string; // ISO 8601 creation date
dateModified?: string; // ISO 8601 modification date
folder?: string; // Folder name
path?: string; // Full path (e.g., "Bookmarks/Work/Dev")
tags?: string[]; // User-defined tags
favicon?: string; // Favicon URL or data URI
domain?: string; // Extracted domain
source: 'bookmarks' | 'history' | 'groups' | 'stars';
// GitHub star specific fields
name?: string; // Repository name
full_name?: string; // owner/repo
stargazers_count?: number; // Star count
description?: string | null; // Repo description
owner?: {
login: string;
avatar_url: string;
};
}

import { encryptObject, hashData } from '@bitmarks.sh/core';
async function createBookmark(bookmark, key) {
const plaintext = JSON.stringify(bookmark);
const encrypted = await encryptObject(bookmark, key);
const hash = await hashData(new TextEncoder().encode(plaintext));
return fetch('/api/v1/bookmarks', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify({
encrypted_data: encrypted,
data_hash: hash
})
});
}
import { decryptObject } from '@bitmarks.sh/core';
async function getBookmarks(key) {
const response = await fetch('/api/v1/bookmarks', {
credentials: 'include'
});
const { data } = await response.json();
return Promise.all(
data.map(async (item) => {
const decrypted = await decryptObject(item.encrypted_data, key);
return {
...item,
bookmark: decrypted
};
})
);
}