---
title: "Deploy BookStack | (Just Updated) Wiki With REST API, Admin and API Token Generated"
description: "BookStack wiki + MariaDB, admin and API token generated, no setup needed"
category: "CMS"
url: https://railway.com/deploy/bookstack-or-just-updated-wiki-with-rest
---

# Deploy BookStack | (Just Updated) Wiki With REST API, Admin and API Token Generated

BookStack wiki + MariaDB, admin and API token generated, no setup needed

**[Deploy BookStack | (Just Updated) Wiki With REST API, Admin and API Token Generated on Railway](https://railway.com/template/bookstack-or-just-updated-wiki-with-rest)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/bookstack-or-just-updated-wiki-with-rest/manifest.json

- **Creator:** SuperSlowSloth
- **Category:** CMS
- **Total deploys:** 1

## 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=bookstack MARIADB_USER=bookstack; 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'`

### bookstack

- **Image:** linuxserver/bookstack@sha256:0d66f65417fa667085849bf9b32b412ec9a90420773c4f47a95138c4711876b7
- **Start command:** `/bin/sh -c 'set -e; export PUID=1000 PGID=1000 TZ=Etc/UTC DB_PORT=3306 DB_DATABASE=bookstack DB_USERNAME=bookstack APP_PROXIES="*"; export APP_KEY="base64:$(printf %s "$BOOKSTACK_KEY_SEED" | openssl dgst -sha256 -binary | openssl base64 -A)"; mkdir -p /custom-cont-init.d; echo "IyEvYmluL2Jhc2gKIyBCb29rU3RhY2sgb24gUmFpbHdheTogcnVucyBpbnNpZGUg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pbHdheV0gdG9rZW4gc3RlcCBleGl0PSQ/Igo=" | base64 -d > /custom-cont-init.d/10-railway.sh; chmod +x /custom-cont-init.d/10-railway.sh; P=${PORT:-8080}; sed -i "s/listen 80 /listen $P /; s/listen \[::\]:80 /listen [::]:$P /" /defaults/nginx/site-confs/default.conf.sample /config/nginx/site-confs/default.conf 2>/dev/null || true; echo "[railway] uid=$(id -u) config_owner=$(stat -c %u:%g /config) port=$P db=$DB_HOST"; n=0; until nc -z -w2 "$DB_HOST" "$DB_PORT" 2>/dev/null; do n=$((n+1)); if [ $n -gt 150 ]; then echo "[railway] database never answered"; break; fi; sleep 2; done; exec /init'`
- **Health check:** /status
- **Public domain:** Yes

## Documentation

# Deploy and Host BookStack on Railway

BookStack is the open-source wiki that organises documentation as shelves, books, chapters and pages, with a full REST API. This template deploys BookStack with its own MariaDB database, a persistent volume, and **everything an AI agent needs already generated** - nothing to fill in, no browser step, no default password left behind.

**Easy for an LLM agent to use.** There is no manual deploy step: deploy, read the variables below, and call the API. The admin login and a working API token pair are generated at deploy time (BookStack's well-known `admin@admin.com` / `password` is replaced on first boot), the contract block below lists every URL and variable name, and one `curl` against `/api/books` works as soon as the service is healthy.

## About Hosting BookStack

Two services run in one Railway project:

- **bookstack** - the `linuxserver/bookstack` image (pinned by digest: nginx, PHP-FPM, queue worker and cron in one container). The uploads, images, themes and config live on a volume mounted at `/config`.
- **mariadb** - the official `mariadb` image (pinned by digest) on its own volume. The data directory is a subfolder of the mount, so the filesystem's `lost+found` never lands inside it. The database password is generated and wired into BookStack over the private network.

On first boot the start command derives a valid Laravel `APP_KEY` (`base64:` plus 32 bytes) from a generated seed, waits for MariaDB, lets BookStack run its migrations, then a boot step (a) rewrites the default admin with the generated email and password and (b) creates the API token pair in the database. On every later boot the same step finds both already in place and changes nothing, so redeploys are safe.

### Agent contract

- Base URL: `https://` (also in variable `APP_URL`)
- Health path: `GET /status` - unauthenticated, returns `{"database":true,"cache":true,"session":true}`
- Admin login (`/login`): email in `BOOKSTACK_ADMIN_EMAIL`, password in `BOOKSTACK_ADMIN_PASSWORD`
- API token id: `BOOKSTACK_API_TOKEN_ID`, token secret: `BOOKSTACK_API_TOKEN_SECRET` (admin role, expires in 100 years)
- API header: `Authorization: Token :`
- API reference: `/api/docs` (after logging in)
- Database (private network only): service `mariadb`, host in `DB_HOST`, password in `DB_PASSWORD`, database and user `bookstack`
- Generated variables, all on the `bookstack` service: `BOOKSTACK_KEY_SEED`, `BOOKSTACK_ADMIN_PASSWORD`, `BOOKSTACK_API_TOKEN_ID`, `BOOKSTACK_API_TOKEN_SECRET`

One working call:

```bash
curl -s https:///api/books \
  -H "Authorization: Token $BOOKSTACK_API_TOKEN_ID:$BOOKSTACK_API_TOKEN_SECRET"
# {"data":[],"total":0}
```

Create a book and a page:

```bash
curl -s https:///api/books -X POST \
  -H "Authorization: Token $BOOKSTACK_API_TOKEN_ID:$BOOKSTACK_API_TOKEN_SECRET" \
  -H 'content-type: application/json' -d '{"name":"Runbooks","description":"Team runbooks"}'
```

## Why Deploy BookStack 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 BookStack 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.

- **No default credentials** - the stock `admin@admin.com` / `password` account is rewritten on first boot; the generated password is in your variables.
- **API token ready** - a token pair is created at boot, so an agent can read and write the wiki without opening the UI.
- **Zero configuration** - no variable asks you for anything; `APP_URL` follows the public domain and the database is wired automatically.
- **Data survives redeploys** - uploads, images and the database each sit on a volume, verified with a write, a redeploy and a read.

## Common Use Cases

- **Agent memory and knowledge base** - let an LLM agent write structured notes and look them up through the REST API.
- **Team documentation and runbooks** - a Confluence alternative with shelves, books, chapters, search and permissions.
- **Internal handbooks and onboarding** - a wiki non-technical colleagues can edit in a visual or Markdown editor.

## Dependencies for BookStack Hosting

- A volume at `/config` on the `bookstack` service and a volume at `/var/lib/mysql` on the `mariadb` service (both included in this template).

### Deployment Dependencies

- [BookStackApp/BookStack](https://github.com/BookStackApp/BookStack) - upstream project
- [linuxserver/docker-bookstack](https://github.com/linuxserver/docker-bookstack) - the image this template deploys
- [mariadb on Docker Hub](https://hub.docker.com/_/mariadb) - the database image


## Similar templates

- [Libredesk - Complete Setup](https://railway.com/deploy/libredesk-complete-setup) — Complete self-hosted omnichannel customer support desk.
- [Paperless-ngx](https://railway.com/deploy/paperless-ngx-3) — Paperless-ngx — document management with OCR and full-text search
- [Instatic CMS - Postgres](https://railway.com/deploy/instatic-cms-postgres) — Design, build and manage powerful static sites from state-of-the-art CMS

Open this page in a browser: https://railway.com/deploy/bookstack-or-just-updated-wiki-with-rest
