---
title: "Documentation"
description: "Standards for documenting code and features in the Formbricks codebase"
icon: "book"
---

## Overview

At Formbricks, we maintain strict documentation standards to ensure code clarity, maintainability, and ease of use for both internal developers and external contributors.

### Contribute to Documentation

We use Mintlify to maintain our documentation. You can find more information about how to contribute to the documentation in the [README](https://github.com/formbricks/formbricks/blob/main/docs/README.md) file.

## Code Documentation

### Function Documentation

1. **Complex Logic Documentation**
   - All functions with complex logic must include JSDoc comments
   - Document parameters, return types, and potential side effects
   - Example:

```typescript
/**
Creates a new user and initializes their preferences
@param {string} name - User's full name
@param {UserOptions} options - Configuration options for user creation
@returns {Promise<User>} The created user object
@throws {ValidationError} If name is invalid
*/
async function createUser(name: string, options: UserOptions): Promise<User> {
  // implementation
}
```

2. **TypeScript Ignore Comments**
   - When using `@ts-ignore` or `@ts-expect-error`, always include a comment explaining why
   - Example:

```typescript
// @ts-expect-error -- Required for dynamic function calls
void window.formbricks.setup(...args);
```

### API Documentation

1. **API Endpoints**

   - All new API endpoints must be documented in the OpenAPI specification
   - Include request/response schemas, authentication requirements, and examples
   - Document both Client API and Management API endpoints
   - Use `docs/api-reference/openapi.json` for v1, `docs/api-v2-reference/openapi.yml` for v2, and the v3 sources under `docs/api-v3-reference/src/`; regenerate the v3 bundle with `pnpm api:v3:sync`

2. **Authentication**
   - Clearly specify authentication requirements
   - Document API key usage and permissions
   - Include error scenarios and handling

### Feature Documentation

- All new features must include a feature documentation file
- Document the feature's purpose, usage, and implementation details
- Include code examples and best practices

## Working with Mintlify

We use Mintlify to write our documentation.

### File Structure

1. **MDX Files**
   - All documentation files must use the `.mdx` extension
   - Include frontmatter with required metadata:

```markdown
---
title: "Document Title"
description: "Brief description of the content"
icon: "appropriate-icon"
---
```

2. **Navigation**
   - Add new pages to the appropriate section in `docs/docs.json`
   - Follow the existing navigation structure
   - Include proper redirects if URLs change

### Content Guidelines

1. **Writing Style**
   - Use clear, concise language
   - Break content into logical sections with proper headings
   - Include practical examples and code snippets
   - Use Mintlify components for notes, warnings, and callouts:

```markdown
<Note>
Important information goes here
</Note>
```

2. **Media and Assets**

   - Store images in the appropriate `/images` subdirectory
   - Use descriptive alt text for all images
   - Optimize images for web delivery
   - Use relative paths for internal links

3. **Code Examples**
   - Specify the language for all code blocks
   - Include comments for complex code snippets
   - Use proper indentation and formatting

## Validation

1. **Local Testing**
   - Test documentation locally using Mintlify CLI:

```bash
mint dev
```

2. **Review Process**
   - Documentation changes require peer review
   - Verify all links and references work
   - Ensure proper formatting and rendering

These documentation requirements ensure that our codebase remains maintainable, accessible, and well-documented for both current and future developers.

## One home for each instruction

| Content | Canonical home |
| --- | --- |
| Release notes and upgrade impact | GitHub Releases (source of truth), mirrored in `/platform/changelog` |
| Upgrade rules and stops | `/self-hosting/upgrade/paths` |
| Ordered upgrade commands | The runbooks: Kubernetes, Docker Compose, one-click |
| What a version changes and needs | One version page per minor under `/self-hosting/upgrade/versions/` |
| Compatibility and support promises | Release and maintenance policy |
| Product and integration behavior | Product guide or integration setup page |

Keep the runbooks version-neutral; version pages add only what's specific to that version.
Use pinned versions in examples, never `latest`.

### Release notes for every release

GitHub Releases is the source of truth. The `release-notes` skill writes each stable release, including
patches and backports, with an `## Upgrade impact` section: **None**, or **Action required** for named
setups with a link to the steps. After publication, copy the summary and the upgrade-impact line into
`docs/platform/changelog.mdx`. Don't rewrite the text, and don't publish a "review required" or other
"not yet known" status.

A release with nothing to do still gets an entry, but no extra page.

### Version pages

Each minor gets one page, named `<version>: Upgrade guide`, with the sections **What changes**,
**Before you upgrade**, **Patch actions**, **Upgrade**, **Check it worked** and **If something goes wrong**.
Each patch adds a row to its minor's **Patch actions** table. Use `Unreleased: <Topic>` for changes that
aren't in a release yet. Use the copyable template in `docs/templates/release-guidance.md`.

Upgrades go one minor version at a time, to the latest patch of each. Skipping a minor version is not
supported. When you add a minor, add its row to the upgrade paths table.

### Write for the reader

- For each manual step, say where to run it, the exact command or file change, and what the operator should see.
- Explain secret generation and bindings; don't stop at "generate tokens" or "merge services".
- Say what runs automatically and what the operator runs.
- Don't describe how the page was made: no "evidence", "source review" or "reviewed on" notes.
- Use plain words and short sentences. Avoid slash compounds such as "app/Hub" in sentences.

### Review a documentation change

- Keep existing URLs. Add redirects for moved pages, and an invisible `<span id>` for a removed heading anchor.
- Check navigation, links, anchors, MDX rendering and mobile layout in the preview. Include screenshots in the PR.
- A documentation build doesn't prove that an upgrade works.
