REST API
Everything the website and the CLI do with your scripts, you can do from your own code: create scripts, push versions, read them back. This page covers the basics every call shares.
Top things to remember
- Every endpoint lives under
https://pasteblox.com/api/v1. Send and receive JSON. - Sign requests with your API key in the
x-api-keyheader. Never put a key in a Roblox script, a loadstring or anything players can see: anyone with it can push code into your scripts. - Every error has the same shape:
{ "error": { "code", "message" } }. Branch oncode, showmessage. - On a
429, wait theRetry-Afterseconds before trying again. Hammering keeps you blocked. - A script is identified by its slug: 10 characters like
k3m9x2p7qa. Versions are numbered 1, 2, 3…, andlatestworks wherever a number does when reading. - Private scripts, and the code of key-protected scripts, are only visible to their owner. Everyone else gets
404, as if they didn't exist. - Lists are paged with an opaque
cursor. Keep asking withnextCursoruntil it'snull.
Your first call
- 1
Create an API key
Go to Dashboard → API keys (more below in API keys). Copy the key, it starts with
pbx_. - 2
Ask who you are
Requestshcurl https://pasteblox.com/api/v1/me \ -H "x-api-key: $PASTEBLOX_TOKEN"Response · 200json{ "user": { "handle": "you", "name": "You", "image": null, "role": "user" }, "auth": { "method": "api_key", "keyId": "utl7S1TH6DlpzKlqkQjw1YNtCy8y2e9d", "keyName": "github actions" } }This assumes the key is in an environment variable called
PASTEBLOX_TOKEN(export PASTEBLOX_TOKEN=pbx_…on macOS and Linux,$env:PASTEBLOX_TOKEN="pbx_…"in PowerShell). That's the same variable the CLI reads. - 3
Create a script
create.mjsjs// node 18+, deno, bun or a browser extension: anything with fetch const res = await fetch("https://pasteblox.com/api/v1/scripts", { method: "POST", headers: { "x-api-key": process.env.PASTEBLOX_TOKEN, "content-type": "application/json", }, body: JSON.stringify({ title: "door", content: 'print("open")' }), }); const data = await res.json(); if (!res.ok) throw new Error(`${data.error.code}: ${data.error.message}`); console.log(data.script.urls.loadstring);Every endpoint, with its fields and examples, is on Scripts endpoints.
Base URL and versioning
The v1 in the path is the contract the pbx CLI is built on, so it changes carefully. New fields can show up in responses over time: ignore the ones you don't know rather than failing on them.
Authentication
pasteblox looks at a request's headers in this order and uses the first one it finds:
No header at all means anonymous. Anonymous callers can read public and unlisted scripts, create unlisted scripts and report scripts.
API keys
Create them at Dashboard → API keys. A key acts as you, on everything you own, so make one per program and revoke it when you stop using it.

Dashboard → API keys: New API key (1), and your keys with when they were last used and when they expire (2).
- 1
Name it and pick when it expires

(1) A name you'll recognise later, like "GitHub Actions · my-game", up to 80 characters. (2) Never, 30 days, 90 days (the default) or 1 year: an expired key gets
401 unauthorizedand you make a new one. (3) Create key. - 2
Copy it now

The key is shown this one time. After that pasteblox only keeps a hash of it, so nobody (us included) can show it to you again. Lost it? Revoke it and make another. For GitHub Actions, save it as a secret named
PASTEBLOX_TOKEN(walkthrough).
- The list shows each key's name, when it was last used and when it expires. Revoking is instant (and has a short undo).
- Keys the CLI and VS Code create when you sign in are listed separately, under Dashboard → CLI devices.
- A suspended account's keys get
403 forbidden.
Anonymous scripts and claim tokens
Create a script with no key and the response includes a claimToken, exactly once. Send it as x-claim-token to push versions, edit or delete that script. Anonymous scripts are always unlisted. Later, POST /claim with a key moves them into your account (see Claim anonymous scripts).
Rate limits
Limits are token buckets: you can do a burst of requests at once, then they refill at a steady rate. The numbers:
Reads (getting a script, listing versions, your scripts) only count against the per-key limit. Go over any limit and you get a 429 with a Retry-After header and the same number in the body:
HTTP/1.1 429 Too Many Requests
Retry-After: 12
{ "error": { "code": "rate_limited", "message": "rate limited, retry in 12s", "retryAfter": 12 } }Wait that many seconds, then retry. A client that keeps retrying right away stays blocked, because blocked requests still count.
Errors
Anything that isn't a 2xx comes back with this body (the raw endpoint too):
{
"error": {
"code": "validation_failed",
"message": "content: script is empty",
"issues": [{ "path": "content", "message": "script is empty" }]
}
}Safe pushes with baseVersion
When you push a new version, send the version you started from as baseVersion. If it's not the newest any more, the push is refused instead of overwriting someone's work:
{
"error": {
"code": "version_conflict",
"message": "version 2 was pushed since your base @1; pull and retry",
"latestVersion": 2
}
}Fetch the newest version, merge, and push again with the new baseVersion. Leave it out to always overwrite. This is exactly what pbx push does, and what --force turns off.
Pagination
List endpoints (GET /me/scripts, GET /scripts/:slug/versions) return one page at a time:
{ "items": [ … ], "nextCursor": "SLgTdr2gACD4pSg54BNYfVFaDr9qHnSBjjAq-W_R7g" }cursor=""
while :; do
page=$(curl -s "https://pasteblox.com/api/v1/me/scripts?limit=100&cursor=$cursor" \
-H "x-api-key: $PASTEBLOX_TOKEN")
echo "$page" | jq -r '.items[].slug'
cursor=$(echo "$page" | jq -r '.nextCursor // empty')
[ -z "$cursor" ] && break
done