
Deploy Typesense API Keys
scoped keys and multi-tenant search
typesense-railway
Just deployed
Deploy and Host self hosted Typesense API Keys (Open-Source Instant Search) on Railway
.
About Hosting Typesense API Keys open-source software on Railway (self hosted Typesense template)
Typesense API Keys is a deployment template that packages the open-source Typesense instant search engine with a focus on scoped API keys and multi-tenant search isolation. Instead of relying on a single admin key for all reads and writes, this template lets you generate granular, expiring, collection-scoped keys that restrict search to specific tenants, datasets, or fields. Running Typesense API Keys on Railway means you control the full key lifecycle: create keys with actions: ["documents:search"], bind them to a collection alias, set an expiration timestamp, and revoke them instantly when a tenant leaves. The template uses the official typesense/typesense:30.2 Docker image, starts the server with --data-dir /data --api-key=$TYPESENSE_API_KEY --enable-cors, and persists the /data volume on Railway so API key metadata and search indexes survive restarts and deploys.
Typesense is GPL-3.0 licensed, so you own the binaries, data directory, key store, and network path. On Railway, the service runs as a single container with an internal hostname, an exposed 8108 port, and a persistent volume. You can mount the same volume across redeploys, clone the service for staging, or add a second replica for high availability. The TYPESENSE_API_KEY environment variable is the bootstrap admin key: Typesense requires it at startup and refuses to boot without it. That single secret unlocks every scoped key you will later mint via the REST API. Losing it means losing administrative access, so Railway's encrypted environment variable store is your first line of defense.
Why Deploy Typesense API Keys, the Algolia alternative on Railway (Railway Free Trial)
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 Typesense API Keys 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.
Railway vs Other Hosting Providers and VPS for Typesense API Keys self hosting
| Provider | Key Differences for Typesense API Keys | Pricing Model | Best For |
|---|---|---|---|
| DigitalOcean | Droplet gives full VM control but you manage Docker, volume snapshots, firewall, and TLS termination manually. No built-in zero-downtime redeploys for key rotation. | Flat monthly VM + block storage | Developers comfortable with SSH and systemd |
| AWS | EC2 or ECS gives deep IAM integration, but Typesense API key scoping is separate from AWS IAM. You pay for ALB, EBS, and CloudWatch. | Pay-per-hour + egress + storage | Enterprises already inside AWS VPC |
| Hetzner | Very cheap dedicated or cloud VPS, but no managed volumes or one-click rollback. You must secure the admin API key endpoint yourself. | Low hourly VM + storage | Budget-conscious self-hosters |
Railway removes the VPS babysitting: volume attached automatically, health checks hit 8108/health, and redeploys swap containers without losing /data. You still set TYPESENSE_API_KEY once and use the same scoped-key REST calls as on any host. The $5 GitHub trial lets you test multi-tenant search without a credit card.
Common Use Cases for hosted Typesense API Keys
Multi-tenant SaaS search is the primary use case. Each tenant gets a scoped API key that filters searches to only their documents using the filter_by parameter baked into the key. For example, a key created with filter_by: tenant_id:=acme will never return documents from tenant_id:=globex, even if the client modifies the query. This removes the need for separate collections per tenant and keeps your index compact.
Public-facing faceted search with time-limited keys is another common use case. An e-commerce site can issue a scoped key that expires in 15 minutes, restricts searches to visible:true, and allows only documents:search — no writes, no collection listing, no key creation. The InstantSearch.js frontend uses that key directly from the browser because --enable-cors is enabled at startup. When the key expires, the client silently fails and you mint a new one server-side.
Internal analytics dashboards also benefit. A data team can get a read-only key scoped to an analytics_events collection with filter_by: team:data-eng. They can query aggregations and facets but cannot delete documents or alter schema. Because Typesense API Keys runs on Railway with a persistent volume, key definitions survive container restarts; no external Redis or database is needed for scoped key metadata.
Finally, ephemeral demo environments are trivial: clone the Railway service, generate a temporary admin key, seed sample documents, and hand out a 24-hour scoped key to a prospect. Destroy the clone when done. No per-search fees, no record count limits, no vendor lock-in.
Dependencies for Typesense API Keys Docker hosted on Railway
.
Deployment Dependencies for Managed Typesense API Keys Service (Instant Search)
The only hard dependency is the typesense/typesense:30.2 image and a writable volume mounted at /data. Railway provides both. You must set TYPESENSE_API_KEY as a service variable. Optionally set TYPESENSE_DATA_DIR to /data, but the start command already includes --data-dir /data. No external database, message queue, or object storage is required; the service is fully self-contained.
Network-wise, the container listens on 8108. Railway's private network gives the service an internal hostname for internal access, and you can generate a public domain if browser clients will call the search endpoint directly. For scoped key generation, your application server makes an HTTP call to http://:8108/keys with the admin API key in the X-TYPESENSE-API-KEY header. That application server can be another Railway service in the same project.
Implementation Details for Typesense API Keys (Using Typesense official docker image)
Deploy a Railway service from the typesense/typesense:30.2 image. Set the start command to:
--data-dir /data --api-key=$TYPESENSE_API_KEY --enable-cors
Attach a volume to /data. Set TYPESENSE_API_KEY to a long random string, e.g., 64 hex characters. Do not use latest; pin to 30.2 for reproducibility. Railway's health check should hit http://localhost:8108/health and expect a 200 response. The service becomes healthy only after the server loads the data directory and the API key is set.
Once healthy, create a collection via REST:
curl -X POST http://:8108/collections \
-H "X-TYPESENSE-API-KEY: $TYPESENSE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"products","fields":[{"name":"title","type":"string"},{"name":"tenant_id","type":"string","facet":true}],"default_sorting_field":"num_sales"}'
Then create a scoped key:
curl -X POST http://:8108/keys \
-H "X-TYPESENSE-API-KEY: $TYPESENSE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"description":"tenant acme search key","actions":["documents:search"],"collections":["products"],"filter_by":"tenant_id:=acme","expires_at":1735689600}'
The response contains the scoped key value. Use that key in the browser InstantSearch client. Keys are stored in Typesense's internal metadata on the persistent /data volume, so redeploys keep them valid. To revoke a key, send DELETE /keys/:id with the admin key.
How does Typesense API Keys compare against other Search Security platforms
Typesense API Keys vs Algolia (Algolia Alternative)
Algolia offers API keys with ACLs, indices, and optional filters, but you cannot self-host Algolia. Its security model lives inside Algolia's proprietary cloud. Typesense API Keys gives you the same scoped-key concepts — actions, collections, filter_by, expiration — but on infrastructure you control. Algolia Grow pricing charges per search request and per record stored; a multi-tenant app with millions of searches can quickly become unpredictable. Self-hosted Typesense on Railway costs a flat compute and volume fee, typically single-digit to low-teens USD per month for a small node. You also avoid sharing tenant data with a third-party search vendor.
Typesense API Keys vs Elasticsearch (Elasticsearch Alternative)
Elasticsearch has document-level security via X-Pack, but it is complex to configure and often requires separate Kibana or Shield layers. Scoped API keys in Elasticsearch are tied to roles, and multi-tenant filtering usually demands custom scripts or separate indices. Typesense API Keys bakes tenant filtering into the key itself with filter_by, which is simpler and faster to audit. Elasticsearch is also heavier: a minimum production cluster needs 3 nodes and significant RAM. A single Typesense container on Railway handles most multi-tenant search workloads under a few million documents.
Typesense API Keys vs Meilisearch (Meilisearch Alternative)
Meilisearch has API keys with scopes and indexes, and it is also open-source and self-hostable. However, Meilisearch's tenant isolation is less granular out of the box; you often need a separate index per tenant or tenant tokens with custom JWT claims. Typesense API Keys puts the tenant filter directly in the scoped key without an external JWT signing service. Both are lightweight and fast, but Typesense's filter_by scoping and per-key expiration timestamps make multi-tenant SaaS search more explicit and easier to manage from a single admin key.
Typesense API Keys vs Typesense Cloud (Typesense Cloud Alternative)
Typesense Cloud is the managed SaaS version of the same engine. It provides scoped API keys identically, bu
Template Content
typesense-railway
Shinyduo/typesense-railway