API & MCP
Everything you can do on PasteCode, from a terminal or from an AI assistant. Same rules, same limits, one key.
Base URL
https://pastecode.io/api/v1MCP endpoint
https://pastecode.io/api/mcpAuth
Authorization: Bearercurl -X POST https://pastecode.io/api/v1/snippets \
-H "Authorization: Bearer pc_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "content": "print(\"hello\")", "language": "python", "visibility": "public" }'Getting started
Open your profile, go to the API & MCP tab and create a key. It is shown once, so copy it then. A key belongs to your account and can do what you can do, nothing more.
Choose read only for anything that should never change your snippets, which is usually the right choice for an AI assistant you are still getting to know.
Authentication
Send the key as a bearer token on every request. There is no cookie, no session and no other header that works.
curl https://pastecode.io/api/v1/me -H "Authorization: Bearer pc_YOUR_API_KEY"Requests are accepted from any origin, since a bearer token cannot be attached by a browser on your behalf. Never put a key in client-side code: anyone reading the page can take it.
Limits
The API enforces exactly what the website does. The one exception is the captcha, which a key replaces. In particular creating snippets is paced at one every 15 seconds, so a batch has to wait between writes.
A few things only the browser can do: creating an end-to-end encrypted snippet, since its passphrase never leaves your machine, and changing a snippet's password, expiry or burn-after-read after it exists. Reading a burn-after-read snippet over the API destroys it, exactly as opening it would.
Errors
Every failure carries the right status and the same body. Branch on
code; the message is for a human and may be reworded.{
"error": {
"code": "validation_failed",
"message": "title can not be longer than 50 characters"
}
}Snippets
Create, read, change and delete the snippets your account owns. Reading also works for any public snippet.
GET
/api/v1/snippetsList the snippets you own, newest first.
Query parameters
Response
{
"data": [ {
"slug": "a1b2c3d4",
"url": "https://pastecode.io/s/a1b2c3d4",
"rawUrl": "https://pastecode.io/api/v1/snippets/a1b2c3d4/raw",
"title": "Debounce hook",
"description": "A small React hook",
"language": "typescript",
"content": "export const useDebounce = () => {}",
"visibility": "public",
"passwordProtected": false,
"encrypted": false,
"burnAfterRead": false,
"commentsAllowed": true,
"collectionId": null,
"hits": 12,
"banned": false,
"spam": false,
"createdAt": "2026-08-06T10:00:00.000Z",
"updatedAt": "2026-08-06T10:00:00.000Z",
"expiresAt": null
} ],
"pagination": { "page": 1, "perPage": 20, "total": 42, "totalPages": 3 }
}POST
/api/v1/snippetsneeds a read & write keyCreate a snippet. Answers 201 with a Location header naming the new resource.
Body
Request
curl -X POST https://pastecode.io/api/v1/snippets \
-H "Authorization: Bearer pc_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "export const useDebounce = () => {}",
"title": "Debounce hook",
"language": "typescript",
"visibility": "public"
}'Response
{
"slug": "a1b2c3d4",
"url": "https://pastecode.io/s/a1b2c3d4",
"rawUrl": "https://pastecode.io/api/v1/snippets/a1b2c3d4/raw",
"title": "Debounce hook",
"description": "A small React hook",
"language": "typescript",
"content": "export const useDebounce = () => {}",
"visibility": "public",
"passwordProtected": false,
"encrypted": false,
"burnAfterRead": false,
"commentsAllowed": true,
"collectionId": null,
"hits": 12,
"banned": false,
"spam": false,
"createdAt": "2026-08-06T10:00:00.000Z",
"updatedAt": "2026-08-06T10:00:00.000Z",
"expiresAt": null
}GET
/api/v1/snippets/{slug}Read one snippet. Works for your own and for any public one.
Request
curl https://pastecode.io/api/v1/snippets/a1b2c3d4 \
-H "Authorization: Bearer pc_YOUR_API_KEY"Response
{
"slug": "a1b2c3d4",
"url": "https://pastecode.io/s/a1b2c3d4",
"rawUrl": "https://pastecode.io/api/v1/snippets/a1b2c3d4/raw",
"title": "Debounce hook",
"description": "A small React hook",
"language": "typescript",
"content": "export const useDebounce = () => {}",
"visibility": "public",
"passwordProtected": false,
"encrypted": false,
"burnAfterRead": false,
"commentsAllowed": true,
"collectionId": null,
"hits": 12,
"banned": false,
"spam": false,
"createdAt": "2026-08-06T10:00:00.000Z",
"updatedAt": "2026-08-06T10:00:00.000Z",
"expiresAt": null
}GET
/api/v1/snippets/{slug}/rawThe body alone, as text/plain. Send X-Snippet-Password for a protected snippet.
Request
curl https://pastecode.io/api/v1/snippets/a1b2c3d4/raw \
-H "Authorization: Bearer pc_YOUR_API_KEY"Response
export const useDebounce = () => {}PATCH
/api/v1/snippets/{slug}needs a read & write keyChange a snippet you own. Anything you leave out keeps its current value; an explicit null clears it.
Body
Request
curl -X PATCH https://pastecode.io/api/v1/snippets/a1b2c3d4 \
-H "Authorization: Bearer pc_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "title": "A better title" }'Response
{
"slug": "a1b2c3d4",
"url": "https://pastecode.io/s/a1b2c3d4",
"rawUrl": "https://pastecode.io/api/v1/snippets/a1b2c3d4/raw",
"title": "Debounce hook",
"description": "A small React hook",
"language": "typescript",
"content": "export const useDebounce = () => {}",
"visibility": "public",
"passwordProtected": false,
"encrypted": false,
"burnAfterRead": false,
"commentsAllowed": true,
"collectionId": null,
"hits": 12,
"banned": false,
"spam": false,
"createdAt": "2026-08-06T10:00:00.000Z",
"updatedAt": "2026-08-06T10:00:00.000Z",
"expiresAt": null
}DELETE
/api/v1/snippets/{slug}needs a read & write keyDelete a snippet you own. Answers 204 with no body.
Response
204 No ContentCollections
Collections are named folders of snippets. Membership is its own resource, so attaching is a PUT and detaching a DELETE.
GET
/api/v1/collectionsList the collections you own.
Response
{ "data": [ {
"id": "abc123",
"url": "https://pastecode.io/collections/abc123",
"name": "React hooks",
"description": "Things I keep rewriting",
"isPublic": true,
"spam": false,
"snippetCount": 4,
"createdAt": "2026-08-06T10:00:00.000Z",
"updatedAt": "2026-08-06T10:00:00.000Z"
} ] }POST
/api/v1/collectionsneeds a read & write keyCreate a collection. Answers 201 with a Location header.
Body
Request
curl -X POST https://pastecode.io/api/v1/collections \
-H "Authorization: Bearer pc_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "React hooks", "isPublic": true }'Response
{
"id": "abc123",
"url": "https://pastecode.io/collections/abc123",
"name": "React hooks",
"description": "Things I keep rewriting",
"isPublic": true,
"spam": false,
"snippetCount": 4,
"createdAt": "2026-08-06T10:00:00.000Z",
"updatedAt": "2026-08-06T10:00:00.000Z"
}GET
/api/v1/collections/{id}Read one collection.
Response
{
"id": "abc123",
"url": "https://pastecode.io/collections/abc123",
"name": "React hooks",
"description": "Things I keep rewriting",
"isPublic": true,
"spam": false,
"snippetCount": 4,
"createdAt": "2026-08-06T10:00:00.000Z",
"updatedAt": "2026-08-06T10:00:00.000Z"
}PATCH
/api/v1/collections/{id}needs a read & write keyRename a collection or change whether it is public.
Body
Response
{
"id": "abc123",
"url": "https://pastecode.io/collections/abc123",
"name": "React hooks",
"description": "Things I keep rewriting",
"isPublic": true,
"spam": false,
"snippetCount": 4,
"createdAt": "2026-08-06T10:00:00.000Z",
"updatedAt": "2026-08-06T10:00:00.000Z"
}DELETE
/api/v1/collections/{id}needs a read & write keyDelete an empty collection. One still holding snippets has to be emptied first.
Response
204 No ContentGET
/api/v1/collections/{id}/snippetsList the snippets inside a collection.
Query parameters
Response
{
"data": [ {
"slug": "a1b2c3d4",
"url": "https://pastecode.io/s/a1b2c3d4",
"rawUrl": "https://pastecode.io/api/v1/snippets/a1b2c3d4/raw",
"title": "Debounce hook",
"description": "A small React hook",
"language": "typescript",
"content": "export const useDebounce = () => {}",
"visibility": "public",
"passwordProtected": false,
"encrypted": false,
"burnAfterRead": false,
"commentsAllowed": true,
"collectionId": null,
"hits": 12,
"banned": false,
"spam": false,
"createdAt": "2026-08-06T10:00:00.000Z",
"updatedAt": "2026-08-06T10:00:00.000Z",
"expiresAt": null
} ],
"pagination": { "page": 1, "perPage": 20, "total": 42, "totalPages": 3 }
}PUT
/api/v1/collections/{id}/snippets/{slug}needs a read & write keyPut one of your snippets in this collection. Idempotent, answers 204.
Request
curl -X PUT https://pastecode.io/api/v1/collections/abc123/snippets/a1b2c3d4 \
-H "Authorization: Bearer pc_YOUR_API_KEY"Response
204 No ContentDELETE
/api/v1/collections/{id}/snippets/{slug}needs a read & write keyTake a snippet out of this collection. The snippet itself is not deleted.
Response
204 No ContentArchive search
Search the public archive, including the code inside snippets. This is how to find something you do not already have a slug for. A query shorter than 3 characters does not reach snippet bodies, because a trigram index cannot serve it.
GET
/api/v1/archive/snippetsSearch or browse public snippets. Returns at most 100 matches.
Query parameters
Request
curl "https://pastecode.io/api/v1/archive/snippets?q=useState&language=typescript" \
-H "Authorization: Bearer pc_YOUR_API_KEY"Response
{
"data": [
{
"slug": "a1b2c3d4",
"url": "https://pastecode.io/s/a1b2c3d4",
"title": "Debounce hook",
"description": "A small React hook",
"language": "typescript",
"languageLabel": "TypeScript",
"author": "beykan",
"preview": "const [value, setValue] = useState('')",
"previewTruncated": true,
"matchedInBody": true,
"hits": 12,
"createdAt": "2026-08-06T10:00:00.000Z"
}
],
"pagination": { "page": 1, "perPage": 20, "total": 42, "totalPages": 3 },
"query": "useState",
"resultLimit": 100
}GET
/api/v1/archive/languagesThe syntaxes public snippets actually use, and so the valid values for the language filter.
Response
{ "data": [ { "language": "typescript", "label": "TypeScript" } ] }Account
Who the key acts as, and what it may do.
GET
/api/v1/meThe account behind this key, and the key itself.
Request
curl https://pastecode.io/api/v1/me -H "Authorization: Bearer pc_YOUR_API_KEY"Response
{
"userId": "9d4c...",
"nick": "beykan",
"email": "[email protected]",
"premium": true,
"key": { "name": "Claude Code", "scope": "read_write" }
}MCP setup
PasteCode speaks the Model Context Protocol over streamable HTTP at
https://pastecode.io/api/mcp, authenticated with the same key. Pick your client and paste.Claude Code
Cursor
VS Code
Codex CLI
Claude Desktop
ChatGPT
Run this in any terminal.
claude mcp add --transport http pastecode https://pastecode.io/api/mcp \
--header "Authorization: Bearer pc_YOUR_API_KEY"MCP tools
A read only key is offered the read tools alone, so an assistant is never shown something it would only be refused.