Pastes API
Full pastes support rich features including syntax highlighting, multiple visibility modes, expiry, burn-after-view, and client-side encryption.
Tier requirement: Paste endpoints require a Pro or Max account, except
deletewhich is available on Free (10/mo).
Create a paste
Section titled “Create a paste”POST /api/dev/pastes/create
Section titled “POST /api/dev/pastes/create”Request body
| Field | Type | Default | Description |
|---|---|---|---|
name | string | required | Display name for the paste |
text | string | required | The text content |
tags | string | '' | Comma-separated tags |
mode | number | 1 (Public) | Visibility: 0=Private, 1=Public, 2=Unlisted |
neverExpire | boolean | true | Never expire if true |
expireDate | string (ISO) | – | Expiry date (used when neverExpire is false) |
burnAfterView | boolean | false | Delete paste after first view |
curl
curl -X POST https://api.anonpaste.com/api/dev/pastes/create \ -H "x-api-key: your_api_key" \ -H "Content-Type: application/json" \ -d '{ "name": "My Paste", "text": "Hello, world!", "tags": "hello,test", "neverExpire": true }'Response
{ "success": true, "id": "aB3xYz", "remaining": 499}SDK
const { id } = await anonpaste.pastes.create({ name: 'My Paste', text: 'Hello, world!', tags: 'hello,test',});Get a paste
Section titled “Get a paste”GET /api/dev/pastes/get/:ref
Section titled “GET /api/dev/pastes/get/:ref”curl
curl https://api.anonpaste.com/api/dev/pastes/get/aB3xYz \ -H "x-api-key: your_api_key"Response
{ "success": true, "paste": { "pasteID": 12345, "ref": "aB3xYz", "name": "My Paste", "views": 3, "encrypted": false, "mode": 1, "burnAfterView": false, "content": [{ "contentType": 0, "data": "Hello, world!" }] }, "remaining": 2999}Text content is stored compressed. The SDK automatically decompresses it. When using raw HTTP, the
datafield will be a compressed base64 string.
SDK
const paste = await anonpaste.pastes.get('aB3xYz');console.log(paste.content[0].data); // already decompressedUpdate a paste
Section titled “Update a paste”PUT /api/dev/pastes/update/:ref
Section titled “PUT /api/dev/pastes/update/:ref”Updates the text content of a paste you own.
curl
curl -X PUT https://api.anonpaste.com/api/dev/pastes/update/aB3xYz \ -H "x-api-key: your_api_key" \ -H "Content-Type: application/json" \ -d '{ "text": "Updated content" }'Response
{ "success": true, "remaining": 499 }SDK
await anonpaste.pastes.update('aB3xYz', { text: 'Updated content' });Delete a paste
Section titled “Delete a paste”DELETE /api/dev/pastes/delete/:ref
Section titled “DELETE /api/dev/pastes/delete/:ref”curl
curl -X DELETE https://api.anonpaste.com/api/dev/pastes/delete/aB3xYz \ -H "x-api-key: your_api_key"Response
{ "success": true, "remaining": 499 }SDK
await anonpaste.pastes.delete('aB3xYz');Error codes
Section titled “Error codes”| Status | Reason | Description |
|---|---|---|
400 | name and text are required | Missing required fields |
403 | API key does not have access to this paste | Paste belongs to another account |
404 | Paste not found | No paste with that ref |
429 | Monthly limit reached for paste.create | Quota exhausted |