Forward Email provides a comprehensive API for managing email forwarding, domains, aliases, and more. The API documentation is generated from an OpenAPI specification and rendered using Scalar.
The API specification is maintained as a structured OpenAPI v3 JSON file:
- File Location: The specification is stored as
api-spec.jsonin theassets/folder - Build Process: During the build process, the specification is copied to the build folder
- Web Routes: The API documentation is served via the
/apiand/email-apiweb routes - Renderer: The documentation is rendered using Scalar API tool, configured in
app/views/email-api.pug
When updating the API, follow these steps to maintain the specification:
- Edit the Specification: Update
assets/api-spec.jsonwith new endpoints, schemas, or descriptions - Use Markdown: Leverage rich markdown in descriptions for better rendering in Scalar
- Follow Best Practices:
- Keep the main API description concise and high-level
- Place error details in the Error schema component
- Add specific examples to individual endpoints
- Use tables for parameter descriptions
- Include code examples with syntax highlighting
The API specification uses markdown for rich documentation in Scalar:
{
"schemas": {
"Example": {
"description": "## Example Object\n\n### Properties Overview\n\n| Property | Type | Description |\n|----------|------|-------------|\n| id | string | Unique identifier |\n| name | string | The name of the example |\n\n### Example JSON\n\n```json\n{\n \"id\": \"123\",\n \"name\": \"Example Name\"\n}\n```"
}
}
}{
"paths": {
"/v1/example": {
"get": {
"description": "**Get Example**\n\n### Parameters\n\n| Parameter | Type | Required | Description |\n|-----------|------|----------|-------------|\n| id | string | Yes | Example ID |\n\n### Example Request\n\n```bash\ncurl https://api.forwardemail.net/v1/example \\\n -u API_TOKEN:\n```\n\n### Example Response\n\n```json\n{\n \"id\": \"123\",\n \"name\": \"Example Name\"\n}\n```"
}
}
}
}After updating the API specification:
- Run the build process to copy the updated specification to the build folder
- Navigate to
/apior/email-apiin your development environment - Verify that the documentation renders correctly in Scalar
- Check that all markdown formatting appears as expected
- Test the "Try It" functionality if available
The Scalar API documentation tool is configured in app/views/email-api.pug. If you need to customize the Scalar rendering:
- Edit the configuration in this file
- Refer to the Scalar documentation for available options
- Test changes in the development environment before deploying
When deploying API documentation changes:
- Ensure the updated
api-spec.jsonis included in the deployment - Verify that the build process correctly copies the specification
- Check the live documentation after deployment to confirm changes are visible