The xpaste API lets you create links, manage pastes, and pull analytics data from any application or script. Whether you're building an internal tool, automating campaign setup, or integrating link shortening into your product, the API covers it all.
Authentication
Every API request requires a Bearer token in the Authorization header. Generate your API key from the dashboard under API Access.
Authorization: Bearer xp_your_api_key_hereCreating Your First Short Link
curl -X POST https://xpaste.io/api/v1/links \
-H "Authorization: Bearer xp_your_key" \
-H "Content-Type: application/json" \
-d '{
"originalUrl": "https://example.com/very/long/path?with=params",
"title": "My Campaign Link"
}'The response includes the generated short code and the full short URL ready to share.
{
"id": "clxyz123",
"shortCode": "a1b2c3d4",
"shortUrl": "https://xpaste.io/a1b2c3d4",
"originalUrl": "https://example.com/very/long/path?with=params",
"title": "My Campaign Link",
"createdAt": "2026-05-03T10:00:00Z"
}Bulk Link Generation with Node.js
const API_KEY = process.env.XPASTE_API_KEY
const BASE = 'https://xpaste.io/api/v1'
const campaigns = [
{ url: 'https://example.com/page-a', title: 'Ad Set A — Instagram' },
{ url: 'https://example.com/page-b', title: 'Ad Set B — Facebook' },
{ url: 'https://example.com/page-c', title: 'Ad Set C — Twitter' },
]
for (const campaign of campaigns) {
const res = await fetch(`${BASE}/links`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(campaign),
})
const data = await res.json()
console.log(`${campaign.title}: ${data.shortUrl}`)
}Available Endpoints
- GET /api/v1/me — Account info
- GET /api/v1/links — List all links with pagination
- POST /api/v1/links — Create a new short link
- PATCH /api/v1/links/:id — Update title, destination, or active status
- DELETE /api/v1/links/:id — Remove a link
- GET /api/v1/pastes — List pastes
- POST /api/v1/pastes — Create a paste
- DELETE /api/v1/pastes/:id — Delete a paste
Your API key is shown only once when created. Store it in an environment variable — never hardcode it in your source files.