Apidog Docs
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ ζ—₯本θͺž
HomeLearning CenterSupport CenterAPI References
HomeLearning CenterSupport CenterAPI References
Discord Community
Slack Community
X / Twitter
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ ζ—₯本θͺž
  1. Pre/Post processors
  • Apidog Learning Center
  • Get started
    • Introduce Apidog
    • Basic concepts in Apidog
    • Navigating Apidog
    • Quick Start
      • Overview
      • Specify a new endpoint
      • Make a request to the endpoint
      • Add an assertion
      • Create a test scenario
      • Share your API documentation
      • Explore more
      • Send a request and save as an endpoint
    • Migration
      • Overview
      • Manual import
      • Scheduled import
      • Import options
      • Export data
      • Import from...
        • Import from Postman
        • Import OpenAPI (Swagger) 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
    • Components
    • Common fields
    • Global parameters
    • Endpoint change history
    • Batch endpoint management
    • Configure multiple request body examples
    • Schemas
      • Generate Schemas from JSON etc.
      • Build a schema
      • Overview
      • Create a new schema
    • Security schemes
      • Overview
      • Create a security scheme
      • Use the security scheme
      • Security scheme in online documentation
    • Advanced features
      • Custom endpoint fields
      • Import endpoints as test steps
      • Endpoint status
      • Appearance of parameter lists
      • Endpoint unique idenfication
  • Develop and Debug APIs
    • Overview
    • Generate requests
    • Send requests
    • Endpoint cases
    • Dynamic values
    • Validate responses
    • Design-first Mode & Request-first Mode
    • Generate code
    • Environments & variables
      • Overview
      • Using variables
      • Environments & services
    • Vault secrets
      • Overview
      • HashiCorp Vault
      • Azure Key Vault
      • AWS Secrets Manager
    • Pre/Post processors
      • Overview
      • Assertion
      • Extract variable
      • Wait
      • Database operations
        • Overview
        • MongoDB
        • Redis
        • Oracle Client
      • Using scripts
        • Overview
        • Postman scripts reference
        • Pre processor scripts
        • Post processor scripts
        • Public scripts
        • Calling other programming languages
        • Using JS libraries
        • Visualizing responses
        • Script examples
          • Assertion scripts
          • Using variables in scripts
          • Using scripts to modify request messages
          • Other examples
    • 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)
  • Automated tests
    • Overview
    • Test reports
    • Test scenarios
      • Create a test scenario
      • Pass data between requests
      • Flow control conditions
      • Import endpoints/endpoint cases from other projects
      • Sync data from endpoints/endpoint cases
      • Export test scenarios
    • Run test scenarios
      • Run a test scenario
      • Data-driven testing
      • Run test scenarios in batch
      • Scheduled tasks
      • Manage the runtime environment of APIs from other projects
    • Test APIs
      • Integration testing
      • Performance testing
      • End-to-end testing
      • Regression testing
    • Apidog CLI
      • Overview
      • Installing and running Apidog CLI
      • Apidog CLI Options
    • CI/CD
      • Overview
      • Integrate with Jenkins
      • Integration with Gitlab
  • Publish API Docs
    • Overview
    • API Technologies Supported
    • Quick share
    • View the API documentation
    • Publish docs sites
    • Folder tree settings
    • Custom layouts
    • Visibility settings
    • Endpoint SEO settings
    • Custom domain
    • Embedding values in document URLs
    • Documentation Search
    • Integrating Google Analytics with Doc Sites
    • CORS Proxy
    • API Versions
      • Overview
      • Create API versions
      • Publish API versions
      • Share endpoints with API versions
  • Send requests
    • Overview
    • gRPC
    • Use request proxy agents for debugging
    • SOAP/WebService
    • GraphQL
    • WebSocket
    • Socket.IO
    • SSE debugging
    • Create requests
      • Request History
      • Request basics
      • Parameters and body
      • Request headers
      • Request settings
      • HTTP/2
    • Authentication and authorization
      • Overview
      • CA and client certificates
      • Authorization types supported by Apidog
      • Digest Auth
      • OAuth 1.0
      • OAuth 2.0
      • Hawk Authentication
      • Kerberos
      • NTLM
      • Akamai EdgeGrid
    • Response and cookies
      • Overview
      • API response in Apidog
      • Create and send cookies
      • Debug requests
      • Save the request as an endpoint
  • Branches
    • Overview
    • Create a new sprint branch
    • Test APIs in a branch
    • Design API in a branch
    • Merge sprint branches
    • Manage sprint branches
  • Apidog MCP Server
    • Overview
    • Conntect API Specification within Apidog Project to AI via Apidog MCP Server
    • Conntect Online API Documentation Published by Apidog to AI via Apidog MCP Server
    • Conntect OpenAPI Files to AI via Apidog MCP Server
  • Best practices
    • How to handle API signatures
    • How to access OAuth 2.0 protected APIs
    • Apidog collaboration workflow
    • Managing authentication state in Apidog
  • Administration
    • Onboarding Checklist
      • Basic Concepts
      • Onboarding Guide
    • 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
    • Managing Projects
      • Managing Projects
      • Managing Project Members
      • Notification Settings
      • Project Resources
        • Database Connection
    • Managing Organizations
      • Single Sign-On (SSO)
        • SSO Overview
        • Configure Microsoft Entra ID
        • Configure Okta
        • Configure SSO for an Organization
        • Managing user accounts
        • Mapping Groups to Teams
      • SCIM Provisioning
        • Intro to SCIM Provisioning
        • Microsoft Entra ID
        • Okta
      • Organization Resources
        • Self-hosted Runner
  • Billing
    • Overview
    • Credits
    • Unable to use credit cards?
    • Managing subscriptions
    • Upgrade plan
  • Add-ons
    • API Hub
    • Apidog Intellij IDEA plugin
    • Browser Extension
      • Chrome
      • Microsoft Edge
    • Request Proxy
      • Request proxy in Apidog web
      • Request proxy in shared docs
      • Request proxy in Apidog client
  • Account & preferences
    • Language settings
    • Data backup
    • Network proxy configuration
    • Hot keys
    • Updating Apidog
    • Generate OpenAPI access token
    • Deleting account
    • Account settings
  • References
    • API-Design First Approach
    • Apidog OpenAPI/Swagger Specificaiton Extensions
    • JSONPath
    • XPath
    • Regular Expressions
    • JSON Schema
    • CSV File Format
    • Install Java Environment
    • Runner deployment environment
    • Apidog flavored Markdown
  • Apidog Europe
    • Apidog Europe
  • Support Center
  1. Pre/Post processors

Pre/Post Processors in Apidog

Pre and Post-request Processors are a key feature in Apidog. When you send a request, you can use pre-request processors to dynamically control your request, or use post-request processors to handle the received response.
In Postman, all pre and post-request operations need to be implemented using scripts, which is more complex, less maintainable, and has a higher learning curve. In contrast, Apidog allows you to conveniently perform the majority of pre and post-request operations through visual, drag-and-drop actions.

Getting started with pre/post processors#

Here are the steps to use pre and post-request processors in Apidog:
1
Open any endpoint and navigate to the Run tab (Design-first Mode) or Request tab (Request-first mode).
Design-first Mode
Request-first Mode
image.png
2
Switch to the Pre processors or Post processors section, hover over Add processor, and select the desired processor to add.
3
Fill in the necessary fields for the added processor.
4
Click Send, and the request will execute with the configured pre/post processors.
5
In Design-first Mode, click Save as case to save the request. In Request-first Mode, click Save/Save as case to save the request.
Design-first Mode
Request-first Mode
image.png
In Apidog, you can also create a standalone request and apply pre and post-processors to it. However, the recommended approach is to leverage the pre and post-processors on top of the endpoint specification. This makes the API debugging and testing process more convenient and streamlined.

What do pre/post processors do#

Pre/post processors can collectively achieve various functionalities like below.

Pre processors#

Setting the values of request parameters and the request body: This involves defining the input data that will be sent to the API endpoint for processing.
Setting request headers: Specifying necessary headers such as Content-Type, Accept, Authorization, etc., for the API request.
Adding authentication to the request: Including authentication tokens, API keys, or any other credentials required for accessing protected endpoints.
Retrieving values from a database to use as request parameters: Fetching relevant data from a database to populate the API request with dynamic or pre-defined values.
Encrypting the request: Securing the data being transmitted by encrypting the request payload to protect sensitive information.

Post processors#

Writing assertions to validate the response received from the API against expected results. This can include checking status codes, response messages, specific data values, etc.
Extracting variables from the response to use them in subsequent requests. This is useful for maintaining state and continuity in API test flows.
Writing data to a database to store or update information generated during API testing. This can be particularly useful for scenarios where data persistence is required for later analysis or reference.
Visualizing response data for better analysis and understanding. This can involve generating reports, graphs, or any other visual representation of the API response data to gain insights into the system's behavior and performance.

List of pre/post-request processors#

Apidog supports the following pre/post processors:
Assertion: Available only in post processors. Allows you to define validation rules to check the response data against expected values or conditions. It supports various assertion types like status code, response body, headers, etc.
Extract variable: Available only in post processors. Enables extracting values from the response (JSON, XML, or plain text) and storing them as variables. It supports using JSONPath and XPath expressions to target specific parts of the response. Variables can be used in subsequent requests or other processors.
Database Operation: Available both in pre and post processors. Allows you to connect to databases and execute SQL queries. The query results can be stored as variables for use in further processing. It supports various database types, including SQL and NoSQL databases.
Custom Scripts: Available both in pre and post processors. Provides a scripting environment where you can write your own JavaScript code. Scripts can access request and response data, as well as environment variables. It's useful for complex logic or integrations that cannot be easily expressed through the visual processors.
We recommend using the Apidog Script Generator to simplify script writing. Simply describe the script you want in natural language, and the generator will create a runnable script for you.
Public Scripts: Available both in pre and post processors. Enables creating reusable script snippets that can be shared across multiple processors or scenarios. It's helpful for encapsulating common logic or utility functions.
Wait: Available both in pre and post processors. Introduces a delay or wait period before or after a request is sent. It's useful for simulating real-world scenarios or handling asynchronous responses.

The execution order of pre/post processors#

The pre and post-request processors in Apidog can be set at multiple levels:
Run/Endpoint case level: Default level. Processors set at this level will only affect the current run/endpoint case.
Endpoint level: Processors set at the endpoint level will be applied to all cases (requests) associated with that endpoint.
Folder level: Processors configured at the folder level will impact all endpoints within that folder.
A set of pre-operations in a request may look like this:
image.png
In the screenshot above, the first three processors are grouped under the label "Inherit from parent". The label on the right-hand side indicates that they are located in the Root folder, Pets folder, and the current endpoint. In the current run, these processors can only be executed or switched on/off, but not edited directly. If you need to edit them, you can click the folder to navigate to the corresponding level.
The "Inherit from parent" processors are collapsed by default, and you can click the checkbox in front of them to choose whether to execute them or not.
The last processor, a custom script, is a new addition in the current run and can be edited within the current run.

Variable Substitution#

You may also notice that at the end of all the pre-processors, there is a step called "Variable Substitution & Inherit from Parents".
In Apidog, the "Variable Substitution" pre-processor is a special pre-processor that serves the purpose of replacing variable placeholders like {{variable}} with their current values.
Most pre-processors can be executed before variable substitution, which is the default execution order in Apidog. However, some processors require execution after variable substitution to be effective, such as scripts like API signature. In such cases, these processors need to be manually moved after the "Variable Substitution & Inherit from Parents" step.
Additionally, in the parent pre-processor section, you can also drag a processor after the variable substitution. These parent-level operations will then appear in the "Inherit from Parents" section within the "Variable Substitution & Inherit from Parents" step.

Execution order#

The processors execution order for a single request looks like this:
Modified atΒ 2025-03-17 04:24:43
Previous
AWS Secrets Manager
Next
Assertion
Built with