feat: add rule-based internal accounts and the sweep failure webhook - #835
feat: add rule-based internal accounts and the sweep failure webhook#835ls-bolt[bot] wants to merge 1 commit into
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
a0a2b64 to
3ada236
Compare
✱ Stainless preview builds for gridThis PR will update the cli go kotlin openapi php python ruby typescript Edit this comment to update them. They will appear in their respective SDK's changelogs. ✅ grid-typescript studio · code · diff
✅ grid-kotlin studio · code · diff
✅ grid-php studio · code · diff
✅ grid-openapi studio · code · diff
✅ grid-ruby studio · code · diff
✅ grid-go studio · code · diff
✅ grid-python studio · code · diff
✅ grid-cli studio · code · diff
This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push. |

Summary
Adds the API surface for rule-based internal accounts — an additional account number for an existing customer with a routing rule attached, so incoming payments can be attributed to a specific payer and forwarded automatically.
Every schema change the feature needs is bundled here, in one reviewable PR, rather than arriving in pieces.
What's added
RULE_BASEDonInternalAccountType, plus the same value as atypefilter onGET /customers/internal-accounts.POST /customers/internal-accounts— a new method on the existing path. The body takescustomerId,type, andcurrency, an optionallabel, and asweepRuledescribing where funds are forwarded: adestination(account id plus an optional payment rail) and optionalpurposeOfPayment,description, andremittanceInformation.Idempotency-Keyis required, matching the other endpoints that mint something irreversible.Only
RULE_BASEDis creatable. The other account types are provisioned automatically when a customer is created or approved, so the endpoint rejects them with a specific message rather than a generic error.SWEEP.FAILEDwebhook — fired whenever a settled payment does not reach the rule's destination, including when the balance is below the corridor minimum and gets consolidated into the customer's main account instead. The payload carries both transaction ids, areason, and anoutcome, so an integrator can distinguish "this payment failed" from "and therefore this amount is somewhere else now."Delivery is at-least-once and a redelivery carries a new event id, so the payload documents deduplicating on
incomingTransactionId.Two decisions worth a second opinion
DESTINATION_UNAVAILABLEis not included. It appeared in the original design, but nothing in the implementation can produce it — rail validation raises a single condition thatNO_ELIGIBLE_RAILalready covers. Publishing a value that never arrives costs a permanently un-removable enum member (adding one is non-breaking; removing one is not) and generates a dead case in every SDK. Adding it later, if a rail ever produces it, is free. Happy to reserve it if you'd rather.ABOVE_MAXIMUMis included and wasn't in the original design. A balance over the corridor ceiling would otherwise be submitted whole, rejected, and stranded; it now consolidates instead, and this is how the platform is told.What's deliberately not here
GET /customers/internal-accounts/{id}andDELETEwere in the original design but are not implemented. Speccing them now would generate SDK methods that 405, so they're left for whenever the endpoints land.Verification
make lintpasses with 0 errors, and zero warnings or informational findings on any schema added here. The root and Mintlify bundles are regenerated viamake build, never hand-edited. All 1,922$refs resolve.