{
  "mockstudioVersion": 1,
  "id": "6e8930bd-b599-5269-afbb-61b76428dae8",
  "name": "Flaky Payments (sample)",
  "description": "A payment API that fails on purpose, for resilience testing. From learn.dhivalabs.com.",
  "port": 4030,
  "corsEnabled": true,
  "proxyBaseUrl": "",
  "recordProxy": false,
  "globalDelayMs": 0,
  "globalHeaders": {},
  "endpoints": [
    {
      "id": "01e0e96b-b72b-5a9c-a23e-056cdc8aa95a",
      "name": "Charge a card",
      "method": "post",
      "path": "/payments",
      "enabled": true,
      "strategy": "random",
      "responses": [
        {
          "id": "00e20c4f-9a81-5088-9666-173fa64788d2",
          "label": "Approved",
          "statusCode": 201,
          "bodyType": "json",
          "body": "{\n  \"id\": \"pay_{{randomInt(10000,99999)}}\",\n  \"status\": \"approved\",\n  \"amount\": {{body.amount}}\n}",
          "headers": {},
          "conditions": [],
          "weight": 7,
          "delayMs": null,
          "fault": "none"
        },
        {
          "id": "f3f814e8-dad0-54c6-b3ec-2b885bf1f02c",
          "label": "Server error",
          "statusCode": 500,
          "bodyType": "json",
          "body": "{\n  \"error\": \"internal_error\",\n  \"message\": \"Something went wrong. Try again.\"\n}",
          "headers": {},
          "conditions": [],
          "weight": 2,
          "delayMs": null,
          "fault": "none"
        },
        {
          "id": "dd389a20-8d52-546a-9c4a-a060e1ca5e74",
          "label": "Busy",
          "statusCode": 503,
          "bodyType": "json",
          "body": "{\n  \"error\": \"service_unavailable\",\n  \"message\": \"Try again in 2 seconds\"\n}",
          "headers": {
            "Retry-After": "2"
          },
          "conditions": [],
          "weight": 1,
          "delayMs": null,
          "fault": "none"
        }
      ],
      "defaultDelayMs": 0,
      "jitterMs": 0,
      "requireAuth": false,
      "authHeader": "Authorization",
      "description": "Random: about 7 in 10 calls are approved, 2 fail with 500, 1 with 503."
    },
    {
      "id": "9948df81-e667-538f-8c49-cde1ae7eb6c1",
      "name": "Payment status",
      "method": "get",
      "path": "/payments/:id/status",
      "enabled": true,
      "strategy": "sequence",
      "responses": [
        {
          "id": "26b2943c-3c31-5fd6-990a-4770d40214d1",
          "label": "Pending (1st call)",
          "statusCode": 200,
          "bodyType": "json",
          "body": "{ \"id\": \"{{params.id}}\", \"status\": \"pending\" }",
          "headers": {},
          "conditions": [],
          "weight": 1,
          "delayMs": null,
          "fault": "none"
        },
        {
          "id": "de0dda4d-8c7f-5ef3-9027-a35513f0f794",
          "label": "Pending (2nd call)",
          "statusCode": 200,
          "bodyType": "json",
          "body": "{ \"id\": \"{{params.id}}\", \"status\": \"pending\" }",
          "headers": {},
          "conditions": [],
          "weight": 1,
          "delayMs": null,
          "fault": "none"
        },
        {
          "id": "6144663c-e789-5514-84f5-6f1e076c8795",
          "label": "Completed (3rd call)",
          "statusCode": 200,
          "bodyType": "json",
          "body": "{ \"id\": \"{{params.id}}\", \"status\": \"completed\" }",
          "headers": {},
          "conditions": [],
          "weight": 1,
          "delayMs": null,
          "fault": "none"
        }
      ],
      "defaultDelayMs": 0,
      "jitterMs": 0,
      "requireAuth": false,
      "authHeader": "Authorization",
      "description": "Sequence: pending, pending, completed, then round again. For testing polling."
    },
    {
      "id": "272b0c9a-ac16-5966-89c5-b6db9ff9c356",
      "name": "Rate limited",
      "method": "get",
      "path": "/rates",
      "enabled": true,
      "strategy": "sequence",
      "responses": [
        {
          "id": "733c7954-30c2-5f14-acb8-1727a361f699",
          "label": "OK (1st call)",
          "statusCode": 200,
          "bodyType": "json",
          "body": "{\n  \"usd\": 1.0,\n  \"eur\": 0.92\n}",
          "headers": {},
          "conditions": [],
          "weight": 1,
          "delayMs": null,
          "fault": "none"
        },
        {
          "id": "3706b0d8-1afd-5305-8af3-4bdc88186e74",
          "label": "OK (2nd call)",
          "statusCode": 200,
          "bodyType": "json",
          "body": "{\n  \"usd\": 1.0,\n  \"eur\": 0.92\n}",
          "headers": {},
          "conditions": [],
          "weight": 1,
          "delayMs": null,
          "fault": "none"
        },
        {
          "id": "903882b6-7bf7-58b4-adf6-3e99e0193e57",
          "label": "Too many requests (3rd call)",
          "statusCode": 429,
          "bodyType": "json",
          "body": "{\n  \"error\": \"rate_limited\",\n  \"message\": \"Slow down\"\n}",
          "headers": {
            "Retry-After": "1"
          },
          "conditions": [],
          "weight": 1,
          "delayMs": null,
          "fault": "none"
        }
      ],
      "defaultDelayMs": 0,
      "jitterMs": 0,
      "requireAuth": false,
      "authHeader": "Authorization",
      "description": "Every third call is refused with 429 and a Retry-After header."
    },
    {
      "id": "947c4eb0-3b54-54f3-97db-de6ec801e51a",
      "name": "Slow answer",
      "method": "get",
      "path": "/slow",
      "enabled": true,
      "strategy": "single",
      "responses": [
        {
          "id": "6d48d45f-f243-55a8-b70d-794ca00e5287",
          "label": "Slow but fine",
          "statusCode": 200,
          "bodyType": "json",
          "body": "{\n  \"status\": \"ok\",\n  \"note\": \"This answer was held back for 3 seconds\"\n}",
          "headers": {},
          "conditions": [],
          "weight": 1,
          "delayMs": null,
          "fault": "none"
        }
      ],
      "defaultDelayMs": 3000,
      "jitterMs": 0,
      "requireAuth": false,
      "authHeader": "Authorization",
      "description": "Waits 3 seconds before answering. For timeout and time-limit tests."
    },
    {
      "id": "945433c0-9df9-5251-b30e-69d2666a8bec",
      "name": "Wobbly answer",
      "method": "get",
      "path": "/wobbly",
      "enabled": true,
      "strategy": "single",
      "responses": [
        {
          "id": "6e6a9ce3-edc7-59c0-a697-7fc953263323",
          "label": "OK",
          "statusCode": 200,
          "bodyType": "json",
          "body": "{\n  \"status\": \"ok\"\n}",
          "headers": {},
          "conditions": [],
          "weight": 1,
          "delayMs": null,
          "fault": "none"
        }
      ],
      "defaultDelayMs": 100,
      "jitterMs": 900,
      "requireAuth": false,
      "authHeader": "Authorization",
      "description": "Takes between 0.1 and 1 second, at random."
    },
    {
      "id": "64aefe60-c1c2-5a09-9436-e04860dacf34",
      "name": "Broken JSON",
      "method": "get",
      "path": "/broken-json",
      "enabled": true,
      "strategy": "single",
      "responses": [
        {
          "id": "5b0733ce-89b9-5cb7-b8d3-6df20d107776",
          "label": "Malformed",
          "statusCode": 200,
          "bodyType": "json",
          "body": "{\n  \"status\": \"ok\"\n}",
          "headers": {},
          "conditions": [],
          "weight": 1,
          "delayMs": null,
          "fault": "malformedBody"
        }
      ],
      "defaultDelayMs": 0,
      "jitterMs": 0,
      "requireAuth": false,
      "authHeader": "Authorization",
      "description": "Answers with a body that is not valid JSON."
    },
    {
      "id": "7e953b81-9ccc-5a42-9cd8-074c01856699",
      "name": "Empty answer",
      "method": "get",
      "path": "/empty",
      "enabled": true,
      "strategy": "single",
      "responses": [
        {
          "id": "8bb969f8-6e2b-5625-b9a8-c1984dbb86b2",
          "label": "Empty",
          "statusCode": 200,
          "bodyType": "json",
          "body": "{\n  \"status\": \"ok\"\n}",
          "headers": {},
          "conditions": [],
          "weight": 1,
          "delayMs": null,
          "fault": "emptyResponse"
        }
      ],
      "defaultDelayMs": 0,
      "jitterMs": 0,
      "requireAuth": false,
      "authHeader": "Authorization",
      "description": "Answers 200 with no body at all."
    },
    {
      "id": "c8686b16-08e9-53f6-8b31-49a31786ef73",
      "name": "Dropped connection",
      "method": "get",
      "path": "/drop",
      "enabled": true,
      "strategy": "single",
      "responses": [
        {
          "id": "b9bb2339-a4e3-5522-a1cb-9aa87cbf4fb3",
          "label": "Dropped",
          "statusCode": 200,
          "bodyType": "json",
          "body": "{\n  \"status\": \"ok\"\n}",
          "headers": {},
          "conditions": [],
          "weight": 1,
          "delayMs": null,
          "fault": "connectionReset"
        }
      ],
      "defaultDelayMs": 0,
      "jitterMs": 0,
      "requireAuth": false,
      "authHeader": "Authorization",
      "description": "Closes the connection without answering."
    },
    {
      "id": "7e93b382-4276-50d8-9a2a-786b5aa52a3b",
      "name": "Never answers",
      "method": "get",
      "path": "/hang",
      "enabled": true,
      "strategy": "single",
      "responses": [
        {
          "id": "25bd4999-c238-5f8d-8a7f-bee9b1fe4807",
          "label": "Hang",
          "statusCode": 200,
          "bodyType": "json",
          "body": "{\n  \"status\": \"ok\"\n}",
          "headers": {},
          "conditions": [],
          "weight": 1,
          "delayMs": null,
          "fault": "hang"
        }
      ],
      "defaultDelayMs": 0,
      "jitterMs": 0,
      "requireAuth": false,
      "authHeader": "Authorization",
      "description": "Accepts the request and never answers. Your client must give up by itself."
    }
  ]
}
