{
"error": "expired",
"message": "This paste has expired."
}
Response 404 — Not found
{
"error": "not_found",
"message": "Paste not found or already expired."
}
Responses
200 OKPaste found and returned.
404 Not FoundNo paste with this ID.
410 GonePaste existed but TTL has elapsed.
OPTIONS/api/pasteCORS preflight
Handled automatically by the browser before cross-origin requests. You never need to call this manually.
CORS is fully open — call the API from any frontend without a proxy.
Response headers
Access-Control-Allow-Origin: *Access-Control-Allow-Methods: GET, POST, OPTIONSAccess-Control-Allow-Headers: Content-Type
Responses
204 No ContentPreflight accepted. No body.
Error Reference
Status
error
When
400
bad_request
Missing/empty text, exceeds 50,000 chars, or ttl outside 60,000–3,600,000 ms.
404
not_found
ID doesn't exist or was never created.
410
expired
Paste existed but TTL has elapsed.
405
method_not_allowed
HTTP method other than GET, POST, OPTIONS.
Full Example
JavaScript — create & read
// 1. Create a paste (expires in 5 min)const res = awaitfetch('https://paste.dockhub.dev/api/paste', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: 'secret note', ttl: 300000 })
});
const { id } = await res.json();
// 2. Read it backconst paste = awaitfetch(`https://paste.dockhub.dev/api/paste?id=${id}`)
.then(r => r.json());
console.log(paste.text); // 'secret note'console.log(paste.remainingMs); // ~299xxx ms
Python
import requests
# Create
r = requests.post(
"https://paste.dockhub.dev/api/paste",
json={"text": "hello from python", "ttl": 600000}
)
paste_id = r.json()["id"]
# Read
data = requests.get(
"https://paste.dockhub.dev/api/paste",
params={"id": paste_id}
).json()
print(data["text"]) # 'hello from python'print(data["remainingMs"]) # ms until expiry