Apidog Docs
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ ζ—₯本θͺž
HomeLearning Center
Support CenterAPI ReferencesDownloadChangelog
HomeLearning Center
Support CenterAPI ReferencesDownloadChangelog
Discord Community
Slack Community
X / Twitter
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ ζ—₯本θͺž
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ ζ—₯本θͺž
  1. Mock API Data
  • Apidog Learning Center
  • Getting Started
    • Introduction to Apidog
    • Basic Concepts in Apidog
    • Navigating Apidog
    • Quick Start
      • Overview
      • Creating an Endpoint
      • Making a Request
      • Adding an Assertion
      • Creating Test Scenarios
      • Sharing API Documentation
      • Explore More
    • Migration to Apidog
      • Overview
      • Manual Import
      • Scheduled Import (Bind Data Sources)
      • Import Options
      • Export Data
      • Import From
        • Import from Postman
        • Import OpenAPI Spec
        • Import cURL
        • Import Markdowns
        • Import from Insomnia
        • Import from apiDoc
        • Import .har File
        • Import WSDL
  • Design APIs
    • Overview
    • Create a New API Project
    • Endpoint Basics
    • APl Design Guidelines
    • Module
    • Configure Multiple Request Body Examples
    • Components
    • Common Fields
    • Global Parameters
    • Endpoint Change History
    • Comments
    • Batch Endpoint Management
    • Custom Protocol API
    • Schemas
      • Overview
      • Create a New Schema
      • Build a Schema
      • Generate Schemas from JSON Etc
      • oneOf, allOf, anyOf
      • Using Discriminator
    • Security Schemes
      • Overview
      • Create a Security Scheme
      • Use the Security Scheme
      • Security Scheme in Online Documentation
    • Advanced Features
      • Custom Endpoint Fields
      • Associated Test Scenarios
      • Endpoint Status
      • Appearance of Parameter Lists
      • Endpoint Unique Identification
  • Develop and Debug APIs
    • Overview
    • Generating Requests
    • Sending Requests
    • Debugging Cases
    • Test Cases
    • Dynamic Values
    • Validating Responses
    • Design-First vs Request-First
    • Generating Code
    • Environments & Variables
      • Overview
      • Environment Management
      • Using Variables
    • Vault Secrets
      • Overview
      • HashiCorp Vault
      • Azure Key Vault
      • AWS Secrets Manager
    • Pre and Post Processors
      • Assertion
      • Extract Variable
      • Wait
      • Overview
      • Using Scripts
        • Overview
        • Pre Processor Scripts
        • Post Processor Scripts
        • Public Scripts
        • Postman Scripts Reference
        • Calling Other Programming Languages
        • Using JS Libraries
        • Visualizing Responses
        • Script Examples
          • Assertion Scripts
          • Using Variables
          • Modifying Requests
          • Other Examples
      • Database Operations
        • Overview
        • MySQL
        • MongoDB
        • Redis
        • Oracle Client
    • Dynamic Values Modules
  • Mock API Data
    • Overview
    • Smart Mock
    • Custom Mock
    • Mock Priority Sequence
    • Mock Scripts
    • Cloud Mock
    • Self-Hosted Runner Mock
    • Mock Language (Locales)
  • API Testing
    • Overview
    • Test Scenarios
      • Create a Test Scenario
      • Pass Data Between Requests
      • Flow Control Conditions
      • Sync Data from Endpoints and Endpoint Cases
      • Import Endpoints and Endpoint Cases from Other Projects
      • Export Test Scenarios
    • Run Test Scenarios
      • Run a Test Scenario
      • Run Test Scenarios in Batch
      • Manage Runtime Environment of APIs from Other Projects
      • Data-Driven Testing
      • Scheduled Tasks
    • Test Suite
      • Overview
      • Create A Test Suite
      • Orchestrate Test Suite
      • Run Test Suites Locally
      • Run Test Suites Via CLI
      • Scheduled tasks
    • Test Reports
      • Test Reports
    • Test APIs
      • Integration Testing
      • Performance Testing
      • End-to-End Testing
      • Regression Testing
      • Contract Testing
    • Apidog CLI
      • Overview
      • Installing and Running Apidog CLI
      • Apidog CLI Options
    • CI CD
      • Overview
      • Integrate with Gitlab
      • Integrate with Jenkins
      • Trigger Test by Git Commit
      • Integrate with Github Actions
  • Publish API Docs
    • Overview
    • API Technologies Supported
    • Quick Share
    • Viewing API Documentation
    • Markdown Documentation
    • Publishing Documentation Sites
    • Custom Login Page
    • Custom Layouts
    • Custom CSS, JavaScript, HTML
    • Custom Domain
    • LLM-Friendly Features
    • SEO Settings
    • Advanced Settings
      • Documentation Search
      • CORS Proxy
      • Integrating Google Analytics with Doc Sites
      • Folder Tree Settings
      • Visibility Settings
      • Embedding Values in Document URLs
    • API Versions
      • Overview
      • Creating API Versions
      • Publishing API Versions
      • Sharing Endpoints with API Versions
  • Send Requests
    • Overview
    • SSE Debugging
    • MCP Client
    • Socket.IO
    • WebSocket
    • Webhook
    • SOAP or WebService
    • GraphQL
    • gRPC
    • Use Request Proxy Agents for Debugging
    • Create Requests
      • Request History
      • Request Basics
      • Parameters and Body
      • Request Headers
      • Request Settings
      • Debug Requests
      • Saving Requests as Endpoints
      • HTTP/2
    • Response and Cookies
      • Viewing API Responses
      • Managing Cookies
      • Overview
    • Authentication and Authorization
      • Overview
      • CA and Client Certificates
      • Authorization Types
      • Digest Auth
      • OAuth 1.0
      • OAuth 2.0
      • Hawk Authentication
      • Kerberos
      • NTLM
      • Akamai EdgeGrid
  • Branches
    • Overview
    • Creating a Sprint Branch
    • Testing APIs in a Branch
    • Designing APIs in a Branch
    • Merging Sprint Branches
    • Managing Sprint Branches
  • AI Features
    • Overview
    • Enabling AI Features
    • Generating Test Cases
    • Modifying Schemas with AI
    • Endpoint Compliance Check
    • API Documentation Completeness Check
    • AI-Powered Field Naming
    • FAQs
  • Apidog MCP Server
    • Overview
    • Connect Apidog Project to AI
    • Connect Published Documentation to AI
    • Connect OpenAPI Files to AI
  • Best Practices
    • Handling API Signatures
    • Accessing OAuth 2.0 Protected APIs
    • Collaboration Workflow
    • Managing Authentication State
  • Offline Space
    • Overview
  • Administration
    • Managing Teams
      • Managing Teams
      • Managing Team Members
      • Member Roles & Permission Settings
      • Team Activities
      • Team Resources
        • General Runner
        • Team Variables
        • Request Proxy Agent
      • Real-time Collaborations
        • Team Collaboration
    • Onboarding Checklist
      • Basic Concepts
      • Onboarding Guide
    • Managing Projects
      • Managing Projects
      • Managing Project Members
      • Notification Settings
      • Project Resources
        • Database Connection
        • Git Connection
    • Managing Organization
      • Managing Organization
      • Single Sign-On (SSO)
        • SSO Overview
        • Configuring Microsoft Entra ID
        • Configuring Okta
        • Configuring SSO for an Organization
        • Managing User Accounts
        • Mapping Groups to Teams
      • SCIM Provisioning
        • Introduction to SCIM Provisioning
        • Microsoft Entra ID
        • Okta
      • Plans Management
        • Billing Managers in Organizations
      • Organization Resources
        • Self-Hosted Runner
  • Billing
    • Overview
    • Credits
    • Alternative Payment Methods
    • Managing Subscriptions
    • Upgrading Your Plan
    • Moving Paid Teams to Organizations
  • Data & Security
    • Data Storage and Security
    • User Data Privacy and Security
    • Request Routing and Data Security
  • Add-ons
    • API Hub
    • Apidog Intellij IDEA Plugin
    • Browser Extension
      • Chrome
      • Microsoft Edge
    • Request Proxy
      • Request Proxy in Web
      • Request Proxy in Shared Docs
      • Request Proxy in Client
  • Account & Preferences
    • Account Settings
    • Generating OpenAPI Access Token
    • Notification
    • Language Settings
    • Hot Keys
    • Network Proxy Configuration
    • Backing Up Data
    • Updating Apidog
    • Deleting Account
    • Experimental Features
  • References
    • API Design-First Approach
    • Apidog OpenAPI Specificaiton Extensions
    • JSONPath
    • XPath
    • Regular Expressions
    • JSON Schema
    • CSV File Format
    • Installing Java Environment
    • Runner Deployment Environment
    • Apidog flavored Markdown
  • Apidog Europe
    • Apidog Europe
  • Support Center
HomeLearning Center
Support CenterAPI ReferencesDownloadChangelog
HomeLearning Center
Support CenterAPI ReferencesDownloadChangelog
Discord Community
Slack Community
X / Twitter
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ ζ—₯本θͺž
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ ζ—₯本θͺž
  1. Mock API Data

Custom Mock

Apidog provides powerful mock customization features that give you fine-grained control over API responses. This document introduces two approaches to customize mock data:
1.
Field-Level Customization: Control specific fields while using smart mock for others
2.
Full Response Customization: Define complete mock responses with expectations (fixed, conditional, or dynamic)

Field-Level Customization#

Sometimes you need to define specific values for certain fields while letting Apidog automatically generate the rest. Apidog offers flexible methods for field-level control.

Setting Custom Field Values#

1. Fixed Values#

Specify a static value in the endpoint spec's mock field. Apidog will always return this exact value for that field, while using smart mock for unspecified fields.
Example:
image.png

2. Dynamic Values with Faker.js#

Generate realistic random data using Apidog's dynamic values (based on Faker.js). Use the syntax:
{{$category.method}}
Common Examples:
ExpressionExample Result
{{$person.fullName}}Rachel Wheeler
{{$internet.email}}Arno.Huels33@yahoo.com
{{$commerce.productName}}Elegant Plastic Bike
Select dynamic values directly from the dropdown menu:
image.png

3. Parameterized Faker Methods#

Pass parameters to dynamic value methods for specialized data generation using Apidog's enhanced Faker.js syntax.
Examples:
Use CaseExpressionDescription
Integer range{{$number.int(min=0,max=10000)}}Random integer between 0 and 10,000
Readable phone{{$phone.number(style='human')}}Human-readable phone format
Multiple of N{{$number.int(multipleOf=3)}}Integer divisible by 3
Array element{{$helpers.arrayElement(['red','blue','green'])}}Random color from array
Date range{{$date.between(from='2024-01-01',to='2024-12-31',format='yyyy-MM-dd')}}Date between specified range
Explore the complete list of modules, methods, and parameters in the Dynamic Values Modules documentation.

4. Concatenating Multiple Expressions#

Combine static text and multiple dynamic expressions to generate complex field values.
Example: Full Address Generation
{{$location.streetAddress}}, {{$location.city}}, {{$location.state}}, {{$location.zipCode}}, {{$location.country}}
Sample Output:
8507 Hudson Alley, Rochester, Wisconsin, 96512, United States
Each component is dynamically generated, creating unique, realistic addresses for every mock API call.
Mock Locales
Apidog supports customizable mock locales, allowing you to generate dynamic test data in different languages and formats that match your target region or audience. To learn more about configuring mock locales, visit Mock language (Locales).

Full Response Customization (Mock Expectations)#

For complete control over mock responses, use mock expectations. This feature allows you to define fixed, conditional, or dynamic responses.

Creating Mock Expectations#

image.png

Fixed Responses#

Return the same data for every request by creating an unconditional expectation.
Steps:
1
Click New expectation
2
Add an expectation name and leave conditions blank
3
Fill in the response data you want to return, then save
4
Copy and use the provided mock URL to access this endpoint

Conditional Responses#

Return different mock data based on request parameters. The mock engine evaluates conditions from top to bottom, returning the first matching expectation.
Supported Condition Types:
Parameter TypeDescription
Query parametersURL query strings
Path parametersDynamic URL segments
Header parametersHTTP headers
Cookie parametersCookie values
Body parametersJSON body fields (via JSON path)
Condition Behavior
Multiple conditions are combined with AND logic (all must match)
If no conditions match, Apidog falls back to the Mock method priority in Project Settings β†’ Feature Settings β†’ Mock Settings
Limitations
Body parameters support JSON only, not XML
Parameter conditions cannot use {{variables}}
Request body format must match the API spec (e.g., form-data, JSON)
IP address conditions can restrict responses to specific IPs

Dynamic Mock Data#

Mock expectations support dynamic, randomized data using Faker.js and Nunjucks template syntax.
Example:
{
    "data": [
        {% for i in range(0, 20) %}
        {% if i>1 %},{% endif %}
        {
            "id": {{i}},
            "firstname": "{{$person.firstName}}",
            "lastname": "{{$person.lastName}}"
        }
        {% endfor %}
    ],
    "success": true
}
This generates:
Array of 20 user objects (id from 0 to 19)
Each with randomly generated first and last names
A constant "success": true field
Syntax Notes:
SyntaxPurpose
{{$...}}Invokes Faker.js for random values
{% for ... %}Nunjucks loop structure
{{i}}Nunjucks loop variable (not an Apidog variable)
Important Differences
Apidog uses {{$person.firstName}} instead of native Faker.js faker.person.firstName()
Apidog project/environment variables ({{variable}}) are not available in mock expectations
Consult Faker.js and Nunjucks documentation for full syntax

Advanced Features#

Custom Response Headers#

Add custom headers to mock expectations to simulate authentication, pagination, or other API behaviors.

Advanced Response Properties#

Configure additional response properties in the More tab:
PropertyPurposeDefault
HTTP Status CodeSimulate errors or special cases200
Response DelaySimulate network latency (milliseconds)0

Enable/Disable Expectations#

Toggle expectations on or off independently for local and cloud mock environments from the expectation list.

Summary#

Apidog's custom mock features provide:
Flexible field customization with fixed or dynamic values
Full response control through mock expectations
Conditional logic for parameter-based responses
Dynamic data generation using Faker.js and Nunjucks
Advanced simulation with custom headers, delays, and status codes
These features enable you to create robust, high-fidelity API simulations that accurately mirror production behavior!
Modified atΒ 2026-01-15 08:58:15
Previous
Smart Mock
Next
Mock Priority Sequence
Built with