---
title: "Deploy ByteStash | (Just Updated) Self-Hosted Code Snippet Manager, API Key + Login Locked From Boot"
description: "ByteStash self-hosted code snippet manager with REST API and MCP"
category: "Other"
url: https://railway.com/deploy/bytestash-or-just-updated-self-hosted-co
---

# Deploy ByteStash | (Just Updated) Self-Hosted Code Snippet Manager, API Key + Login Locked From Boot

ByteStash self-hosted code snippet manager with REST API and MCP

**[Deploy ByteStash | (Just Updated) Self-Hosted Code Snippet Manager, API Key + Login Locked From Boot on Railway](https://railway.com/template/bytestash-or-just-updated-self-hosted-co)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/bytestash-or-just-updated-self-hosted-co/manifest.json

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

## Template content

### bytestash

- **Image:** ghcr.io/bon5co/bytestash-railway:1.6.2@sha256:df10930d753ec4a9f19b2337380522e3357f0410465e6aaa748e9c9ee1cf22f7
- **Health check:** /
- **Public domain:** Yes

## Documentation

# Deploy and Host ByteStash on Railway

**Built for an LLM agent to deploy and use.** The deploy form has no fields to fill: the admin password and the API key are generated, sign-ups are closed before the first request, and the REST API and the MCP endpoint take the generated key. ByteStash is a self-hosted code snippet manager: store, tag, search and share snippets with syntax highlighting and multiple files per snippet.

## About Hosting ByteStash

This template runs one service, **bytestash** (Node.js and React with a built-in SQLite database), with the database on one volume mounted at `/data/snippets`. There is no separate database service to run.

**Locked from the first request.** A stock ByteStash has open registration and no account, so whoever opens the URL first registers and owns the instance. This template's image closes sign-ups, creates the `admin` account from `ADMIN_PASSWORD` at boot, installs `API_KEY` as a real API key, and refuses to start if either is empty. Add an `ADMIN_USERNAME` variable to change the username. Rotating either variable and redeploying applies the new value.

**What persists.** Snippets, accounts and API keys live on the volume at `/data/snippets`.

**Using the web interface.** Open the public URL and sign in as `admin` with the `ADMIN_PASSWORD` value from the service variables.

### Agent contract

- Public URL: `https://RAILWAY_PUBLIC_DOMAIN` (the generated domain of the `bytestash` service)
- Private URL: `http://bytestash.railway.internal:8080`
- Credentials: the variable `API_KEY` on the `bytestash` service for the API; `ADMIN_PASSWORD` (username `admin`; add an `ADMIN_USERNAME` variable to change it) for the web login
- Auth: send the header `x-api-key: API_KEY_VALUE` (the value of the `API_KEY` variable) on every `/api/snippets` request; without a valid key the API answers `401`. The MCP endpoint at `/mcp` takes the same key as `Authorization: Bearer API_KEY_VALUE` or `x-api-key`
- Health: `GET /` returns 200 without credentials

```bash
# needs: SITE_URL (public https URL of the bytestash service) and API_KEY (its variable); also curl, sed
BODY='{"title":"agent-check","description":"created by the agent contract","categories":["agent"],"fragments":[{"file_name":"hello.sh","code":"echo hello","language":"bash","position":0}]}'
curl -s -o /dev/null -w "health: %{http_code}\n" "$SITE_URL/"
curl -s -o /dev/null -w "read without key: %{http_code}\n" "$SITE_URL/api/snippets"
curl -s -o /dev/null -w "write without key: %{http_code}\n" -X POST -H "Content-Type: application/json" -d "$BODY" "$SITE_URL/api/snippets"
curl -s -o /dev/null -w "write wrong key: %{http_code}\n" -X POST -H "x-api-key: wrong" -H "Content-Type: application/json" -d "$BODY" "$SITE_URL/api/snippets"
ID=$(curl -s -X POST -H "x-api-key: $API_KEY" -H "Content-Type: application/json" -d "$BODY" "$SITE_URL/api/snippets" | sed -n 's/^{"id":\([0-9]*\).*/\1/p')
echo "snippet created: $ID"
{ curl -s -H "x-api-key: $API_KEY" "$SITE_URL/api/snippets"; echo; } | sed -n 's/.*"title":"\([^"]*\)".*/listed: \1/p'
curl -s -o /dev/null -w "snippet delete: %{http_code}\n" -X DELETE -H "x-api-key: $API_KEY" "$SITE_URL/api/snippets/$ID"
```

A fresh deploy prints `health: 200`, `read without key: 401`, `write without key: 401`, `write wrong key: 401`, a created snippet id, `listed: agent-check` and `snippet delete: 200`.

## Why Deploy ByteStash 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 ByteStash 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 key, a write and the refusal without it.
- **Locked from boot** - registration is closed and the password and key are generated, instead of upstream's first-visitor-owns-it default.
- **Data survives redeploys** - the database sits on a volume.
- **Pinned** - the image is pinned by digest.
- **Your snippets stay yours** - no cloud account, no subscription.

## Common Use Cases

- **Personal code snippet library** - shell one-liners, SQL, config fragments and boilerplate, searchable by tag and language.
- **Team snippet sharing** - share a snippet by link, public or protected, or embed it in docs.
- **Agent memory for code** - a coding agent stores and retrieves reusable snippets through the REST API or the MCP endpoint.
- **Self-hosted Gist alternative** - multi-file snippets with syntax highlighting on your own infrastructure.

## Dependencies for ByteStash Hosting

- Nothing else: SQLite runs inside the service on its volume. A custom domain is optional.

### Deployment Dependencies

- [ByteStash repository](https://github.com/jordan-dalby/ByteStash)
- [ByteStash documentation](https://github.com/jordan-dalby/ByteStash/wiki)
- [Official Docker image](https://github.com/jordan-dalby/ByteStash/pkgs/container/bytestash)
- [Wrapper image source](https://github.com/bon5co/bytestash-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/bytestash-or-just-updated-self-hosted-co
