Skip to main content

Users API Overview

The Users API is a multi-tenant, schema-driven API for collecting and managing user data from static frontend applications. Built with Fastify and MongoDB, it provides a secure, scalable solution for storing user information with per-app customization.

Features

  • Schema-Driven: Each app can define custom user fields and validation rules
  • Multi-Tenant: Isolated data per app using x-app-id header
  • Email-Based Deduplication: Automatic deduplication by email per app
  • RESTful API: Simple HTTP endpoints for integration
  • Admin Dashboard: Built-in React UI for managing apps and viewing users
  • Secure: Cookie-based sessions, rate limiting, and CORS protection
  • Static Site Friendly: Designed for React/Vite static sites

Architecture

The API uses an app-based authentication model:

  • Each frontend app has a unique sourceAppId (app identifier)
  • Apps authenticate with sourceAppId + password to access their dashboard
  • Public endpoints use the x-app-id header to identify the source app
  • User data is automatically scoped to the app's sourceAppId

Use Cases

  • Opt-in Forms: Collect user data from static marketing sites
  • Lead Generation: Capture leads from landing pages
  • Newsletter Signups: Store subscriber information
  • User Registration: Collect user data before account creation
  • Multi-App Platforms: Manage users across multiple frontend applications

Key Concepts

User Schema

Each app defines a custom schema that specifies:

  • Which fields are allowed (fullName, age, consentRequired, etc.)
  • Field types (text, checkbox, select, number, date)
  • Required vs optional fields
  • Validation rules (min/max length, regex patterns, etc.)

App Credentials

Apps authenticate using:

  • sourceAppId: Unique identifier for your app (e.g., my-marketing-site)
  • password: Secure password generated by the admin

User Data

User records contain:

  • email: Required, normalized and deduplicated per app
  • data: Custom fields defined by your app's schema
  • createdAt / updatedAt: Automatic timestamps

Next Steps