{"type":"root","children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"What this solves"}]},{"type":"text","value":": Let you drill all kinds of failure scenarios without actually burning through your quota or waiting for a real outage."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Mock (drill) doesn't actually hit upstream. It makes Tare return errors that match the "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"shape"}]},{"type":"text","value":" of a real failure, following a specified script."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Why you need it"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The hardest branch to create on your own in a drill is the error branch. To really hit quota exhaustion, you'd have to spend all the money first; to really encounter an upstream failure, you can only wait for it to happen on its own, at a time you don't get to pick."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Attach a fixed scenario to a key, and requests made with that key return the simulated result directly, without actually reaching upstream. Not a single token is spent, and you don't have to wait for a real outage to occur."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"When to use Mock"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Before launch, verify how the client handles rate limiting, arrears, and quota exhaustion."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Verify the error copy that support or the frontend shows to end users."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Verify that retry logic only retries errors that should be retried."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Verify that monitoring and alerts can recognize failures."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Suggested drill order"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ol","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Start with a normal Mock response ("},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"SUCCESS"}]},{"type":"text","value":") to confirm the call path is controllable."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Drill 429 and confirm the client reads "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"Retry-After"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Drill quota exhaustion and arrears, and confirm it doesn't blindly retry."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Drill all upstreams down, and confirm both the frontend and alerts can recognize it."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Drill a DLP block, and confirm sensitive content isn't still being sent upstream."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Details"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{},"children":[{"type":"text","value":"Attaching a scenario"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Console path: "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"API Keys"}]},{"type":"text","value":" → the flask icon on a key."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can also call the API directly:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"curl -X PUT https://tare.jamerly.ai/v1/mocks/{apiKeyId} \\\n  -H \"Authorization: Bearer $TARE_KEY\" -H \"Content-Type: application/json\" \\\n  -d '{\"scenario\":\"UPSTREAM_TIMEOUT\",\"enabled\":true}'\n"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"warning"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"The scope is only the key you name, not the whole account."}]},{"type":"text","value":" When operating with management credentials, you can only touch the keys they own. Using a dedicated key for a drill won't turn your colleagues' production traffic into fake data."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{},"children":[{"type":"text","value":"Scenario list"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"GET /v1/mocks/scenarios"}]},{"type":"text","value":" gives the full list; "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"read it from here, don't hard-code it in the client"}]},{"type":"text","value":", because the list may grow:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"table","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"thead","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Scenario"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"What it simulates"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tbody","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"KEY_CREDIT_EXHAUSTED"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"This key's own spend limit is used up"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"BUDGET_EXHAUSTED"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"The account's monthly budget is used up"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"ACCOUNT_BALANCE_INSUFFICIENT"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"The account balance is exhausted"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"RATE_LIMITED"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Requests too frequent"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"UPSTREAM_TIMEOUT"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Upstream never responds"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"UPSTREAM_ERROR"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Upstream returns 5xx"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"INVALID_KEY"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"The credential is rejected"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"MODEL_NOT_FOUND"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"The requested model doesn't exist"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"BAD_REQUEST"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Malformed request"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"CONTENT_FILTERED"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Blocked by content policy"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"SUCCESS"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Normal response, with content specified by "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"you"}]},{"type":"text","value":" (see below)"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Every failure scenario returns an error of exactly the same shape Tare would give if it really happened. The point is to make your code take "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"the actual branch"}]},{"type":"text","value":", not an approximation of it."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"SUCCESS"}]},{"type":"text","value":": a fixed response, not a failure"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is the only non-failure scenario. Set "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"responseBody"}]},{"type":"text","value":" to the complete JSON you want; it is replayed as-is. Plain text is wrapped into a normal completion. Optionally add "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"delayMs"}]},{"type":"text","value":" to simulate latency. Good for testing the happy path: you get a stable, predictable output instead of a real model's varying answer."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{},"children":[{"type":"text","value":"Expiry"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A drill is supposed to be temporary: if you don't set "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"expiresAt"}]},{"type":"text","value":", by default it expires "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"4 hours"}]},{"type":"text","value":" after being enabled, and there's no \"permanent\" option."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"note"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A drill nobody remembers enabling, sitting on a credential that quietly became a production key, is far worse than the hassle of turning it on again."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{},"children":[{"type":"text","value":"What it doesn't affect"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Calls on other keys are unaffected."}]},{"type":"text","value":" A drill is a property attached to a key, not account-level."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Not a single token is consumed"}]},{"type":"text","value":"; a drill never actually reaches upstream."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Turning it off or deleting it takes effect from the next call"}]},{"type":"text","value":"; calls already in flight are unaffected."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{},"children":[{"type":"text","value":"A drill still leaves traces, and may be billed"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A drill call "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"always writes a usage record"}]},{"type":"text","value":", marked "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"MOCKED"}]},{"type":"text","value":", so whichever scenario it is, it doesn't count toward your success-rate statistics (a "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"SUCCESS"}]},{"type":"text","value":" scenario won't push it up, and a failure scenario won't pull it down)."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"It goes through "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"the same billing path as a real call"}]},{"type":"text","value":": token usage is always 0, but if the channel this model uses has a per-call minimum charge, that minimum charge is still collected. This call also has to pass the same three gates — balance, key limit, budget — as a real call. A key that has already exhausted its quota can't dodge the checks by turning on a drill and picking up a routing fee along the way."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"warning"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Turning the drill on and off also leaves traces."}]},{"type":"text","value":" Someone will eventually ask you to explain what happened during the period when production traffic quietly started returning fake data. See "},{"type":"element","tagName":"a","properties":{"href":"audit-trail"},"children":[{"type":"text","value":"Audit Trail"}]},{"type":"text","value":" for details."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Next steps"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"To see the real meaning of each error code: read "},{"type":"element","tagName":"a","properties":{"href":"errors"},"children":[{"type":"text","value":"Error codes"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"To learn how quota and budget are configured: read "},{"type":"element","tagName":"a","properties":{"href":"limits"},"children":[{"type":"text","value":"Rate limits and quotas"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"To know where changes on the account are recorded: read "},{"type":"element","tagName":"a","properties":{"href":"audit-trail"},"children":[{"type":"text","value":"Audit Trail"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"}]}]}