Free Pastebin API — Share Code Snippets via REST

March 2026 7 min read No signup required

Need a programmatic way to share code snippets, logs, or text? The Agent Paste Bin API lets you create, retrieve, update, and delete pastes via REST. It auto-detects programming languages, supports paste collections, provides a line-by-line diff tool, and offers both formatted and raw content endpoints — all without creating an account.

In this guide you'll learn how to create pastes, organize them into collections, diff two pastes, and integrate paste sharing into your development workflow.

Auto Language Detection

Upload code and the API detects Python, JavaScript, TypeScript, Go, Rust, and 20+ languages automatically.

Collections

Group related pastes into named collections — like a multi-file Gist but via API.

Paste Diff

Compare two pastes line-by-line. Great for code reviews, config changes, and version comparisons.

Expiring Pastes

Set pastes to auto-delete after a time period. Perfect for sharing sensitive logs or temporary snippets.

Quick Start — Create a Paste

curl
Python
Node.js
curl -X POST https://agent-gateway-kappa.vercel.app/v1/agent-paste/api/pastes \
  -H "Content-Type: application/json" \
  -d '{
    "content": "def fibonacci(n):\n    a, b = 0, 1\n    for _ in range(n):\n        a, b = b, a + b\n    return a",
    "title": "fibonacci.py"
  }'

# Response:
{
  "id": "aii5yhht",
  "url": ".../api/pastes/aii5yhht",
  "rawUrl": ".../api/pastes/aii5yhht/raw",
  "title": "fibonacci.py",
  "language": "python",
  "lines": 5,
  "bytes": 89,
  "hash": "3d73da5b43ce076f",
  "expiresAt": null,
  "created": "2026-03-03T20:31:26.666Z"
}
import requests

BASE = "https://agent-gateway-kappa.vercel.app/v1/agent-paste"

code = """def fibonacci(n):
    a, b = 0, 1
    for _ in range(n):
        a, b = b, a + b
    return a"""

resp = requests.post(
    f"{BASE}/api/pastes",
    json={"content": code, "title": "fibonacci.py"}
)
paste = resp.json()
print(f"Paste ID: {paste['id']}")
print(f"Language: {paste['language']}")  # "python"
print(f"Raw URL: {paste['rawUrl']}")
const BASE = "https://agent-gateway-kappa.vercel.app/v1/agent-paste";

const code = `def fibonacci(n):
    a, b = 0, 1
    for _ in range(n):
        a, b = b, a + b
    return a`;

const resp = await fetch(`${BASE}/api/pastes`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ content: code, title: "fibonacci.py" })
});
const paste = await resp.json();
console.log(`${paste.id} (${paste.language}) - ${paste.lines} lines`);

No API key required for basic paste creation. The language is detected automatically from the content and filename.

API Endpoints

MethodEndpointDescription
POST/api/pastesCreate a new paste
GET/api/pastes/:idGet paste by ID (with metadata)
GET/api/pastes/:id/rawGet raw paste content (plain text)
GET/api/pastesList your pastes
PUT/api/pastes/:idUpdate paste content
DELETE/api/pastes/:idDelete a paste
POST/api/collectionsCreate a collection of pastes
GET/api/collections/:idGet collection with all pastes
POST/api/diffDiff two pastes line-by-line

Create Options

When creating a paste, you can set several options:

curl -X POST https://agent-gateway-kappa.vercel.app/v1/agent-paste/api/pastes \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "SELECT * FROM users WHERE active = true;",
    "title": "active-users-query.sql",
    "language": "sql",
    "expiresIn": "1h",
    "visibility": "public",
    "metadata": {
      "project": "user-dashboard",
      "author": "devops-bot"
    }
  }'
FieldTypeDescription
contentstring (required)The paste content (max 5 MB)
titlestringFilename or description
languagestringProgramming language (auto-detected if omitted)
expiresInstringAuto-delete after: 1h, 6h, 1d, 7d, 30d
visibilitystringpublic (default) or unlisted
metadataobjectCustom key-value metadata for your own use

Get Raw Content

The /raw endpoint returns plain text — perfect for piping into scripts or embedding:

# Get raw content (no JSON wrapping)
curl https://agent-gateway-kappa.vercel.app/v1/agent-paste/api/pastes/aii5yhht/raw

def fibonacci(n):
    a, b = 0, 1
    for _ in range(n):
        a, b = b, a + b
    return a

# Pipe directly into a file
curl -s https://agent-gateway-kappa.vercel.app/v1/agent-paste/api/pastes/aii5yhht/raw > fibonacci.py

Collections — Multi-File Sharing

Group related pastes into a collection, like a multi-file Gist:

curl -X POST https://agent-gateway-kappa.vercel.app/v1/agent-paste/api/collections \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "API Bug Report",
    "description": "Files related to the auth token expiry bug",
    "pastes": ["paste_id_1", "paste_id_2", "paste_id_3"]
  }'

{
  "id": "col_x7y8z9",
  "name": "API Bug Report",
  "description": "Files related to the auth token expiry bug",
  "pasteCount": 3,
  "created": "2026-03-03T20:35:00.000Z"
}

Diff Two Pastes

Compare two pastes line-by-line to see what changed:

curl -X POST https://agent-gateway-kappa.vercel.app/v1/agent-paste/api/diff \
  -H "Content-Type: application/json" \
  -d '{
    "pasteA": "paste_id_old",
    "pasteB": "paste_id_new"
  }'

{
  "added": 3,
  "removed": 1,
  "unchanged": 12,
  "changes": [
    {"line": 5, "type": "removed", "content": "    return None"},
    {"line": 5, "type": "added", "content": "    return result"},
    {"line": 8, "type": "added", "content": "    logger.info('Done')"},
    {"line": 9, "type": "added", "content": "    return True"}
  ]
}

Real-World Use Cases

CI/CD Log Sharing

Save build logs, test output, or deployment results as pastes. Share URLs in Slack or Jira instead of pasting long text blocks.

AI Agent Output

AI agents can store generated code, analysis results, or reports as pastes with auto-detected language and shareable URLs.

Code Review & Collaboration

Share snippets for review, use collections for related files, and diff to compare versions before and after changes.

Config & Dotfile Sharing

Share nginx configs, .env templates, Dockerfiles, or CI configs with expiring links for security.

Comparison: Free Pastebin API vs Alternatives

FeatureAgent PastePastebin.comGitHub Gistdpaste.org
REST APIFull CRUDCreate onlyFull CRUDCreate only
Signup requiredNoNo (limited)Yes (GitHub)No
Auto language detectYesNoBy extensionNo
CollectionsYesNoMulti-file gistsNo
Diff toolYesNoNo (API)No
Raw content URLYesYesYesYes
Expiring pastesYesYesNoYes
Update pastesYesNoYesNo
Custom metadataYesNoNoNo
Max size5 MB512 KB100 MB250 KB

Key advantage: Agent Paste is the only pastebin with built-in collections and a diff API. Pastebin.com's API only supports creating pastes (no retrieval or updates without paid plan). GitHub Gist requires authentication. Agent Paste gives you full CRUD, collections, diff, and auto language detection — all without an account.

FAQ

Do I need an API key to create pastes?

Basic paste creation works without an API key. For listing your pastes, creating collections, updating, and deleting, you'll need a free API key from /api/keys/create.

Which programming languages are auto-detected?

Python, JavaScript, TypeScript, Java, C, C++, Go, Rust, Ruby, PHP, SQL, HTML, CSS, JSON, YAML, Bash, Markdown, and more. You can also manually set the language field.

What's the maximum paste size?

5 MB per paste. This is large enough for most code files, logs, and data dumps. For larger files, consider the File Storage API which supports up to 50 MB.

Can I use this as a GitHub Gist replacement?

For API-driven paste sharing, yes. Agent Paste has collections (like multi-file gists), full CRUD, and no auth requirement. However, Gists integrate with GitHub's ecosystem (version history, forking, starring), so they're better for public community sharing.

Are pastes public by default?

Pastes are public by default, meaning anyone with the paste ID/URL can view them. Set visibility: "unlisted" for pastes that shouldn't appear in listings. Use expiresIn for sensitive content that should auto-delete.

Create a Paste in One Request

No signup, no login. Just POST your content and get a shareable URL back instantly.

Getting Started Guide

API Catalog (39+ services) · Swagger Docs · More Tutorials