// API
Create and manage pastes programmatically. All endpoints accept and return JSON.
Authentication
All endpoints work without authentication for basic paste creation and retrieval. To associate pastes with your account, use a Bearer API key.
Generate an API key from your Dashboard → API Keys section. Include it in the Authorization header:
curl -H "Authorization: Bearer pn_YOUR_API_KEY" \\
https://pastednow.com/api/userRate Limits
| Auth Method | Limit | Window |
|---|---|---|
| Anonymous (no key) | 10 requests | per minute |
| Bearer API Key | 60 requests | per minute |
| Session (browser) | 30 requests | per minute |
When rate limited, the response includes an X-RateLimit-Reset header with the reset timestamp.
/api/pastesCreate a new paste. Returns the paste URL and a delete token.
curl -X POST https://pastednow.com/api/pastes \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer pn_YOUR_KEY" \\
-d '{
"content": "console.log(\\"hello world\\");",
"title": "My snippet",
"language": "javascript",
"expiresIn": "1d"
}'Response 201:
{
"id": "a1b2c3d4",
"url": "https://pastednow.com/a1b2c3d4",
"rawUrl": "https://pastednow.com/api/pastes/a1b2c3d4/raw",
"deleteToken": "xyz..."
}/api/pastes/:idFetch a paste by ID. Use the raw endpoint for plain text output.
# JSON response
curl https://pastednow.com/api/pastes/a1b2c3d4
# Plain text (pipe-friendly)
curl https://pastednow.com/api/pastes/a1b2c3d4/raw/api/pastesencryptedCreate a password-protected paste. Fetch by passing the password as a query parameter.
# Create encrypted paste
curl -X POST https://pastednow.com/api/pastes \\
-H "Content-Type: application/json" \\
-d '{"content": "secret data", "password": "mypassword"}'
# Fetch with password
curl "https://pastednow.com/api/pastes/a1b2c3d4/raw?password=mypassword"/api/pastes/:idDelete a paste using the delete token (from creation) or Bearer auth (for your own pastes).
# With delete token (no auth needed)
curl -X DELETE "https://pastednow.com/api/pastes/a1b2c3d4?token=xyz..."
# With Bearer auth (owner only)
curl -X DELETE https://pastednow.com/api/pastes/a1b2c3d4 \\
-H "Authorization: Bearer pn_YOUR_KEY"/api/userauth requiredReturns the authenticated user's profile information.
curl -H "Authorization: Bearer pn_YOUR_KEY" \\
https://pastednow.com/api/userResponse 200:
{
"id": "clx...",
"name": "YourName",
"email": "you@example.com",
"role": "USER",
"xp": 1250,
"rankTier": "contributor",
"pasteCount": 42,
"totalViews": 8190,
"createdAt": "2025-01-15T..."
}API Key Management
Manage your API keys programmatically. All key management endpoints require session authentication (browser cookie).
/api/keysList your API keys (prefix, name, usage info — no raw keys).
/api/keysCreate a new API key. The raw key is returned once in the response.
curl -X POST https://pastednow.com/api/keys \\
-H "Content-Type: application/json" \\
-b "authjs.session-token=YOUR_SESSION" \\
-d '{"name": "My CLI key"}'/api/keys?id=KEY_IDRevoke an API key by its ID.
Statistics
/api/statsPublic platform statistics (total pastes, users, views).
/api/stats/chart14-day daily activity data (views, pastes, new users). Used by the /statistic page.
/api/healthHealth check endpoint. Returns status and timestamp.
Create Paste Options
| Field | Type | Default | Description |
|---|---|---|---|
content | string | required | The paste content (max 512 KB) |
title | string | "" | Optional title (max 100 chars) |
language | string | "auto" | Language for syntax highlighting |
password | string | null | Encrypt content with this password |
expiresIn | enum | "never" | "1h", "1d", "1w", "never", "burn" |
isPublic | boolean | false | Whether the paste is publicly listed |
Error Responses
All errors return a JSON object with an error field:
{ "error": "Rate limit exceeded. Try again later." }| Code | Meaning |
|---|---|
400 | Invalid input / validation error |
401 | Not authenticated (missing or invalid key) |
403 | Forbidden (wrong password / invalid delete token) |
404 | Resource not found |
410 | Paste has expired |
429 | Rate limit exceeded |
500 | Internal server error |