Deploy Pastefy | (Just Updated) Pastebin & GitHub Gist Alternative, REST API Key Generated at Boot

Pastefy self-hosted pastebin with REST API, MariaDB and API key set at boot

Deploy Pastefy | (Just Updated) Pastebin & GitHub Gist Alternative, REST API Key Generated at Boot

Just deployed

/var/lib/mysql

Just deployed

Deploy and Host Pastefy on Railway

Built for an LLM agent to deploy and use. The deploy form has no fields to fill: the API key is generated at deploy time, the MariaDB that stores the pastes is included with a volume, and every write answers 401 until the generated key is sent. Pastefy is an open-source self-hosted pastebin, a GitHub Gist alternative: store text and code snippets, share them by link, and read or create them over a REST API.

About Hosting Pastefy

This template runs two services: pastefy (the pastebin API and web page behind one public domain) and mariadb (MariaDB 11.8 with a volume mounted at /var/lib/mysql). Pastes, folders and users live in MariaDB, so they survive redeploys of either service.

Locked from boot. Stock Pastefy lets anyone create pastes, and the only way to get an API key is to sign in through an OAuth provider, so a fresh instance has no credential an agent can use. This template's image requires login to create a paste, and at every boot creates an administrator and an API key from the PASTEFY_API_KEY variable (40 generated alphanumerics) once the database tables exist. A write without the key, or with a wrong one, answers 401. Reading a paste is open to anyone who has its link, and a new paste is unlisted by default.

Using it. Create, update and delete pastes with the REST API below. The web page serves reads; its OAuth sign-in button is not connected to anything, so creating pastes from the page is not available.

Agent contract

  • Public URL: https://RAILWAY_PUBLIC_DOMAIN (the generated domain of the pastefy service)
  • Private URL: http://pastefy.railway.internal:8080
  • Credentials: the variable PASTEFY_API_KEY on the pastefy service (there is no username)
  • Auth: send Authorization: Bearer $PASTEFY_API_KEY on every write; a write without it or with a wrong key answers 401
  • Health: GET /api/v2/app/info returns 200 without credentials
#!/bin/sh
# needs: SITE_URL (public https URL of the pastefy service) and PASTEFY_API_KEY (its variable); also curl, grep, cut
H="Content-Type: application/json"
curl -s -o /dev/null -w "health: %{http_code}\n" "$SITE_URL/api/v2/app/info"
curl -s -o /dev/null -w "write without key: %{http_code}\n" -X POST -H "$H" -d '{"title":"x","content":"x"}' "$SITE_URL/api/v2/paste"
curl -s -o /dev/null -w "write with wrong key: %{http_code}\n" -X POST -H "$H" -H "Authorization: Bearer not-the-key-not-the-key-not-the-key-0" -d '{"title":"x","content":"x"}' "$SITE_URL/api/v2/paste"
ID=$(curl -s -X POST -H "$H" -H "Authorization: Bearer $PASTEFY_API_KEY" -d '{"title":"agent-check","content":"hello from an agent"}' "$SITE_URL/api/v2/paste" | grep -o '"id":"[A-Za-z0-9]*"' | head -1 | cut -d'"' -f4)
echo "paste id: ${ID:+created}"
echo "raw read: $(curl -s "$SITE_URL/$ID/raw")"
curl -s -o /dev/null -w "delete: %{http_code}\n" -X DELETE -H "Authorization: Bearer $PASTEFY_API_KEY" "$SITE_URL/api/v2/paste/$ID"
curl -s -o /dev/null -w "after delete: %{http_code}\n" "$SITE_URL/$ID/raw"

A fresh deploy prints health: 200, write without key: 401, write with wrong key: 401, paste id: created, raw read: hello from an agent, delete: 200 and after delete: 404.

Why Deploy Pastefy on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Pastefy on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

  • Agent-ready - no deployer fields, a contract block and one script that proves the refusal without a key, a create, a read and a delete.
  • Locked by default - nobody can create pastes anonymously, and there is no API key to fetch from a sign-in provider you do not have.
  • Data survives redeploys - pastes sit in MariaDB on a volume.
  • Pinned - the upstream image is pinned by digest.
  • No per-paste pricing - unlimited pastes on your own domain.

Common Use Cases

  • Self-hosted pastebin - share logs, configs and code snippets by link without sending them to a public paste site.
  • Agent scratch space - an agent stores long output or a patch as a paste and hands back the raw link.
  • Gist alternative for a team - snippets and notes on infrastructure you control.
  • Log and diff sharing for CI - a job posts a build log with the API key and prints the paste URL.

Dependencies for Pastefy Hosting

  • The pastefy service and a MariaDB service with a volume, both created by the template. A custom domain is optional.

Deployment Dependencies


Template Content

More templates in this category

View Template
Rocky Linux
Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀

codestorm
51
View Template
Foundry Virtual Tabletop
A Self-Hosted & Modern Roleplaying Platform

Lucas
71
View Template
Letta Code Remote
Run a Letta Code agent 24/7. No inbound ports, just deploy.

Letta
52