Overview
Server commands let you run your own Vestauth server with full control over your agent identity infrastructure.Self-hosting is optional. You can use
api.vestauth.com without running your own server.Prerequisites
- PostgreSQL database
- Node.js 18+ or standalone binary
Quick Start
server init
Create or update the server.env configuration file.
Options
string
default:"3000"
Server port. Defaults to
PORT environment variable, then 3000.string
default:"http://localhost:3000"
Server hostname (including scheme). Defaults to
HOSTNAME environment variable, then http://localhost:3000.In production, use your public domain (e.g., https://vestauth.yoursite.com).string
default:"postgres://localhost/vestauth_production"
PostgreSQL connection string. Defaults to
DATABASE_URL environment variable.Format: postgresql://USER:PASS@HOST:PORT/DATABASEExamples
Generated Configuration
Creates a.env file:
server start
Start the Vestauth server.Options
string
Override server port. Defaults to
PORT from .env.string
Override server hostname. Defaults to
HOSTNAME from .env.string
default:"postgres://localhost/vestauth_production"
Override database connection string. Defaults to
DATABASE_URL from .env.Examples
Server Endpoints
The server provides these endpoints:Production Deployment
For production:- Use a managed PostgreSQL database
- Set
HOSTNAMEto your public domain - Configure wildcard DNS (
*.vestauth.yoursite.com) - Use a process manager (PM2, systemd, etc.)
- Enable HTTPS via reverse proxy (nginx, Caddy)
server db:create
Create thevestauth_production PostgreSQL database.
Options
string
default:"postgres://localhost/vestauth_production"
PostgreSQL connection string. Defaults to
DATABASE_URL from .env.Examples
Requires PostgreSQL to be running and the user to have
CREATEDB privileges.server db:migrate
Run database migrations to create the required schema.Options
string
default:"postgres://localhost/vestauth_production"
PostgreSQL connection string. Defaults to
DATABASE_URL from .env.Database Schema
Creates these tables: agentsuid- Unique agent identifiercreated_at- Agent creation timestampupdated_at- Last update timestamp
kid- Key IDagent_uid- Associated agent UIDjwk- Public key (JSON Web Key)created_at- Key creation timestamprevoked_at- Key revocation timestamp (if revoked)
Running Migrations
Migrations are idempotent. Running them multiple times is safe.
server db:drop
Delete thevestauth_production database.
Options
string
default:"postgres://localhost/vestauth_production"
PostgreSQL connection string. Defaults to
DATABASE_URL from .env.When to Use
- Development: Reset local database
- Testing: Clean slate between test runs
- Migration testing: Verify migrations work on fresh database
Environment Variables
Server commands read these from.env:
Complete Setup Example
Here’s a full self-hosting workflow:Troubleshooting
Database Connection Failed
Port Already in Use
Migrations Failed
Related
- Agent Commands - Create agents using your server
- Development Guide - Contributing to Vestauth