Prompt
How do I create docs for multiple API environments?
Latest observation
Oct 16, 2026
OpenAI APIWeb search: off
To document multiple API environments, the usual pattern is to separate shared API content from environment-specific values.
1. Define each environment clearly
Common environments:
devstagingproduction
For each one, document:
- Base URL
- Authentication method
- Any environment-specific credentials or scopes
- Feature flags or limitations
- Sample responses if they differ
Example:
| Environment | Base URL | Notes |
|---|---|---|
| Dev | https://api-dev.example.com | Test data only |
| Staging | https://api-staging.example.com | Mirrors production closely |
| Prod | https://api.example.com | Live data |
2. Keep endpoint docs reusable
Write each endpoint once, then parameterize the parts that change by environment:
- base URL
- API keys
- tenant IDs
- region codes
Example:
GET /v1/users
Authorization: Bearer {{api_token}}
Host: {{base_url}}
Then show environment-specific values in a table or variables section.
3. Use variables in docs if your tooling supports it
If you use tools like:
- OpenAPI/Swagger
- Postman
- Stoplight
- Redoc
- Slate
you can define server/environment variables.
OpenAPI example
servers:
- url: https://api-dev.example.com
description: Development
- url: https://api-staging.example.com
description: Staging
- url: https://api.example.com
description: Production
4. Add an environment selector or page per environment
Two common approaches:
Option A: One page with a section per environment
Best when the API is mostly the same across environments.
Option B: Separate docs pages per environment
Best when environments differ a lot, especially in:
- authentication
- endpoints available
- rate limits
- sample payloads
5. Document differences explicitly
Call out anything that changes, for example:
- “Webhooks are disabled in dev”
- “Sandbox uses mock payment processing”
- “Prod requires stricter scopes”
- “Staging resets nightly”
6. Provide example requests for each environment
Include:
- curl examples
- Postman collections
- sample SDK config
Example:
curl -H "Authorization: Bearer $TOKEN" \
https://api-staging.example.com/v1/users
7. Automate if possible
If you generate docs from:
- OpenAPI
- code annotations
- API gateways
make environment values configurable via:
- build-time variables
- doc site config
- CI/CD secrets or env files
If you want, I can also show you:
- an OpenAPI example with multiple servers,
- a Markdown docs template for dev/staging/prod, or
- a recommended structure for a developer portal.