Collection Overview

Collections are the core organizational unit in DoMock. Learn how to structure and manage your mock API endpoints effectively.

What is a Collection?

A Collection is a group of related mock API endpoints within a Workspace. Collections help you organize your mock APIs by feature, service, or any logical grouping that makes sense for your project.

Think of Collections as:

  • • A microservice or API module (e.g., "User Service", "Payment API")
  • • A feature domain (e.g., "Authentication", "Orders", "Products")
  • • A version of your API (e.g., "API v1", "API v2")
  • • Any logical grouping that helps your team organize endpoints

Collection Structure

Each Collection contains endpoints with configurable Responses. A Response defines how your mock API behaves when called.

Workspace

Top-level container for all your mock APIs

Collection

Group of related API endpoints

Endpoint: GET /api/users
→ Response (status, body, headers, rules)
Endpoint: POST /api/users
→ Response (status, body, headers, rules)

Response Components

Each endpoint in a Collection has a Response configuration with three main components:

Templates

Dynamic response body generation with template syntax. Use faker functions, repeat blocks, and variables to create realistic mock data.

json
{
  "user": {
    "id": "{{faker 'string.uuid'}}",
    "name": "{{faker 'person.fullName'}}",
    "email": "{{faker 'internet.email'}}"
  }
}
Learn more about Templates →

Rules

Conditional logic to return different responses based on request data. Check query parameters, headers, body, cookies, and form data.

text
Query Parameter | userId | = Match | 123
HTTP Header | Authorization | ✓ Has value
JSON Body | user.role | = Match | admin
Learn more about Rules →

Headers

HTTP response headers for Content-Type, CORS, caching, authentication, and custom headers. Configure how clients should handle your responses.

text
Content-Type: application/json
Access-Control-Allow-Origin: *
Cache-Control: no-cache
X-API-Version: 2.0
Learn more about Headers →

Common Use Cases

Frontend Development

Build UI components before the backend API is ready. Create realistic mock data that matches your API specification.

Example: Mock user authentication flow with JWT tokens, user profiles, and role-based access

API Testing

Test edge cases, error scenarios, and different response conditions without modifying your backend.

Example: Simulate rate limiting, timeout errors, validation failures, and various HTTP status codes

API Documentation

Create interactive examples for API documentation. Let developers test API calls with realistic responses.

Example: Provide sandbox endpoints that demonstrate API behavior for each documentation section

Third-Party API Simulation

Mock external APIs to avoid rate limits, reduce costs, or work offline during development.

Example: Simulate payment gateways, social media APIs, or cloud service responses

Best Practices

📁 Organize by Domain

Group related endpoints in Collections based on features or services. This makes it easier to find and manage endpoints.

✅ Match Real API Structure

Design your Collections to mirror your actual API structure. This makes transitioning from mock to real API seamless.

⚡ Use Realistic Data

Leverage faker functions in Templates to generate realistic data. This helps catch issues that only appear with real-world data patterns.

🎯 Test Edge Cases

Use Rules to create multiple response scenarios for the same endpoint. Test success, error, and edge cases without backend changes.

Next Steps

Explore Response configuration options:

  • → Templates - Generate dynamic response bodies with template syntax
  • → Rules - Add conditional logic to return different responses
  • → Headers - Configure HTTP response headers
Collection Overview - DoMock Documentation