---
title: "Deploy Pastefy | (Just Updated) Pastebin & GitHub Gist Alternative, REST API Key Generated at Boot"
description: "Pastefy self-hosted pastebin with REST API, MariaDB and API key set at boot"
category: "Other"
url: https://railway.com/deploy/pastefy-or-just-updated-pastebin-and-git
---

# 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 on Railway](https://railway.com/template/pastefy-or-just-updated-pastebin-and-git)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/pastefy-or-just-updated-pastebin-and-git/manifest.json

- **Creator:** SuperSlowSloth
- **Category:** Other

## Template content

### mariadb

- **Image:** mariadb:11.8@sha256:6422478cb8e159f080fb1d8ccf65101e26fe51385787fde7d16c3b165a331f15
- **Start command:** `/bin/sh -c 'set -e; M=$(cat /sys/fs/cgroup/memory.max 2>/dev/null || echo max); if [ "$M" != max ]; then B=$((M / 2 / 1048576)); [ "$B" -lt 128 ] && B=128; else B=512; fi; export MARIADB_DATABASE=pastefy MARIADB_USER=pastefy; echo "[railway] uid=$(id -u) innodbBufferPoolMB=$B owner=$(stat -c %u:%g /var/lib/mysql)"; exec docker-entrypoint.sh mariadbd --datadir=/var/lib/mysql/data --innodb-buffer-pool-size=${B}M --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci'`

### pastefy

- **Image:** ghcr.io/bon5co/pastefy-railway:7.2.6@sha256:99c7b927bd453398cb2921a4f6546eaeb88e7cebd90d67df5fac36cad99ff1e2
- **Health check:** /api/v2/app/info
- **Public domain:** Yes

## Documentation

# 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

```bash
#!/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

- [Pastefy repository](https://github.com/interaapps/pastefy)
- [Official Docker image](https://hub.docker.com/r/interaapps/pastefy)
- [Wrapper image source](https://github.com/bon5co/pastefy-railway)


## Similar templates

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — A Self-Hosted & Modern Roleplaying Platform
- [Letta Code Remote](https://railway.com/deploy/letta-code-remote) — Run a Letta Code agent 24/7. No inbound ports, just deploy.

Open this page in a browser: https://railway.com/deploy/pastefy-or-just-updated-pastebin-and-git
