<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hassann</title>
    <description>The latest articles on DEV Community by Hassann (@hassann).</description>
    <link>https://dev.to/hassann</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3890506%2F89a141f2-4995-48b3-b5f2-e00ba5055afb.png</url>
      <title>DEV Community: Hassann</title>
      <link>https://dev.to/hassann</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hassann"/>
    <language>en</language>
    <item>
      <title>How to Add If/Else Branching and Flow Control to API Test Scenarios in Apidog</title>
      <dc:creator>Hassann</dc:creator>
      <pubDate>Wed, 15 Jul 2026 09:49:32 +0000</pubDate>
      <link>https://dev.to/hassann/how-to-add-ifelse-branching-and-flow-control-to-api-test-scenarios-in-apidog-26fa</link>
      <guid>https://dev.to/hassann/how-to-add-ifelse-branching-and-flow-control-to-api-test-scenarios-in-apidog-26fa</guid>
      <description>&lt;p&gt;Most API tests run in a straight line: call login, call checkout, call the receipt endpoint, and assert each response. That approach breaks down when a later request depends on an earlier result. If login returns &lt;code&gt;401&lt;/code&gt;, running checkout adds noise and can hide the root cause. A better scenario reads the login response, branches on its result, and reports exactly where execution stopped.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation" class="crayons-btn crayons-btn--primary"&gt;Try Apidog today&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;This guide shows how to add if/else logic to an API test scenario in &lt;a href="https://apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog&lt;/a&gt;. You will build a scenario that logs in, checks the response status, and runs checkout only when login succeeds. If you need the linear scenario basics first, see &lt;a href="http://apidog.com/blog/how-to-write-test-scenario-with-apidog?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;how to write a test scenario with Apidog&lt;/a&gt;. For a language-level introduction to branching, see the &lt;a href="https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Scripting/Conditionals" rel="noopener noreferrer"&gt;MDN guide to conditional statements&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What flow control is—and is not
&lt;/h2&gt;

&lt;p&gt;In Apidog, automated tests are built in the &lt;strong&gt;Tests&lt;/strong&gt; module. The main unit is a &lt;strong&gt;Test Scenario&lt;/strong&gt;, similar to a Collection in Postman. A scenario contains &lt;strong&gt;Test Steps&lt;/strong&gt;, which can be API requests or &lt;a href="https://en.wikipedia.org/wiki/Control_flow" rel="noopener noreferrer"&gt;control-flow elements&lt;/a&gt;, such as branches, loops, and delays.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fm9w0igi1qorj982thy5e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fm9w0igi1qorj982thy5e.png" alt="Apidog Test Scenario flow control interface" width="799" height="530"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Flow control lets a scenario make decisions instead of executing every request sequentially. The &lt;a href="https://docs.apidog.com/flow-control-conditions-599419m0" rel="noopener noreferrer"&gt;Apidog flow control and conditional branching documentation&lt;/a&gt; covers the available controls.&lt;/p&gt;

&lt;p&gt;This article focuses on &lt;strong&gt;Conditional Branching&lt;/strong&gt;, Apidog's if/else implementation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if login status is 200:
  run checkout
else:
  report login failure
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do not confuse branching with looping:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Conditional Branching&lt;/strong&gt; evaluates a condition and chooses a path once.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;For Loops&lt;/strong&gt; and &lt;strong&gt;ForEach Loops&lt;/strong&gt; repeat a block of steps.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, use a &lt;code&gt;ForEach&lt;/code&gt; loop to process multiple order IDs. Use a branch to decide whether a checkout request should run at all. See the &lt;a href="http://apidog.com/blog/foreach-loop-tutorial?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;ForEach loop tutorial&lt;/a&gt; for iteration workflows.&lt;/p&gt;

&lt;p&gt;Apidog documentation lists no free-versus-paid restriction for flow control, branching, loops, or passing data between steps. It also does not identify a cloud-versus-self-hosted difference for these features.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build a scenario that branches on the login response
&lt;/h2&gt;

&lt;p&gt;The target workflow is simple:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Send a login request.&lt;/li&gt;
&lt;li&gt;Check whether it returns HTTP &lt;code&gt;200&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Run checkout only if login succeeds.&lt;/li&gt;
&lt;li&gt;Run a failure-reporting step if login fails.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 1: Create a test scenario
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open Apidog.&lt;/li&gt;
&lt;li&gt;Go to the &lt;strong&gt;Tests&lt;/strong&gt; module.&lt;/li&gt;
&lt;li&gt;Click the &lt;code&gt;+&lt;/code&gt; next to the search bar.&lt;/li&gt;
&lt;li&gt;Create a &lt;strong&gt;Test Scenario&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select its directory and priority.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You now have an empty scenario ready for steps.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Add the login request
&lt;/h3&gt;

&lt;p&gt;Add a Test Step for your login endpoint. You can import an existing endpoint, use a saved endpoint case, paste cURL, or create a custom request.&lt;/p&gt;

&lt;p&gt;For a quick implementation, create a custom &lt;code&gt;POST&lt;/code&gt; request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;POST https://api.your-store.com/v1/login
Content-Type: application/json

{
  "email": "dana@example.com",
  "password": "correct-horse-battery-staple"
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the request once to confirm its expected response. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"token"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"userId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"usr_10482"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important part for this tutorial is the HTTP status: a successful login should return &lt;code&gt;200&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Enter orchestrate mode
&lt;/h3&gt;

&lt;p&gt;Click any scenario step to open &lt;strong&gt;orchestrate mode&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The left panel shows the complete execution flow.&lt;/li&gt;
&lt;li&gt;The right panel shows configuration for the selected step.&lt;/li&gt;
&lt;li&gt;Drag the &lt;code&gt;≡&lt;/code&gt; handle to reorder steps when needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You will use this view to place and configure the conditional branch.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Add a Conditional Branching step
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Click &lt;strong&gt;Add Step&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;Conditional Branching&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Configure the condition using the login response status.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Apidog supports these judgment operators:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Equals&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Does not equal&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Exists&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Does not exist&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Less than&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Less than or equal&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Greater than&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Greater than or equal&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Matches with Regex&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Contains&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Does not contain&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Is empty&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Is not Empty&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;In List&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Not in List&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For this scenario, configure the branch as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Login response status Equals 200
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5: Reference the login response
&lt;/h3&gt;

&lt;p&gt;Use &lt;strong&gt;Retrieve pre-step data&lt;/strong&gt; to read a value from an earlier step.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click the condition value field.&lt;/li&gt;
&lt;li&gt;Click the magic wand icon.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Retrieve pre-step data&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Choose the login step.&lt;/li&gt;
&lt;li&gt;Select its response status.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Apidog uses pre-step references in this format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{$.&amp;lt;step id&amp;gt;.response.body.&amp;lt;field path&amp;gt;}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, to retrieve the login token from step &lt;code&gt;1&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{$.1.response.body.token}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqzrproro9rhx7r9qjh3t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqzrproro9rhx7r9qjh3t.png" alt="Retrieve pre-step data in Apidog" width="799" height="235"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Keep these constraints in mind:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Retrieve pre-step data&lt;/strong&gt; works only in the &lt;strong&gt;Tests&lt;/strong&gt; module.&lt;/li&gt;
&lt;li&gt;It resolves only when you run the &lt;strong&gt;full scenario&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Running a single step in isolation does not provide data from earlier scenario steps.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For this status-code condition, retrieving the prior step's status is the fastest option.&lt;/p&gt;

&lt;h4&gt;
  
  
  Alternative: extract a named variable
&lt;/h4&gt;

&lt;p&gt;If you need to reuse a response value across multiple steps or modules, extract it into a variable.&lt;/p&gt;

&lt;p&gt;In the login request:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open &lt;strong&gt;Post-processors&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Add &lt;strong&gt;Extract Variable&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Use a JSONPath expression such as:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$.token
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Save it under a variable name such as &lt;code&gt;token&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can then use the token later as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{token}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach works in both the Tests and APIs modules. For more examples, see &lt;a href="http://apidog.com/blog/pass-data-test-steps?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;how to pass data between test steps&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6: Add the else path
&lt;/h3&gt;

&lt;p&gt;Hover over the If block and click &lt;code&gt;+ Else&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You now have two paths to configure:&lt;/p&gt;

&lt;h4&gt;
  
  
  If: login succeeded
&lt;/h4&gt;

&lt;p&gt;Add the checkout request inside the If block.&lt;/p&gt;

&lt;p&gt;If checkout requires authentication, add the login token to the request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;Authorization: Bearer {{token}}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use a pre-step response reference instead of an extracted variable. This is the same bearer-token pattern used by authenticated APIs such as those documented in the &lt;a href="https://docs.stripe.com/api" rel="noopener noreferrer"&gt;Stripe API reference&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Else: login failed
&lt;/h4&gt;

&lt;p&gt;Add a step that makes the failure explicit. Options include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sending a request to a logging endpoint.&lt;/li&gt;
&lt;li&gt;Sending a notification request.&lt;/li&gt;
&lt;li&gt;Adding a custom request with an assertion that always fails.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The resulting workflow is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if login status == 200:
  create checkout
else:
  report failure
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prevents checkout from running after an invalid login response.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 7: Save and run the scenario
&lt;/h3&gt;

&lt;p&gt;Click &lt;strong&gt;Save All&lt;/strong&gt; to persist the scenario. If Apidog shows an unsaved-change dot, save before running.&lt;/p&gt;

&lt;p&gt;Then run the full scenario:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use valid credentials to verify that the If path runs.&lt;/li&gt;
&lt;li&gt;Use invalid credentials to verify that the Else path runs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Variations and advanced flow control
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Branch on a response body field
&lt;/h3&gt;

&lt;p&gt;You are not limited to status codes. A branch can evaluate any value you can reference.&lt;/p&gt;

&lt;p&gt;For example, your login API might return &lt;code&gt;200&lt;/code&gt; for a locked account but include account state in the body:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"locked"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"token"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reference the field:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{$.1.response.body.status}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then configure a condition such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;status Equals "active"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Other practical examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Contains&lt;/code&gt; for a response message.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Greater than&lt;/code&gt; for a balance or stock count.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;In List&lt;/code&gt; for role-based access checks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Combine branches with loops
&lt;/h3&gt;

&lt;p&gt;Branches can run inside loops.&lt;/p&gt;

&lt;p&gt;For example, a &lt;code&gt;ForEach&lt;/code&gt; loop can iterate over product IDs, while a Conditional Branching step skips out-of-stock products:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for each product:
  if product.stock &amp;gt; 0:
    process product
  else:
    skip product
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Within loop contexts, Apidog supports references such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{$.&amp;lt;loop step id&amp;gt;.index}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The loop index starts at &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To access the current ForEach element:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{$.&amp;lt;loop step id&amp;gt;.element.&amp;lt;field path&amp;gt;}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a complete iteration walkthrough, see the &lt;a href="http://apidog.com/blog/foreach-loop-tutorial?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;ForEach loop tutorial&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg5ntdtrc78qpkgo7goh8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg5ntdtrc78qpkgo7goh8.png" alt="Conditional branching and looping in Apidog" width="722" height="836"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Stop a loop with Break If
&lt;/h3&gt;

&lt;p&gt;Inside a loop, use &lt;strong&gt;Break If condition&lt;/strong&gt; to stop iterating when a condition becomes true.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Break If response.status Equals "complete"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can reposition the element in the loop and add multiple break conditions where appropriate.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configure loop error handling
&lt;/h3&gt;

&lt;p&gt;Loops include an &lt;code&gt;On Error&lt;/code&gt; element at the beginning of the loop. Its location is fixed.&lt;/p&gt;

&lt;p&gt;Available behaviors are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Ignore&lt;/code&gt;: continue with the next request.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Continue&lt;/code&gt;: skip the remaining requests in the current iteration.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Break execution&lt;/code&gt;: end the loop and continue after it.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;End execution&lt;/code&gt;: stop the entire scenario.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Choose the behavior based on whether one failed item should fail the whole workflow.&lt;/p&gt;

&lt;h3&gt;
  
  
  Add a Wait step
&lt;/h3&gt;

&lt;p&gt;Use the &lt;code&gt;Wait&lt;/code&gt; element when a downstream system needs time to reflect an update.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POST /orders
Wait 1000 ms
GET /orders/{id}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The delay is measured in milliseconds.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use scripts for complex logic
&lt;/h3&gt;

&lt;p&gt;If the built-in operators are not enough, use a pre-processor or post-processor script to calculate the result you need.&lt;/p&gt;

&lt;p&gt;Inside scripts, do not use &lt;code&gt;{{variable}}&lt;/code&gt; syntax directly. Instead, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;pm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;variables&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;$.2.response.body.token&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update the step ID and field path to match your scenario.&lt;/p&gt;

&lt;p&gt;For related workflows, see &lt;a href="http://apidog.com/blog/request-chaining?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;request chaining&lt;/a&gt; and &lt;a href="http://apidog.com/blog/api-test-orchestration-passing-data?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;API test orchestration and passing data&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A scenario cannot reference the original test scenario itself. This prevents accidental infinite loops when nesting scenarios.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Automate the workflow with the Apidog CLI
&lt;/h2&gt;

&lt;p&gt;A branching scenario does not need to run only in the Apidog UI. Use the Apidog CLI to execute saved scenarios in CI.&lt;/p&gt;

&lt;p&gt;Install the CLI and authenticate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; apidog-cli
apidog login &lt;span class="nt"&gt;--with-token&lt;/span&gt; &amp;lt;YOUR_ACCESS_TOKEN&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run a scenario by scenario ID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="nt"&gt;--access-token&lt;/span&gt; &lt;span class="nv"&gt;$APIDOG_ACCESS_TOKEN&lt;/span&gt; &lt;span class="nt"&gt;-t&lt;/span&gt; &amp;lt;scenario_id&amp;gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &amp;lt;env_id&amp;gt; &lt;span class="nt"&gt;-r&lt;/span&gt; cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Arguments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-t&lt;/code&gt;: test scenario ID&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-e&lt;/code&gt;: environment ID&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-r&lt;/code&gt;: reporter&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use &lt;code&gt;cli&lt;/code&gt; for terminal output. Use &lt;code&gt;html&lt;/code&gt; or &lt;code&gt;junit&lt;/code&gt; to generate pipeline artifacts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--access-token&lt;/span&gt; &lt;span class="nv"&gt;$APIDOG_ACCESS_TOKEN&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-t&lt;/span&gt; &amp;lt;scenario_id&amp;gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-e&lt;/span&gt; &amp;lt;env_id&amp;gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-r&lt;/span&gt; html,cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CLI resolves the branch exactly as the app does: it evaluates the login response, runs the If or Else path, and returns an exit code based on the outcome.&lt;/p&gt;

&lt;p&gt;For setup details, see the &lt;a href="http://apidog.com/blog/apidog-cli-installation-guide?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog CLI installation guide&lt;/a&gt;. For CI integration, see the &lt;a href="http://apidog.com/blog/apidog-cli-github-actions?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog CLI GitHub Actions guide&lt;/a&gt;. To run scenarios on a schedule, see &lt;a href="http://apidog.com/blog/how-to-schedule-api-tests-apidog?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;how to schedule API tests in Apidog&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is the difference between Conditional Branching and a loop in Apidog?
&lt;/h3&gt;

&lt;p&gt;Conditional Branching evaluates a condition once and chooses a path. A loop repeats a block of steps.&lt;/p&gt;

&lt;p&gt;Use a branch for an either/or decision:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if login succeeds:
  run checkout
else:
  stop checkout
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use a For or ForEach loop to repeat requests across a count or array. See the &lt;a href="http://apidog.com/blog/foreach-loop-tutorial?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;ForEach loop tutorial&lt;/a&gt; for details.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why is Retrieve pre-step data empty?
&lt;/h3&gt;

&lt;p&gt;Two common causes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It works only in the &lt;strong&gt;Tests&lt;/strong&gt; module.&lt;/li&gt;
&lt;li&gt;It resolves only when you run the &lt;strong&gt;entire scenario&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you run one request by itself, it has no previous scenario response to reference.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I branch on a response body field instead of a status code?
&lt;/h3&gt;

&lt;p&gt;Yes. Use a pre-step reference such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{$.1.response.body.status}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or extract the value into a named variable. Then evaluate it with operators such as &lt;code&gt;Equals&lt;/code&gt;, &lt;code&gt;Contains&lt;/code&gt;, or &lt;code&gt;In List&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For data-passing patterns, see &lt;a href="http://apidog.com/blog/pass-data-test-steps?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;how to pass data between test steps&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I use a scenario value inside a script?
&lt;/h3&gt;

&lt;p&gt;Scripts do not support direct &lt;code&gt;{{variable}}&lt;/code&gt; references. Use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;pm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;variables&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;$.2.response.body.token&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adjust the step ID and response path for your scenario.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does branching require a paid or self-hosted plan?
&lt;/h3&gt;

&lt;p&gt;The Apidog documentation lists no plan restriction for flow control, conditional branching, loops, or passing data between steps. It also lists no cloud-versus-self-hosted distinction for these features.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;A linear test can tell you that something failed. A branching scenario tells you where it failed and prevents requests from running when their prerequisites are missing.&lt;/p&gt;

&lt;p&gt;To implement this pattern:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add a login request.&lt;/li&gt;
&lt;li&gt;Add a &lt;strong&gt;Conditional Branching&lt;/strong&gt; step.&lt;/li&gt;
&lt;li&gt;Read the prior response with &lt;strong&gt;Retrieve pre-step data&lt;/strong&gt; or an extracted variable.&lt;/li&gt;
&lt;li&gt;Configure the If condition, such as &lt;code&gt;status Equals 200&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Put checkout in the If path.&lt;/li&gt;
&lt;li&gt;Put explicit failure handling in the Else path.&lt;/li&gt;
&lt;li&gt;Run the same scenario in CI with &lt;code&gt;apidog run&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Try Apidog free&lt;/a&gt; and turn straight-line API tests into scenarios that can make decisions.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Schedule Automated API Tests in Apidog (Cloud, Runner, and CLI)</title>
      <dc:creator>Hassann</dc:creator>
      <pubDate>Wed, 15 Jul 2026 08:59:42 +0000</pubDate>
      <link>https://dev.to/hassann/how-to-schedule-automated-api-tests-in-apidog-cloud-runner-and-cli-239o</link>
      <guid>https://dev.to/hassann/how-to-schedule-automated-api-tests-in-apidog-cloud-runner-and-cli-239o</guid>
      <description>&lt;p&gt;A passing test suite only helps if it keeps passing. Your checkout flow works today, but a dependency can ship a breaking change at 2 a.m., a certificate can expire over the weekend, or config drift can take down payments on a Sunday. If an angry customer finds it before your tests do, your checks are not doing their job. The practical fix: run API tests on a schedule and alert the team as soon as something fails.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation" class="crayons-btn crayons-btn--primary"&gt;Try Apidog today&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog&lt;/a&gt; includes a Scheduled Tasks feature for this workflow. Select existing test scenarios, configure a cadence, choose a machine to execute them, and set up alerts. If you are new to unattended checks against live endpoints, start with this primer on &lt;a href="http://apidog.com/blog/api-monitoring?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;API monitoring&lt;/a&gt;. For UI-specific details, use the &lt;a href="https://docs.apidog.com/scheduled-tasks-603702m0" rel="noopener noreferrer"&gt;Apidog Scheduled Tasks documentation&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Scheduled Tasks is currently labeled Beta. The number of scheduled runs available depends on your plan.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What Scheduled Tasks do—and what they do not do
&lt;/h2&gt;

&lt;p&gt;A scheduled task runs one or more saved Test Scenarios on a recurring cycle. Common uses include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Nightly regression tests for core API flows&lt;/li&gt;
&lt;li&gt;A staging smoke test every few hours&lt;/li&gt;
&lt;li&gt;Weekend health checks for production endpoints&lt;/li&gt;
&lt;li&gt;Scheduled checks for authentication, payments, or other critical paths&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each task stores:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The test scenarios to run&lt;/li&gt;
&lt;li&gt;The target environment&lt;/li&gt;
&lt;li&gt;The schedule&lt;/li&gt;
&lt;li&gt;The Runner that executes requests&lt;/li&gt;
&lt;li&gt;Notification settings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Scheduled Tasks are not web scrapers or data-collection jobs. They run API test scenarios, including assertions, chained requests, extracted variables, and test data. The output is a pass/fail report for your API tests—not a scraped dataset.&lt;/p&gt;

&lt;p&gt;That changes the setup: you do not configure CSS selectors or crawl rules. You select test scenarios you already built and define when and where they run.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before you start: configure a self-hosted Runner
&lt;/h2&gt;

&lt;p&gt;Scheduled Tasks require a self-hosted Runner.&lt;/p&gt;

&lt;p&gt;A Runner is the machine that executes your test suite. When a task fires, Apidog sends the job to the selected Runner. Requests do not run from your desktop client; they originate from the Runner machine.&lt;/p&gt;

&lt;p&gt;Good Runner choices include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An always-on VM&lt;/li&gt;
&lt;li&gt;A CI server&lt;/li&gt;
&lt;li&gt;A small server inside your VPC&lt;/li&gt;
&lt;li&gt;A dedicated monitoring host&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Make sure the Runner stays online during the scheduled window.&lt;/p&gt;

&lt;p&gt;The runner target currently offers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Apidog Cloud&lt;/strong&gt; — marked “coming soon”&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Self-hosted Runner&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because Apidog Cloud is not available yet, select a self-hosted Runner for scheduled execution.&lt;/p&gt;

&lt;p&gt;Also account for the Runner's network location. A Runner behind a VPN, in another region, or inside a firewalled subnet may receive different responses than your laptop. This is often useful because it tests the API from a realistic network environment, but it also explains why local and scheduled results can differ.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step by step: create a scheduled task
&lt;/h2&gt;

&lt;p&gt;This example creates a nightly regression suite for an e-commerce API covering signup, product browsing, cart operations, and checkout with &lt;a href="https://docs.stripe.com/" rel="noopener noreferrer"&gt;Stripe&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Open Scheduled Tasks in the Tests module
&lt;/h3&gt;

&lt;p&gt;In the Apidog client:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the &lt;strong&gt;Tests&lt;/strong&gt; module.&lt;/li&gt;
&lt;li&gt;In the Tests folder tree, select &lt;strong&gt;Scheduled Tasks&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This view lists scheduled tasks for the current project and shows what is configured to run.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Create the task
&lt;/h3&gt;

&lt;p&gt;Click &lt;strong&gt;+ New&lt;/strong&gt; to create a scheduled task.&lt;/p&gt;

&lt;p&gt;Set a clear task name and description, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Task Name: Nightly regression - production
Description: Validates signup, catalog, cart, and checkout flows against production.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also create folders to group tasks. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Scheduled Tasks
├── Production
│   ├── Nightly regression
│   └── Payment smoke test
└── Staging
    ├── Pre-release smoke test
    └── Contract regression
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tasks can be enabled or disabled at any time, so you can pause a noisy suite without deleting its configuration.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Select test scenarios
&lt;/h3&gt;

&lt;p&gt;Under &lt;strong&gt;Test Scenario&lt;/strong&gt;, select one or more scenarios.&lt;/p&gt;

&lt;p&gt;For an e-commerce regression task, select scenarios such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Signup and login&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Browse and add to cart&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Checkout with Stripe test card&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each scenario can use its own execution settings:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Environment&lt;/li&gt;
&lt;li&gt;Test data&lt;/li&gt;
&lt;li&gt;Iterations&lt;/li&gt;
&lt;li&gt;Delay&lt;/li&gt;
&lt;li&gt;Whether to save requests and responses&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If every scenario should use identical settings, enable &lt;strong&gt;Use same execution config&lt;/strong&gt;. This applies one runtime configuration across all selected scenarios.&lt;/p&gt;

&lt;p&gt;For most scheduled suites, keep the environment consistent:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;production&lt;/strong&gt; for real production monitoring.&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;staging&lt;/strong&gt; for pre-release smoke tests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Although a task can use different environments per scenario, a single environment per task is usually easier to operate and troubleshoot.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Set the run cycle
&lt;/h3&gt;

&lt;p&gt;Configure the schedule using the run-schedule field. Depending on the UI, this may appear as &lt;strong&gt;Run Cycle&lt;/strong&gt; or &lt;strong&gt;Run Mode&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every Sunday at 11 PM&lt;/li&gt;
&lt;li&gt;Every 6 hours&lt;/li&gt;
&lt;li&gt;Every 8 hours&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Choose a cadence based on risk and test cost:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Use case&lt;/th&gt;
&lt;th&gt;Suggested cadence&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Production regression suite&lt;/td&gt;
&lt;td&gt;Nightly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Staging smoke test&lt;/td&gt;
&lt;td&gt;Every 6 hours&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Critical health flow&lt;/td&gt;
&lt;td&gt;Every few hours&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Resource-intensive end-to-end suite&lt;/td&gt;
&lt;td&gt;Nightly or weekly&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A nightly run is usually a good starting point for broad regression coverage because it catches failures before the next workday without putting unnecessary load on the environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Choose where the task runs
&lt;/h3&gt;

&lt;p&gt;Set the Runner field to your self-hosted Runner.&lt;/p&gt;

&lt;p&gt;Depending on the screen, this may be labeled:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Runs on&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Run On&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Runs On&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All labels refer to the machine that sends the test requests.&lt;/p&gt;

&lt;p&gt;If you have multiple Runners, choose the one that best represents the traffic you want to validate. For example, select a Runner in the same VPC as your API if you want to validate internal connectivity.&lt;/p&gt;

&lt;p&gt;Remember: every request in the scenario originates from this Runner machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Enable notifications
&lt;/h3&gt;

&lt;p&gt;Enable &lt;strong&gt;Notification&lt;/strong&gt; so failures reach the team automatically.&lt;/p&gt;

&lt;p&gt;Supported channels include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Slack&lt;/li&gt;
&lt;li&gt;Teams&lt;/li&gt;
&lt;li&gt;Webhook&lt;/li&gt;
&lt;li&gt;Jenkins&lt;/li&gt;
&lt;li&gt;Email&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For email notifications, project member addresses can auto-complete, and you can manually add non-member addresses such as an on-call inbox.&lt;/p&gt;

&lt;p&gt;Choose when notifications fire:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;After every run&lt;/strong&gt;: useful while validating a new task or during an active rollout.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;On failures only&lt;/strong&gt;: best for stable nightly suites, where silence indicates success.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, use failures-only notifications for production regression:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Channel: Slack
When to notify: Failures only
Target: #api-alerts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use every-run notifications temporarily when you need confirmation that the task itself is executing.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Save and enable the task
&lt;/h3&gt;

&lt;p&gt;Save the configuration, then enable the task using its toggle.&lt;/p&gt;

&lt;p&gt;The task begins running on the configured cadence. Disable it later if you need to pause monitoring during planned maintenance, an outage, or a migration window.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Review run history
&lt;/h3&gt;

&lt;p&gt;After each run, the Runner uploads results back to the server.&lt;/p&gt;

&lt;p&gt;Open &lt;strong&gt;Scheduled Tasks - Run History&lt;/strong&gt; to inspect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pass/fail status&lt;/li&gt;
&lt;li&gt;Execution time&lt;/li&gt;
&lt;li&gt;Failed assertions&lt;/li&gt;
&lt;li&gt;Request and response details, if saved&lt;/li&gt;
&lt;li&gt;The time each run occurred&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When a Slack or email alert arrives, use Run History to investigate the failing scenario and assertion.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advanced settings and variations
&lt;/h2&gt;

&lt;p&gt;Once the basic task works, configure variable handling and folder structure carefully.&lt;/p&gt;

&lt;h3&gt;
  
  
  Variable scope
&lt;/h3&gt;

&lt;p&gt;Apidog provides three levels of variable sharing:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Share only in the current test scenario&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Keeps variables isolated to one scenario.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Share across all test scenarios in the current scheduled task&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Allows scenarios in the same task to use shared values.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Share across all scheduled tasks in the current scheduled task folder&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Lets related tasks inside a folder share variables.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use the narrowest scope that supports your workflow. For example, avoid sharing an authentication token across unrelated scenarios unless those scenarios explicitly require it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Variable persistence
&lt;/h3&gt;

&lt;p&gt;To preserve values between scheduled runs, enable &lt;strong&gt;Keep variable values&lt;/strong&gt; on the test scenario design page.&lt;/p&gt;

&lt;p&gt;Without this option, each scheduled run starts with fresh variable values.&lt;/p&gt;

&lt;p&gt;Enable persistence only when your tests require cross-run state, such as a captured order ID or refreshed token.&lt;/p&gt;

&lt;h3&gt;
  
  
  Group tasks with folders
&lt;/h3&gt;

&lt;p&gt;Use folders to separate task types:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Scheduled Tasks
├── Production monitors
├── Staging smoke tests
├── Payment checks
└── Pre-release regression
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Folders also support the widest scheduled-task variable-sharing scope, which can help related tasks reuse setup data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Check plan limits before increasing frequency
&lt;/h3&gt;

&lt;p&gt;The number of scheduled runs available depends on your subscription. Before configuring hourly or high-frequency tasks, check your plan limits.&lt;/p&gt;

&lt;p&gt;For deeper scheduling patterns, see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://apidog.com/blog/schedules-tasks-advanced?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Advanced scheduled tasks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://apidog.com/blog/how-to-add-conditional-logic-api-test-scenarios-apidog?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Conditional logic in API test scenarios&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://apidog.com/blog/nightly-api-test-runs-ci?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Nightly API test runs in CI&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Automate with the Apidog CLI
&lt;/h2&gt;

&lt;p&gt;The Scheduled Tasks UI is one option. You can also run saved scenarios headlessly with the &lt;a href="https://apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog&lt;/a&gt; CLI and let cron or your CI platform provide the schedule.&lt;/p&gt;

&lt;p&gt;The CLI does not include a native schedule command. Scheduling happens outside Apidog through cron, GitHub Actions, or another CI scheduler.&lt;/p&gt;

&lt;p&gt;Install the CLI, authenticate, and run a scenario against a chosen environment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; apidog-cli
apidog login &lt;span class="nt"&gt;--with-token&lt;/span&gt; &amp;lt;YOUR_TOKEN&amp;gt;
apidog run &lt;span class="nt"&gt;--access-token&lt;/span&gt; &lt;span class="nv"&gt;$APIDOG_ACCESS_TOKEN&lt;/span&gt; &lt;span class="nt"&gt;-t&lt;/span&gt; &amp;lt;SCENARIO_ID&amp;gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &amp;lt;ENV_ID&amp;gt; &lt;span class="nt"&gt;-r&lt;/span&gt; cli,junit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The relevant flags are:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Flag&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-t&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Test scenario ID&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-e&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Environment ID&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-r&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Reporter format&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Available reporters include &lt;code&gt;cli&lt;/code&gt;, &lt;code&gt;html&lt;/code&gt;, and &lt;code&gt;junit&lt;/code&gt;. Combine reporters with commas:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--access-token&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$APIDOG_ACCESS_TOKEN&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-t&lt;/span&gt; 4471 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-e&lt;/span&gt; 88 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-r&lt;/span&gt; cli,junit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Schedule a nightly CLI run with cron
&lt;/h3&gt;

&lt;p&gt;Add a cron entry to run the scenario every night at 2:00 a.m.:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;0 2 &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; /srv/api-tests &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; apidog run &lt;span class="nt"&gt;--access-token&lt;/span&gt; &lt;span class="nv"&gt;$APIDOG_ACCESS_TOKEN&lt;/span&gt; &lt;span class="nt"&gt;-t&lt;/span&gt; 4471 &lt;span class="nt"&gt;-e&lt;/span&gt; 88 &lt;span class="nt"&gt;-r&lt;/span&gt; junit &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; run.log 2&amp;gt;&amp;amp;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Changes into the test directory.&lt;/li&gt;
&lt;li&gt;Runs the selected scenario against environment &lt;code&gt;88&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Produces a JUnit report.&lt;/li&gt;
&lt;li&gt;Appends output and errors to &lt;code&gt;run.log&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can also schedule the command through GitHub Actions. The JUnit output can then feed into existing CI reporting workflows.&lt;/p&gt;

&lt;p&gt;For implementation details, see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://apidog.com/blog/apidog-cli-installation-guide?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog CLI installation guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://apidog.com/blog/apidog-cli-ci-cd-pipeline?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog CLI in your CI/CD pipeline&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#schedule" rel="noopener noreferrer"&gt;GitHub Actions schedule triggers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Cron" rel="noopener noreferrer"&gt;cron&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can I run scheduled tests on Apidog Cloud today?
&lt;/h3&gt;

&lt;p&gt;Not yet. Apidog Cloud is marked “coming soon,” so use a self-hosted Runner for scheduled execution.&lt;/p&gt;

&lt;h3&gt;
  
  
  How often can scheduled tasks run?
&lt;/h3&gt;

&lt;p&gt;The cadence is flexible, with examples such as every 6 hours or every Sunday at 11 PM. However, the number of scheduled runs is limited by your subscription plan.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I receive alerts only when a test fails?
&lt;/h3&gt;

&lt;p&gt;In the task's &lt;strong&gt;Notification&lt;/strong&gt; settings:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select a channel: Slack, Teams, Webhook, Jenkins, or Email.&lt;/li&gt;
&lt;li&gt;Choose the failures-only notification option.&lt;/li&gt;
&lt;li&gt;Save the task.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This keeps channels quiet when tests pass and alerts the team when a failure occurs. Pair it with an &lt;a href="http://apidog.com/blog/api-health-check?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;API health check&lt;/a&gt; for a faster liveness signal alongside deeper regression coverage.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why do scheduled results differ from local test runs?
&lt;/h3&gt;

&lt;p&gt;Scheduled requests originate from the Runner machine, not your laptop. Its network, region, VPN configuration, and firewall rules can affect API responses.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why do my variables reset after every run?
&lt;/h3&gt;

&lt;p&gt;Enable &lt;strong&gt;Keep variable values&lt;/strong&gt; on the test scenario design page. Without it, every scheduled run starts with fresh values.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;Scheduled tests turn “we think the API works” into “we know, and we would have heard if it did not.”&lt;/p&gt;

&lt;p&gt;Start with this implementation checklist:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Build and validate your test scenarios.&lt;/li&gt;
&lt;li&gt;Register a self-hosted Runner.&lt;/li&gt;
&lt;li&gt;Create a scheduled task.&lt;/li&gt;
&lt;li&gt;Select scenarios and an environment.&lt;/li&gt;
&lt;li&gt;Set a run cadence.&lt;/li&gt;
&lt;li&gt;Configure failure notifications.&lt;/li&gt;
&lt;li&gt;Review Run History when alerts arrive.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For CI-driven scheduling, run the same scenarios with the CLI and schedule them with cron or GitHub Actions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/download?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Download Apidog&lt;/a&gt; to set up your first scheduled regression suite.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Use Database Queries in API Tests with Apidog (MySQL, MongoDB, Redis)</title>
      <dc:creator>Hassann</dc:creator>
      <pubDate>Wed, 15 Jul 2026 06:51:20 +0000</pubDate>
      <link>https://dev.to/hassann/how-to-use-database-queries-in-api-tests-with-apidog-mysql-mongodb-redis-2a76</link>
      <guid>https://dev.to/hassann/how-to-use-database-queries-in-api-tests-with-apidog-mysql-mongodb-redis-2a76</guid>
      <description>&lt;p&gt;A green status code can lie. Your &lt;code&gt;POST /orders&lt;/code&gt; endpoint returns &lt;code&gt;201 Created&lt;/code&gt;, the response body looks correct, and the HTTP assertion passes—but did the row reach the database with the expected status? Did inventory decrement? HTTP-only tests verify what the API &lt;em&gt;reported&lt;/em&gt;, not what the system &lt;em&gt;persisted&lt;/em&gt;. Query the database to close that gap.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation" class="crayons-btn crayons-btn--primary"&gt;Try Apidog today&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;Database queries let a scenario seed known data, call an API, and verify the resulting state in one workflow. &lt;a href="https://apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog&lt;/a&gt; supports this with Database Connections and the Database Operation processor, so you can run SQL or NoSQL commands before and after HTTP requests without external scripts. If you need the request-level foundation first, see &lt;a href="http://apidog.com/blog/how-to-write-test-scenario-with-apidog?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;how to write a test scenario with Apidog&lt;/a&gt;. For relational-database fundamentals, MDN’s &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/Server-side" rel="noopener noreferrer"&gt;server-side overview&lt;/a&gt; is a useful primer.&lt;/p&gt;

&lt;h2&gt;
  
  
  What database operations add to API tests
&lt;/h2&gt;

&lt;p&gt;An API test that never checks persistence is a black-box test: it trusts the response. That is often enough for contract validation, but it misses bugs such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A status field that was never updated.&lt;/li&gt;
&lt;li&gt;A foreign key that references the wrong record.&lt;/li&gt;
&lt;li&gt;A soft-delete endpoint that hard-deletes data.&lt;/li&gt;
&lt;li&gt;A successful response returned before a write fails or is rolled back.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Database steps add three practical capabilities:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Seed a deterministic starting state&lt;/strong&gt; so tests do not depend on leftover records.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Assert against persisted state&lt;/strong&gt; rather than relying only on the response body.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extract database-generated values&lt;/strong&gt; for later requests.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In &lt;a href="https://apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog&lt;/a&gt;, configure a reusable connection under &lt;strong&gt;Settings &amp;gt; Database Connections&lt;/strong&gt;, then add a &lt;strong&gt;Database Operation&lt;/strong&gt; as either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;Pre Processor&lt;/strong&gt;, which runs before the HTTP request.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;Post Processor&lt;/strong&gt;, which runs after the HTTP request.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Create a connection once and reuse it across scenarios in the project.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Plan support:&lt;/strong&gt; MySQL, SQL Server (2014+), PostgreSQL, and Oracle are available on the free plan. ClickHouse, MongoDB, and Redis require a paid plan. The MySQL examples below work on the free tier; the MongoDB and Redis examples require paid access.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Step 1: Create a database connection
&lt;/h2&gt;

&lt;p&gt;Open &lt;strong&gt;Settings &amp;gt; Database Connections&lt;/strong&gt;, then click &lt;strong&gt;+ New&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Select your database type and provide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Host&lt;/strong&gt;, such as &lt;code&gt;db.staging.internal&lt;/code&gt; or &lt;code&gt;127.0.0.1&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Port&lt;/strong&gt;, such as &lt;code&gt;3306&lt;/code&gt; for MySQL&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Username&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Password&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database Name&lt;/strong&gt;, such as &lt;code&gt;shop&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fii00hnryftshu2mx0qgi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fii00hnryftshu2mx0qgi.png" alt="Apidog database connection configuration" width="800" height="513"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If the database is behind a bastion host, expand &lt;strong&gt;SSH Tunnel&lt;/strong&gt; and configure the jump host.&lt;/p&gt;

&lt;p&gt;For MySQL, choose an SSL mode:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Prefer&lt;/code&gt;: attempts SSL, then falls back if unavailable.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Require&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Verify CA&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Verify Full&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use the strictest mode supported by your server, then click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  MySQL 8 authentication issue
&lt;/h3&gt;

&lt;p&gt;MySQL 8 commonly uses &lt;code&gt;caching_sha2_password&lt;/code&gt;. If your connection fails with an authentication error, switch the test user to &lt;code&gt;mysql_native_password&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;USER&lt;/span&gt; &lt;span class="s1"&gt;'tester'&lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="s1"&gt;'%'&lt;/span&gt;
&lt;span class="n"&gt;IDENTIFIED&lt;/span&gt; &lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="n"&gt;mysql_native_password&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="s1"&gt;'...'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See the &lt;a href="https://dev.mysql.com/doc/refman/8.0/en/" rel="noopener noreferrer"&gt;MySQL reference manual&lt;/a&gt; for details about authentication plugins.&lt;/p&gt;

&lt;h3&gt;
  
  
  Connection credentials are local
&lt;/h3&gt;

&lt;p&gt;Database connection details are stored locally and are not synced to the cloud project. Each teammate must configure their own connection. For team workflows, see &lt;a href="http://apidog.com/blog/database-connection-settings-sharing?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;sharing database connection settings&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Seed test data with a Pre Processor
&lt;/h2&gt;

&lt;p&gt;Assume you are testing order creation. Before calling &lt;code&gt;POST /api/orders&lt;/code&gt;, seed a known active customer.&lt;/p&gt;

&lt;p&gt;In the request:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open &lt;strong&gt;Pre Processors&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Hover &lt;strong&gt;Add Database Processor&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;Database operation&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Name the step &lt;code&gt;seed customer&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Select the MySQL connection.&lt;/li&gt;
&lt;li&gt;Add an insert statement.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use environment variables with &lt;code&gt;{{variable_name}}&lt;/code&gt; syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;customers&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;({{&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;}},&lt;/span&gt; &lt;span class="s1"&gt;'{{customer_email}}'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'active'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;DUPLICATE&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt; &lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'active'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This setup makes the test self-contained:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The customer exists.&lt;/li&gt;
&lt;li&gt;The customer is active.&lt;/li&gt;
&lt;li&gt;The ID is known before the API request runs.&lt;/li&gt;
&lt;li&gt;The scenario does not depend on execution order or existing database contents.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 3: Verify persistence with a Post Processor
&lt;/h2&gt;

&lt;p&gt;Now call the API that creates an order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;POST /api/orders
Content-Type: application/json

{
  "customer_id": {{customer_id}},
  "items": [{ "sku": "APRON-01", "qty": 2 }]
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Capture the returned order ID from the response into &lt;code&gt;order_id&lt;/code&gt; using a normal response assertion.&lt;/p&gt;

&lt;p&gt;Then add a database check:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open &lt;strong&gt;Post Processors&lt;/strong&gt;.

&lt;ul&gt;
&lt;li&gt;In &lt;strong&gt;DESIGN Mode&lt;/strong&gt;, use the &lt;strong&gt;Run&lt;/strong&gt; tab.&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;DEBUG Mode&lt;/strong&gt;, use the &lt;strong&gt;Request&lt;/strong&gt; tab.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Hover &lt;strong&gt;Add PostProcessor&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Database operation&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Name it &lt;code&gt;verify order row&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Choose the database connection.&lt;/li&gt;
&lt;li&gt;Run this query:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total_cents&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{{&lt;/span&gt;&lt;span class="n"&gt;order_id&lt;/span&gt;&lt;span class="p"&gt;}};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Database query results are returned as an array of objects. Extract the status from the first result:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Variable Name:&lt;/strong&gt; &lt;code&gt;db_order_status&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JSONPath Expression:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$[0].status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Click &lt;strong&gt;Send&lt;/strong&gt;, then inspect the &lt;strong&gt;Console&lt;/strong&gt; to view the raw database result and extracted variable.&lt;/p&gt;

&lt;p&gt;Finally, add an assertion that &lt;code&gt;db_order_status&lt;/code&gt; equals &lt;code&gt;pending&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db_order_status == pending
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now a response that returns &lt;code&gt;201 Created&lt;/code&gt; but persists &lt;code&gt;status = 'draft'&lt;/code&gt; will fail the scenario.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Reuse a database value in a later request
&lt;/h2&gt;

&lt;p&gt;Database extraction is also useful when an API does not return a server-generated value.&lt;/p&gt;

&lt;p&gt;For example, creating an order might generate an internal &lt;code&gt;fulfillment_ref&lt;/code&gt; that is stored in the &lt;code&gt;orders&lt;/code&gt; table but omitted from the API response. Query it after order creation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;fulfillment_ref&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{{&lt;/span&gt;&lt;span class="n"&gt;order_id&lt;/span&gt;&lt;span class="p"&gt;}};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Extract the value with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Variable Name:&lt;/strong&gt; &lt;code&gt;fulfillment_ref&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JSONPath Expression:&lt;/strong&gt; &lt;code&gt;$[0].fulfillment_ref&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use it in the next request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;GET /api/fulfillments/{{fulfillment_ref}}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This follows the same chaining pattern as HTTP response variables, except the source is the database. See &lt;a href="http://apidog.com/blog/pass-data-test-steps?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;passing data between test steps&lt;/a&gt; and &lt;a href="http://apidog.com/blog/api-test-orchestration-passing-data?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;API test orchestration and passing data&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  MongoDB and Redis: NoSQL variants
&lt;/h2&gt;

&lt;p&gt;MongoDB and Redis use the same Database Operation concept, but their configuration differs from SQL databases. Both require a paid plan. See the &lt;a href="https://docs.apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog documentation&lt;/a&gt; for the complete field reference.&lt;/p&gt;

&lt;h3&gt;
  
  
  MongoDB
&lt;/h3&gt;

&lt;p&gt;Add a Database Operation and select &lt;strong&gt;MongoDB&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Instead of SQL, select an &lt;strong&gt;Operation Type&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Find&lt;/li&gt;
&lt;li&gt;Insert&lt;/li&gt;
&lt;li&gt;Update&lt;/li&gt;
&lt;li&gt;Delete&lt;/li&gt;
&lt;li&gt;Run Database Command&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For CRUD operations, &lt;strong&gt;Collection Name&lt;/strong&gt; is required. Enter JSON in &lt;strong&gt;Query Condition&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"65486728456e79993a150f1c"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apidog automatically converts a matching ID string to an &lt;code&gt;ObjectId&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When you need BSON-specific types, these helpers are supported:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nc"&gt;ISODate&lt;/span&gt;&lt;span class="p"&gt;(...)&lt;/span&gt;
&lt;span class="nc"&gt;ObjectId&lt;/span&gt;&lt;span class="p"&gt;(...)&lt;/span&gt;
&lt;span class="nc"&gt;NumberDecimal&lt;/span&gt;&lt;span class="p"&gt;(...)&lt;/span&gt;
&lt;span class="nc"&gt;NumberLong&lt;/span&gt;&lt;span class="p"&gt;(...)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Refer to the &lt;a href="https://www.mongodb.com/docs/" rel="noopener noreferrer"&gt;MongoDB manual&lt;/a&gt; for the stored-value mappings. You can configure the connection with either a full connection string or individual host and credential fields.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The SQL workflow documents JSONPath extraction through &lt;strong&gt;Extract Result To Variable&lt;/strong&gt;. MongoDB and Redis documentation does not describe the same extraction mechanism. Use NoSQL operations for setup and state verification, and verify any extraction behavior in the Console before relying on it in a scenario.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Redis
&lt;/h3&gt;

&lt;p&gt;A Redis connection requires:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Host&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Port&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Password&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Database Index&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Visual operations support &lt;strong&gt;GET&lt;/strong&gt;, &lt;strong&gt;SET&lt;/strong&gt;, and &lt;strong&gt;DELETE&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To verify a cached session:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select &lt;strong&gt;GET&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Set &lt;strong&gt;Key&lt;/strong&gt; to a value such as &lt;code&gt;user:session:123&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For commands not covered by the dropdown, use &lt;strong&gt;Run Redis Command&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;KEYS user:*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use this to confirm that an endpoint wrote a cache entry or to clear a key before testing whether the endpoint repopulates it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advanced patterns and limits
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Iterate through rows
&lt;/h3&gt;

&lt;p&gt;When using a &lt;code&gt;ForEach&lt;/code&gt; step, reference the current item with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{$.StepID.element.field}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;StepID&lt;/code&gt; with the actual loop step number. This is useful when asserting one database row per iteration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Branch based on a database value
&lt;/h3&gt;

&lt;p&gt;Extract a database status, then route the scenario based on that value. Combine database reads with &lt;a href="http://apidog.com/blog/how-to-add-conditional-logic-api-test-scenarios-apidog?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;conditional logic in API test scenarios&lt;/a&gt; to take one path for &lt;code&gt;paid&lt;/code&gt; records and another for &lt;code&gt;pending&lt;/code&gt; records.&lt;/p&gt;

&lt;h3&gt;
  
  
  Route safely by environment
&lt;/h3&gt;

&lt;p&gt;Create one database connection per environment, such as &lt;code&gt;local&lt;/code&gt; and &lt;code&gt;staging&lt;/code&gt;. Apidog selects the matching connection when you switch the active environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Keep SQL operations straightforward
&lt;/h3&gt;

&lt;p&gt;The visual interface does not support complex operations such as stored procedures. Use direct statements such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="k"&gt;DELETE&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Oracle requires a local client
&lt;/h3&gt;

&lt;p&gt;Oracle requires the Oracle Client to be installed on your machine before Apidog can connect.&lt;/p&gt;

&lt;h2&gt;
  
  
  Handle database credentials per environment
&lt;/h2&gt;

&lt;p&gt;Never point tests at production accidentally.&lt;/p&gt;

&lt;p&gt;Create separate connections for each environment:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;local&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;staging&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Any other isolated test environment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each connection has its own host, credentials, and database name.&lt;/p&gt;

&lt;p&gt;When you switch the active environment using the top-right dropdown, Apidog routes database operations to the matching connection automatically:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select &lt;code&gt;staging&lt;/code&gt;: the scenario queries staging.&lt;/li&gt;
&lt;li&gt;Select &lt;code&gt;local&lt;/code&gt;: the same scenario queries your local database.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The SQL and test steps do not need to change.&lt;/p&gt;

&lt;p&gt;Because credentials are stored locally rather than synced into the shared cloud project, production passwords remain outside the shared project configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run database-backed scenarios in CI with the Apidog CLI
&lt;/h2&gt;

&lt;p&gt;After the scenario passes locally, run it in CI so pull requests validate persistence as well as HTTP behavior.&lt;/p&gt;

&lt;p&gt;Install the CLI and authenticate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; apidog-cli
apidog login &lt;span class="nt"&gt;--with-token&lt;/span&gt; &amp;lt;YOUR_ACCESS_TOKEN&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run a scenario by scenario ID and environment ID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="nt"&gt;--access-token&lt;/span&gt; &lt;span class="nv"&gt;$APIDOG_ACCESS_TOKEN&lt;/span&gt; &lt;span class="nt"&gt;-t&lt;/span&gt; &amp;lt;scenario_id&amp;gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &amp;lt;env_id&amp;gt; &lt;span class="nt"&gt;-r&lt;/span&gt; cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-t&lt;/code&gt;: test scenario ID&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-e&lt;/code&gt;: environment ID&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-r&lt;/code&gt;: reporter&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Supported reporters include:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cli
html
junit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use multiple reporters by comma-separating them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="nt"&gt;--access-token&lt;/span&gt; &lt;span class="nv"&gt;$APIDOG_ACCESS_TOKEN&lt;/span&gt; &lt;span class="nt"&gt;-t&lt;/span&gt; &amp;lt;scenario_id&amp;gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &amp;lt;env_id&amp;gt; &lt;span class="nt"&gt;-r&lt;/span&gt; html,cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Database connections are local, so your CI runner needs the exported configuration required to reach the target database.&lt;/p&gt;

&lt;p&gt;For data-driven execution, see &lt;a href="http://apidog.com/blog/apidog-cli-data-driven-testing?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;data-driven testing with the Apidog CLI&lt;/a&gt;. To run scenarios on a schedule, see &lt;a href="http://apidog.com/blog/how-to-schedule-api-tests-apidog?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;scheduling API tests with Apidog&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Which databases are free and which require a paid plan?
&lt;/h3&gt;

&lt;p&gt;MySQL, SQL Server (2014+), PostgreSQL, and Oracle are available on the free plan. ClickHouse, MongoDB, and Redis require a paid plan.&lt;/p&gt;

&lt;p&gt;Try the free database integrations first by &lt;a href="https://apidog.com/download?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;downloading Apidog&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I use a database value in a later request?
&lt;/h3&gt;

&lt;p&gt;Yes. Add a Post Processor with a Database Operation, run a &lt;code&gt;SELECT&lt;/code&gt;, and use &lt;strong&gt;Extract Result To Variable&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;fulfillment_ref&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{{&lt;/span&gt;&lt;span class="n"&gt;order_id&lt;/span&gt;&lt;span class="p"&gt;}};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Extract with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$[0].fulfillment_ref
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then reference it later:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{fulfillment_ref}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For response-based chaining, see &lt;a href="http://apidog.com/blog/pass-data-test-steps?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;passing data between test steps&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do teammates automatically receive my database connections?
&lt;/h3&gt;

&lt;p&gt;No. Connection credentials are local to each client and are not synced to the cloud. Every teammate configures their own connection.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why does my MySQL 8 connection fail?
&lt;/h3&gt;

&lt;p&gt;MySQL 8 defaults to &lt;code&gt;caching_sha2_password&lt;/code&gt;, which can prevent a connection. Switch the user to &lt;code&gt;mysql_native_password&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;USER&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="n"&gt;IDENTIFIED&lt;/span&gt; &lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="n"&gt;mysql_native_password&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then reconnect.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I run stored procedures?
&lt;/h3&gt;

&lt;p&gt;Not through the visual interface. Use direct &lt;code&gt;SELECT&lt;/code&gt;, &lt;code&gt;INSERT&lt;/code&gt;, &lt;code&gt;UPDATE&lt;/code&gt;, and &lt;code&gt;DELETE&lt;/code&gt; statements for database test steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrap up
&lt;/h2&gt;

&lt;p&gt;Database operations turn an API test from “the response looked right” into “the persisted data is correct.”&lt;/p&gt;

&lt;p&gt;A practical workflow is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Seed a known state with a Pre Processor.&lt;/li&gt;
&lt;li&gt;Call the API.&lt;/li&gt;
&lt;li&gt;Query the resulting row with a Post Processor.&lt;/li&gt;
&lt;li&gt;Assert persisted values.&lt;/li&gt;
&lt;li&gt;Extract server-generated database values for downstream requests.&lt;/li&gt;
&lt;li&gt;Configure separate connections for local and staging environments.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Start with one request: point a MySQL connection at your development database, create an order, and add a Post Processor that reads the created row back from &lt;code&gt;orders&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/download?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Download Apidog&lt;/a&gt; to try the free database integrations.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Run a Self-Hosted Mock Server on Your Intranet with Apidog</title>
      <dc:creator>Hassann</dc:creator>
      <pubDate>Wed, 15 Jul 2026 06:48:36 +0000</pubDate>
      <link>https://dev.to/hassann/how-to-run-a-self-hosted-mock-server-on-your-intranet-with-apidog-5a22</link>
      <guid>https://dev.to/hassann/how-to-run-a-self-hosted-mock-server-on-your-intranet-with-apidog-5a22</guid>
      <description>&lt;p&gt;Some teams cannot send API traffic to the cloud. Corporate firewalls may block third-party services, compliance policies may require request and response data to stay on infrastructure you control, or the environment may be fully air-gapped. In these cases, even a hosted mock endpoint with fake data is not an option. Apidog supports this setup with a self-hosted runner: you deploy the runner on your own server and serve mock responses from inside your network, while keeping API definitions and mock design in your Apidog project. For broader context, see &lt;a href="http://apidog.com/blog/self-hosted-api-mock-servers?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;self-hosted API mock servers&lt;/a&gt; and the &lt;a href="https://www.openapis.org/" rel="noopener noreferrer"&gt;OpenAPI Initiative&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation" class="crayons-btn crayons-btn--primary"&gt;Try Apidog today&lt;/a&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  What the self-hosted runner is
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://docs.apidog.com/self-hosted-runner-mock-621086m0?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog Self-hosted Runner&lt;/a&gt;, officially called the &lt;strong&gt;General Runner&lt;/strong&gt;, is a program you host on a standalone server. It can:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run scheduled automated tests.&lt;/li&gt;
&lt;li&gt;Import API documents.&lt;/li&gt;
&lt;li&gt;Serve mock responses.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This article focuses on mock serving.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F33t7her1ppzil2tz10al.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F33t7her1ppzil2tz10al.png" alt="Apidog Self-hosted Runner" width="799" height="625"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After you deploy a General Runner and configure its &lt;strong&gt;Server Host&lt;/strong&gt;, Apidog automatically creates a &lt;strong&gt;Runner Mock&lt;/strong&gt; environment in your project. Requests sent through that environment receive responses from your self-hosted runner rather than Apidog cloud mock.&lt;/p&gt;

&lt;p&gt;The mock definition and generated data remain the same. Only the machine serving the response changes.&lt;/p&gt;

&lt;p&gt;Use the runner when you need one or more of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Outbound traffic to external hosts is blocked or audited.&lt;/li&gt;
&lt;li&gt;Compliance policies require request data to remain on internal infrastructure.&lt;/li&gt;
&lt;li&gt;Your environment is air-gapped.&lt;/li&gt;
&lt;li&gt;You need mock latency measured on your LAN rather than over the public internet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your team can access the internet and has no data-location restrictions, &lt;a href="https://apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog&lt;/a&gt; cloud mock is usually simpler because there is no server to deploy.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You need team or project admin permissions to deploy a runner. Runner configuration is managed in &lt;strong&gt;Team Resources&lt;/strong&gt;, which is available to admins.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What you need before you start
&lt;/h2&gt;

&lt;p&gt;The General Runner is distributed as a Docker container. Your host needs Docker 20.10.0 or later; Docker 20.10.13 or newer is recommended.&lt;/p&gt;

&lt;p&gt;Verify your Docker version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You also need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Linux, macOS, or Windows machine to run the container.&lt;/li&gt;
&lt;li&gt;A stable internal IP address or hostname for shared use.&lt;/li&gt;
&lt;li&gt;Network access between your Apidog clients, the runner host, and the Apidog service.&lt;/li&gt;
&lt;li&gt;Team or project admin permissions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Configure the rest from &lt;a href="https://apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploy the General Runner
&lt;/h2&gt;

&lt;p&gt;Apidog generates the Docker command for you. Do not create the command manually because it contains a runner token.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Generate the deployment command
&lt;/h3&gt;

&lt;p&gt;In Apidog:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open &lt;strong&gt;Home&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select your team.&lt;/li&gt;
&lt;li&gt;Open &lt;strong&gt;Resources&lt;/strong&gt; in the right sidebar.&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;Deploy General Runner&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Configure the deployment dialog:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Server OS&lt;/strong&gt;: Select Linux, macOS, or Windows.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker Image&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;General&lt;/strong&gt; includes Node.js 18, Java 21, Python 3, and PHP 8.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Slim&lt;/strong&gt; includes Node.js 18 only.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Custom&lt;/strong&gt; lets you provide a Dockerfile for additional test-script runtimes.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exposed Port&lt;/strong&gt;: Configure Docker port mapping with &lt;code&gt;-p&lt;/code&gt;, such as &lt;code&gt;-p 80:4524&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mounted Data Directory&lt;/strong&gt;: Configure persistent storage with &lt;code&gt;-v&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Copy the generated command immediately. Apidog displays it only once because it includes your token. If you lose it, generate a new command and token.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Run the command on your server
&lt;/h3&gt;

&lt;p&gt;Paste the generated command into a terminal on the runner host.&lt;/p&gt;

&lt;p&gt;A typical command looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--name&lt;/span&gt; apidog-runner &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-p&lt;/span&gt; 80:4524 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-v&lt;/span&gt; /opt/apidog-runner/data:/app/data &lt;span class="se"&gt;\&lt;/span&gt;
  apidog/runner:latest &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--token&lt;/span&gt; &amp;lt;YOUR_GENERATED_TOKEN&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your actual command will include the token generated by Apidog.&lt;/p&gt;

&lt;p&gt;Confirm that the container is running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see the runner container and its port mapping. You can also verify this in Docker Desktop.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Confirm that the runner registered
&lt;/h3&gt;

&lt;p&gt;Back in Apidog:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open &lt;strong&gt;Team Resources&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;General Runner&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Refresh&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The runner should appear with a &lt;strong&gt;Started&lt;/strong&gt; status.&lt;/p&gt;

&lt;p&gt;Runner statuses mean:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Started&lt;/strong&gt;: The runner is enabled, connected to Apidog, and ready to process tasks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stopped&lt;/strong&gt;: The runner was manually stopped in Apidog and will not process tasks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Offline&lt;/strong&gt;: The runner lost its connection to Apidog. Check the container and network connectivity.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Enable Runner Mock
&lt;/h2&gt;

&lt;p&gt;Deploying the container creates the runner agent. Next, point mock traffic at it.&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;Team Resources&lt;/strong&gt; &amp;gt; &lt;strong&gt;General Runner&lt;/strong&gt;, set &lt;strong&gt;Server Host&lt;/strong&gt; to the address where the runner is reachable.&lt;/p&gt;

&lt;p&gt;Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://127.0.0.1:80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://runner.internal.example.com:80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you place a TLS-terminating reverse proxy in front of the runner:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://runner.example.com:443
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After you save &lt;strong&gt;Server Host&lt;/strong&gt;, Apidog automatically adds a &lt;strong&gt;Runner Mock&lt;/strong&gt; environment to the project.&lt;/p&gt;

&lt;p&gt;Verify it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the project.&lt;/li&gt;
&lt;li&gt;Go to &lt;strong&gt;Environment Management&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Confirm that &lt;strong&gt;Runner Mock&lt;/strong&gt; appears in the environment list.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Send a request through the self-hosted mock
&lt;/h2&gt;

&lt;p&gt;Assume your internal order-management API has this endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET /orders/{orderId}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To use the self-hosted mock:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the endpoint in Apidog.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Runner Mock&lt;/strong&gt; from the environment dropdown.&lt;/li&gt;
&lt;li&gt;Send the request.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can also call the runner directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl http://runner.internal.example.com:80/orders/10583
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a well-defined &lt;code&gt;Order&lt;/code&gt; schema, the response can contain generated, schema-aware values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"orderId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10583&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"customerEmail"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"amelia.turner@example.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"shipped"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;148.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"currency"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"USD"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"createdAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2026-07-14T09:32:11Z"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response is generated and served inside your network. The runner uses the same schema-driven mock behavior as cloud mock.&lt;/p&gt;

&lt;p&gt;To return a specific response for a request, add a mock expectation to the endpoint. The runner serves that expectation the same way cloud mock does. For more on generated data, see &lt;a href="http://apidog.com/blog/how-to-auto-mock-apis-apidog-smart-mock?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;auto-generating realistic mock data with smart mock&lt;/a&gt;. General &lt;a href="http://apidog.com/blog/mock-api?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;API mocking&lt;/a&gt; concepts apply whether you use cloud mock or a self-hosted runner.&lt;/p&gt;

&lt;h2&gt;
  
  
  HTTPS, mounts, and deployment details
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Use a reverse proxy for HTTPS
&lt;/h3&gt;

&lt;p&gt;The runner does not include built-in HTTPS certificate support or automatic certificate provisioning. To expose the runner over HTTPS, terminate TLS at a reverse proxy such as &lt;a href="https://nginx.org/en/docs/http/configuring_https_servers.html" rel="noopener noreferrer"&gt;Nginx&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For example, this Nginx configuration accepts HTTPS traffic and forwards it to a runner listening on port &lt;code&gt;4524&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="k"&gt;server&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&gt;listen&lt;/span&gt; &lt;span class="mi"&gt;443&lt;/span&gt; &lt;span class="s"&gt;ssl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;server_name&lt;/span&gt; &lt;span class="s"&gt;runner.example.com&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;ssl_certificate&lt;/span&gt;     &lt;span class="n"&gt;/etc/ssl/certs/runner.example.com.pem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;ssl_certificate_key&lt;/span&gt; &lt;span class="n"&gt;/etc/ssl/private/runner.example.com.key&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;location&lt;/span&gt; &lt;span class="n"&gt;/&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kn"&gt;proxy_pass&lt;/span&gt; &lt;span class="s"&gt;http://127.0.0.1:4524&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;Host&lt;/span&gt; &lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set &lt;strong&gt;Server Host&lt;/strong&gt; to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://runner.example.com:443
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without a reverse proxy, use an HTTP address such as &lt;code&gt;http://host:port&lt;/code&gt;. Do not configure an &lt;code&gt;https://&lt;/code&gt; Server Host unless TLS is terminated before traffic reaches the runner.&lt;/p&gt;

&lt;p&gt;See the &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/HTTPS" rel="noopener noreferrer"&gt;MDN HTTPS guide&lt;/a&gt; for more on HTTPS and TLS termination.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mount files at the required container paths
&lt;/h3&gt;

&lt;p&gt;If tests or mocks need external files, mount them at the paths expected by the runner:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Use case&lt;/th&gt;
&lt;th&gt;Container path&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;External programs&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/app/external-programs/&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database connection configuration&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/app/database/database-connections.json&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SSL client certificates&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/app/ssl/ssl-client-cert-list.json&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Use Docker &lt;code&gt;-v&lt;/code&gt; mounts so these files persist across container restarts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Understand redeploy and upgrade behavior
&lt;/h3&gt;

&lt;p&gt;When a new runner version is available, Apidog provides an &lt;strong&gt;Upgrade&lt;/strong&gt; option. You can also use &lt;strong&gt;More Actions&lt;/strong&gt; &amp;gt; &lt;strong&gt;Redeploy&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Both operations stop the active container while the replacement starts. Existing scheduled tasks remain configured in Apidog, but live mock serving is interrupted for the duration of the container restart.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use the Apidog CLI for CI, not mock serving
&lt;/h2&gt;

&lt;p&gt;The General Runner and the Apidog CLI solve different problems:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;General Runner&lt;/td&gt;
&lt;td&gt;Long-running agent that serves mocks and runs scheduled tasks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Apidog CLI&lt;/td&gt;
&lt;td&gt;One-shot test runner for local automation and CI&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The CLI does &lt;strong&gt;not&lt;/strong&gt; serve, start, or host a mock server. There is no &lt;code&gt;apidog run mock&lt;/code&gt; or &lt;code&gt;apidog mock serve&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;apidog run&lt;/code&gt; to execute test scenarios, scenario folders, and test suites. The CLI &lt;code&gt;mock&lt;/code&gt; command group manages mock expectations as data, but it does not host mock traffic.&lt;/p&gt;

&lt;p&gt;A practical workflow looks like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Define or update endpoints and schemas in Apidog.&lt;/li&gt;
&lt;li&gt;Use Runner Mock to unblock frontend development inside your network.&lt;/li&gt;
&lt;li&gt;Run test scenarios against the real backend in CI.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="nt"&gt;-t&lt;/span&gt; &amp;lt;scenario_id&amp;gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &amp;lt;env_id&amp;gt; &lt;span class="nt"&gt;-r&lt;/span&gt; html,cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This runs a test scenario against the selected environment and produces HTML and CLI reports.&lt;/p&gt;

&lt;p&gt;Install the CLI with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; apidog-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CLI requires Node.js v16 or later. See the &lt;a href="http://apidog.com/blog/apidog-cli-installation-guide?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog CLI installation guide&lt;/a&gt; for &lt;code&gt;apidog login&lt;/code&gt; and token setup, then use the &lt;a href="http://apidog.com/blog/apidog-cli-ci-cd-pipeline?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog CLI CI/CD guide&lt;/a&gt; to run tests on every push.&lt;/p&gt;

&lt;p&gt;For the distinction between managing mock definitions and hosting mocks, see &lt;a href="http://apidog.com/blog/how-to-mock-apis-in-cli?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;mocking APIs from the CLI&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Do I need a self-hosted runner if my team can access the internet?
&lt;/h3&gt;

&lt;p&gt;Usually not. Cloud mock is simpler because it requires no infrastructure. Use a runner when outbound traffic is blocked or audited, compliance requires internal data handling, or your environment is air-gapped.&lt;/p&gt;

&lt;p&gt;See the &lt;a href="http://apidog.com/blog/how-to-use-apidog-cloud-mock?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog cloud mock&lt;/a&gt; guide for the hosted option.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can the Apidog CLI start a self-hosted mock server?
&lt;/h3&gt;

&lt;p&gt;No. The CLI runs tests with &lt;code&gt;apidog run&lt;/code&gt; and manages mock expectations through its &lt;code&gt;mock&lt;/code&gt; command group. Mock serving is handled by the General Runner or cloud mock.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does the runner support HTTPS directly?
&lt;/h3&gt;

&lt;p&gt;No. Put a reverse proxy such as Nginx in front of the runner to terminate TLS, then configure Server Host with the proxy's &lt;code&gt;https://&lt;/code&gt; URL. Otherwise, use &lt;code&gt;http://host:port&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why does my runner not appear after deployment?
&lt;/h3&gt;

&lt;p&gt;Try these checks:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In Apidog, open &lt;strong&gt;Team Resources&lt;/strong&gt; &amp;gt; &lt;strong&gt;General Runner&lt;/strong&gt; and click &lt;strong&gt;Refresh&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Confirm that the container is running:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   docker ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Verify that the runner host has the required network connectivity.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;An &lt;strong&gt;Offline&lt;/strong&gt; status indicates a lost connection. The expected status is &lt;strong&gt;Started&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can multiple teams share one runner?
&lt;/h3&gt;

&lt;p&gt;A runner registers with the team where it was deployed, and Runner Mock environments appear per project. If you need a distributed setup, see &lt;a href="http://apidog.com/blog/mock-servers-sharing-environments-global-teams?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;sharing mock environments across global teams&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;The General Runner lets you serve Apidog mocks from infrastructure you control while keeping API definitions and mock configuration in your Apidog project.&lt;/p&gt;

&lt;p&gt;The implementation path is straightforward:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Deploy the Docker container.&lt;/li&gt;
&lt;li&gt;Configure &lt;strong&gt;Server Host&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select the automatically created &lt;strong&gt;Runner Mock&lt;/strong&gt; environment.&lt;/li&gt;
&lt;li&gt;Send requests without routing mock traffic through the public internet.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use self-hosted mock when cloud access is restricted. Otherwise, cloud mock remains the lower-maintenance option. To get started, &lt;a href="https://apidog.com/download?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;download Apidog&lt;/a&gt;, deploy a runner, and serve your first internal mock response.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Host a Shareable Cloud Mock Server with Apidog</title>
      <dc:creator>Hassann</dc:creator>
      <pubDate>Wed, 15 Jul 2026 06:16:11 +0000</pubDate>
      <link>https://dev.to/hassann/how-to-host-a-shareable-cloud-mock-server-with-apidog-1k73</link>
      <guid>https://dev.to/hassann/how-to-host-a-shareable-cloud-mock-server-with-apidog-1k73</guid>
      <description>&lt;p&gt;Your frontend team is blocked: the design is approved, screens are partially built, and the backend API is still a sprint away. A local mock may unblock you temporarily, but it disappears when the machine hosting it goes offline—breaking teammates, QA, and partners who depend on that endpoint.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation" class="crayons-btn crayons-btn--primary"&gt;Try Apidog today&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog&lt;/a&gt; Cloud Mock provides a hosted URL at &lt;code&gt;mock.apidog.com&lt;/code&gt; that remains available independently of your laptop. Frontend, QA, and partner developers can call realistic endpoints before backend implementation is complete. For more background, see &lt;a href="http://apidog.com/blog/mock-api?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;what an API mock is and when to use one&lt;/a&gt; and MDN’s &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview" rel="noopener noreferrer"&gt;HTTP request/response overview&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Cloud Mock solves
&lt;/h2&gt;

&lt;p&gt;Apidog generates a mock endpoint for every API endpoint you define. By default, that mock is local: it runs through your Apidog instance and stops responding when your machine is offline.&lt;/p&gt;

&lt;p&gt;That is useful for individual debugging, but it does not work as a shared integration environment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.apidog.com/cloud-mock-621066m0?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Cloud Mock&lt;/a&gt; hosts the mock independently of any developer machine. Once enabled, the endpoint stays available 24/7, even if every teammate closes Apidog.&lt;/p&gt;

&lt;p&gt;Use it to create a shared contract-first workflow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Define the endpoint and response schema.&lt;/li&gt;
&lt;li&gt;Enable Cloud Mock for the project.&lt;/li&gt;
&lt;li&gt;Share the generated URL with frontend, QA, or partners.&lt;/li&gt;
&lt;li&gt;Let consumers build and test against the contract while backend work continues.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For distributed teams, see &lt;a href="http://apidog.com/blog/mock-servers-sharing-environments-global-teams?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;sharing mock servers and environments with global teams&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enable Cloud Mock and get a public URL
&lt;/h2&gt;

&lt;p&gt;Assume you are designing a &lt;code&gt;users&lt;/code&gt; service with this endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;GET /users
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The endpoint should return a list of customer records. Here is how to make it available as a shared cloud mock.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Enable Cloud Mock
&lt;/h3&gt;

&lt;p&gt;In your Apidog project, open:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project Settings &amp;gt; Feature Settings &amp;gt; Mock Settings&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Enable &lt;strong&gt;Cloud Mock&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You only need to do this once per project. After Cloud Mock is enabled, endpoints in that project have a cloud mock URL in addition to their local mock URL.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fezx1stzvamt507r3z65a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fezx1stzvamt507r3z65a.png" alt="Cloud Mock settings" width="800" height="513"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Copy the Cloud Mock URL
&lt;/h3&gt;

&lt;p&gt;Open &lt;code&gt;GET /users&lt;/code&gt;, then select the &lt;strong&gt;Mock&lt;/strong&gt; tab. Copy the Cloud Mock URL.&lt;/p&gt;

&lt;p&gt;It will look similar to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://mock.apidog.com/m1/2689726-0-default/users?apidogToken=GdfNrEm6lxM9nDGGIMCWC1OPSiZ6hGOi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The URL generally follows this structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mock.apidog.com/m1/&amp;lt;projectId&amp;gt;-&amp;lt;num&amp;gt;-&amp;lt;env&amp;gt;/&amp;lt;path&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do not construct these URLs manually. Copy the URL generated by Apidog, since the documentation presents the format by example rather than as a fixed public template.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Validate the response in Apidog
&lt;/h3&gt;

&lt;p&gt;Before sharing the endpoint, test it from the same &lt;strong&gt;Mock&lt;/strong&gt; tab.&lt;/p&gt;

&lt;p&gt;Send a request to the mock URL and verify that the generated data matches your schema. For example, a &lt;code&gt;GET /users&lt;/code&gt; response might look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Amelia Turner"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"amelia.turner@example.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"city"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Portland"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Marcus Bell"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"marcus.bell@example.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"city"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Austin"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apidog uses the field names and types in your schema to generate plausible values. This lets frontend developers work with data that better resembles production responses than placeholder values such as &lt;code&gt;"string"&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Call the URL from your app
&lt;/h3&gt;

&lt;p&gt;For &lt;code&gt;GET&lt;/code&gt; endpoints, paste the full Cloud Mock URL into a browser to quickly inspect the JSON response.&lt;/p&gt;

&lt;p&gt;Your frontend can call it like any API endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="s2"&gt;"https://mock.apidog.com/m1/2689726-0-default/users?apidogToken=GdfNrEm6lxM9nDGGIMCWC1OPSiZ6hGOi"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is the core workflow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Design the endpoint.&lt;/li&gt;
&lt;li&gt;Enable Cloud Mock.&lt;/li&gt;
&lt;li&gt;Copy the hosted URL.&lt;/li&gt;
&lt;li&gt;Share it with consumers.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Protect Cloud Mock with token authentication
&lt;/h2&gt;

&lt;p&gt;A public mock URL is convenient, but you may not want unrestricted access to mocks for unreleased features or partner integrations.&lt;/p&gt;

&lt;p&gt;To require authentication, open:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project Settings &amp;gt; Feature Settings &amp;gt; Mock Settings&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Set the access permission to &lt;strong&gt;Token Authentication&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Once enabled, requests must include a valid &lt;code&gt;apidogToken&lt;/code&gt;. Requests without one are rejected.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option 1: Send the token as a query parameter
&lt;/h3&gt;

&lt;p&gt;The copied Cloud Mock URL already uses this format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="s2"&gt;"https://mock.apidog.com/m1/2689726-0-default/users?apidogToken=GdfNrEm6lxM9nDGGIMCWC1OPSiZ6hGOi"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Option 2: Send the token as a request header
&lt;/h3&gt;

&lt;p&gt;Using a header keeps the token out of the URL and reduces the chance of exposing it in URL logs or browser history.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="s2"&gt;"https://mock.apidog.com/m1/2689726-0-default/users"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"apidogToken: GdfNrEm6lxM9nDGGIMCWC1OPSiZ6hGOi"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For frontend code, this is usually the cleaner option:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://mock.apidog.com/m1/2689726-0-default/users&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;apidogToken&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;GdfNrEm6lxM9nDGGIMCWC1OPSiZ6hGOi&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Option 3: Send the token in a form body
&lt;/h3&gt;

&lt;p&gt;You can also provide &lt;code&gt;apidogToken&lt;/code&gt; as a body parameter in a &lt;code&gt;form-data&lt;/code&gt; or &lt;code&gt;x-www-form-urlencoded&lt;/code&gt; request.&lt;/p&gt;

&lt;p&gt;If you enable token authentication after sharing an unauthenticated URL, coordinate the change with all consumers. They must update their requests with the token before calls begin failing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generate region-aware mock data with locales
&lt;/h2&gt;

&lt;p&gt;Mock responses such as this are rarely useful:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Realistic names, addresses, phone numbers, and timestamps help teams find UI issues early, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;text overflow&lt;/li&gt;
&lt;li&gt;address formatting assumptions&lt;/li&gt;
&lt;li&gt;non-Latin character rendering&lt;/li&gt;
&lt;li&gt;timestamp localization issues&lt;/li&gt;
&lt;li&gt;table and card layout problems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Apidog uses &lt;a href="https://fakerjs.dev/" rel="noopener noreferrer"&gt;Faker.js&lt;/a&gt; for generated mock data and supports locale controls.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use the project language as the default locale
&lt;/h3&gt;

&lt;p&gt;By default, generated data follows the project language configured in:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project Settings &amp;gt; Basic Settings&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For example, setting the project language to French makes generated names and addresses French-flavored without configuring each field individually.&lt;/p&gt;

&lt;h3&gt;
  
  
  Override the locale for the entire project
&lt;/h3&gt;

&lt;p&gt;To use a locale different from the project language, open:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project Settings &amp;gt; Feature Settings &amp;gt; Mock Settings&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Choose a Faker locale from the locale dropdown.&lt;/p&gt;

&lt;p&gt;This setting overrides the Basic Settings language for all mock values in the project.&lt;/p&gt;

&lt;p&gt;For example, setting the project mock locale to Japan can help you test names, addresses, and scripts that differ from English-language data. For more on schema-driven generation, see &lt;a href="http://apidog.com/blog/how-to-auto-mock-apis-apidog-smart-mock?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog’s smart mock and how it reads your schema&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Override the locale for one field
&lt;/h3&gt;

&lt;p&gt;For mixed-region datasets, set the locale directly in a mock expression:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{$person.fullName(locale='ja')}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This generates Japanese names, such as &lt;code&gt;田中 太郎&lt;/code&gt;, for that field while other fields continue using the project-level locale.&lt;/p&gt;

&lt;p&gt;The precedence order is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Field-level locale&lt;/li&gt;
&lt;li&gt;Project-level mock locale&lt;/li&gt;
&lt;li&gt;Basic Settings language&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use the project-level setting as the default, then add field-level overrides only where needed.&lt;/p&gt;

&lt;p&gt;The documentation uses &lt;code&gt;ja&lt;/code&gt; as an example but does not publish a complete locale list. Confirm your target locale in the &lt;a href="https://docs.apidog.com/?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog mock documentation&lt;/a&gt; before depending on it. Faker’s locale conventions are documented in the &lt;a href="https://fakerjs.dev/guide/localization.html" rel="noopener noreferrer"&gt;Faker.js localization reference&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configure time zones too
&lt;/h3&gt;

&lt;p&gt;Mock settings also include a project-level time zone control. You can override the time zone per field with the &lt;code&gt;timeZone&lt;/code&gt; parameter in a mock expression.&lt;/p&gt;

&lt;p&gt;Use this when generating fields such as &lt;code&gt;createdAt&lt;/code&gt;, &lt;code&gt;updatedAt&lt;/code&gt;, or scheduled event timestamps. It helps ensure mock timestamps match the region your UI is simulating.&lt;/p&gt;

&lt;p&gt;Combined locale and time-zone settings let you model a Japanese user base, a German user base, or a mixed international dataset from the same API schema. See &lt;a href="http://apidog.com/blog/api-mocking-use-cases?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;practical API mocking use cases&lt;/a&gt; for additional scenarios.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cloud Mock vs. self-hosted mock servers
&lt;/h2&gt;

&lt;p&gt;Cloud Mock is the hosted option. It is useful when you want a shared endpoint without running infrastructure yourself.&lt;/p&gt;

&lt;p&gt;Use a self-hosted mock service when your organization has requirements such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;data residency restrictions&lt;/li&gt;
&lt;li&gt;internal-only test environments&lt;/li&gt;
&lt;li&gt;policies against routing test traffic through a vendor cloud&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The trade-off is simple:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;th&gt;Trade-off&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cloud Mock&lt;/td&gt;
&lt;td&gt;Fast setup and always-on shared URLs&lt;/td&gt;
&lt;td&gt;Hosted by Apidog&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Self-hosted mock&lt;/td&gt;
&lt;td&gt;Infrastructure and traffic control&lt;/td&gt;
&lt;td&gt;You operate the service&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For self-hosting details, see &lt;a href="http://apidog.com/blog/how-to-self-host-apidog-mock-server?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;self-hosting the Apidog mock server&lt;/a&gt;. For a broader comparison, see &lt;a href="http://apidog.com/blog/online-api-mocking-tools-comparison?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;online API mocking tools&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The Cloud Mock and locale documentation does not state a specific plan requirement. Check availability in your workspace rather than relying on a blog post for plan details. You can &lt;a href="https://apidog.com/download?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Download Apidog&lt;/a&gt; and test the workflow in your account.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep mock contracts current with the Apidog CLI
&lt;/h2&gt;

&lt;p&gt;Cloud Mock itself is a hosted capability: Apidog generates responses from your endpoint schema and serves them through its hosted mock engine.&lt;/p&gt;

&lt;p&gt;The &lt;a href="http://apidog.com/blog/apidog-cli-installation-guide?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog CLI&lt;/a&gt; does not start or host a mock server. Its role is to help keep the API definitions that drive your mocks accurate.&lt;/p&gt;

&lt;p&gt;A practical workflow looks like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create or update endpoint schemas in your project.&lt;/li&gt;
&lt;li&gt;Let Cloud Mock generate responses from the updated schema.&lt;/li&gt;
&lt;li&gt;Build frontend features against the mock URL.&lt;/li&gt;
&lt;li&gt;Implement the backend against the same contract.&lt;/li&gt;
&lt;li&gt;Run saved API test scenarios against the live backend in CI.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When an AI coding agent such as Cursor or Claude Code updates an endpoint schema, the Cloud Mock response can reflect the changed contract without manually editing mock payloads.&lt;/p&gt;

&lt;p&gt;Once the real backend is available, run a saved Apidog scenario from the CLI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="nt"&gt;-t&lt;/span&gt; &amp;lt;scenario_id&amp;gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &amp;lt;env_id&amp;gt; &lt;span class="nt"&gt;-r&lt;/span&gt; cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command runs a saved test scenario against an environment and reports the results.&lt;/p&gt;

&lt;p&gt;Copy the generated command from your Apidog scenario instead of assembling &lt;code&gt;-t&lt;/code&gt; and &lt;code&gt;-e&lt;/code&gt; values manually. For pipeline integration, see &lt;a href="http://apidog.com/blog/apidog-cli-ci-cd-pipeline?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;running Apidog in a CI/CD pipeline&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Does the Cloud Mock URL work after I close Apidog?
&lt;/h3&gt;

&lt;p&gt;Yes. Cloud Mock is served from Apidog’s infrastructure, so it remains available 24/7 even when your computer is offline.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I open a Cloud Mock URL in a browser?
&lt;/h3&gt;

&lt;p&gt;For &lt;code&gt;GET&lt;/code&gt; requests, yes. Paste the full URL, including the &lt;code&gt;apidogToken&lt;/code&gt; query parameter, into the browser to view the JSON response.&lt;/p&gt;

&lt;p&gt;For other HTTP methods—or to avoid exposing tokens in URL history—use curl, Postman, Apidog, or your application client and send the token as a header.&lt;/p&gt;

&lt;h3&gt;
  
  
  What happens when a request does not include the token?
&lt;/h3&gt;

&lt;p&gt;When &lt;strong&gt;Token Authentication&lt;/strong&gt; is enabled, requests without a valid &lt;code&gt;apidogToken&lt;/code&gt; are rejected.&lt;/p&gt;

&lt;p&gt;Provide the token through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a query-string parameter&lt;/li&gt;
&lt;li&gt;a request header&lt;/li&gt;
&lt;li&gt;a form request body parameter&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How do I generate mock data for a specific country?
&lt;/h3&gt;

&lt;p&gt;Choose one of these levels:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set the project language in &lt;strong&gt;Basic Settings&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Set a project-wide Faker locale in &lt;strong&gt;Feature Settings &amp;gt; Mock Settings&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Set a field-level locale in a mock expression.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{$person.fullName(locale='ja')}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Field-level settings override project-level settings, and project-level settings override the Basic Settings default. See the &lt;a href="http://apidog.com/blog/how-to-auto-mock-apis-apidog-smart-mock?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;smart mock walkthrough&lt;/a&gt; for schema-aware generation details.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should I use Cloud Mock or a headless mock tool?
&lt;/h3&gt;

&lt;p&gt;Use Cloud Mock when you need a hosted, low-maintenance endpoint connected to your API design.&lt;/p&gt;

&lt;p&gt;If you need mocks embedded in an automated build with no GUI workflow, review &lt;a href="http://apidog.com/blog/headless-api-mock-tool?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;headless API mock tooling&lt;/a&gt;. Most tools in this space build on API contracts, often using the &lt;a href="https://www.openapis.org/" rel="noopener noreferrer"&gt;OpenAPI Initiative&lt;/a&gt; specification.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;A mock that runs only on your laptop unblocks one developer. Cloud Mock creates a shared &lt;code&gt;mock.apidog.com&lt;/code&gt; endpoint that frontend developers, QA engineers, and partners can use while backend implementation is still in progress.&lt;/p&gt;

&lt;p&gt;Use Cloud Mock to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;share a stable mock URL&lt;/li&gt;
&lt;li&gt;protect endpoints with token authentication&lt;/li&gt;
&lt;li&gt;generate locale-aware test data&lt;/li&gt;
&lt;li&gt;keep frontend work moving from the API contract&lt;/li&gt;
&lt;li&gt;validate the eventual backend with tests tied to the same project&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Define the endpoint, enable Cloud Mock, share the URL, and let frontend work continue without waiting for the backend. &lt;a href="https://apidog.com/download?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Download Apidog&lt;/a&gt; to create your first shareable cloud mock.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Return Conditional Mock Data in Apidog (Custom Rules and Mock Scripts)</title>
      <dc:creator>Hassann</dc:creator>
      <pubDate>Wed, 15 Jul 2026 06:10:55 +0000</pubDate>
      <link>https://dev.to/hassann/how-to-return-conditional-mock-data-in-apidog-custom-rules-and-mock-scripts-1oab</link>
      <guid>https://dev.to/hassann/how-to-return-conditional-mock-data-in-apidog-custom-rules-and-mock-scripts-1oab</guid>
      <description>&lt;p&gt;&lt;a href="http://apidog.com/blog/how-to-auto-mock-apis-apidog-smart-mock?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Smart mock&lt;/a&gt; creates a fake API in seconds. It reads your endpoint schema and returns plausible data: realistic emails, sensible timestamps, and usable names. For most frontend work, that is enough to unblock development.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation" class="crayons-btn crayons-btn--primary"&gt;Try Apidog today&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;But some cases require request-aware behavior. You may want &lt;code&gt;/login&lt;/code&gt; to return &lt;code&gt;200&lt;/code&gt; for a known user and &lt;code&gt;401&lt;/code&gt; for everyone else. Or &lt;code&gt;/orders/{id}&lt;/code&gt; to return a shipped order for one ID and a cancelled order for another. You may also need to force a &lt;code&gt;500&lt;/code&gt; so error handling is tested before production.&lt;/p&gt;

&lt;p&gt;Smart mock returns one generated response shape per endpoint, so it cannot branch on the incoming request. This guide shows how to fill that gap with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mock expectations&lt;/strong&gt; for rule-based conditional responses.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mock scripts&lt;/strong&gt; for logic that fixed rules cannot express.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For background, see the &lt;a href="http://apidog.com/blog/mock-api?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;API mocking overview&lt;/a&gt;. This tutorial uses &lt;a href="https://apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog&lt;/a&gt; and follows the contract-first workflow described by the &lt;a href="https://www.openapis.org/" rel="noopener noreferrer"&gt;OpenAPI Initiative&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What conditional mocking means
&lt;/h2&gt;

&lt;p&gt;A conditional mock is a rule:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When the request looks like this, return that response.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Apidog provides two layers for mocking.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Field-level customization&lt;/strong&gt; inside an endpoint schema&lt;br&gt;&lt;br&gt;
Use fixed values or dynamic &lt;a href="http://apidog.com/blog/faker-js-and-how-to-use-it-in-apidog?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Faker.js&lt;/a&gt; expressions. This controls individual field values, but the endpoint still has one response shape.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Full-response mock expectations&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
An expectation is a named rule with optional conditions, a response body, status code, headers, and delay.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;An expectation with no conditions always returns its configured response. An expectation with conditions responds only when the request matches. By combining expectations, you can return:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A different body for each path parameter.&lt;/li&gt;
&lt;li&gt;An error when a required header is absent.&lt;/li&gt;
&lt;li&gt;A specific status code for a known request body.&lt;/li&gt;
&lt;li&gt;A fallback response for every other request.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Field-level dynamic values first
&lt;/h2&gt;

&lt;p&gt;Before adding request-based branches, configure dynamic values for a single response shape.&lt;/p&gt;

&lt;p&gt;In an endpoint schema, string fields can use Faker.js expressions in the format &lt;code&gt;{{$category.method}}&lt;/code&gt;. Apidog resolves these expressions on every mock call using the types declared in your &lt;a href="https://json-schema.org/" rel="noopener noreferrer"&gt;JSON Schema&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"{{$number.int(min=1000,max=9999)}}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"customer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"{{$person.fullName}}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"{{$internet.email}}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"product"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"{{$commerce.productName}}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"shippingAddress"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"{{$location.streetAddress}}, {{$location.city}}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"orderedAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"{{$date.between(from='2024-01-01',to='2024-12-31',format='yyyy-MM-dd')}}"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Parameterized methods let you constrain generated values:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;{{$number.int(min=1000,max=9999)}}&lt;/code&gt; generates IDs in a known range.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;{{$date.between(...)}}&lt;/code&gt; constrains dates and output format.&lt;/li&gt;
&lt;li&gt;You can combine static text and multiple expressions in one field.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Apidog also supports configurable mock locales for region-specific names, addresses, and phone numbers. See the &lt;a href="http://apidog.com/blog/faker-js-and-how-to-use-it-in-apidog?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Faker.js reference in Apidog&lt;/a&gt; for available methods.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqgopwdefvceih5ya2phd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqgopwdefvceih5ya2phd.png" alt="Smart mock configuration" width="800" height="452"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is Smart mock territory: values are dynamic, but the response is not conditional. To branch based on the request, use expectations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Walkthrough: return &lt;code&gt;200&lt;/code&gt; or &lt;code&gt;401&lt;/code&gt; from &lt;code&gt;POST /login&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Assume &lt;code&gt;POST /login&lt;/code&gt; accepts this JSON body:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"username"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"alice@example.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"password"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"whatever"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The desired behavior is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;alice@example.com&lt;/code&gt; receives &lt;code&gt;200&lt;/code&gt; and a token.&lt;/li&gt;
&lt;li&gt;Every other user receives &lt;code&gt;401&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  1. Open the expectation list
&lt;/h3&gt;

&lt;p&gt;The UI location depends on your working mode:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In &lt;strong&gt;DEBUG (Request-first)&lt;/strong&gt; mode, open the endpoint and select the &lt;strong&gt;Mock&lt;/strong&gt; tab.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu8f7ldswhec7xmvviurc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu8f7ldswhec7xmvviurc.png" alt="Mock tab in DEBUG mode" width="800" height="513"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In &lt;strong&gt;DESIGN (Design-first)&lt;/strong&gt; mode, open the endpoint and select the &lt;strong&gt;Advanced mock&lt;/strong&gt; tab.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frdprxybbsrpxmdyla2ut.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frdprxybbsrpxmdyla2ut.png" alt="Advanced mock tab in DESIGN mode" width="800" height="513"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Both views open the same expectation list. If needed, &lt;a href="https://apidog.com/download?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;download Apidog&lt;/a&gt; and create or import a &lt;code&gt;/login&lt;/code&gt; endpoint first.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Add the success expectation
&lt;/h3&gt;

&lt;p&gt;Click &lt;strong&gt;New expectation&lt;/strong&gt; and configure the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Expectation name:&lt;/strong&gt; &lt;code&gt;login-success&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Condition type:&lt;/strong&gt; body parameter&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Name:&lt;/strong&gt; &lt;code&gt;username&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Condition:&lt;/strong&gt; equals&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Value:&lt;/strong&gt; &lt;code&gt;alice@example.com&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjpynqwjddov1ryfskq05.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjpynqwjddov1ryfskq05.png" alt="Login expectation condition" width="799" height="602"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For JSON request bodies, body conditions use the JSON path entered in the name field. For nested properties, use dot notation such as &lt;code&gt;user.email&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Set &lt;strong&gt;Response data&lt;/strong&gt; to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"token"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"mock-jwt-{{$string.uuid}}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;4821&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"username"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"alice@example.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"member"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the expectation. The default HTTP status is &lt;code&gt;200&lt;/code&gt;, so no additional status configuration is required.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Add the catch-all failure expectation
&lt;/h3&gt;

&lt;p&gt;Create another expectation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Expectation name:&lt;/strong&gt; &lt;code&gt;login-failure&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Conditions:&lt;/strong&gt; none&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Leaving conditions blank makes this rule a catch-all. Set &lt;strong&gt;Response data&lt;/strong&gt; to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"invalid_credentials"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Username or password is incorrect."&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the expectation’s &lt;strong&gt;More&lt;/strong&gt; tab and set:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;HTTP Status Code:&lt;/strong&gt; &lt;code&gt;401&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;strong&gt;More&lt;/strong&gt; tab also lets you configure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Response Delay&lt;/strong&gt; in milliseconds, defaulting to &lt;code&gt;0&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Custom response headers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, set a &lt;code&gt;400&lt;/code&gt; ms delay to verify that your loading UI appears during login.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Put expectations in the correct order
&lt;/h3&gt;

&lt;p&gt;Expectations run from top to bottom, and the first matching rule wins.&lt;/p&gt;

&lt;p&gt;Order the rules like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;login-success&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;login-failure&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The success rule must be first. If the blank-condition failure rule comes first, it matches every request and the success rule never runs.&lt;/p&gt;

&lt;p&gt;Test both responses using the endpoint’s mock URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Known user -&amp;gt; 200 with a token&lt;/span&gt;
curl &lt;span class="nt"&gt;-X&lt;/span&gt; POST https://&amp;lt;your-mock-host&amp;gt;/login &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{"username":"alice@example.com","password":"whatever"}'&lt;/span&gt;

&lt;span class="c"&gt;# Any other user -&amp;gt; 401&lt;/span&gt;
curl &lt;span class="nt"&gt;-X&lt;/span&gt; POST https://&amp;lt;your-mock-host&amp;gt;/login &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{"username":"stranger@example.com","password":"whatever"}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Walkthrough: return different &lt;code&gt;/orders/{id}&lt;/code&gt; bodies
&lt;/h2&gt;

&lt;p&gt;Path parameters are another common conditional-mocking use case.&lt;/p&gt;

&lt;p&gt;For example, configure &lt;code&gt;/orders/{id}&lt;/code&gt; so that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/orders/5001&lt;/code&gt; returns a shipped order.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/orders/5002&lt;/code&gt; returns a cancelled order.&lt;/li&gt;
&lt;li&gt;Any other ID returns a generic pending order.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Create one expectation for each state.&lt;/p&gt;

&lt;h3&gt;
  
  
  Shipped order
&lt;/h3&gt;

&lt;p&gt;Create an expectation named &lt;code&gt;order-shipped&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Condition type:&lt;/strong&gt; path parameter&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parameter:&lt;/strong&gt; &lt;code&gt;id&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Condition:&lt;/strong&gt; equals&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Value:&lt;/strong&gt; &lt;code&gt;5001&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use this response body:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5001&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"shipped"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;129.9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"trackingNumber"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1Z{{$string.alphanumeric(length=16)}}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"shippedAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"{{$date.recent(days=3,format='yyyy-MM-dd')}}"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Cancelled order
&lt;/h3&gt;

&lt;p&gt;Create an expectation named &lt;code&gt;order-cancelled&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Condition type:&lt;/strong&gt; path parameter&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parameter:&lt;/strong&gt; &lt;code&gt;id&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Condition:&lt;/strong&gt; equals&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Value:&lt;/strong&gt; &lt;code&gt;5002&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use this response body:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5002&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"cancelled"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"cancelledAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"{{$date.recent(days=1,format='yyyy-MM-dd')}}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"refundIssued"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Add a fallback
&lt;/h3&gt;

&lt;p&gt;Add one final expectation with no conditions. Return a generic pending order so unknown IDs still get a valid response.&lt;/p&gt;

&lt;p&gt;Place the rules in this order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;order-shipped&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;order-cancelled&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Generic pending-order fallback&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can combine condition types. For example, add both a path parameter condition and a header condition. Apidog combines multiple conditions with &lt;strong&gt;AND&lt;/strong&gt; logic, so every configured condition must match.&lt;/p&gt;

&lt;p&gt;Conditions can target:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Request body parameters&lt;/li&gt;
&lt;li&gt;Path parameters&lt;/li&gt;
&lt;li&gt;Query parameters&lt;/li&gt;
&lt;li&gt;Headers&lt;/li&gt;
&lt;li&gt;Cookies&lt;/li&gt;
&lt;li&gt;IP addresses&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Force error states on demand
&lt;/h2&gt;

&lt;p&gt;You do not need a failing backend to test frontend error handling.&lt;/p&gt;

&lt;p&gt;To force a &lt;code&gt;500&lt;/code&gt; response, add an expectation that matches a client-controlled header:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Header:&lt;/strong&gt; &lt;code&gt;X-Mock-Scenario&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Condition:&lt;/strong&gt; equals&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Value:&lt;/strong&gt; &lt;code&gt;server-error&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HTTP Status Code:&lt;/strong&gt; &lt;code&gt;500&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Set the response body to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"internal_error"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"requestId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"{{$string.uuid}}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Something went wrong on our end. Please retry."&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the endpoint can return its usual &lt;code&gt;200&lt;/code&gt; response by default and return &lt;code&gt;500&lt;/code&gt; only when the client sends:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;X-Mock-Scenario: server-error
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use the same pattern for other states:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;404&lt;/code&gt; for missing resources&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;429&lt;/code&gt; with a &lt;code&gt;Retry-After&lt;/code&gt; response header&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;503&lt;/code&gt; for temporary unavailability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you validate these cases in tests, pair this approach with &lt;a href="http://apidog.com/blog/api-assertions?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;API assertions&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In shared projects, each expectation can be independently enabled or disabled for local and cloud mock environments. For example, keep a forced &lt;code&gt;500&lt;/code&gt; rule enabled locally but disabled in the cloud mock used by teammates.&lt;/p&gt;

&lt;h2&gt;
  
  
  When expectations are not enough: mock scripts
&lt;/h2&gt;

&lt;p&gt;Expectations are declarative: they match requests and return predefined responses. They do not compute values.&lt;/p&gt;

&lt;p&gt;Use a mock script when the response must be derived from the incoming request, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Summing order line items.&lt;/li&gt;
&lt;li&gt;Calculating tax.&lt;/li&gt;
&lt;li&gt;Changing response shape based on several inputs.&lt;/li&gt;
&lt;li&gt;Echoing request headers into the response.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mock scripts are JavaScript and run in the &lt;strong&gt;Mock Script&lt;/strong&gt; section at the bottom of the &lt;strong&gt;Mock&lt;/strong&gt; tab.&lt;/p&gt;

&lt;p&gt;The runtime exposes two globals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;$$.mockRequest&lt;/code&gt; for reading the incoming request.

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;getParam(key)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;headers&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;cookies&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;body&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;formdata&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;urlencoded&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;$$.mockResponse&lt;/code&gt; for changing the outgoing response.

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;setBody()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;setCode()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;setDelay()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;json()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;headers&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;code&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, this script calculates an order total from posted line items and returns the caller’s currency header:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;$$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;mockRequest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;subtotal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;currency&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;$$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;mockRequest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;x-currency&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;USD&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;$$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;mockResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;201&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;$$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;mockResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setBody&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;orderId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;90000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;subtotal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;subtotal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;tax&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;subtotal&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.08&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toFixed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
  &lt;span class="na"&gt;total&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;subtotal&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;1.08&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toFixed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The execution flow is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Smart mock generates an initial response.&lt;/li&gt;
&lt;li&gt;The script reads &lt;code&gt;$$.mockRequest&lt;/code&gt; and the current &lt;code&gt;$$.mockResponse&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The script applies custom logic.&lt;/li&gt;
&lt;li&gt;The script calls &lt;code&gt;setBody()&lt;/code&gt;, &lt;code&gt;setCode()&lt;/code&gt;, &lt;code&gt;setDelay()&lt;/code&gt;, or modifies headers.&lt;/li&gt;
&lt;li&gt;Apidog returns the final response.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript" rel="noopener noreferrer"&gt;MDN JavaScript reference&lt;/a&gt; when you need more complex array, date, or object logic.&lt;/p&gt;

&lt;h3&gt;
  
  
  Important: scripts do not run with expectations
&lt;/h3&gt;

&lt;p&gt;Mock scripts work only with &lt;strong&gt;Smart mock&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;They do &lt;strong&gt;not&lt;/strong&gt; apply to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mock expectations&lt;/li&gt;
&lt;li&gt;Response examples&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If an expectation matches a request, the mock script does not run.&lt;/p&gt;

&lt;p&gt;Choose one approach per endpoint:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;expectations&lt;/strong&gt; for fixed, rule-based branching.&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;mock scripts&lt;/strong&gt; for computed output built on Smart mock.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How mock priority works
&lt;/h2&gt;

&lt;p&gt;For every mock request, Apidog resolves the response in this order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Evaluate expectations from top to bottom&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The first expectation whose conditions all match wins. Its response is returned immediately.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Fall back to Mock method priority&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
If no expectation matches, Apidog uses the priority configured in:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Project Settings → Feature Settings → Mock Settings
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is where Smart mock, including any attached mock script, generates the response.&lt;/p&gt;

&lt;p&gt;Use this mental model:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Specific rules first, generated data second.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Put the most specific expectations first, place a blank-condition fallback at the bottom when you need a guaranteed response, and let Smart mock handle the remaining cases.&lt;/p&gt;

&lt;p&gt;For more examples, see the &lt;a href="http://apidog.com/blog/api-mocking-use-cases?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;API mocking use cases guide&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gotchas to check before shipping
&lt;/h2&gt;

&lt;p&gt;Keep these constraints in mind:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Parameter conditions do not support &lt;code&gt;{{variables}}&lt;/code&gt;. Apidog project and environment variables are unavailable in mock expectations, so use literal values.&lt;/li&gt;
&lt;li&gt;Body-parameter conditions support JSON only. Use JSON paths in the condition name field.&lt;/li&gt;
&lt;li&gt;The request body format in the condition must match the API specification. For a &lt;code&gt;form-data&lt;/code&gt; endpoint, configure a form-data condition rather than a JSON condition.&lt;/li&gt;
&lt;li&gt;Mock scripts have no logging function.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;pm&lt;/code&gt; object is unavailable in mock scripts because they run in a different environment from test scripts.&lt;/li&gt;
&lt;li&gt;Apidog variables cannot be used inside mock scripts, so keep script logic self-contained.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The docs do not describe plan gating for these features. The local-versus-cloud difference is functional: expectations can be toggled independently in each environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Automate the workflow with the Apidog CLI
&lt;/h2&gt;

&lt;p&gt;Mocking itself is a GUI and cloud capability. The mock engine serves endpoints through local and cloud mock URLs; there is no CLI command to start a running mock server.&lt;/p&gt;

&lt;p&gt;The &lt;a href="http://apidog.com/blog/how-to-mock-apis-in-cli?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog CLI&lt;/a&gt; helps manage the API resources that mocks are generated from.&lt;/p&gt;

&lt;p&gt;Because mock responses come from endpoint schemas, mock accuracy depends on spec accuracy. The CLI and AI coding agents that use it—such as Cursor, Claude Code, Trae, and Codex—can create and update endpoints and schemas in a project.&lt;/p&gt;

&lt;p&gt;A practical workflow looks like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Update the API contract in code.&lt;/li&gt;
&lt;li&gt;Sync the contract to the project.&lt;/li&gt;
&lt;li&gt;Let the mock output reflect the updated schema.&lt;/li&gt;
&lt;li&gt;Run test scenarios in CI against the real backend.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Run a scenario headlessly with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="nt"&gt;-t&lt;/span&gt; &amp;lt;scenario_id&amp;gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &amp;lt;env_id&amp;gt; &lt;span class="nt"&gt;-r&lt;/span&gt; cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This executes test scenarios and reports results, letting the mock contract and backend verification use the same source of truth.&lt;/p&gt;

&lt;p&gt;See the &lt;a href="http://apidog.com/blog/apidog-cli-installation-guide?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog CLI installation guide&lt;/a&gt; for setup and the &lt;a href="http://apidog.com/blog/apidog-cli-github-actions?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog CLI in GitHub Actions guide&lt;/a&gt; for CI integration.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Why is my expectation ignored even though the condition looks correct?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Check ordering and request format. Expectations run top to bottom, so a broad blank-condition expectation above a specific one will match first. Also verify that the condition uses the request format defined in the API spec: JSON paths for JSON bodies and form-data placement for form endpoints. Review the &lt;a href="http://apidog.com/blog/mock-api?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;API mocking overview&lt;/a&gt; if needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can I use a mock script and a mock expectation for the same response?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No. Mock scripts only run with Smart mock. They do not run for mock expectations or response examples. Use expectations for rule-based branches and scripts for computed responses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I return &lt;code&gt;401&lt;/code&gt; or &lt;code&gt;500&lt;/code&gt; without breaking the default &lt;code&gt;200&lt;/code&gt; response?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a dedicated expectation with a condition controlled by the client, such as a header. In the expectation’s &lt;strong&gt;More&lt;/strong&gt; tab, set the HTTP status code. The default response remains &lt;code&gt;200&lt;/code&gt;, and the error response is returned only when the condition matches.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can conditions use environment variables?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No. Apidog &lt;code&gt;{{variable}}&lt;/code&gt; values are unavailable in mock expectations, and parameter conditions do not support &lt;code&gt;{{variables}}&lt;/code&gt;. Use literal condition values.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happens when no expectation matches?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Apidog falls back to the Mock method priority configured under &lt;strong&gt;Project Settings → Feature Settings → Mock Settings&lt;/strong&gt;. Smart mock then generates a response from the schema. Add a blank-condition expectation when you need a specific fallback response instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;Smart mock handles generated schema-based data. Mock expectations handle request-aware behavior:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;200&lt;/code&gt; for a known user and &lt;code&gt;401&lt;/code&gt; for everyone else.&lt;/li&gt;
&lt;li&gt;Different order bodies for different IDs.&lt;/li&gt;
&lt;li&gt;A forced &lt;code&gt;500&lt;/code&gt; for error-state testing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use mock scripts only when you need computed output that declarative rules cannot express. Remember the priority order: matching expectations run first, and Smart mock is the fallback.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/download?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Download Apidog&lt;/a&gt; to build your first conditional mock.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Mock an API in Apidog Without Writing Any Code</title>
      <dc:creator>Hassann</dc:creator>
      <pubDate>Wed, 15 Jul 2026 06:02:00 +0000</pubDate>
      <link>https://dev.to/hassann/how-to-mock-an-api-in-apidog-without-writing-any-code-25mp</link>
      <guid>https://dev.to/hassann/how-to-mock-an-api-in-apidog-without-writing-any-code-25mp</guid>
      <description>&lt;p&gt;Your frontend team is blocked: &lt;code&gt;GET /users&lt;/code&gt; and &lt;code&gt;GET /orders&lt;/code&gt; are not ready, but the UI needs realistic data for lists, pagination, loading states, and empty states. Hand-maintained JSON fixtures work briefly, then drift from the real API contract. If you already have an API specification, &lt;a href="https://apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog&lt;/a&gt; can generate a mock directly from each endpoint’s response schema with no mock-server code or configuration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation" class="crayons-btn crayons-btn--primary"&gt;Try Apidog today&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;This feature, Smart Mock, uses property names and schema types to generate plausible values. For example, a &lt;code&gt;name&lt;/code&gt; property can return a realistic name, while &lt;code&gt;email&lt;/code&gt; returns an email-shaped value. This guide shows how to mock two e-commerce endpoints, call their mock URLs, control generated values, and understand response priority. For background, see &lt;a href="http://apidog.com/blog/mock-api?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;what API mocking is and how it works&lt;/a&gt; and the &lt;a href="https://json-schema.org/" rel="noopener noreferrer"&gt;JSON Schema documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Smart Mock does
&lt;/h2&gt;

&lt;p&gt;Apidog supports several ways to generate mock responses:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Smart Mock&lt;/strong&gt;: generates data automatically from the API response schema.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Response Example&lt;/strong&gt;: returns an example defined in the endpoint specification.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Custom Response&lt;/strong&gt;: returns a manually configured response.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Conditional Mocking&lt;/strong&gt;: returns different responses based on request parameters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mock Scripts&lt;/strong&gt;: generates values related to the incoming request.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fde62ilx5qwglcdids56f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fde62ilx5qwglcdids56f.png" alt="Apidog mock response options" width="800" height="517"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Smart Mock is the zero-configuration option. Add a response schema to an endpoint, and Apidog fills its properties with generated data. If an endpoint does not have a predefined response example, Smart Mock can act as the fallback instead of returning an empty result.&lt;/p&gt;

&lt;p&gt;For frontend work, this means the API schema becomes the source of truth for both the contract and the mock. Update a field in the schema, and the mock updates with it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisite: define a response schema
&lt;/h2&gt;

&lt;p&gt;Smart Mock requires a response definition on the endpoint.&lt;/p&gt;

&lt;p&gt;If you design APIs in Apidog, add a response schema under the endpoint response definition. If you import an &lt;a href="https://www.openapis.org/" rel="noopener noreferrer"&gt;OpenAPI&lt;/a&gt; document, response schemas typically import with the endpoints.&lt;/p&gt;

&lt;p&gt;Without a response schema, Smart Mock has no structure to generate from.&lt;/p&gt;

&lt;p&gt;To use Local Mock, install the Apidog desktop client. Local Mock runs on your machine and is not available in Apidog Web. &lt;a href="https://apidog.com/download?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Download Apidog&lt;/a&gt; to follow along.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-by-step: mock &lt;code&gt;GET /users&lt;/code&gt; and &lt;code&gt;GET /orders&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Use a small store API as an example.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Define &lt;code&gt;GET /users&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Create a &lt;code&gt;GET /users&lt;/code&gt; endpoint and add a response schema such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1024&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Amara Osei"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"amara.osei@example.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"phone"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"+1-415-555-0148"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"createdAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2026-03-11T09:24:00Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"isActive"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure the schema declares property types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;id&lt;/code&gt;: integer&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;name&lt;/code&gt;, &lt;code&gt;email&lt;/code&gt;, &lt;code&gt;phone&lt;/code&gt;: string&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;createdAt&lt;/code&gt;: string, optionally with a date-time format&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;isActive&lt;/code&gt;: boolean&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 2: Define &lt;code&gt;GET /orders&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Create &lt;code&gt;GET /orders&lt;/code&gt; with an array response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"orderId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ORD-58210"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"userId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1024&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;84.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"currency"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"USD"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"shipped"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"createdAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2026-05-02T14:03:00Z"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use explicit types for every property. Smart Mock uses both property names and schema constraints to choose generated values.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Copy the mock URL
&lt;/h3&gt;

&lt;p&gt;Each endpoint receives a mock URL automatically.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In &lt;strong&gt;DESIGN&lt;/strong&gt; mode, find it in the endpoint’s &lt;strong&gt;API&lt;/strong&gt; tab.&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;DEBUG&lt;/strong&gt; mode, find it in the &lt;strong&gt;Mock&lt;/strong&gt; tab.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use &lt;strong&gt;Click to copy&lt;/strong&gt; to copy the URL.&lt;/p&gt;

&lt;p&gt;The copied value is only the URL. When calling non-&lt;code&gt;GET&lt;/code&gt; endpoints, set the HTTP method and request body in your client.&lt;/p&gt;

&lt;p&gt;A Local Mock URL uses &lt;code&gt;127.0.0.1:4523&lt;/code&gt;. In path mode, it looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://127.0.0.1:4523/m1/{projectID}-{versionNo}-{serverNo}/users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apidog starts Local Mock automatically while the desktop client is open.&lt;/p&gt;

&lt;p&gt;You can also target a specific endpoint using ID mode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://127.0.0.1:4523/m2/{projectID}-{versionNo}-{serverNo}/{endpointId}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Call the mock
&lt;/h3&gt;

&lt;p&gt;Call &lt;code&gt;GET /users&lt;/code&gt; with &lt;code&gt;curl&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl http://127.0.0.1:4523/m1/1234567-0-0/users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Smart Mock can return a response similar to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3187&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Diego Marchetti"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"diego.marchetti@example.net"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"phone"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"+1-628-555-0113"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"createdAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2026-01-27T18:41:22Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"isActive"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;email&lt;/code&gt; values are generated through property-name matching rather than random strings. Refresh the request to generate new dynamic values and test how the UI handles different content lengths and values.&lt;/p&gt;

&lt;p&gt;Call the orders endpoint the same way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl http://127.0.0.1:4523/m1/1234567-0-0/orders
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You now have an array of generated order objects for an order-list UI.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Smart Mock chooses values
&lt;/h2&gt;

&lt;p&gt;Smart Mock uses a three-level priority order for each property:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Mock Field&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Property Name Matching&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;JSON Schema defaults and constraints&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  1. Mock Field
&lt;/h3&gt;

&lt;p&gt;A property-level Mock Field has the highest priority.&lt;/p&gt;

&lt;p&gt;Use one of these input types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fixed value&lt;/strong&gt;: always return the same value.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Faker statement&lt;/strong&gt;: return varied generated values.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, use a fixed value for a constant currency:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;USD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or configure a Faker statement for &lt;code&gt;status&lt;/code&gt; to return values such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;shipped
pending
delivered
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Property Name Matching
&lt;/h3&gt;

&lt;p&gt;If no Mock Field is configured, Smart Mock matches property names against built-in wildcard or regular-expression rules.&lt;/p&gt;

&lt;p&gt;That is why fields such as &lt;code&gt;email&lt;/code&gt; and &lt;code&gt;createdAt&lt;/code&gt; can receive appropriate generated values. You can review or add rules in &lt;strong&gt;Mock Settings&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. JSON Schema
&lt;/h3&gt;

&lt;p&gt;If a property has no Mock Field and no matching property-name rule, Smart Mock falls back to its schema type and constraints.&lt;/p&gt;

&lt;p&gt;For example, a string property with no matching name or extra constraints receives a generic string value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc8vwz0vr1tzmkjl0uzfx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc8vwz0vr1tzmkjl0uzfx.png" alt="Smart Mock configuration" width="800" height="593"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Smart Mock respects JSON Schema constraints, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;enum&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;string length&lt;/li&gt;
&lt;li&gt;numeric minimum and maximum values&lt;/li&gt;
&lt;li&gt;array &lt;code&gt;minItems&lt;/code&gt; and related length constraints&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"enum"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"pending"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"shipped"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"delivered"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A &lt;code&gt;status&lt;/code&gt; field with this schema only returns one of those three values.&lt;/p&gt;

&lt;p&gt;You can also select mock locales to generate regionalized data. For example, switching to a Japanese locale changes generated names and addresses to match that format.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fixing incorrect Smart Mock values
&lt;/h2&gt;

&lt;p&gt;Smart Mock is schema-driven inference, so some field names may need more guidance.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;sku&lt;/code&gt; may fall back to a generic string.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;total&lt;/code&gt; may be generated as a number outside the range your UI expects.&lt;/li&gt;
&lt;li&gt;A domain-specific identifier may not match a built-in name rule.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Apply these fixes in order.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tighten the schema
&lt;/h3&gt;

&lt;p&gt;Start by expressing the rule in JSON Schema.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"number"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"minimum"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"maximum"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use an enum for known states:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"enum"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"pending"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"paid"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"shipped"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"delivered"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use a pattern for identifiers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"pattern"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^SKU-[A-Z0-9]{8}$"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Schema constraints keep generated output within the expected shape without requiring custom mock values.&lt;/p&gt;

&lt;h3&gt;
  
  
  Set a Mock Field
&lt;/h3&gt;

&lt;p&gt;Use a Mock Field when schema constraints are not enough.&lt;/p&gt;

&lt;p&gt;Use a &lt;strong&gt;Fixed value&lt;/strong&gt; when a property must never change:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;USD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use a &lt;strong&gt;Faker statement&lt;/strong&gt; when you need controlled variation.&lt;/p&gt;

&lt;p&gt;Apidog’s Faker support follows ideas similar to the &lt;a href="https://github.com/nuysoft/Mock" rel="noopener noreferrer"&gt;Mock.js&lt;/a&gt; library. See the guide to &lt;a href="http://apidog.com/blog/faker-js-and-how-to-use-it-in-apidog?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;using Faker in Apidog&lt;/a&gt; for expression syntax.&lt;/p&gt;

&lt;h3&gt;
  
  
  Add a Property Name Matching rule
&lt;/h3&gt;

&lt;p&gt;If the same field appears across multiple endpoints, add a reusable rule instead of configuring each property separately.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;Settings&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Open &lt;strong&gt;General Settings&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Open &lt;strong&gt;Feature Settings&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Open &lt;strong&gt;Mock Settings&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;New&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Define a field-name condition and mock expression.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For example, add a rule for &lt;code&gt;sku&lt;/code&gt; so every matching property uses your defined SKU pattern rather than a generic string.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mock response priority: which response wins?
&lt;/h2&gt;

&lt;p&gt;An endpoint can have a Mock Expectation, a Response Example, and Smart Mock available. Apidog resolves them using the &lt;strong&gt;Default mock method&lt;/strong&gt; setting in &lt;strong&gt;Project Settings → Mock Settings&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Available modes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Smart Mock First&lt;/strong&gt;: &lt;code&gt;Mock Expectation → Smart Mock&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Response example first&lt;/strong&gt;: &lt;code&gt;Mock Expectation → Response Example → Smart Mock&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Read the order from left to right.&lt;/p&gt;

&lt;p&gt;Under the default &lt;strong&gt;Smart Mock First&lt;/strong&gt; setting, Apidog first checks for a matching Mock Expectation. If none matches, Smart Mock generates the response.&lt;/p&gt;

&lt;p&gt;Under &lt;strong&gt;Response example first&lt;/strong&gt;, Apidog checks a Response Example before falling back to Smart Mock.&lt;/p&gt;

&lt;p&gt;A matching &lt;strong&gt;Mock Expectation&lt;/strong&gt; always has the highest priority. For example, you can configure a conditional &lt;code&gt;404&lt;/code&gt; response when &lt;code&gt;userId=9999&lt;/code&gt;, and it will override the other response methods. See &lt;a href="http://apidog.com/blog/how-to-mock-conditional-api-responses-apidog?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;mocking conditional API responses in Apidog&lt;/a&gt; for a parameter-driven workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Local Mock, Cloud Mock, and Runner Mock
&lt;/h2&gt;

&lt;p&gt;Smart Mock defines &lt;em&gt;how&lt;/em&gt; a response is generated. Local, Cloud, and Runner Mock define &lt;em&gt;where&lt;/em&gt; it runs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local Mock&lt;/strong&gt; runs through the Apidog desktop client on your computer. It is reachable only while the client is open and listens on &lt;code&gt;127.0.0.1:4523&lt;/code&gt;. To access it from another device on your local network, use your machine’s LAN IP. It is not available in Apidog Web.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloud Mock&lt;/strong&gt; runs on Apidog servers and is available 24/7. Enable it in environment management when teammates or deployed previews need access. Its URLs use &lt;code&gt;https://mock.apidog.com&lt;/code&gt; with the same &lt;code&gt;m1&lt;/code&gt; and &lt;code&gt;m2&lt;/code&gt; path formats. It is intended for testing rather than production traffic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Runner Mock&lt;/strong&gt; is self-hosted on your team infrastructure, which is useful when the mock must stay within your own network.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local Mock&lt;/strong&gt; for individual frontend development.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloud Mock&lt;/strong&gt; for shared or remote testing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Runner Mock&lt;/strong&gt; for self-hosted internal environments.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For more context, see the &lt;a href="http://apidog.com/blog/online-api-mocking-tools-comparison?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;comparison of online API mocking tools&lt;/a&gt; and the &lt;a href="http://apidog.com/blog/how-to-use-apidog-cloud-mock?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog Cloud Mock guide&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Routing gotchas
&lt;/h2&gt;

&lt;p&gt;Keep these rules in mind when a mock endpoint does not route as expected.&lt;/p&gt;

&lt;h3&gt;
  
  
  Start endpoint paths with &lt;code&gt;/&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Use paths such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/orders
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A complete URL that does not begin with &lt;code&gt;/&lt;/code&gt; does not use the mock environment. A path without a leading slash only works in ID mode.&lt;/p&gt;

&lt;h3&gt;
  
  
  Disambiguate duplicate method-and-path endpoints
&lt;/h3&gt;

&lt;p&gt;If two endpoints share the same HTTP method and path, path mode cannot distinguish them automatically.&lt;/p&gt;

&lt;p&gt;Add the endpoint ID as a query parameter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;?apidogApiId={endpointId}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Refresh to regenerate dynamic data
&lt;/h3&gt;

&lt;p&gt;Dynamic mock data regenerates when you refresh the request. If you receive the same generated body repeatedly, check whether your API client, browser, or UI is showing a cached response.&lt;/p&gt;

&lt;h2&gt;
  
  
  Automate contract checks with the Apidog CLI
&lt;/h2&gt;

&lt;p&gt;The Apidog CLI does not start or host a mock server. Local, Cloud, and Runner Mock serve the responses.&lt;/p&gt;

&lt;p&gt;The CLI helps keep the schema behind Smart Mock accurate as the API evolves. Because Smart Mock is generated from endpoint schemas, updating the specification updates the generated mock output.&lt;/p&gt;

&lt;p&gt;The CLI and AI coding agents such as Cursor, Claude Code, Trae, and Codex can create and update endpoints and schemas in the project. Once frontend work is unblocked, run the project’s test scenarios in CI against the real backend using the same API contract.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="nt"&gt;-t&lt;/span&gt; &amp;lt;scenario_id&amp;gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &amp;lt;env_id&amp;gt; &lt;span class="nt"&gt;-r&lt;/span&gt; html,cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install and authenticate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; apidog-cli
apidog login &lt;span class="nt"&gt;--with-token&lt;/span&gt; &amp;lt;your-token&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CLI requires Node.js v16 or later. See &lt;a href="http://apidog.com/blog/apidog-cli-ci-cd-pipeline?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;running Apidog in a CI/CD pipeline&lt;/a&gt; for setup details.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Do I need to write code to use Smart Mock?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No. Define an endpoint response schema and Smart Mock generates data automatically. Use a Faker statement or mock script only when you need to override a specific value. See the &lt;a href="http://apidog.com/blog/mock-api?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;mock API overview&lt;/a&gt; for the core concepts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why is my mock URL returning nothing?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, verify that the endpoint has a response definition. Smart Mock needs a response schema. Also confirm that the path starts with &lt;code&gt;/&lt;/code&gt; and, for Local Mock, that the Apidog desktop client is open.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I return a fixed value instead of generated data?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Set the property’s Mock Field to a Fixed value. Mock Fields have higher priority than property-name matching and schema defaults.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can teammates access a mock running on my laptop?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Only over your local network and only while the Apidog client is running. Local Mock listens on &lt;code&gt;127.0.0.1:4523&lt;/code&gt;. For always-on shared access, enable Cloud Mock at &lt;code&gt;https://mock.apidog.com&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which response wins when both a Response Example and Smart Mock exist?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It depends on the Default mock method:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Smart Mock First&lt;/strong&gt; uses Smart Mock after no Mock Expectation matches.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Response example first&lt;/strong&gt; uses the Response Example before Smart Mock.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A matching Mock Expectation overrides both.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrap up
&lt;/h2&gt;

&lt;p&gt;Smart Mock turns a response schema into a working API mock without hand-writing fixture files. Define the response schema, copy the endpoint mock URL, and call it from your frontend. When generated data needs adjustment, tighten the JSON Schema, configure a Mock Field, or add a reusable property-name rule.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Let an AI Agent Update Your API Spec with the Apidog CLI</title>
      <dc:creator>Hassann</dc:creator>
      <pubDate>Wed, 15 Jul 2026 03:22:38 +0000</pubDate>
      <link>https://dev.to/hassann/how-to-let-an-ai-agent-update-your-api-spec-with-the-apidog-cli-5cp5</link>
      <guid>https://dev.to/hassann/how-to-let-an-ai-agent-update-your-api-spec-with-the-apidog-cli-5cp5</guid>
      <description>&lt;p&gt;Editing an API spec by hand is error-prone: rename a field, add an enum value, or change a required flag, and every dependent endpoint must remain valid. With the &lt;a href="https://apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog&lt;/a&gt; CLI, an AI agent can make these changes with guardrails: validate before writing, work in an isolated branch, and submit changes for review.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation" class="crayons-btn crayons-btn--primary"&gt;Try Apidog today&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;This is the &lt;em&gt;mutation&lt;/em&gt; companion to letting an agent &lt;a href="http://apidog.com/blog/apidog-cli-agent-api-documentation?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;create API documentation&lt;/a&gt;. Documentation generation is additive and relatively low-risk. Updating an existing API contract needs a safer workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  What “update the spec” means in the CLI
&lt;/h2&gt;

&lt;p&gt;An Apidog project contains endpoints and data schemas. You typically update a spec with one of these commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;endpoint update&lt;/code&gt;: Change a path, parameter, request, or response.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;schema update&lt;/code&gt;: Change a data model referenced by endpoints.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;import&lt;/code&gt;: Reconcile an entire OpenAPI file with the project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before giving an agent access to these commands, establish two rules:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;update&lt;/code&gt; is a full replacement, not a patch.&lt;/li&gt;
&lt;li&gt;The agent should work in an isolated AI branch.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Critical behavior: &lt;code&gt;update&lt;/code&gt; replaces the full object
&lt;/h2&gt;

&lt;p&gt;Apidog CLI &lt;code&gt;update&lt;/code&gt; commands are &lt;strong&gt;not JSON Patch&lt;/strong&gt; operations.&lt;/p&gt;

&lt;p&gt;If you submit only one item from a &lt;code&gt;parameters&lt;/code&gt; array, the CLI does not merge that item into the existing array. It replaces the entire array with the value you submitted. Any omitted parameters are removed.&lt;/p&gt;

&lt;p&gt;Use a full read-modify-validate-write loop every time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Fetch the complete current resource&lt;/span&gt;
apidog endpoint get &amp;lt;endpointId&amp;gt; &lt;span class="nt"&gt;--project&lt;/span&gt; &amp;lt;projectId&amp;gt;

&lt;span class="c"&gt;# 2. Edit the complete structure locally.&lt;/span&gt;
&lt;span class="c"&gt;# Keep every field that should remain unchanged.&lt;/span&gt;

&lt;span class="c"&gt;# 3. Get the payload schema and validate the complete object&lt;/span&gt;
apidog cli-schema get endpoint-create
apidog cli-schema validate endpoint-create &lt;span class="nt"&gt;--file&lt;/span&gt; ./endpoint-full.json

&lt;span class="c"&gt;# 4. Write the complete object back&lt;/span&gt;
apidog endpoint update &amp;lt;endpointId&amp;gt; &lt;span class="nt"&gt;--project&lt;/span&gt; &amp;lt;projectId&amp;gt; &lt;span class="nt"&gt;--file&lt;/span&gt; ./endpoint-full.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Put this directly in the agent instructions:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Never send a partial object to &lt;code&gt;update&lt;/code&gt;. Always fetch the full resource, modify it, validate it, and send it back as a complete object.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Skipping &lt;code&gt;get&lt;/code&gt; can silently remove fields. Running &lt;code&gt;cli-schema validate&lt;/code&gt; before writing catches malformed payloads locally.&lt;/p&gt;

&lt;h2&gt;
  
  
  Safe workflow: use an AI branch
&lt;/h2&gt;

&lt;p&gt;Avoid granting an agent direct write access to &lt;code&gt;main&lt;/code&gt; when starting out. Use an &lt;strong&gt;AI branch&lt;/strong&gt; instead.&lt;/p&gt;

&lt;p&gt;An AI branch isolates agent changes from the source branch. Nothing reaches &lt;code&gt;main&lt;/code&gt; until you review and merge it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Create an AI branch
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog branch create &lt;span class="nt"&gt;--project&lt;/span&gt; &amp;lt;projectId&amp;gt; &lt;span class="nt"&gt;--type&lt;/span&gt; ai &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--from&lt;/span&gt; main &lt;span class="nt"&gt;--name&lt;/span&gt; &lt;span class="s2"&gt;"ai/20260713-from-main-refund-fields"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use a name that makes the source and purpose obvious:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ai/YYYYMMDD-from-source-feature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;--from&lt;/code&gt; branch must be &lt;code&gt;main&lt;/code&gt; or a normal sprint branch, not a general branch.&lt;/p&gt;

&lt;p&gt;An AI branch with no differences from its source is automatically archived after 24 hours, which keeps abandoned experiments from accumulating.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Import existing resources into the branch
&lt;/h3&gt;

&lt;p&gt;An AI branch starts empty. It does &lt;strong&gt;not&lt;/strong&gt; automatically clone all resources from its source branch.&lt;/p&gt;

&lt;p&gt;Before an agent can modify an existing endpoint or schema, import that resource using &lt;code&gt;pick-to&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog branch pick-to &lt;span class="nt"&gt;--project&lt;/span&gt; &amp;lt;projectId&amp;gt; &lt;span class="nt"&gt;--type&lt;/span&gt; ai &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--from&lt;/span&gt; main &lt;span class="nt"&gt;--to&lt;/span&gt; &lt;span class="s2"&gt;"ai/20260713-from-main-refund-fields"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--endpoint-ids&lt;/span&gt; &amp;lt;ids&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use &lt;code&gt;pick-to&lt;/code&gt; only for existing resources the agent needs to edit or delete. Resources created from scratch on the AI branch do not need to be picked first.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Run the full update loop on the AI branch
&lt;/h3&gt;

&lt;p&gt;Point each command to the branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog endpoint get &amp;lt;endpointId&amp;gt; &lt;span class="nt"&gt;--project&lt;/span&gt; &amp;lt;projectId&amp;gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--branch&lt;/span&gt; &lt;span class="s2"&gt;"ai/20260713-from-main-refund-fields"&lt;/span&gt;

apidog endpoint update &amp;lt;endpointId&amp;gt; &lt;span class="nt"&gt;--project&lt;/span&gt; &amp;lt;projectId&amp;gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--branch&lt;/span&gt; &lt;span class="s2"&gt;"ai/20260713-from-main-refund-fields"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--file&lt;/span&gt; ./endpoint-full.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The agent can make changes, validate them, and retry as needed without modifying &lt;code&gt;main&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Review and merge
&lt;/h3&gt;

&lt;p&gt;AI branch changes are not merged automatically. Review the diff first.&lt;/p&gt;

&lt;p&gt;For protected targets, use a merge request rather than a direct merge:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog merge-request &lt;span class="nt"&gt;--help&lt;/span&gt;

apidog branch merge &lt;span class="nt"&gt;--project&lt;/span&gt; &amp;lt;projectId&amp;gt; &lt;span class="nt"&gt;--type&lt;/span&gt; ai &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--from&lt;/span&gt; &lt;span class="s2"&gt;"ai/20260713-from-main-refund-fields"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--to&lt;/span&gt; main &lt;span class="nt"&gt;--endpoint-ids&lt;/span&gt; &amp;lt;ids&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A direct CLI merge requires direct-edit permission on both source and target branches. If &lt;code&gt;main&lt;/code&gt; is protected, open a merge request and approve it in the Apidog client.&lt;/p&gt;

&lt;h2&gt;
  
  
  Worked example: rename a schema field safely
&lt;/h2&gt;

&lt;p&gt;Suppose you need to rename &lt;code&gt;amount&lt;/code&gt; to &lt;code&gt;amountCents&lt;/code&gt; in a &lt;code&gt;Refund&lt;/code&gt; schema and change the type to an integer.&lt;/p&gt;

&lt;p&gt;Tell the agent:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Rename the &lt;code&gt;amount&lt;/code&gt; field on the Refund schema to &lt;code&gt;amountCents&lt;/code&gt; and make it an integer.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;First, fetch the complete schema from the AI branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog schema get &amp;lt;refundSchemaId&amp;gt; &lt;span class="nt"&gt;--project&lt;/span&gt; &lt;span class="nv"&gt;$PID&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--branch&lt;/span&gt; &lt;span class="s2"&gt;"ai/20260713-from-main-refund-fields"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then update the full &lt;code&gt;jsonSchema&lt;/code&gt;, preserving properties that are not changing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Refund"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"jsonSchema"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"object"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"required"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"orderId"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"amountCents"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"properties"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"orderId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"amountCents"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"integer"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"reason"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do not send only the changed property. Send the complete schema so &lt;code&gt;orderId&lt;/code&gt; and &lt;code&gt;reason&lt;/code&gt; remain intact.&lt;/p&gt;

&lt;p&gt;Validate and update the AI branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Validate the complete payload&lt;/span&gt;
apidog cli-schema validate schema-create &lt;span class="nt"&gt;--file&lt;/span&gt; ./refund-full.json

&lt;span class="c"&gt;# Update the schema on the AI branch&lt;/span&gt;
apidog schema update &amp;lt;refundSchemaId&amp;gt; &lt;span class="nt"&gt;--project&lt;/span&gt; &lt;span class="nv"&gt;$PID&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--branch&lt;/span&gt; &lt;span class="s2"&gt;"ai/20260713-from-main-refund-fields"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--file&lt;/span&gt; ./refund-full.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Review the resulting diff, confirm that only the intended field changed, and then merge it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Require breaking-change detection before merging
&lt;/h2&gt;

&lt;p&gt;Renaming a required field is a breaking change. Clients sending &lt;code&gt;amount&lt;/code&gt; will fail validation after the change.&lt;/p&gt;

&lt;p&gt;Make the agent classify each change before it opens or completes a merge:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Before merging any spec change, classify it:
- Non-breaking (new optional field, new endpoint, loosened constraint) → summarize and proceed to merge-request.
- Breaking (renamed/removed field, new required field, tightened type) → STOP.
  Report the breaking change and the affected endpoints, and wait for explicit human approval.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The AI branch makes this checkpoint meaningful: the change remains isolated until a human approves it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Updating from an OpenAPI file
&lt;/h2&gt;

&lt;p&gt;When the change already exists in an OpenAPI file—for example, generated from code or supplied by another team—import it into the AI branch instead of applying individual field updates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog import &lt;span class="nt"&gt;--project&lt;/span&gt; &amp;lt;projectId&amp;gt; &lt;span class="nt"&gt;--format&lt;/span&gt; openapi &lt;span class="nt"&gt;--file&lt;/span&gt; ./openapi.json &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--branch&lt;/span&gt; &lt;span class="s2"&gt;"ai/20260713-from-main-refund-fields"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;import&lt;/code&gt; supports OpenAPI 3.x, Swagger 2.0, Postman, and more. Import into an AI branch first so you can inspect the resulting changes before they reach &lt;code&gt;main&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;After merging, export the reconciled spec to verify the result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog &lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nt"&gt;--project&lt;/span&gt; &amp;lt;projectId&amp;gt; &lt;span class="nt"&gt;--format&lt;/span&gt; openapi &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--oas-version&lt;/span&gt; 3.1 &lt;span class="nt"&gt;--output&lt;/span&gt; ./openapi.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use this approach when the source of truth lives outside Apidog and you are syncing it in. Use &lt;code&gt;endpoint update&lt;/code&gt; or &lt;code&gt;schema update&lt;/code&gt; when Apidog is the source of truth and the change is surgical.&lt;/p&gt;

&lt;h2&gt;
  
  
  Roll back an unwanted agent change
&lt;/h2&gt;

&lt;p&gt;An AI branch makes rollback simple. If you reject the changes, do not merge them. Archive the branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog branch archive &lt;span class="s2"&gt;"ai/20260713-from-main-refund-fields"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--project&lt;/span&gt; &amp;lt;projectId&amp;gt; &lt;span class="nt"&gt;--type&lt;/span&gt; ai
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because &lt;code&gt;main&lt;/code&gt; was never modified, no hand-reversal is required. The branch is your undo button.&lt;/p&gt;

&lt;h2&gt;
  
  
  Permissions
&lt;/h2&gt;

&lt;p&gt;If an &lt;code&gt;update&lt;/code&gt; or &lt;code&gt;import&lt;/code&gt; command is blocked, External AI Edit Permissions may be disabled for the project.&lt;/p&gt;

&lt;p&gt;The AI branch workflow is designed for this situation: let the agent edit an isolated branch, then approve the merge manually.&lt;/p&gt;

&lt;p&gt;To grant direct edits instead, configure the setting in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Project Settings → Feature Settings → AI Feature Settings
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This setting is available in Apidog client &lt;code&gt;2.8.32+&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When an agent encounters a permission restriction, have it report the issue rather than silently attempting a workaround.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common snags
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Partial update removed fields&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;update&lt;/code&gt; replaces rather than merges. Fetch the full object, modify it, validate it, and write the complete payload back.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The agent cannot find a resource on an AI branch&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AI branches start empty. Run &lt;code&gt;pick-to&lt;/code&gt; before editing an existing endpoint or schema.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The AI branch was created from the wrong source&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;--from&lt;/code&gt; branch must be &lt;code&gt;main&lt;/code&gt; or a sprint branch, not a general branch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Validation was skipped&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run &lt;code&gt;apidog cli-schema validate&lt;/code&gt; before every write. It catches malformed payloads before the agent makes an API call.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A breaking change was merged without review&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Require the agent to classify changes and stop on renamed or removed fields, newly required fields, and tightened types.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can an agent edit &lt;code&gt;main&lt;/code&gt; directly?
&lt;/h3&gt;

&lt;p&gt;Yes, if you enable External AI Edit Permissions. However, AI branches are safer because changes do not reach &lt;code&gt;main&lt;/code&gt; until you approve a merge. Reserve direct edits for low-risk, high-trust automation.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between &lt;code&gt;branch merge&lt;/code&gt; and &lt;code&gt;merge-request&lt;/code&gt;?
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;branch merge&lt;/code&gt; writes changes immediately and requires direct-edit permission on both branches.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;merge-request&lt;/code&gt; creates a reviewable request, which is the better option when &lt;code&gt;main&lt;/code&gt; is protected.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does the agent need the Apidog desktop app?
&lt;/h3&gt;

&lt;p&gt;No. The CLI is standalone. The desktop app is only needed to configure External AI Edit Permissions.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I prevent hallucinated field names?
&lt;/h3&gt;

&lt;p&gt;Use the schema validation loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog cli-schema get schema-create
apidog cli-schema validate schema-create &lt;span class="nt"&gt;--file&lt;/span&gt; ./refund-full.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An invented or malformed field fails local validation before it reaches the project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrap up
&lt;/h2&gt;

&lt;p&gt;Agent-driven API spec updates are safe when you enforce three practices:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Work in an isolated AI branch.&lt;/li&gt;
&lt;li&gt;Treat every update as a complete read-modify-write operation.&lt;/li&gt;
&lt;li&gt;Require human approval before merging, especially for breaking changes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That makes spec maintenance an auditable diff instead of a risky direct edit. &lt;a href="https://apidog.com/download?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Download Apidog&lt;/a&gt; to get the CLI, then pair this workflow with &lt;a href="http://apidog.com/blog/apidog-cli-agent-api-documentation?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;agent-generated API documentation&lt;/a&gt; for a complete authoring and maintenance loop.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Stoplight to Apidog Migration Guide: Managing OpenAPI Specs in Spec-First Mode</title>
      <dc:creator>Hassann</dc:creator>
      <pubDate>Tue, 14 Jul 2026 07:28:01 +0000</pubDate>
      <link>https://dev.to/hassann/stoplight-to-apidog-migration-guide-managing-openapi-specs-in-spec-first-mode-2499</link>
      <guid>https://dev.to/hassann/stoplight-to-apidog-migration-guide-managing-openapi-specs-in-spec-first-mode-2499</guid>
      <description>&lt;p&gt;Migrating from Stoplight to Apidog is more than importing one OpenAPI file. You need to move a file-based API workflow that may include specs in Git, Markdown docs, JSON Schema models, local images, &lt;code&gt;toc.json&lt;/code&gt; navigation inputs, and &lt;code&gt;.stoplight.json&lt;/code&gt; path settings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation" class="crayons-btn crayons-btn--primary"&gt;Try Apidog today&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;A Stoplight project may also depend on Postman request examples, Bruno files, CI test scripts, mocks, and publishing workflows. Importing only an OpenAPI file preserves endpoint definitions, but it does not automatically preserve the workflow around them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/spec-first-mode/?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog Spec-first Mode&lt;/a&gt; helps teams keep OpenAPI files as the source of truth during a Stoplight migration while connecting those files to docs, mocks, tests, reports, permissions, and collaboration.&lt;/p&gt;

&lt;p&gt;This guide shows how to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Audit a Stoplight-style repository.&lt;/li&gt;
&lt;li&gt;Carry over portable project files.&lt;/li&gt;
&lt;li&gt;Review Stoplight-specific behavior.&lt;/li&gt;
&lt;li&gt;Rebuild workflow-level assets.&lt;/li&gt;
&lt;li&gt;Connect the OpenAPI contract to the broader API lifecycle.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For operational setup instructions, see the &lt;a href="https://docs.apidog.com/spec-first-mode-beta-2058268m0" rel="noopener noreferrer"&gt;Spec-first Mode help guide&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Stoplight Migration Is More Than an OpenAPI Import
&lt;/h2&gt;

&lt;p&gt;An OpenAPI file defines an API contract. A Stoplight-style project typically includes additional files and conventions around that contract.&lt;/p&gt;

&lt;p&gt;Common project assets include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OpenAPI or Swagger files, often under &lt;code&gt;reference&lt;/code&gt; or another configured directory&lt;/li&gt;
&lt;li&gt;Markdown documentation, often under &lt;code&gt;docs&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;JSON Schema model files, often under &lt;code&gt;models&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Local images referenced by documentation&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.stoplight.json&lt;/code&gt; path configuration&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;toc.json&lt;/code&gt; documentation navigation, grouping, and ordering inputs&lt;/li&gt;
&lt;li&gt;Stoplight identifiers such as &lt;code&gt;x-stoplight-id&lt;/code&gt; or &lt;code&gt;x-stoplight.id&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you import only one spec file, you may keep endpoints but lose important context:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Documentation may need to be rebuilt.&lt;/li&gt;
&lt;li&gt;Navigation may not match the existing project.&lt;/li&gt;
&lt;li&gt;Models may become disconnected from docs.&lt;/li&gt;
&lt;li&gt;Tests, mocks, and request examples may remain in separate tools.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Start from the repository tree—not from a single OpenAPI file.&lt;/p&gt;




&lt;h2&gt;
  
  
  Migration Model: Carry Over, Review, Rebuild, Connect
&lt;/h2&gt;

&lt;p&gt;Before migration, identify the actual source of truth.&lt;/p&gt;

&lt;p&gt;If OpenAPI files in Git define the API contract, start with Spec-first Mode. If Postman or Bruno collections define the real request workflow, resolve that mismatch before moving the project.&lt;/p&gt;

&lt;p&gt;Do not try to preserve everything exactly. Some Stoplight-specific behavior does not map one-to-one to another workspace.&lt;/p&gt;

&lt;p&gt;Use this four-part model instead:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Category&lt;/th&gt;
&lt;th&gt;What belongs here&lt;/th&gt;
&lt;th&gt;Migration stance&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Carry over&lt;/td&gt;
&lt;td&gt;OpenAPI files, supported &lt;code&gt;.stoplight.json&lt;/code&gt; path settings, supported &lt;code&gt;toc.json&lt;/code&gt; navigation inputs, Markdown docs, referenced local images, and JSON Schema models where supported&lt;/td&gt;
&lt;td&gt;Bring file-based project context into Spec-first Mode&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Review&lt;/td&gt;
&lt;td&gt;Markdown links, anchors, images, TOC grouping, schema naming, external &lt;code&gt;$ref&lt;/code&gt;s, Stoplight IDs, generated pages, and rendering differences&lt;/td&gt;
&lt;td&gt;Verify the migrated workspace before treating it as production-ready&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rebuild&lt;/td&gt;
&lt;td&gt;Postman or Bruno request flows, environments, manual tests, mocks, CI jobs, and publishing rules maintained outside the spec project&lt;/td&gt;
&lt;td&gt;Recreate these around the OpenAPI source of truth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Connect&lt;/td&gt;
&lt;td&gt;API docs, mock APIs, tests, CI reports, permissions, team collaboration, and partner workflows&lt;/td&gt;
&lt;td&gt;Use Apidog to make the contract useful across the API lifecycle&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk0lm1dgsh48s0bn17nns.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk0lm1dgsh48s0bn17nns.png" alt="Stoplight to Postman migration workflow" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Stoplight migration has two distinct layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;File layer:&lt;/strong&gt; OpenAPI specs, Markdown docs, models, images, and project structure files. This is where Spec-first Mode is directly useful.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Workflow layer:&lt;/strong&gt; API reviews, publishing, tests, mocks, reports, permissions, and collaboration. Treat this as a separate migration concern.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The goal is not only to import data. It is to connect the contract to the workflow your team needs.&lt;/p&gt;




&lt;h2&gt;
  
  
  How Apidog Spec-first Mode Fits Stoplight Projects
&lt;/h2&gt;

&lt;p&gt;Apidog Spec-first Mode supports file-based API workflows.&lt;/p&gt;

&lt;p&gt;With a Git-connected project, your repository and branch remain the source of truth, while Apidog syncs with those files.&lt;/p&gt;

&lt;p&gt;With a file-backed project, you can work with spec files directly in Apidog first, then connect Git later.&lt;/p&gt;

&lt;p&gt;The Specs workspace gives your team one place to manage source files, inspect parsed API structures, and edit API definitions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1f5901k9r7352tvb9byc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1f5901k9r7352tvb9byc.png" alt="Apidog Specs workspace for managing OpenAPI files in Spec-first Mode" width="800" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The Specs workspace lets teams manage source files, parsed API structure, and editing workflows in one place.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Map Stoplight assets to Apidog
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Stoplight asset&lt;/th&gt;
&lt;th&gt;What happens in Apidog&lt;/th&gt;
&lt;th&gt;What to review&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;OpenAPI / Swagger files&lt;/td&gt;
&lt;td&gt;Can be imported and synced as API modules, endpoints, schemas, and examples&lt;/td&gt;
&lt;td&gt;Bundled references, conversion warnings, module names, and endpoint grouping&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.stoplight.json&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Supported fields can help locate OpenAPI, Markdown, and JSON Schema roots; apply OpenAPI include patterns and global excludes; and resolve &lt;code&gt;tocPath&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Treat it as path discovery for sync, not full Stoplight project configuration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;toc.json&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Can help create DOCS folders from supported groups and dividers, filter and order Markdown docs, apply titles, link folders to OAS modules or spec items, and import referenced JSON Schema models where supported&lt;/td&gt;
&lt;td&gt;Review the final Apidog sidebar because exact Stoplight navigation and arbitrary cross-type ordering may not be preserved&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Markdown docs&lt;/td&gt;
&lt;td&gt;Documentation can be carried into the project workflow; TOC-listed docs can retain more structure where supported&lt;/td&gt;
&lt;td&gt;Internal links, anchors, formatting, missing files, and rendering differences&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Local images&lt;/td&gt;
&lt;td&gt;Images referenced by Markdown can be imported where supported&lt;/td&gt;
&lt;td&gt;Broken references, external images, data URIs, and unreferenced images&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JSON Schema models&lt;/td&gt;
&lt;td&gt;Explicitly referenced schema files, such as files referenced in &lt;code&gt;toc.json&lt;/code&gt;, can be carried into Models where supported&lt;/td&gt;
&lt;td&gt;Schema format, naming, grouping, references, and whether all models should be imported&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stoplight IDs&lt;/td&gt;
&lt;td&gt;Root-level Stoplight IDs may help match imported modules across syncs&lt;/td&gt;
&lt;td&gt;Do not assume endpoint-level or page-level identity is fully preserved&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu5gno375egdj0ctg8b9y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu5gno375egdj0ctg8b9y.png" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Compatibility notes for Stoplight project files
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Treat &lt;code&gt;.stoplight.json&lt;/code&gt; as a supported path-configuration subset for sync. Apidog can use supported OpenAPI, Markdown, and JSON Schema root directories, OpenAPI include patterns, global exclude patterns, and &lt;code&gt;tocPath&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Treat other Stoplight project settings as ignored unless you verify their behavior after import.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;toc.json&lt;/code&gt; to migrate supported navigation semantics, including DOCS folders, Markdown ordering, OAS/module links, selected spec-item links, and TOC-referenced model imports.&lt;/li&gt;
&lt;li&gt;Review the final sidebar in Apidog. It uses the DOCS/OAS/MODELS model, so exact Stoplight layouts and arbitrary cross-type ordering may not be preserved.&lt;/li&gt;
&lt;li&gt;Verify images separately. Referenced local images are the most predictable migration case; unreferenced assets, external images, and data URIs need manual review.&lt;/li&gt;
&lt;li&gt;Reference JSON Schema files explicitly through supported project structures such as &lt;code&gt;toc.json&lt;/code&gt;. Do not assume every file in a models directory becomes a model resource.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The target is not a pixel-perfect Stoplight recreation. The target is a portable, file-based project context connected to a broader API lifecycle.&lt;/p&gt;




&lt;h2&gt;
  
  
  From File Import to a Connected API Workflow
&lt;/h2&gt;

&lt;p&gt;A traditional import workflow often imports an OpenAPI file once and then continues with visual edits in a new tool. That can create drift between:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The OpenAPI files in Git&lt;/li&gt;
&lt;li&gt;Published documentation&lt;/li&gt;
&lt;li&gt;The API workspace&lt;/li&gt;
&lt;li&gt;Tests and mocks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Spec-first Mode keeps files at the center of the workflow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fahtbanqr8k31uo02luki.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fahtbanqr8k31uo02luki.png" width="800" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a Git-connected Spec-first project, teams can edit files in the Specs workspace, commit changes, and push them back to the repository.&lt;/p&gt;

&lt;p&gt;In a file-backed project, teams can edit and save spec files in Apidog before connecting Git.&lt;/p&gt;

&lt;p&gt;Use this responsibility split:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;th&gt;Recommended source&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;API contract&lt;/td&gt;
&lt;td&gt;OpenAPI / Swagger files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Project file structure&lt;/td&gt;
&lt;td&gt;Repository or file-backed project tree&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Supported Stoplight-style path settings&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.stoplight.json&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Supported documentation navigation inputs&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;toc.json&lt;/code&gt; and Markdown docs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Daily API collaboration&lt;/td&gt;
&lt;td&gt;Apidog project workspace&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mocks, tests, reports, and team permissions&lt;/td&gt;
&lt;td&gt;Broader Apidog platform workflow&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This is the main migration benefit: retain a file-first contract model while providing a usable API workspace for backend, frontend, QA, product, platform, and partner teams.&lt;/p&gt;




&lt;h2&gt;
  
  
  Git-Connected vs. File-Backed Migration Paths
&lt;/h2&gt;

&lt;p&gt;Stoplight teams may start from different levels of Git maturity.&lt;/p&gt;

&lt;p&gt;Some teams already review API changes through branches and pull requests. Others store API specs and docs as files but want to validate the workflow before connecting an external Git provider.&lt;/p&gt;

&lt;p&gt;Apidog Spec-first Mode supports both paths.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Path&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;th&gt;Typical workflow&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Git-connected Spec-first project&lt;/td&gt;
&lt;td&gt;Teams already managing OpenAPI specs in Git&lt;/td&gt;
&lt;td&gt;Connect the repository, sync a branch, edit files, commit, and push&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;File-backed Spec-first project&lt;/td&gt;
&lt;td&gt;Teams that want file-based API design before connecting Git&lt;/td&gt;
&lt;td&gt;Work with spec files in Apidog, save changes, and validate the workflow first&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F97hety7d1pe2eyhtaemu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F97hety7d1pe2eyhtaemu.png" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For most Stoplight migrations, a Git-connected project is the clearer long-term approach because the repository remains the contract source of truth.&lt;/p&gt;

&lt;p&gt;Use a file-backed project when you need to evaluate the authoring workflow, clean up project files, or stage the migration before adopting a stricter Git process.&lt;/p&gt;




&lt;h2&gt;
  
  
  What to Review After Migration
&lt;/h2&gt;

&lt;p&gt;Even when files are carried over, run a structured review before using the migrated workspace in production.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Area&lt;/th&gt;
&lt;th&gt;What to check&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;OpenAPI modules&lt;/td&gt;
&lt;td&gt;Confirm all intended spec files were imported, module names are correct, and endpoints are grouped as expected&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;External references&lt;/td&gt;
&lt;td&gt;Check whether &lt;code&gt;$ref&lt;/code&gt; dependencies resolved correctly and whether conversion issues were reported&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lint and validation&lt;/td&gt;
&lt;td&gt;Run Apidog Specs validation on imported OpenAPI files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.stoplight.json&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Confirm supported OpenAPI, Markdown, and JSON Schema roots, include patterns, global excludes, and &lt;code&gt;tocPath&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;toc.json&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Review groups, dividers, titles, Markdown filtering and ordering, clickable groups, OAS links, selected spec-item links, model imports, and final sidebar output&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Markdown docs&lt;/td&gt;
&lt;td&gt;Check formatting, headings, relative links, anchors, and links to API files or operations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Images&lt;/td&gt;
&lt;td&gt;Confirm referenced local images render correctly; review external images, data URIs, broken references, and unused assets separately&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Models&lt;/td&gt;
&lt;td&gt;Confirm which &lt;code&gt;toc.json&lt;/code&gt;-referenced JSON Schema files became model resources and whether names, folders, and references are correct&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stoplight IDs&lt;/td&gt;
&lt;td&gt;Confirm module matching behaves correctly across repeated syncs; do not rely on IDs for every resource type&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tests and mocks&lt;/td&gt;
&lt;td&gt;Rebuild or reconnect workflows previously maintained in Postman, Bruno, CI, or separate tooling&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Permissions and publishing&lt;/td&gt;
&lt;td&gt;Recreate team access, documentation visibility, review rules, and release responsibilities&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For validation, Apidog can use root-level Spectral configuration files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.spectral.yaml
.spectral.yml
.spectral.json
.spectral.mjs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It can also fall back to &lt;code&gt;.stoplight/styleguide.json&lt;/code&gt; for Spectral-based editor validation.&lt;/p&gt;

&lt;p&gt;Treat validation results as review signals. Passing validation does not prove that every Stoplight-specific behavior was preserved.&lt;/p&gt;




&lt;h2&gt;
  
  
  What About Postman and Bruno Assets?
&lt;/h2&gt;

&lt;p&gt;Many Stoplight teams also use Postman or Bruno. Plan those assets separately from the OpenAPI project migration.&lt;/p&gt;

&lt;p&gt;OpenAPI files define the contract. Postman collections and Bruno &lt;code&gt;.bru&lt;/code&gt; files usually define request workflows, examples, environments, or tests. These are valuable assets, but they are not the same migration object as a Stoplight-style OpenAPI project.&lt;/p&gt;

&lt;p&gt;Answer these questions before migration:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Question&lt;/th&gt;
&lt;th&gt;Why it matters&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Is OpenAPI the source of truth, or are collections driving actual API behavior?&lt;/td&gt;
&lt;td&gt;Spec-first migration should begin from the authoritative contract&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Which request examples still matter?&lt;/td&gt;
&lt;td&gt;Rebuild important examples around the connected API workspace&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Which tests must keep running?&lt;/td&gt;
&lt;td&gt;Move or reconnect tests instead of assuming they migrate with documentation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Which environments and secrets are shared?&lt;/td&gt;
&lt;td&gt;Plan environment management separately from spec migration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Which CI jobs depend on current tooling?&lt;/td&gt;
&lt;td&gt;Reconnect validation, testing, and reporting intentionally&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For Bruno users, Git-native workflows are already valuable. Spec-first Mode can keep your API contract file-based, but Bruno assets may need separate migration, rebuilding, or replacement based on how your team uses them.&lt;/p&gt;




&lt;h2&gt;
  
  
  Recommended Migration Plan
&lt;/h2&gt;

&lt;p&gt;Use a staged plan instead of attempting to migrate every workflow at once.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frt6oxsr2yhf65orr5wxr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frt6oxsr2yhf65orr5wxr.png" width="800" height="460"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A staged migration plan: move the OpenAPI contract first, then reconnect the surrounding workflow.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Audit the Stoplight-style repository
&lt;/h3&gt;

&lt;p&gt;Inventory:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OpenAPI files&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.stoplight.json&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;toc.json&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Markdown docs&lt;/li&gt;
&lt;li&gt;JSON Schema models&lt;/li&gt;
&lt;li&gt;Local images&lt;/li&gt;
&lt;li&gt;Postman collections or Bruno files&lt;/li&gt;
&lt;li&gt;CI scripts, tests, and publishing configuration&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Decide the source of truth
&lt;/h3&gt;

&lt;p&gt;Confirm that OpenAPI files in Git define the API contract.&lt;/p&gt;

&lt;p&gt;If a Postman collection or Bruno workflow is effectively the source of truth, resolve that before starting a Spec-first migration.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Create the Spec-first project
&lt;/h3&gt;

&lt;p&gt;Choose a Git-connected project when the team is ready to keep Git as the source of truth.&lt;/p&gt;

&lt;p&gt;Choose a file-backed project when the team wants to validate the file-based workflow before connecting Git.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Review carried-over files
&lt;/h3&gt;

&lt;p&gt;Check:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Imported API modules&lt;/li&gt;
&lt;li&gt;Markdown documentation&lt;/li&gt;
&lt;li&gt;JSON Schema models&lt;/li&gt;
&lt;li&gt;Referenced images&lt;/li&gt;
&lt;li&gt;Internal links and anchors&lt;/li&gt;
&lt;li&gt;Supported &lt;code&gt;toc.json&lt;/code&gt; navigation inputs&lt;/li&gt;
&lt;li&gt;Supported &lt;code&gt;.stoplight.json&lt;/code&gt; path settings&lt;/li&gt;
&lt;li&gt;Specs validation results&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Fix source project files where possible instead of manually patching symptoms in the workspace.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Rebuild workflow-level assets
&lt;/h3&gt;

&lt;p&gt;Reconnect or recreate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mocks&lt;/li&gt;
&lt;li&gt;Test scenarios&lt;/li&gt;
&lt;li&gt;Request examples&lt;/li&gt;
&lt;li&gt;CI jobs&lt;/li&gt;
&lt;li&gt;Reports&lt;/li&gt;
&lt;li&gt;Permissions&lt;/li&gt;
&lt;li&gt;Documentation publishing responsibilities&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. Run one real API change through the new workflow
&lt;/h3&gt;

&lt;p&gt;Use a small, low-risk OpenAPI change to verify the full path:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Update the OpenAPI file.&lt;/li&gt;
&lt;li&gt;Review the change.&lt;/li&gt;
&lt;li&gt;Sync or commit it.&lt;/li&gt;
&lt;li&gt;Update documentation if required.&lt;/li&gt;
&lt;li&gt;Validate downstream mocks, tests, and reports.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If your team already maintains OpenAPI files, Markdown docs, and schema models in a Stoplight-style repository, this approach lets you validate the migration path before rebuilding the complete workflow.&lt;/p&gt;




&lt;h2&gt;
  
  
  When This Migration Path Fits Best
&lt;/h2&gt;

&lt;p&gt;This path is a good fit when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your team manages OpenAPI or Swagger specifications as files.&lt;/li&gt;
&lt;li&gt;Your Stoplight project includes Markdown docs, models, images, &lt;code&gt;.stoplight.json&lt;/code&gt;, or &lt;code&gt;toc.json&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Your API review process depends on Git branches or pull requests.&lt;/li&gt;
&lt;li&gt;You want docs, mocks, tests, reports, and collaboration connected to the API contract.&lt;/li&gt;
&lt;li&gt;You want to reduce drift between API files and the workspace used by frontend, QA, product, platform, or partner teams.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It may require more planning when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Postman or Bruno collection is the real source of truth rather than OpenAPI.&lt;/li&gt;
&lt;li&gt;The Stoplight project relies heavily on custom publishing behavior.&lt;/li&gt;
&lt;li&gt;Documentation includes many external links, anchors, generated pages, or unreferenced assets.&lt;/li&gt;
&lt;li&gt;JSON Schema models use formats or structures that need manual review.&lt;/li&gt;
&lt;li&gt;The team expects a pixel-perfect recreation of Stoplight navigation or rendering.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Is Apidog Spec-first Mode a Stoplight alternative?
&lt;/h3&gt;

&lt;p&gt;It can be used as a Stoplight alternative for teams that want to keep OpenAPI projects file-based while adding API collaboration, testing, mocking, documentation, reporting, and permission management around those files.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I keep OpenAPI specs in Git?
&lt;/h3&gt;

&lt;p&gt;Yes. In a Git-connected Spec-first project, teams can keep Git as the source of truth, sync a branch, edit files, and commit changes back to the repository.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do I need Git to start?
&lt;/h3&gt;

&lt;p&gt;No. Use a file-backed Spec-first project to work with spec files first, then connect Git later.&lt;/p&gt;

&lt;h3&gt;
  
  
  Are &lt;code&gt;.stoplight.json&lt;/code&gt; and &lt;code&gt;toc.json&lt;/code&gt; fully preserved?
&lt;/h3&gt;

&lt;p&gt;No. Apidog uses supported parts of these files as migration inputs.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.stoplight.json&lt;/code&gt; is primarily used for path discovery during sync, including supported OpenAPI, Markdown, and JSON Schema roots, OpenAPI include patterns, global excludes, and &lt;code&gt;tocPath&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;toc.json&lt;/code&gt; can help organize supported DOCS content, OAS/module links, selected spec-item links, and TOC-referenced model imports.&lt;/p&gt;

&lt;p&gt;The final online documentation sidebar is constrained by Apidog's DOCS/OAS/MODELS model, so exact Stoplight navigation and arbitrary cross-type ordering may not be preserved.&lt;/p&gt;

&lt;h3&gt;
  
  
  What happens to Markdown docs?
&lt;/h3&gt;

&lt;p&gt;Markdown docs can be carried into the Spec-first project workflow. When &lt;code&gt;toc.json&lt;/code&gt; is present, TOC-listed docs can retain more structure where supported.&lt;/p&gt;

&lt;p&gt;Review internal links, anchors, images, and rendering after migration.&lt;/p&gt;

&lt;h3&gt;
  
  
  What happens to JSON Schema models?
&lt;/h3&gt;

&lt;p&gt;JSON Schema models can be carried over where supported when they are explicitly referenced through supported project structures, such as &lt;code&gt;toc.json&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Do not assume every JSON file in a models directory automatically becomes a model resource. Review schema formats, names, folders, and references after migration.&lt;/p&gt;

&lt;h3&gt;
  
  
  What happens to images?
&lt;/h3&gt;

&lt;p&gt;Local images referenced by Markdown can be imported where supported.&lt;/p&gt;

&lt;p&gt;Do not treat &lt;code&gt;formats.image.rootDir&lt;/code&gt; as a guarantee that every image file in that directory will be imported. Review external images, data URIs, broken references, and unused image files separately.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should I run lint or validation after migration?
&lt;/h3&gt;

&lt;p&gt;Yes. Run Specs validation on imported OpenAPI files.&lt;/p&gt;

&lt;p&gt;Apidog supports Spectral-based editor validation and can read root-level &lt;code&gt;.spectral.yaml&lt;/code&gt;, &lt;code&gt;.spectral.yml&lt;/code&gt;, &lt;code&gt;.spectral.json&lt;/code&gt;, and &lt;code&gt;.spectral.mjs&lt;/code&gt; files, or fall back to &lt;code&gt;.stoplight/styleguide.json&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Use the results to review contract and style issues. Do not treat successful validation as proof that every Stoplight-specific behavior was preserved.&lt;/p&gt;

&lt;h3&gt;
  
  
  What should Bruno or Postman users do?
&lt;/h3&gt;

&lt;p&gt;First identify whether OpenAPI or collections are the source of truth.&lt;/p&gt;

&lt;p&gt;Spec-first migration centers on OpenAPI and related project files. Collection-based request workflows, environments, and tests may need separate migration or rebuilding.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does Apidog support mocks, tests, CI/CD, reports, and collaboration?
&lt;/h3&gt;

&lt;p&gt;Yes. Spec-first Mode connects the file-based API contract to Apidog, while the broader platform can support documentation, mocks, test scenarios, CI/CD execution with Apidog CLI, reports, permissions, and team collaboration.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Stoplight migration does not require giving up file-based API work.&lt;/p&gt;

&lt;p&gt;Keep the repository as the source of truth. Preserve portable project files where supported, including OpenAPI specs, Markdown docs, referenced images, TOC-referenced JSON Schema models, and supported project structure files.&lt;/p&gt;

&lt;p&gt;Then rebuild and connect the workflow around those files.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/spec-first-mode/?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog Spec-first Mode&lt;/a&gt; provides a practical path: carry over supported file-based assets, review Stoplight-specific structures carefully, and reconnect API docs, mocks, tests, reports, permissions, and collaboration around a shared API contract.&lt;/p&gt;

&lt;p&gt;For enterprise migration planning, see &lt;a href="https://apidog.com/enterprise/?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog Enterprise&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Use the Apidog CLI in Trae</title>
      <dc:creator>Hassann</dc:creator>
      <pubDate>Tue, 14 Jul 2026 05:49:21 +0000</pubDate>
      <link>https://dev.to/hassann/how-to-use-the-apidog-cli-in-trae-5c6d</link>
      <guid>https://dev.to/hassann/how-to-use-the-apidog-cli-in-trae-5c6d</guid>
      <description>&lt;p&gt;Trae’s Builder agent can read your repository, edit files, run terminal commands, and use command output to decide what to do next. API tests should be part of that same loop. With &lt;code&gt;apidog-cli&lt;/code&gt;, Builder can run Apidog test scenarios from the terminal, inspect the exit code, and use failures as feedback while it works.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation" class="crayons-btn crayons-btn--primary"&gt;Try Apidog today&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;The setup is a small project rules file. Once the CLI is installed and authenticated, Builder can run an Apidog scenario just like it runs unit tests: execute the command, read the result, and treat a non-zero exit code as a failure.&lt;/p&gt;

&lt;p&gt;Before continuing, confirm that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;prints a version number and that your Apidog account is authenticated. For installation, authentication, and a first run, follow &lt;a href="http://apidog.com/blog/apidog-cli-installation-guide?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;How to install the Apidog CLI with an AI coding agent&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which Trae this is about
&lt;/h2&gt;

&lt;p&gt;This article covers ByteDance’s desktop Trae IDE: the VS Code-based editor with a chat panel and the Builder agent mode. See &lt;a href="https://www.trae.ai/" rel="noopener noreferrer"&gt;Trae’s official site&lt;/a&gt; for product details.&lt;/p&gt;

&lt;p&gt;It does &lt;strong&gt;not&lt;/strong&gt; cover the standalone &lt;code&gt;trae-agent&lt;/code&gt; GitHub research project. If you can open Trae, see the chat panel, and switch the agent to Builder, this workflow applies to you.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgzbqb48d4dbaf3e77mh0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgzbqb48d4dbaf3e77mh0.png" alt="Trae Builder interface" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Trae can load project rules before Builder starts working. That makes API-test execution persistent instead of relying on a one-off chat prompt. For a Trae-independent overview, see &lt;a href="http://apidog.com/blog/apidog-cli-complete-guide?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;the complete Apidog CLI guide&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Add a Trae project rules file
&lt;/h2&gt;

&lt;p&gt;Trae project rules live at:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.trae/rules/project_rules.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create that file at the repository root. According to &lt;a href="https://docs.trae.ai/ide/rules" rel="noopener noreferrer"&gt;Trae’s rules documentation&lt;/a&gt;, Builder loads these rules during initialization and uses them while generating and editing code.&lt;/p&gt;

&lt;p&gt;Add a rule that tells Builder:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;when API tests are required;&lt;/li&gt;
&lt;li&gt;which Apidog command to run;&lt;/li&gt;
&lt;li&gt;how to interpret the exit code;&lt;/li&gt;
&lt;li&gt;how to handle authentication and unknown flags.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## API testing with the Apidog CLI&lt;/span&gt;

When you change code that touches an API endpoint, verify it by running the
Apidog test scenario, not just the unit tests.

Command:
  apidog run -t &lt;span class="nt"&gt;&amp;lt;scenario_id&amp;gt;&lt;/span&gt; -e &lt;span class="nt"&gt;&amp;lt;env_id&amp;gt;&lt;/span&gt; -r cli

Rules:
&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="sb"&gt;`apidog run`&lt;/span&gt; exits 0 when every assertion passes and non-zero on any failure.
  Treat a non-zero exit code as a failing test, even if the summary looks fine.
&lt;span class="p"&gt;-&lt;/span&gt; This machine is already authenticated via &lt;span class="sb"&gt;`apidog login`&lt;/span&gt;. Never add an
  --access-token flag and never put a token in this file.
&lt;span class="p"&gt;-&lt;/span&gt; If a flag is unknown, run &lt;span class="sb"&gt;`apidog run --help`&lt;/span&gt; and use the exact flag from there.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Commit this file with the repository. Unlike a scenario ID pasted into chat, project rules remain available for every teammate and every future Builder session.&lt;/p&gt;

&lt;p&gt;For monorepos, Trae can also read &lt;code&gt;.trae/rules/&lt;/code&gt; folders in subdirectories, allowing each service to keep its own API test command close to its code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Copy the real scenario command from Apidog
&lt;/h2&gt;

&lt;p&gt;Do not manually guess scenario or environment IDs.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your test scenario in &lt;a href="https://apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Open the &lt;strong&gt;CI/CD&lt;/strong&gt; tab.&lt;/li&gt;
&lt;li&gt;Copy the generated &lt;code&gt;apidog run&lt;/code&gt; command.&lt;/li&gt;
&lt;li&gt;Paste its &lt;code&gt;-t&lt;/code&gt; scenario ID and &lt;code&gt;-e&lt;/code&gt; environment ID into &lt;code&gt;project_rules.md&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;Command:
  apidog run -t your_scenario_id -e your_environment_id -r cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using the generated command avoids errors caused by invented or stale IDs. For available options, see &lt;a href="http://apidog.com/blog/apidog-run-command-reference?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;the &lt;code&gt;apidog run&lt;/code&gt; command reference&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Run the scenario with Builder
&lt;/h2&gt;

&lt;p&gt;Switch Trae to &lt;strong&gt;Builder&lt;/strong&gt; mode and open your repository. Builder loads &lt;code&gt;project_rules.md&lt;/code&gt; during initialization.&lt;/p&gt;

&lt;p&gt;After changing API-related code, ask Builder to run the check:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Run the Apidog test scenario and tell me the exit code.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Builder should use the command from your rules file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="nt"&gt;-t&lt;/span&gt; &amp;lt;scenario_id&amp;gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &amp;lt;env_id&amp;gt; &lt;span class="nt"&gt;-r&lt;/span&gt; cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Trae requires approval before Builder executes shell commands. Review the proposed command and click &lt;strong&gt;Run&lt;/strong&gt;. Once it completes, Builder can read the terminal output and use the result in its next step.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;-r cli&lt;/code&gt; reporter is useful for agent workflows because it prints request-by-request results and a summary directly in the terminal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Read failures in the terminal
&lt;/h2&gt;

&lt;p&gt;When a scenario fails, &lt;code&gt;-r cli&lt;/code&gt; provides Builder with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;each request that ran;&lt;/li&gt;
&lt;li&gt;each assertion;&lt;/li&gt;
&lt;li&gt;expected and actual values for failures;&lt;/li&gt;
&lt;li&gt;the final exit code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This gives Builder concrete debugging context. For example, a failed assertion can identify a wrong status code, a missing response field, or an unexpected value.&lt;/p&gt;

&lt;p&gt;To also generate a browser-friendly report, add the HTML reporter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="nt"&gt;-t&lt;/span&gt; &amp;lt;scenario_id&amp;gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &amp;lt;env_id&amp;gt; &lt;span class="nt"&gt;-r&lt;/span&gt; cli,html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep &lt;code&gt;cli&lt;/code&gt; enabled so Builder can still read inline terminal output. The &lt;code&gt;html&lt;/code&gt; reporter writes a self-contained report to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./apidog-reports
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For JSON, JUnit, and other report formats, see &lt;a href="http://apidog.com/blog/apidog-cli-test-reports?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;the guide to Apidog CLI test reports&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Put API tests inside Builder’s edit-test-fix loop
&lt;/h2&gt;

&lt;p&gt;The goal is not just running a command manually. The goal is making API validation part of Builder’s normal workflow.&lt;/p&gt;

&lt;p&gt;For example, when Builder edits a checkout handler, the loop becomes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Edit the handler.&lt;/li&gt;
&lt;li&gt;Run the Apidog scenario against the configured environment.&lt;/li&gt;
&lt;li&gt;Read the exit code and failed assertions.&lt;/li&gt;
&lt;li&gt;Fix the implementation if the run fails.&lt;/li&gt;
&lt;li&gt;Re-run the scenario.&lt;/li&gt;
&lt;li&gt;Continue only after the scenario passes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A green run lets Builder move on. A red run gives it request and assertion details to investigate. Your API scenario becomes a test gate alongside unit tests.&lt;/p&gt;

&lt;p&gt;You still author and maintain scenarios visually in &lt;a href="https://apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog&lt;/a&gt;, while Builder executes them from the repository workflow. For more on this pattern, see &lt;a href="http://apidog.com/blog/ai-agents-api-testing?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;how to use AI agents for API testing&lt;/a&gt; and &lt;a href="http://apidog.com/blog/ai-agent-apidog-test-harness?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;the Apidog AI test harness&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Verify that Trae actually ran the CLI
&lt;/h2&gt;

&lt;p&gt;Do not rely only on Builder’s summary. Verify the command and its result.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Check that &lt;code&gt;apidog run&lt;/code&gt; appears in the terminal
&lt;/h3&gt;

&lt;p&gt;Trae shows the commands Builder executed and their output. Look for the literal &lt;code&gt;apidog run&lt;/code&gt; command and its resulting output.&lt;/p&gt;

&lt;p&gt;If Builder claims it ran tests but no command appears in the terminal, ask it to run the scenario again and show the raw output.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Check the exit code
&lt;/h3&gt;

&lt;p&gt;Ask:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;What was the exit code of that apidog run command?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;apidog run&lt;/code&gt; exits with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;0&lt;/code&gt; when every assertion passes;&lt;/li&gt;
&lt;li&gt;a non-zero code when any assertion fails.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Treat the exit code as the source of truth. If Builder says “tests passed” but the process exited non-zero, the test failed.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Verify the scenario and environment IDs
&lt;/h3&gt;

&lt;p&gt;If the CLI reports that a scenario cannot be found, Builder may be using an incorrect ID.&lt;/p&gt;

&lt;p&gt;Compare the command in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.trae/rules/project_rules.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;with the command generated in Apidog’s &lt;strong&gt;CI/CD&lt;/strong&gt; tab. Verify both:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nt"&gt;-t&lt;/span&gt; &amp;lt;scenario_id&amp;gt;
&lt;span class="nt"&gt;-e&lt;/span&gt; &amp;lt;environment_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The IDs stored in your project rules should match the generated Apidog command.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optional: Connect the Apidog MCP server
&lt;/h2&gt;

&lt;p&gt;The CLI is enough for running API tests. An MCP server adds specification context while Builder writes code.&lt;/p&gt;

&lt;p&gt;Trae agents can act as MCP clients. To connect a server:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open Trae settings.&lt;/li&gt;
&lt;li&gt;Go to the &lt;strong&gt;MCP&lt;/strong&gt; tab.&lt;/li&gt;
&lt;li&gt;Choose a marketplace server or select &lt;strong&gt;Add Manually&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Provide the server JSON configuration with &lt;code&gt;command&lt;/code&gt;, &lt;code&gt;args&lt;/code&gt;, and &lt;code&gt;env&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;See &lt;a href="https://docs.trae.ai/ide/add-mcp-servers" rel="noopener noreferrer"&gt;Trae’s guide to adding MCP servers&lt;/a&gt; for the configuration flow.&lt;/p&gt;

&lt;p&gt;The &lt;a href="http://apidog.com/blog/apidog-mcp-server?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog MCP server&lt;/a&gt; exposes API specifications over MCP. This creates a useful separation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Apidog CLI&lt;/strong&gt; runs test scenarios.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Apidog MCP server&lt;/strong&gt; gives Builder access to API specifications.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Troubleshooting common setup failures
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Builder ignores the rules file
&lt;/h3&gt;

&lt;p&gt;Confirm the path is exactly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.trae/rules/project_rules.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The directory must be named &lt;code&gt;rules&lt;/code&gt;, not &lt;code&gt;rule&lt;/code&gt;, and the file must be under the repository root. Restart the Builder session to force Trae to reload project rules.&lt;/p&gt;

&lt;h3&gt;
  
  
  Builder adds &lt;code&gt;--access-token&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;If Builder tries to add an access token, it is likely copying a public example instead of following your rules.&lt;/p&gt;

&lt;p&gt;Keep this instruction in &lt;code&gt;project_rules.md&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;This machine is already authenticated via &lt;span class="sb"&gt;`apidog login`&lt;/span&gt;. Never add an
--access-token flag and never put a token in this file.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do not store real tokens in the repository. For interactive and CI authentication details, see &lt;a href="http://apidog.com/blog/apidog-cli-authentication?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog CLI authentication&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Builder invents a CLI flag
&lt;/h3&gt;

&lt;p&gt;An “unknown option” error means the installed CLI version does not support the flag Builder used.&lt;/p&gt;

&lt;p&gt;Have it run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="nt"&gt;--help&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then update the command or rule using the exact syntax reported by your installed version.&lt;/p&gt;

&lt;h3&gt;
  
  
  Builder reports success after a failed run
&lt;/h3&gt;

&lt;p&gt;Always check the process exit code. If the terminal summary and exit code appear to disagree, treat the non-zero exit code as a failure.&lt;/p&gt;

&lt;p&gt;That is why the exit-code rule belongs in &lt;code&gt;project_rules.md&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  From daily agent usage to a tested workflow
&lt;/h2&gt;

&lt;p&gt;The implementation is straightforward:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install and authenticate &lt;code&gt;apidog-cli&lt;/code&gt; using &lt;a href="http://apidog.com/blog/apidog-cli-installation-guide?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;the install guide&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Create &lt;code&gt;.trae/rules/project_rules.md&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Paste the real &lt;code&gt;apidog run&lt;/code&gt; scenario command from Apidog.&lt;/li&gt;
&lt;li&gt;Require Builder to treat non-zero exit codes as failed tests.&lt;/li&gt;
&lt;li&gt;Verify the command and exit code in Trae’s terminal.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Your API scenarios remain visual and maintainable in &lt;a href="https://apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog&lt;/a&gt;, while Builder can execute them during implementation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/download?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Download Apidog&lt;/a&gt;, create a scenario, add its &lt;code&gt;apidog run&lt;/code&gt; command to your project rules, and use it as part of Builder’s next API change. To run the same scenario in CI, see &lt;a href="http://apidog.com/blog/apidog-cli-github-actions?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog CLI in GitHub Actions&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Use the Apidog CLI in Windsurf</title>
      <dc:creator>Hassann</dc:creator>
      <pubDate>Tue, 14 Jul 2026 05:47:56 +0000</pubDate>
      <link>https://dev.to/hassann/how-to-use-the-apidog-cli-in-windsurf-2cfp</link>
      <guid>https://dev.to/hassann/how-to-use-the-apidog-cli-in-windsurf-2cfp</guid>
      <description>&lt;h1&gt;
  
  
  Run Apidog API Tests in Windsurf Cascade
&lt;/h1&gt;

&lt;p&gt;Windsurf’s Cascade agent already follows an edit-test-fix loop: it changes files, runs commands, reads output, and decides what to do next. Add your Apidog API test scenario to that loop so Cascade can run it from the terminal, inspect the exit code, and react to failures instead of leaving tests behind a GUI.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation" class="crayons-btn crayons-btn--primary"&gt;Try Apidog today&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;Install the &lt;code&gt;apidog-cli&lt;/code&gt; npm package, authenticate once, and add a project rule that tells Cascade which scenario to run. Cascade can then execute &lt;code&gt;apidog run&lt;/code&gt; alongside your existing unit-test commands.&lt;/p&gt;

&lt;p&gt;Before continuing, verify that the CLI is installed and authenticated:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you need setup instructions, see &lt;a href="http://apidog.com/blog/apidog-cli-installation-guide?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;How to install the Apidog CLI with an AI coding agent&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which Windsurf setup this applies to
&lt;/h2&gt;

&lt;p&gt;This guide is for Codeium’s Windsurf IDE and its built-in Cascade agent. Cascade runs locally, can read your repository, edit files, and execute shell commands in the integrated terminal. Depending on your auto-execution settings, it may ask for command approval.&lt;/p&gt;

&lt;p&gt;If Windsurf is not installed yet, start with &lt;a href="http://apidog.com/blog/download-install-windsurf?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;how to download and install Windsurf&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Add an Apidog rule to &lt;code&gt;.windsurf/rules&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Cascade loads project rules from Markdown files in &lt;code&gt;.windsurf/rules/&lt;/code&gt; at the repository root. Put one rule per file.&lt;/p&gt;

&lt;p&gt;Windsurf also supports the legacy &lt;code&gt;.windsurfrules&lt;/code&gt; file at the workspace root and global rules in &lt;code&gt;~/.codeium/windsurf/memories/global_rules.md&lt;/code&gt;. For a repository-specific test command, use &lt;code&gt;.windsurf/rules/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;See the &lt;a href="https://docs.windsurf.com/windsurf/cascade/memories" rel="noopener noreferrer"&gt;Windsurf rules and memories reference&lt;/a&gt; for the current behavior.&lt;/p&gt;

&lt;p&gt;Create this file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.windsurf/rules/apidog.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Apidog API tests&lt;/span&gt;

This project has Apidog test scenarios. Run them with the Apidog CLI:&lt;span class="sb"&gt;

    apidog run -t &amp;lt;scenario_id&amp;gt; -e &amp;lt;env_id&amp;gt; -r cli

&lt;/span&gt;Rules:
&lt;span class="p"&gt;-&lt;/span&gt; Use the exact command above; do not invent flags. Run &lt;span class="sb"&gt;`apidog run --help`&lt;/span&gt; if unsure.
&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="sb"&gt;`apidog run`&lt;/span&gt; exits 0 when every assertion passes, non-zero when any fails.
  Treat exit 0 as pass and non-zero as fail. Report the real exit code.
&lt;span class="p"&gt;-&lt;/span&gt; The machine is already authenticated via &lt;span class="sb"&gt;`apidog login`&lt;/span&gt;. Never add an
  access token to the command or commit one to this file.
&lt;span class="p"&gt;-&lt;/span&gt; After you change code that touches the API, run the scenario and act on the result.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A rule file is more reliable than a chat instruction:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It persists across Cascade sessions.&lt;/li&gt;
&lt;li&gt;It is shared with teammates through Git.&lt;/li&gt;
&lt;li&gt;Cascade loads it automatically when it starts in the repository.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 2: Copy the real command from Apidog
&lt;/h2&gt;

&lt;p&gt;Do not guess the &lt;code&gt;&amp;lt;scenario_id&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;env_id&amp;gt;&lt;/code&gt; values.&lt;/p&gt;

&lt;p&gt;In Apidog:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the test scenario.&lt;/li&gt;
&lt;li&gt;Open the &lt;strong&gt;CI/CD&lt;/strong&gt; tab.&lt;/li&gt;
&lt;li&gt;Copy the generated &lt;code&gt;apidog run&lt;/code&gt; command.&lt;/li&gt;
&lt;li&gt;Replace the example command in &lt;code&gt;.windsurf/rules/apidog.md&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The generated command includes the correct scenario ID, environment ID, and reporter options for your project.&lt;/p&gt;

&lt;p&gt;For available options, see the &lt;a href="http://apidog.com/blog/apidog-run-command-reference?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;apidog run command reference&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Ask Cascade to run the scenario
&lt;/h2&gt;

&lt;p&gt;Open Cascade in the repository after adding the rule. It should load &lt;code&gt;.windsurf/rules/apidog.md&lt;/code&gt; automatically.&lt;/p&gt;

&lt;p&gt;You can make an API-related code change, then ask:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Run the Apidog scenario and tell me the exit code.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cascade should execute the exact &lt;code&gt;apidog run&lt;/code&gt; command defined in the rule.&lt;/p&gt;

&lt;p&gt;Whether Cascade runs it immediately depends on your auto-execution mode:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Disabled&lt;/strong&gt;: every command needs approval.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Allowlist Only&lt;/strong&gt;: only allowlisted commands run automatically.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto&lt;/strong&gt;: execution is based on a premium-model judgment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Turbo&lt;/strong&gt;: commands run automatically unless denylisted.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To allow Apidog commands without enabling broader automatic execution, add &lt;code&gt;apidog&lt;/code&gt; to the &lt;code&gt;windsurf.cascadeCommandsAllowList&lt;/code&gt; setting.&lt;/p&gt;

&lt;p&gt;You can open settings through the Command Palette and configure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"windsurf.cascadeCommandsAllowList"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"apidog"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The matching denylist setting is &lt;code&gt;windsurf.cascadeCommandsDenyList&lt;/code&gt;. If a command matches both lists, the denylist takes precedence.&lt;/p&gt;

&lt;p&gt;See &lt;a href="https://docs.windsurf.com/windsurf/terminal" rel="noopener noreferrer"&gt;Windsurf’s terminal documentation&lt;/a&gt; for details.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Read failures in Cascade’s terminal
&lt;/h2&gt;

&lt;p&gt;Use the CLI reporter so Cascade can inspect test output directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="nt"&gt;-t&lt;/span&gt; &amp;lt;scenario_id&amp;gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &amp;lt;env_id&amp;gt; &lt;span class="nt"&gt;-r&lt;/span&gt; cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;cli&lt;/code&gt; reporter prints each request, assertion result, and summary in the terminal. When a test fails, Cascade can use the failed status code, field, expected value, or actual value to identify the next code change.&lt;/p&gt;

&lt;p&gt;To also generate a browser-friendly report, add the HTML reporter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="nt"&gt;-t&lt;/span&gt; &amp;lt;scenario_id&amp;gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &amp;lt;env_id&amp;gt; &lt;span class="nt"&gt;-r&lt;/span&gt; cli,html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;html&lt;/code&gt; reporter writes a self-contained report to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./apidog-reports
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep &lt;code&gt;cli&lt;/code&gt; enabled so Cascade still receives inline output.&lt;/p&gt;

&lt;p&gt;For all supported report formats, including JUnit output for CI systems, see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://apidog.com/blog/apidog-cli-complete-guide?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;The complete Apidog CLI guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://apidog.com/blog/apidog-cli-test-reports?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;How to read Apidog CLI test reports&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Put API testing inside Cascade’s loop
&lt;/h2&gt;

&lt;p&gt;Once the rule is in place, Cascade can follow the same workflow it uses for unit tests:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Edit an API handler or service.&lt;/li&gt;
&lt;li&gt;Run the Apidog scenario against the configured environment.&lt;/li&gt;
&lt;li&gt;Read the terminal output and exit code.&lt;/li&gt;
&lt;li&gt;Fix the reported failure.&lt;/li&gt;
&lt;li&gt;Run the scenario again.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For example, if Cascade changes a checkout response handler, your scenario can detect a missing field, incorrect value, or wrong HTTP status before the agent considers the task complete.&lt;/p&gt;

&lt;p&gt;The CLI provides the verification step. You still author and maintain scenarios visually in &lt;a href="https://apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog&lt;/a&gt;, while Cascade executes those scenarios during implementation.&lt;/p&gt;

&lt;p&gt;For the broader agent-testing pattern, see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://apidog.com/blog/ai-agents-api-testing?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;How to use AI agents for API testing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://apidog.com/blog/ai-agent-apidog-test-harness?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;The Apidog AI test harness&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Verify that Cascade actually ran the CLI
&lt;/h2&gt;

&lt;p&gt;Do not rely only on Cascade’s summary. Verify the command and result.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Confirm the command was executed
&lt;/h3&gt;

&lt;p&gt;Look for the literal command and its output in Cascade’s terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If Cascade says tests ran but there is no command output, ask it to rerun the scenario and show the raw terminal result.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Confirm the exit code
&lt;/h3&gt;

&lt;p&gt;Ask Cascade directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;What was the exit code of that apidog run command?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;apidog run&lt;/code&gt; returns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;0&lt;/code&gt; when all assertions pass&lt;/li&gt;
&lt;li&gt;A non-zero exit code when an assertion fails&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Treat the exit code as the source of truth. If Cascade says “tests passed” but the command exited with a non-zero status, the test failed.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Confirm the scenario and environment IDs
&lt;/h3&gt;

&lt;p&gt;If the CLI reports that a scenario cannot be found, Cascade may be using an incorrect ID.&lt;/p&gt;

&lt;p&gt;Compare the &lt;code&gt;-t&lt;/code&gt; and &lt;code&gt;-e&lt;/code&gt; values in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;.windsurf/rules/apidog.md&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;The command generated in Apidog’s &lt;strong&gt;CI/CD&lt;/strong&gt; tab&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use the generated command as the canonical source.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optional: Connect the Apidog MCP server
&lt;/h2&gt;

&lt;p&gt;The rule-based CLI workflow is enough to run tests. If you also want Cascade to access API specifications while writing code, connect an MCP server.&lt;/p&gt;

&lt;p&gt;Windsurf supports Model Context Protocol servers through:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/.codeium/windsurf/mcp_config.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can edit that file directly or configure servers through Cascade’s MCP panel. See the &lt;a href="https://docs.windsurf.com/windsurf/cascade/mcp" rel="noopener noreferrer"&gt;Windsurf MCP reference&lt;/a&gt; and &lt;a href="http://apidog.com/blog/windsurf-mcp-servers?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;how to set up MCP servers in Windsurf&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;a href="http://apidog.com/blog/apidog-mcp-server?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog MCP server&lt;/a&gt; exposes API specifications to MCP-compatible agents.&lt;/p&gt;

&lt;p&gt;Use the two integrations for different jobs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Apidog CLI&lt;/strong&gt;: run API test scenarios and return pass/fail results.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Apidog MCP server&lt;/strong&gt;: provide API schemas and specifications as context while Cascade writes code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Troubleshooting common setup issues
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Cascade ignores the rule
&lt;/h3&gt;

&lt;p&gt;Check that the file:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is located at &lt;code&gt;.windsurf/rules/apidog.md&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Is inside the repository root&lt;/li&gt;
&lt;li&gt;Uses the &lt;code&gt;.md&lt;/code&gt; extension&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each rule file is capped at 12,000 characters, so keep the rule focused. Restart Cascade to force it to reload project rules.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cascade adds an access token
&lt;/h3&gt;

&lt;p&gt;Do not put tokens in a committed rules file.&lt;/p&gt;

&lt;p&gt;Your rule should explicitly state that the machine is already authenticated with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If Cascade still tries to add a token, reinforce that instruction and have it use the existing authenticated CLI session.&lt;/p&gt;

&lt;p&gt;See the &lt;a href="http://apidog.com/blog/apidog-cli-authentication?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog CLI authentication guide&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cascade invents a CLI flag
&lt;/h3&gt;

&lt;p&gt;If the command fails with an “unknown option” error, tell Cascade to inspect the installed CLI version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="nt"&gt;--help&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then update the rule with the supported command syntax.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cascade reports success after a failed run
&lt;/h3&gt;

&lt;p&gt;Use the exit code, not the summary text.&lt;/p&gt;

&lt;p&gt;If the command exits non-zero, the scenario failed and should be treated as a failed gate.&lt;/p&gt;

&lt;h2&gt;
  
  
  From agent assistance to a tested loop
&lt;/h2&gt;

&lt;p&gt;The setup is small:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install &lt;code&gt;apidog-cli&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Authenticate with &lt;code&gt;apidog login&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Add the generated &lt;code&gt;apidog run&lt;/code&gt; command to &lt;code&gt;.windsurf/rules/apidog.md&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Tell Cascade to run the scenario after API changes.&lt;/li&gt;
&lt;li&gt;Validate the terminal output and exit code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Your API tests no longer depend on someone opening a GUI and clicking Run. You continue building scenarios visually in &lt;a href="https://apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog&lt;/a&gt;, while Cascade can execute the same scenarios as part of its local development loop.&lt;/p&gt;

&lt;p&gt;When the command works locally, use it in CI as well. See &lt;a href="http://apidog.com/blog/apidog-cli-github-actions?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog CLI in GitHub Actions&lt;/a&gt; for secrets, reporters, and exit-code gating.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/download?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Download Apidog&lt;/a&gt;, create a scenario, add its generated command to a Windsurf rule, and let Cascade run it on the next API change.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Use the Apidog CLI in Antigravity</title>
      <dc:creator>Hassann</dc:creator>
      <pubDate>Tue, 14 Jul 2026 05:47:26 +0000</pubDate>
      <link>https://dev.to/hassann/how-to-use-the-apidog-cli-in-antigravity-pd8</link>
      <guid>https://dev.to/hassann/how-to-use-the-apidog-cli-in-antigravity-pd8</guid>
      <description>&lt;p&gt;Antigravity is a loop: its agent edits files, runs terminal commands, reads output, and decides what to do next. Your API tests should be part of that loop too. Instead of leaving scenarios in the Apidog GUI until someone manually clicks Run, expose them through the &lt;code&gt;apidog-cli&lt;/code&gt; package and let the agent execute them like any other test command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apidog.com/?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation" class="crayons-btn crayons-btn--primary"&gt;Try Apidog today&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;The setup is one rules-file block. Once &lt;code&gt;apidog-cli&lt;/code&gt; is installed and Antigravity knows the command, it can run an Apidog scenario, inspect its exit code, and iterate on failing code.&lt;/p&gt;

&lt;p&gt;Before continuing, make sure the CLI is installed and authenticated:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you still need setup help, follow &lt;a href="http://apidog.com/blog/apidog-cli-installation-guide?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;How to install the Apidog CLI with an AI coding agent&lt;/a&gt;. This guide assumes &lt;code&gt;apidog --version&lt;/code&gt; prints a version number and &lt;code&gt;apidog login&lt;/code&gt; has already authenticated the machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which Antigravity this is about
&lt;/h2&gt;

&lt;p&gt;Antigravity is Google’s agentic development platform, built on Gemini 3, that launched in late 2025. Its Agent Manager can plan work, edit repository files, execute shell commands, and use a browser.&lt;/p&gt;

&lt;p&gt;If you have started an Antigravity task and watched the agent run commands in its terminal, this workflow applies to you. For a broader introduction, see &lt;a href="http://apidog.com/blog/google-antigravity?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;what Google Antigravity is and how to use it&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The key detail is that Antigravity can load project rules. Put your API test command in those rules, and the agent can use it consistently instead of relying on a one-off chat instruction.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Add an Antigravity rules file
&lt;/h2&gt;

&lt;p&gt;Antigravity recognizes a &lt;code&gt;.agents/&lt;/code&gt; directory at the workspace root. Google’s codelab on &lt;a href="https://codelabs.developers.google.com/autonomous-ai-developer-pipelines-antigravity" rel="noopener noreferrer"&gt;building autonomous developer pipelines in Antigravity&lt;/a&gt; shows workspace rules placed in &lt;code&gt;.agents/rules/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Create this file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.agents/rules/apidog.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, Antigravity can read an &lt;code&gt;AGENTS.md&lt;/code&gt; file at the workspace root. This is also the file &lt;a href="http://apidog.com/blog/apidog-cli-in-codex?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Codex reads for the Apidog CLI&lt;/a&gt;. If your repository already uses &lt;code&gt;AGENTS.md&lt;/code&gt;, keep the instruction there instead of duplicating it.&lt;/p&gt;

&lt;p&gt;Add a short, explicit rule block:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## API testing with the Apidog CLI&lt;/span&gt;
&lt;span class="p"&gt;
-&lt;/span&gt; To test the API, run the Apidog scenario. Do not click through the GUI.
&lt;span class="p"&gt;-&lt;/span&gt; Command: apidog run -t &lt;span class="nt"&gt;&amp;lt;scenario_id&amp;gt;&lt;/span&gt; -e &lt;span class="nt"&gt;&amp;lt;env_id&amp;gt;&lt;/span&gt; -r cli
&lt;span class="p"&gt;-&lt;/span&gt; Exit code 0 means every assertion passed.
&lt;span class="p"&gt;-&lt;/span&gt; A non-zero exit code means a failure: inspect the report and fix the code.
&lt;span class="p"&gt;-&lt;/span&gt; This machine is already authenticated via &lt;span class="sb"&gt;`apidog login`&lt;/span&gt;.
&lt;span class="p"&gt;-&lt;/span&gt; Never add an &lt;span class="sb"&gt;`--access-token`&lt;/span&gt; flag or put a token in this file.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep this instruction in the repository rather than in chat. Antigravity does not retain ad hoc coaching across sessions, but workspace rules are available to every new task and teammate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Copy the generated command from Apidog
&lt;/h2&gt;

&lt;p&gt;Do not guess scenario or environment IDs.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the test scenario in Apidog.&lt;/li&gt;
&lt;li&gt;Open the &lt;strong&gt;CI/CD&lt;/strong&gt; tab.&lt;/li&gt;
&lt;li&gt;Copy the generated CLI command.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It should look similar to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="nt"&gt;-t&lt;/span&gt; 123456 &lt;span class="nt"&gt;-e&lt;/span&gt; 789012 &lt;span class="nt"&gt;-r&lt;/span&gt; cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The flags are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-t&lt;/code&gt;: test scenario ID&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-e&lt;/code&gt;: environment ID&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-r cli&lt;/code&gt;: print results directly in the terminal&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Paste the real command into &lt;code&gt;.agents/rules/apidog.md&lt;/code&gt; or &lt;code&gt;AGENTS.md&lt;/code&gt;. This gives Antigravity a stable, exact command to run.&lt;/p&gt;

&lt;p&gt;For the available options, see the &lt;a href="http://apidog.com/blog/apidog-run-command-reference?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;apidog run command reference&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Ask Antigravity to run the scenario
&lt;/h2&gt;

&lt;p&gt;Start an Antigravity task after adding the rules file. The agent loads the project rules when it begins.&lt;/p&gt;

&lt;p&gt;You can explicitly request the check:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Run the Apidog test scenario and tell me the exit code.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The agent should execute the &lt;code&gt;apidog run&lt;/code&gt; command from your rules file in its terminal.&lt;/p&gt;

&lt;p&gt;Whether Antigravity asks for approval depends on its Security Preset. Google describes these terminal and file-access controls in its &lt;a href="https://codelabs.developers.google.com/getting-started-google-antigravity" rel="noopener noreferrer"&gt;getting started with Antigravity codelab&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If Antigravity requests approval, review the command before allowing it to run. A read-only test scenario against staging is usually an appropriate in-workspace command to approve.&lt;/p&gt;

&lt;p&gt;The important outcome is not a summary such as “tests passed.” You want to see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the literal &lt;code&gt;apidog run ...&lt;/code&gt; command;&lt;/li&gt;
&lt;li&gt;the CLI output;&lt;/li&gt;
&lt;li&gt;the final exit code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 4: Read failures from the terminal report
&lt;/h2&gt;

&lt;p&gt;With &lt;code&gt;-r cli&lt;/code&gt;, Apidog prints a readable test result directly in the terminal. Antigravity can inspect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;requests that ran;&lt;/li&gt;
&lt;li&gt;assertions that passed or failed;&lt;/li&gt;
&lt;li&gt;expected and actual values;&lt;/li&gt;
&lt;li&gt;failing status codes or fields.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That output gives the agent enough context to locate the affected handler, request mapping, or response field and attempt a fix.&lt;/p&gt;

&lt;p&gt;For a browser-readable artifact, add the HTML reporter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="nt"&gt;-t&lt;/span&gt; 123456 &lt;span class="nt"&gt;-e&lt;/span&gt; 789012 &lt;span class="nt"&gt;-r&lt;/span&gt; cli,html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;html&lt;/code&gt; reporter writes a self-contained report to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./apidog-reports
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep &lt;code&gt;cli&lt;/code&gt; in the reporter list. Antigravity needs inline terminal output to evaluate the result and decide its next step.&lt;/p&gt;

&lt;p&gt;For more report formats, including JUnit for CI systems, see the &lt;a href="http://apidog.com/blog/apidog-cli-complete-guide?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;complete Apidog CLI guide&lt;/a&gt; and &lt;a href="http://apidog.com/blog/apidog-cli-test-reports?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;how to read Apidog CLI test reports&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Put API tests inside the agent loop
&lt;/h2&gt;

&lt;p&gt;Once the command is in the rules file, API testing becomes part of the agent’s normal edit-test-fix cycle.&lt;/p&gt;

&lt;p&gt;For example, an agent updates a checkout response handler:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It edits the handler.&lt;/li&gt;
&lt;li&gt;It runs the Apidog scenario against staging.&lt;/li&gt;
&lt;li&gt;It reads the exit code.&lt;/li&gt;
&lt;li&gt;If the run is green, it continues.&lt;/li&gt;
&lt;li&gt;If the run is red, it reads the failed assertion.&lt;/li&gt;
&lt;li&gt;It fixes the response, status code, or missing field.&lt;/li&gt;
&lt;li&gt;It runs the scenario again.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The API scenario now behaves like a unit-test gate, but it validates the real API behavior defined in Apidog.&lt;/p&gt;

&lt;p&gt;This follows a delegate-then-verify workflow: Antigravity executes the command and interprets the result, while you continue authoring and maintaining scenarios visually in Apidog. For related patterns, see &lt;a href="http://apidog.com/blog/ai-agents-api-testing?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;how to use AI agents for API testing&lt;/a&gt; and &lt;a href="http://apidog.com/blog/ai-agent-apidog-test-harness?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;the Apidog AI test harness&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Verify Antigravity actually ran the CLI
&lt;/h2&gt;

&lt;p&gt;Do not rely only on the agent’s prose summary. Verify the run in three steps.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Confirm the command was executed
&lt;/h3&gt;

&lt;p&gt;Open Antigravity’s terminal output and look for the actual command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then confirm that CLI output appears below it.&lt;/p&gt;

&lt;p&gt;If the agent claims it ran tests but there is no command or output, ask it to rerun the scenario and show the raw terminal result.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Confirm the exit code
&lt;/h3&gt;

&lt;p&gt;Ask directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;What was the exit code of that apidog run command?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;apidog run&lt;/code&gt; exits with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;0&lt;/code&gt; when every assertion passes;&lt;/li&gt;
&lt;li&gt;a non-zero value when an assertion fails.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Treat the exit code as the source of truth. If the agent says “tests passed” but the command returned a non-zero exit code, the test run failed.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Confirm it used the correct scenario
&lt;/h3&gt;

&lt;p&gt;If the CLI reports “scenario not found,” verify the IDs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compare the &lt;code&gt;-t&lt;/code&gt; scenario ID with the command generated in Apidog.&lt;/li&gt;
&lt;li&gt;Compare the &lt;code&gt;-e&lt;/code&gt; environment ID with the selected Apidog environment.&lt;/li&gt;
&lt;li&gt;Confirm the same IDs are stored in your rules file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The generated command from Apidog is the authoritative source.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optional: Connect the Apidog MCP server
&lt;/h2&gt;

&lt;p&gt;The CLI is enough to run scenarios. Add MCP when you also want the agent to access API specifications while it writes code.&lt;/p&gt;

&lt;p&gt;Antigravity supports the Model Context Protocol. According to Google’s &lt;a href="https://codelabs.developers.google.com/getting-started-google-antigravity" rel="noopener noreferrer"&gt;getting started codelab&lt;/a&gt;, configure MCP servers in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$HOME/.gemini/config/mcp_config.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add your server under the &lt;code&gt;mcpServers&lt;/code&gt; object with its &lt;code&gt;command&lt;/code&gt;, &lt;code&gt;args&lt;/code&gt;, and &lt;code&gt;env&lt;/code&gt;, then refresh MCP from Antigravity settings.&lt;/p&gt;

&lt;p&gt;The &lt;a href="http://apidog.com/blog/apidog-mcp-server?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog MCP server&lt;/a&gt; exposes API specifications through MCP. Use the two integrations for different purposes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Apidog CLI&lt;/strong&gt;: run scenarios and enforce pass/fail results.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Apidog MCP server&lt;/strong&gt;: provide API schema context while the agent writes code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Troubleshooting common setup failures
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Antigravity ignores the rules file
&lt;/h3&gt;

&lt;p&gt;If the agent uses a generic command or does not run a test:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Confirm the file name and location.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;.agents/rules/apidog.md&lt;/code&gt; at the workspace root, or use root-level &lt;code&gt;AGENTS.md&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Start a fresh task so Antigravity reloads project rules.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The agent adds &lt;code&gt;--access-token&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The agent may infer this from public examples. Your rules should explicitly state that the machine is authenticated through:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do not store a token in &lt;code&gt;AGENTS.md&lt;/code&gt; or &lt;code&gt;.agents/rules/apidog.md&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For authentication details, see &lt;a href="http://apidog.com/blog/apidog-cli-authentication?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog CLI authentication&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  The agent invents a CLI flag
&lt;/h3&gt;

&lt;p&gt;If the CLI returns an “unknown option” error, have the agent check the locally installed version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="nt"&gt;--help&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use the flags printed by that command rather than a guessed flag.&lt;/p&gt;

&lt;h3&gt;
  
  
  The agent reports success after a failed run
&lt;/h3&gt;

&lt;p&gt;When the summary conflicts with the command result, the exit code wins. Keep the exit-code rule in your workspace instructions and require the agent to report it after every run.&lt;/p&gt;

&lt;h2&gt;
  
  
  From a daily agent to a tested loop
&lt;/h2&gt;

&lt;p&gt;Install &lt;code&gt;apidog-cli&lt;/code&gt; once using the &lt;a href="http://apidog.com/blog/apidog-cli-installation-guide?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;installation guide&lt;/a&gt;, then add the generated &lt;code&gt;apidog run&lt;/code&gt; command to your Antigravity rules file.&lt;/p&gt;

&lt;p&gt;From that point, Antigravity has a repeatable API test command it can run while changing code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apidog run &lt;span class="nt"&gt;-t&lt;/span&gt; &amp;lt;scenario_id&amp;gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &amp;lt;env_id&amp;gt; &lt;span class="nt"&gt;-r&lt;/span&gt; cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A test behind a GUI runs only when a person remembers to click it. A CLI command in the agent’s rules can run whenever Antigravity needs to verify an API change.&lt;/p&gt;

&lt;p&gt;Build scenarios visually in &lt;a href="https://apidog.com?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog&lt;/a&gt;, add the generated command to your rules file, and let the agent use it on the next API change. To run the same command in CI without an agent, see &lt;a href="http://apidog.com/blog/apidog-cli-github-actions?utm_source=dev.to&amp;amp;utm_medium=wanda&amp;amp;utm_content=n8n-post-automation"&gt;Apidog CLI in GitHub Actions&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
