API Documentation
Technical documentation for developers who want to integrate PrivNote into their applications.
API Reference
Endpoints for creating and retrieving notes
POST /api/notes
Create a new private note
Request Body
{
"content": "Your encrypted note content",
"expirationTime": "7d", // Optional: "1h", "24h", "7d", or "30d"
"allowedIps": [], // Optional: Array of allowed IP addresses
"restrictIp": false, // Optional: Restrict to current IP
"hasPassword": false, // Optional: Whether the note is password protected
"autoDecryptKey": "..." // Optional: Auto-generated for notes without password protection
}Response
{
"noteId": "uniqueNoteIdentifier",
"publicUrl": "https://example.com/note/uniqueNoteIdentifier",
"rawUrl": "https://example.com/api/notes?id=uniqueNoteIdentifier"
}Response Fields
noteId- The unique identifier for the notepublicUrl- The URL to view the note in the web interfacerawUrl- The URL to retrieve the raw note content via API
Example
// Client-side encryption example
import { encryptData } from './crypto';
// Generate a random key for password-less encryption
const autoDecryptKey = generateRandomKey();
// Encrypt the content
const encryptedContent = await encryptData('This is a secret message', autoDecryptKey);
// Send to server
fetch('/api/notes', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
content: encryptedContent,
hasPassword: false,
autoDecryptKey: autoDecryptKey
}),
})
.then(response => response.json())
.then(data => {
console.log('Public URL:', data.publicUrl);
console.log('Raw API URL:', data.rawUrl);
})