Change the address, not the request
An API call is just an HTTPS request to a base URL baked into the SDK.stripe.charges.create(...)
becomes POST https://api.stripe.com/v1/charges. That base URL is the only thing tying the call to
the vendor’s servers — the path, headers, body, and key are just data riding along.
So we don’t intercept in the wiretap sense. We point the SDK’s base URL at the sandbox, and every
call arrives at us instead, byte-for-byte unchanged:
sandbox.client()
returns the SDK already pointed and keyed.
The instance key authenticates you to one world — it does not select among worlds (there’s
only one per instance). A wrong key is a
401. See Worlds.Why armed faults are the lever
This is the most important consequence of “change the address.” Because the request rides in unmodified, any control that has to travel inside the request only works when your test code makes the call directly. The headline use case — point your unmodified app at the sandbox and run its real code path — can only be steered from out of band.| Mechanism | Test makes the call | Unmodified app makes the call |
|---|---|---|
Armed fault (sandbox.faults.arm) | ✅ | ✅ — out-of-band, always reachable |
Scenario header (X-Mock-Scenario) | ✅ | ❌ — your app won’t add the header |
| Magic input value | ✅ | ⚠️ — only if the app happens to send it |