Xuda Finance API Reference
Xuda Finance API Reference
This reference covers the full method surface of Xuda Finance: the forty-four dashboard methods that drive every Finance screen, the one public token-gated endpoint behind the partner appeal page, and the seven operator methods that run the review queue and commission payouts. It is written for developers who need to know exactly what each method does, what it accepts, what gates it, and which of them they can actually call from their own code today. Every method key, parameter name, type and required flag below is taken from the shipped method contract.
How To Call These Methods
Every method here is a CPI method. CPI methods are dispatched by name over the Xuda API and MCP layer, and the normal credential for that layer is the account API key. For the transport-level detail, including how requests are framed and how the MCP layer exposes methods, see /api-mcp-integration.
Finance is a case you should understand before you write a line of code. None of these methods is exposed in the API-key catalog. All fifty-two are flagged private, and a private method is excluded from the published API-key catalog and refused for API-key callers even when the key holds full API access. What that leaves you today is:
- Forty-four methods with user clearance that require a signed-in dashboard session, with the caller
uidinjected from that session. These are what the Finance screens call. They are documented in full because they define the product's behavior and because any future API tier would expose them. - One method with public clearance,
finance_ambassador_appeal, which is gated on a single-use token rather than on a session and is reached through the public appeal endpoint the Xuda router serves atPOST /api/network/appeal. - Seven methods with admin clearance that additionally re-check superuser membership inside the handler. They are listed for completeness and are not part of the customer-facing surface.
Do not build against the forty-four session methods with an API key. They will be refused.
Two conventions apply to almost every method below:
finance_account_idis optional everywhere it appears. Omitting it targets the caller's default finance account, which is what keeps single-account users from ever having to pick one.uidis supplied by the session, not by the caller, except where the parameter table explicitly lists it.
Every method returns { code, data }. code is 1 on success and negative on failure, and code: -402 specifically means a plan gate refused the call.
What The Availability Labels Mean
Every method below carries one explicit availability line. Read it first, because it tells you whether you can call the method from your own code today.
- Availability: API key means an external developer API key or the MCP layer can call it. No Finance method currently carries this label.
- Availability: Dashboard session means a signed-in user in the Xuda dashboard can call it, and an API key cannot. The account identity comes from the session, never from a parameter.
- Availability: Public endpoint means no session at all. Where a credential is involved, such as the appeal token, it is carried in the body rather than in a session.
- Availability: Operator only means Xuda staff. The method requires admin clearance and the handler re-checks that the caller is in
superuser_account_ids.
Method Index
| Method | What It Does |
|---|---|
| list_finance_accounts | Lists every finance account the caller owns, default first. |
| create_finance_account | Creates a Stripe Express Connect account and the Xuda finance account that wraps it. |
| update_finance_account | Renames a finance account the caller owns. |
| set_default_finance_account | Makes one finance account the default and re-points the account level Connect fields at it. |
| delete_finance_account | Soft deletes a finance account and promotes a new default. |
| create_stripe_account_link | Creates the Stripe hosted onboarding link for a finance account. |
| refresh_stripe_connect_account_status | Re-reads the Connect account from Stripe and refreshes the stored status. |
| create_stripe_connect_login_link | Creates a one-time Stripe Express dashboard login link. |
| finance_list_documents | Lists mirrored finance documents for one account, self-healing as it reads. |
| finance_summary | Totals for one finance account: paid, outstanding, MRR, counts and commission. |
| finance_create_customer | Creates a Stripe customer, optionally with a tax ID attached at creation. |
| finance_add_customer_tax_id | Attaches a VAT or tax registration number to a customer. |
| finance_delete_customer_tax_id | Removes a tax registration number from a customer. |
| finance_create_product | Creates a product and, when an amount is supplied, its price in the same call. |
| finance_create_price | Adds another price to an existing product. |
| finance_set_product_tax_code | Sets the Stripe tax code on one product, overriding the account default. |
| finance_list_tax_codes | Returns Stripe's full tax code catalog for the tax code pickers. |
| finance_create_quote | Creates a quote from saved prices or ad hoc lines. |
| finance_finalize_quote | Finalizes a draft quote so it can be sent and accepted. |
| finance_accept_quote | Accepts a quote and mints the invoice or subscription behind it. |
| finance_cancel_quote | Cancels a draft or open quote. |
| finance_create_invoice | Creates a draft invoice with its line items. |
| finance_finalize_invoice | Finalizes a draft invoice so it becomes payable. |
| finance_send_invoice | Emails a finalized invoice to its customer through Stripe. |
| finance_void_invoice | Voids a finalized invoice, or deletes it outright while it is still a draft. |
| finance_create_subscription | Creates a recurring subscription and mirrors its first invoice. |
| finance_update_subscription | Changes quantity, pauses, resumes, or schedules cancellation. |
| finance_cancel_subscription | Cancels a subscription at period end or immediately. |
| finance_create_payment_link | Creates a Stripe payment link for a saved price. |
| finance_create_portal_session | Creates a Stripe hosted billing portal session for one customer. |
| finance_refund_payment | Refunds a payment collected through the finance account, in full or in part. |
| finance_create_credit_note | Issues a credit note against a finalized invoice. |
| finance_create_coupon | Creates a discount coupon and its promotion code in one call. |
| finance_delete_coupon | Stops new redemptions of a coupon. |
| finance_get_tax_settings | Reads Stripe Tax status, head office, defaults and every registration. |
| finance_update_tax_settings | Sets the head office and tax defaults, which is what turns automatic tax on. |
| finance_create_tax_registration | Records that the account is registered to collect tax in a country or US state. |
| finance_end_tax_registration | Expires a tax registration without deleting the record. |
| finance_get_plan | Reads the account's Finance tier, its flags, its usage and the full ladder. |
| finance_set_plan | Switches the account to a Finance tier and moves its billing line. |
| finance_ambassador_apply | Submits a xuda.network ambassador or mentor application. |
| finance_ambassador_status | Reads the caller's partner state, delegate seat and commission rate. |
| finance_commission_balance | Reads what a partner has earned and whether it can be paid out. |
| finance_request_payout | Asks to be paid accrued commission. |
| finance_ambassador_applications | Lists partner applications for the operator review queue. |
| finance_ambassador_decision | Approves or declines a partner application. |
| finance_commission_payable | Lists every partner with commission owed. |
| finance_payout_commission | Pays a partner as a Stripe transfer and settles the invoice rows it covers. |
| finance_admin_lookup_account | Reads any account's finance accounts and documents, audited against the subject. |
| finance_admin_find_seller | Finds an account by email fragment or account id. |
| finance_platform_overview | Xuda's own platform balance, MRR, plan mix and commission totals. |
| finance_ambassador_appeal | Lets a declined applicant appeal using the single-use token from their decline notice. |
list_finance_accounts
List Finance Accounts
Returns every finance account the caller owns, newest first with the default account promoted to the top. On first read for a legacy marketplace seller, it mints a finance account pointing at the same Stripe Connect account so nothing in flight breaks and nobody is asked to re-onboard. Each row carries the account name, kind (connect or delegate), Stripe account id, default flag, whether it is active, the Connect status summary, capabilities (charges enabled, payouts enabled, details submitted), the object types it may create, and for a delegate seat the commission rate and partner role.
Availability: Dashboard session
Parameters
This method takes no parameters.
Notes
- Auth:
clearance: user,uidinjected from the session. - No
min_plangate and no Finance tier gate. Every account can read its own list. - The legacy migration is silent and happens on read: an account carrying the old
stripe_connect_account_objscalar gets a finance account minted pointing at the sameacct_id, mirroring the real Connect state rather than assuming it is onboarded.
create_finance_account
Create Finance Account
Creates a new Stripe Express Connect account and the Xuda finance account that wraps it. The first account created wins the default flag so single-account users never have to pick. Refused when the account already owns as many connect accounts as its Finance tier allows, with the tier name and allowance in the message.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
name |
string | No | Display name for the finance account. |
country |
string | No | Two letter country code for the Stripe Connect account. |
Notes
- Auth:
clearance: user. No cpimin_plankey, but the handler enforces the Pro membership rank itself so xuda.network partners can be exempted. A partner needs a connected account purely to receive commission Xuda already owes them, so gating that behind Pro would mean buying a plan before Xuda can pay you. - Plan gate: the
finance_accountsallowance caps how manyconnectaccounts may exist. Free allows 1, Starter 2, Growth 5 and Scale 20. - Creating an account is what sets the
finance_activeflag on the account document once it becomes chargeable, and that flag is what the marketplace publish gate reads.
update_finance_account
Update Finance Account
Renames a finance account the caller owns. The name is trimmed and capped at 60 characters.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | Yes | Finance account to update. |
name |
string | No | New display name. |
Notes
- Auth:
clearance: user. The caller must own the finance account. - Unlike almost every other method here,
finance_account_idis required. There is no default-account fallback on a rename.
set_default_finance_account
Set Default Finance Account
Makes one finance account the default and re-points the account level Connect fields at it, which is what decides where a marketplace payout is routed.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | Yes | Finance account to make default. |
Notes
- Auth:
clearance: user. The caller must own the finance account. - Side effect: the legacy
stripe_connect_account_obj,stripe_connect_account_idandstripe_connect_account_statusfields on the account document are re-pointed at the new default, and nulled when the new default is a delegate seat. - Every method that omits
finance_account_idtargets whichever account this call last named, so changing the default changes where unqualified calls land.
delete_finance_account
Delete Finance Account
Soft deletes a finance account by setting its status to 0. Its documents and the Stripe Connect account itself are left intact, because mirror rows point at it and a removed account still has to explain historical documents. Whatever is left is promoted so the account is never left without a default.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | Yes | Finance account to remove. |
Notes
- Auth:
clearance: user. The caller must own the finance account. - A delegate seat is managed by Xuda and cannot be removed here.
- Nothing is deleted at Stripe. The Connect account survives, so a removal is reversible by support and historical documents keep resolving.
- Removing accounts is also how you clear a downgrade block, since
finance_set_planrefuses a downgrade while more accounts exist than the lower tier allows.
create_stripe_account_link
Create Stripe Account Link
Creates a Stripe hosted onboarding link for one finance account, and creates the finance account first when the caller has none, so the same button works for a brand new user and for an existing one.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
uid |
string | Yes | Account ID of the user to create the Connect account link for. |
return_url |
string | Yes | URL Stripe redirects to after the user completes onboarding. |
Notes
- Auth:
clearance: user, and this is the one Finance method carryingmin_plan: "pro", enforced by the generic platform plan gate rather than inside the handler. Pro has rank 1; free and starter are rank 0. - This is also the one method in the set whose parameter table lists
uidexplicitly. - Refused for a delegate seat, which is hosted by Xuda and needs no Stripe onboarding.
- The handler also accepts
finance_account_idandrefresh_url, and the dashboard sends both, but neither is declared in the published field list, so do not rely on them.
refresh_stripe_connect_account_status
Refresh Stripe Seller Account Info
Re-fetches the Connect account from Stripe and refreshes the stored status summary on the finance account, on the account document when it is the default one, and the finance_active flag the marketplace publish gate reads.
Availability: Dashboard session
Parameters
This method takes no parameters.
Notes
- Auth:
clearance: user. - No fields are declared in the published contract. The handler accepts an optional
finance_account_id, defaulting to the caller's default account. - Refused for a delegate seat, which has no Stripe account to refresh.
- The returned status is one of pending, incomplete, restricted, disabled or active, alongside a message and the
canAcceptPaymentsandcanPayoutbooleans.
create_stripe_connect_login_link
Create Stripe Connect Login Link
Creates a one-time Stripe Express dashboard login link for the caller's Connect account. It is worth knowing what they find there: the Express dashboard covers balance, payouts, payments, refunds and disputes, and has no invoicing, products or quotes, which is why those live in Xuda.
Availability: Dashboard session
Parameters
This method takes no parameters.
Notes
- Auth:
clearance: user. - No fields are declared in the published contract. The handler accepts an optional
finance_account_id. - Refused for a delegate seat.
- The link is single use. Generate a fresh one per visit rather than storing it.
finance_list_documents
List Finance Documents
The one list endpoint every Finance screen uses. It reads the Xuda finance_document mirror scoped by finance account, never a Stripe list, because Stripe's list endpoints cannot filter on metadata and a delegate seat lives on Xuda's own platform account. Results are sorted newest first.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
object |
string | No | Filter to one object type: invoice, quote, product, price, customer or payment_link. The handler also accepts subscription, refund, credit_note, coupon and order. |
status |
string | No | Filter to one Stripe status. |
limit |
number | No | Maximum documents to return, capped at 200. |
skip |
number | No | Documents to skip for pagination. |
Notes
- Auth:
clearance: user. No Finance tier gate on reading. - Self-healing read: any non-terminal invoice, quote, subscription, refund, credit note or order in the result is re-read from Stripe by id and refreshed, bounded to 25 per call, so a missed or out-of-order webhook cannot leave a document stale forever.
- When
objectisorderand the account is aconnectaccount, recent completed checkout sessions are pulled in from Stripe first, limit 50, with abandoned sessions skipped. limitis capped server side at 200 regardless of what you send. Page withskip.- Scoping is by construction rather than by filter: a delegate seat on Xuda's platform account sees only the documents raised on that seat.
finance_summary
Finance Summary
Totals for one finance account, computed off the mirror in a single query: counts of invoices, quotes, customers, products, subscriptions, active subscriptions, orders, payment links, refunds, credit notes and coupons; total refunded and credited; MRR with every billing interval normalized to one month; total paid; total outstanding across draft and open invoices; and commission accrued and paid out.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
Notes
- Auth:
clearance: user. - All money values are returned in minor units. Divide by 100 for a two decimal currency before displaying.
- The totals come from the local mirror, not from a Stripe aggregate call, so they reflect whatever the mirror last saw. Loading a list first refreshes non-terminal documents and therefore the numbers behind them.
finance_create_customer
Create Finance Customer
Creates a Stripe customer on the finance account and mirrors it. An email or a name is required. When a tax ID type and value are supplied they are attached at creation, which is what makes the first invoice reverse-charge correctly.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
email |
string | No | Customer email address. |
name |
string | No | Customer name. |
phone |
string | No | Customer phone number. |
tax_id_type |
string | No | Stripe tax ID type to attach at creation, for example eu_vat. |
tax_id_value |
string | No | The tax registration number to attach at creation. |
address |
object | No | Stripe address object for the customer. |
Notes
- Auth:
clearance: user. Available on every Finance tier and to both account kinds. - Neither
emailnornameis individually required, but at least one of them must be present. - A bad tax ID number is logged and skipped rather than losing the customer, so a successful create does not by itself prove the number attached.
- Attaching the tax ID here rather than later matters: adding it afterwards is too late for an invoice already issued, and the customer has been overcharged.
finance_add_customer_tax_id
Add Finance Customer Tax Id
Attaches a VAT or tax registration number to a customer, which is what lets Stripe reverse charge a business customer instead of charging them consumer VAT. Stripe validates the number against the tax authority asynchronously, so the verification status starts as pending. The customer's tax IDs are cached back onto its mirror row so the list screen can show who is a business without a round trip per row.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
customer_id |
string | Yes | Customer the tax ID belongs to. |
type |
string | Yes | Stripe tax ID type, for example eu_vat, gb_vat or us_ein. |
value |
string | Yes | The tax registration number itself. |
Notes
- Auth:
clearance: user. - Plan gate: requires the
stripe_taxflag, so the Finance Scale tier, and aconnectaccount. - Verification is asynchronous. Do not treat a successful call as a verified number.
- Backend-complete but only partially surfaced: a customer tax ID can be added at customer creation from the dashboard, but there is no screen that adds one afterwards.
finance_delete_customer_tax_id
Delete Finance Customer Tax Id
Removes a tax registration number from a customer and refreshes the cached list on the mirror row.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
customer_id |
string | Yes | Customer the tax ID belongs to. |
tax_id |
string | Yes | Stripe tax ID to remove. |
Notes
- Auth:
clearance: user. - Plan gate: requires the
stripe_taxflag and aconnectaccount. - Invoices already issued keep whatever tax treatment they were issued with. Removing the number changes future documents only.
- Backend-complete but not surfaced in the dashboard today.
finance_create_product
Create Finance Product
Creates a Stripe product on the finance account and, when an amount above zero is supplied, its price in the same call, because a product with no price cannot be sold and two steps only ever produces orphans. A per-product tax code beats the account default, which is the only way a seller of both goods and services taxes both correctly.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
name |
string | Yes | Product name. |
description |
string | No | Product description. |
amount |
number | No | Price in major currency units. Creates a price when greater than zero. |
currency |
string | No | Three letter currency code, defaults to usd. |
tax_code |
string | No | Stripe tax code for this product, overriding the account default. |
interval |
string | No | Recurring interval (day, week, month, year). Omit for a one time price. |
Notes
- Auth:
clearance: user. Available on every Finance tier. - Refused on a delegate seat: you sell Xuda, so the products and prices are Xuda's.
amountis given in major units and converted to minor units before it reaches Stripe. This is the opposite convention to whatfinance_summaryreturns.- The account default product tax code is
txcd_10000000, general electronically supplied services. That code is tax-exempt in many US states, so a seller of tangible goods must settax_codeper product or see zero tax.
finance_create_price
Create Finance Price
Creates an additional Stripe price for an existing product on the finance account, for example a second currency or an annual alternative to a monthly one.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
product_id |
string | Yes | Stripe product the price belongs to. |
amount |
number | Yes | Price in major currency units. |
currency |
string | No | Three letter currency code, defaults to usd. |
interval |
string | No | Recurring interval (day, week, month, year). Omit for a one time price. |
Notes
- Auth:
clearance: user. Available on every Finance tier. - Refused on a delegate seat.
- The product must belong to the finance account being acted as.
- Backend-complete but not surfaced in the dashboard today. The create modal sets a product's first price only.
finance_set_product_tax_code
Set Finance Product Tax Code
Sets the Stripe tax code on one product, overriding the account default. Clearing it falls the product back to the account default rather than leaving it untaxed.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
product_id |
string | Yes | Product to set the tax code on. |
tax_code |
string | No | Stripe tax code, for example txcd_99999999. Empty clears it. |
Notes
- Auth:
clearance: user. - Plan gate: requires the
stripe_taxflag and aconnectaccount. - The product must belong to the finance account.
- Backend-complete but only partially surfaced: a tax code is chosen at product creation, and there is no screen to change it later.
finance_list_tax_codes
List Finance Tax Codes
Returns Stripe's full tax code catalog for the product and account tax code pickers, sorted by name. It is paginated in pages of 100 up to 10 pages, because a truncated list silently hides whichever code the seller actually needs, and cached in memory for the life of the process.
Availability: Dashboard session
Parameters
This method takes no parameters.
Notes
- Auth:
clearance: user. It requires a signed-in caller and nothing else, with no Finance tier gate. - The in-process cache means the first call after a restart is the slow one and the rest are effectively free.
- Up to 1000 codes are returned. The catalog is Stripe's, not Xuda's, so codes can appear or change without a Xuda release.
finance_create_quote
Create Finance Quote
Creates a Stripe quote on the finance account. This is the only document a xuda.network partner's delegate seat may raise, and accepting it is what creates the invoice. Lines may reference a saved price id or be typed ad hoc as a description plus an amount. A line marked with an interval creates a recurring price, and that is what decides whether accepting the quote produces an invoice or a subscription.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
customer_id |
string | Yes | Stripe customer the quote is for. |
lines |
array | Yes | Line items, each either a price_id plus quantity or a description, amount and quantity. |
currency |
string | No | Three letter currency code, defaults to usd. |
description |
string | No | Quote description shown to the customer. |
footer |
string | No | Footer text on the quote. |
expires_days |
number | No | Days until the quote expires, defaults to 30. |
Notes
- Auth:
clearance: user. Available on every Finance tier and to both account kinds. - An ad hoc line mints a throwaway Stripe product stamped
xuda_adhoc, which is deliberately not mirrored so one-off lines do not litter the Products screen. - Automatic tax is added when the account's tax settings actually report
active. Stripe rejects the whole document if automatic tax is set on a pending account, so the tax status is checked and cached for six hours on the finance account. - On a delegate seat the quote is stamped with
xuda_referrer_uidandxuda_commission_bps, which is what lets commission accrue when the resulting invoice is paid.
finance_finalize_quote
Finalize Finance Quote
Finalizes a draft quote so it can be sent and accepted. The quote must be in the caller's mirror, which is the ownership record.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
quote_id |
string | Yes | Stripe quote to finalize. |
Notes
- Auth:
clearance: user. Ownership is proven by the mirror row, not by asking Stripe. - You do not have to call this before
finance_accept_quote. Accept finalizes a draft first.
finance_accept_quote
Accept Finance Quote
Accepts a quote, which is the moment the money becomes real. A draft quote is finalized first so the caller does not have to know the state machine. Stripe then mints either an invoice (one-off lines) or a subscription (recurring lines), and both are handled: the resulting object is stamped with the quote id, the referrer uid and the commission rate, and mirrored, and for a subscription its first invoice is adopted immediately.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
quote_id |
string | Yes | Stripe quote to accept. |
Notes
- Auth:
clearance: user. - Returns the quote, the invoice and the subscription, any of which may be null. Check which one you got rather than assuming an invoice.
- Every renewal invoice Stripe mints afterwards for an accepted recurring quote is adopted onto the same finance account, so it never goes missing.
- This is the accrual point for partner commission on the delegate path: the stamped rate rides on the invoice and credits when
invoice.paidarrives.
finance_cancel_quote
Cancel Finance Quote
Cancels a draft or open quote.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
quote_id |
string | Yes | Stripe quote to cancel. |
Notes
- Auth:
clearance: user. - An accepted quote is past this point. Cancel the invoice or subscription it produced instead.
finance_create_invoice
Create Finance Invoice
Creates a draft Stripe invoice with its line items on the finance account, using the send_invoice collection method so the customer is emailed a payable invoice rather than charged a saved card. The invoice is created first and its items attached to it by id, then it is re-read and mirrored.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
customer_id |
string | Yes | Stripe customer the invoice is for. |
lines |
array | Yes | Line items, each either a price_id plus quantity or a description, amount and quantity. |
currency |
string | No | Three letter currency code, defaults to usd. |
description |
string | No | Invoice description shown to the customer. |
footer |
string | No | Footer text on the invoice. |
days_until_due |
number | No | Payment terms in days, defaults to 14. |
auto_advance |
boolean | No | Let Stripe finalize and collect automatically. |
Notes
- Auth:
clearance: user. Available on every Finance tier. - Refused on a delegate seat: an ambassador raises a quote, not an invoice. Xuda invoices the customer when they accept it.
- Automatic tax is added when the account's tax settings report
active. - The invoice is created as a draft. It is not payable and has no number, hosted page or PDF until
finance_finalize_invoiceruns, unlessauto_advanceis set and Stripe does it for you.
finance_finalize_invoice
Finalize Finance Invoice
Finalizes a draft invoice so it becomes payable and gets its number, hosted page and PDF.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
invoice_id |
string | Yes | Stripe invoice to finalize. |
Notes
- Auth:
clearance: user. - Allowed on a delegate seat, because progressing a sale the partner raised is theirs to do.
- Finalizing is one way. A finalized invoice cannot be edited, only voided or credited.
finance_send_invoice
Send Finance Invoice
Emails a finalized invoice to its customer through Stripe.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
invoice_id |
string | Yes | Stripe invoice to send. |
Notes
- Auth:
clearance: user. - Allowed on a delegate seat.
- The email is sent by Stripe from the connected account's own branding, not by Xuda's mail infrastructure.
- Sending is not idempotent at the customer's inbox. Calling it twice sends the invoice twice.
finance_void_invoice
Void Finance Invoice
Voids a finalized invoice, or deletes it outright when it is still a draft, because a draft has never been issued and only a finalized invoice should leave a void behind.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
invoice_id |
string | Yes | Stripe invoice to void. |
Notes
- Auth:
clearance: user. - Refused on a delegate seat: this invoice is issued by Xuda, so support cancels it. Writing off money Xuda is owed stays Xuda's call.
- Behavior depends on state. A draft is deleted and its mirror row goes with it; a finalized invoice is voided and the row survives with a void status.
- A paid invoice cannot be voided. Use
finance_refund_paymentorfinance_create_credit_note.
finance_create_subscription
Create Finance Subscription
Creates a recurring Stripe subscription for a customer on the finance account and mirrors its first invoice so the seller sees the money and not just the subscription. The collection method is chosen from reality rather than assumed: Stripe hard-errors creating a subscription for a customer with no saved card, so a customer without a payment method is billed by emailed invoice each period instead.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
customer_id |
string | Yes | Stripe customer to subscribe. |
lines |
array | Yes | Line items, each either a price_id plus quantity or a description, amount, quantity and interval. |
currency |
string | No | Three letter currency code, defaults to usd. |
trial_days |
number | No | Free trial length in days before the first charge. |
Notes
- Auth:
clearance: user. - Plan gate: requires the
subscriptionsflag, so the Finance Growth tier or above. The refusal names the cheapest tier carrying the flag. - Refused on a delegate seat, which reaches a subscription only through an accepted recurring quote.
- An ad hoc line with no interval defaults to monthly, because a subscription line must be recurring.
- Subscription revenue is what
finance_summaryreports as MRR, with every billing interval normalized to one month.
finance_update_subscription
Update Finance Subscription
Changes a subscription's quantity, pauses or resumes collection, or schedules cancellation at the end of the paid period. Pausing stops collection without ending the subscription, so the customer keeps their place; clearing the pause resumes billing.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
subscription_id |
string | Yes | Stripe subscription to change. |
quantity |
number | No | New quantity for the first subscription item. |
cancel_at_period_end |
boolean | No | True to end the subscription when the current period closes. |
pause |
boolean | No | True to pause collection, false to resume it. |
Notes
- Auth:
clearance: user. - A call that would change nothing is refused. Send at least one of
quantity,cancel_at_period_endorpause. quantityapplies to the first subscription item only.cancel_at_period_end: falseis how a scheduled cancellation is undone, which is the Keep it action in the dashboard.
finance_cancel_subscription
Cancel Finance Subscription
Cancels a subscription either at the end of the paid period, which is reversible and is what the customer has already paid for, or immediately.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
subscription_id |
string | Yes | Stripe subscription to cancel. |
at_period_end |
boolean | No | True to cancel when the current period closes, false to end it now. |
Notes
- Auth:
clearance: user. - Cancelling immediately does not refund the period already paid for. Issue a refund or a credit note separately if that is what you mean.
- A period-end cancellation can still be reversed with
finance_update_subscriptionandcancel_at_period_end: false.
finance_create_payment_link
Create Finance Payment Link
Creates a Stripe payment link for a saved price on the finance account, mirrored so the resulting checkouts can be adopted back as orders. A payment link is the sale that never needed paperwork.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
price_id |
string | Yes | Stripe price the link sells. |
quantity |
number | No | Quantity per checkout, defaults to 1. |
Notes
- Auth:
clearance: user. - Plan gate: requires the
payment_linksflag, so the Finance Starter tier or above. - Refused on a delegate seat.
- No dashboard screen calls this method today, so a link is created over the API. The links themselves are visible:
payment_linkhas its own Documents tile and its own table at/dashboard/finance/payment_link, which lists every link with its status and opens it, and rows can be attached to a contact. What the screen has no button for is creation, because a link is raised against a saved price and the create form has no price picker. payment_linksis also reported as a count byfinance_summary.- Checkouts against the link are adopted onto the finance account that owns it, which is how they surface under
object: "order".
finance_create_portal_session
Create Finance Billing Portal Session
Creates a Stripe-hosted billing portal session on the seller's own connected account so their customer can manage their subscription, payment methods, contact details and invoice history without the seller building any of it.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
customer_id |
string | Yes | Stripe customer the portal session is for. |
return_url |
string | No | URL Stripe returns the customer to when they leave the portal. |
Notes
- Auth:
clearance: user. - Plan gate: requires the
billing_portalflag, so the Finance Scale tier. - Refused on a delegate seat: Xuda bills these customers directly, so there is no separate portal here.
- Stripe does not create a portal configuration implicitly for a connected account, so a sensible default is created on first use (invoice history, payment method update, customer update for email, address and phone, and cancel at period end) and remembered on the finance account as
portal_configuration_id. - The session URL is short lived and belongs to one customer. Generate it per visit and never store or share it.
finance_refund_payment
Refund Finance Payment
Refunds a payment collected through the finance account, in full or in part. The caller can simply name the invoice and the payment behind it is resolved, or pass a payment intent directly for a payment link or checkout sale. The invoice is re-read afterwards so its mirror row shows that a refund happened.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
invoice_id |
string | No | Invoice whose payment should be refunded. |
payment_intent_id |
string | No | Payment intent to refund when there is no invoice. |
amount |
number | No | Amount to refund in major currency units. Omit for a full refund. |
reason |
string | No | One of duplicate, fraudulent or requested_by_customer. |
Notes
- Auth:
clearance: user. Never gated by a Finance tier. Refunds are an obligation to your customer, not a feature to sell. - Refused on a delegate seat: this payment was collected by Xuda, so support refunds it.
- Supply one of
invoice_idorpayment_intent_id. Neither is individually required, but the call needs one of them to find the payment. - Omitting
amountis a full refund. A partial refund creates its own Stripe refund object, so several can stack against one payment. - This is not idempotent. Two identical partial refund calls produce two refunds.
- On a delegate invoice, a refund reaching the
charge.refundedwebhook reverses accrued commission proportionally.
finance_create_credit_note
Create Finance Credit Note
Issues a credit note against a finalized invoice. Where the credit lands depends on whether the money has already arrived: an unpaid invoice has the amount still owed credited, and a paid invoice is either refunded or parked as customer balance for next time.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
invoice_id |
string | Yes | Finalized invoice to credit. |
amount |
number | No | Amount to credit in major currency units. Defaults to the invoice total. |
reason |
string | No | One of duplicate, fraudulent, order_change or product_unsatisfactory. |
refund |
boolean | No | True to refund the credited amount rather than hold it as customer balance. |
Notes
- Auth:
clearance: user. Never gated by a Finance tier. - Refused on a delegate seat: this invoice is issued by Xuda, so support credits it.
- A draft invoice is refused, because it has not been issued yet and should be edited or deleted instead.
- Credit notes appear as their own rows under Credit notes, and the credited amount is reported by
finance_summaryas total credited.
finance_create_coupon
Create Finance Coupon
Creates a discount coupon and its customer-facing promotion code in one call, because creating one without the other is the usual footgun. The discount is either a percentage or a fixed amount, never both.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
name |
string | No | Display name for the coupon. |
percent_off |
number | No | Percentage discount. Use this or amount_off, not both. |
amount_off |
number | No | Fixed discount in major currency units. Use this or percent_off, not both. |
currency |
string | No | Three letter currency code for a fixed amount discount. |
duration |
string | No | One of once, repeating or forever. |
duration_in_months |
number | No | How many months a repeating coupon lasts. |
code |
string | No | Customer-facing promotion code. Generated when omitted. |
max_redemptions |
number | No | How many times the coupon may be redeemed in total. |
Notes
- Auth:
clearance: user. - Plan gate: requires the
couponsflag, so the Finance Starter tier or above. - Refused on a delegate seat: discounts on Xuda pricing are set by Xuda.
- A
repeatingcoupon needsduration_in_months. - The promotion code is uppercased and stripped of non-alphanumeric characters, and Stripe generates one when none is supplied.
- A promotion code collision is logged rather than allowed to orphan the coupon already created, so a successful call can leave you with a coupon whose code did not mint.
finance_delete_coupon
Delete Finance Coupon
Stops new redemptions of a coupon. Subscriptions already carrying it keep their discount, so the mirror row stays with an expired status rather than vanishing.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
coupon_id |
string | Yes | Stripe coupon to delete. |
Notes
- Auth:
clearance: user. - This is not a retroactive removal. Existing discounts on live subscriptions survive.
finance_get_tax_settings
Get Finance Tax Settings
Returns the Stripe Tax status for the finance account, which fields are still missing when it is pending, the head office address, the defaults, and every registration with its country, US state where applicable, status, active-from date and expiry.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
Notes
- Auth:
clearance: user. - Plan gate: requires the
stripe_taxflag, so the Finance Scale tier, and aconnectaccount. A delegate seat is told that Xuda handles tax on these sales. - Stripe Tax is reached over plain REST rather than through the SDK, because the pinned stripe-node 8.x has no
taxnamespace. The sameStripe-Accountheader the SDK would send is sent by hand. - The reported status is cached for six hours on the finance account as
tax_statusandtax_checked_ts, because settingautomatic_taxon a pending account makes Stripe reject the whole invoice.
finance_update_tax_settings
Update Finance Tax Settings
Sets the head office and tax defaults, which is what turns automatic tax calculation on. A head office needs a real street address, city and postal code, not just a country, because Stripe geocodes it and rejects anything it cannot resolve.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
country |
string | No | Two letter country code of the head office. |
state |
string | No | State or province of the head office. |
line1 |
string | No | Street address of the head office. |
line2 |
string | No | Second address line of the head office. |
city |
string | No | City of the head office. |
postal_code |
string | No | Postal or ZIP code of the head office. |
tax_code |
string | No | Default Stripe product tax code for items with none set. |
tax_behavior |
string | No | Either exclusive (tax added on top) or inclusive (price already contains it). |
Notes
- Auth:
clearance: user. - Plan gate: requires the
stripe_taxflag and aconnectaccount. - A bare country is rejected. Send
line1,cityandpostal_codetoo, or Stripe cannot geocode the address. - Enabling tax always leaves a default product tax code in place, because Stripe refuses to calculate tax unless every line carries a code or the account has a default, and it fails at invoice-create time rather than at settings-save time. The default is
txcd_10000000. - Once tax settings report
active, every invoice, quote and subscription raised from that account is created with automatic tax enabled.
finance_create_tax_registration
Create Finance Tax Registration
Registers the finance account to collect tax in a country, or in a US state. The registration shape genuinely differs by place: the US takes a state plus a sales tax type, the EU takes a standard type plus a nested place-of-supply scheme that Stripe rejects the registration without, and everywhere else takes a plain standard registration for the country. Xuda records that you are registered; it does not register you.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
country |
string | Yes | Two letter country code to register in. |
state |
string | No | Two letter state code, required for US registrations. |
place_of_supply_scheme |
string | No | EU only. Either standard or small_seller. Defaults to standard. |
registration_type |
string | No | Registration type, defaults to standard (state_sales_tax in the US). |
Notes
- Auth:
clearance: user. - Plan gate: requires the
stripe_taxflag and aconnectaccount. stateis required whencountryis US.- Known defect: the non-US branch of this method references an undefined constant in the committed repo, so a registration for any country other than the US returns
code: -400with the message "_FIN_EU_COUNTRIES is not defined". US state registrations take the other branch and are unaffected. Treat non-US registration as not working until this is fixed.
finance_end_tax_registration
End Finance Tax Registration
Expires a tax registration. The record is kept rather than deleted, because where you were registered and when is exactly what a tax audit asks for.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
finance_account_id |
string | No | Finance account to act as. Defaults to the caller's default finance account. |
registration_id |
string | Yes | Stripe tax registration to expire. |
Notes
- Auth:
clearance: user. - Plan gate: requires the
stripe_taxflag and aconnectaccount. - Expiring is not deleting. The registration keeps showing in
finance_get_tax_settingswith an expiry date.
finance_get_plan
Finance Get Plan
Returns the Finance plan the account is on, its display name, its feature flags, current usage against its limits (today, the number of connect finance accounts owned), and the full Finance ladder with id, name, tagline, price, flags and feature list, so the plans sheet renders without a second call.
Availability: Dashboard session
Parameters
This method takes no parameters.
Notes
- Auth:
clearance: user. - Read only. It never activates or changes anything.
- The ladder it returns is the source of truth for what each tier unlocks. Do not hardcode the flag set on the client.
- Backend-complete but only partially surfaced in the dashboard today.
finance_set_plan
Finance Set Plan
Switches the account to a Finance plan, adding or repricing its line item on the consolidated Xuda subscription.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
plan_id |
string | Yes | Finance plan key, for example finance_growth. |
Notes
- Auth:
clearance: user. - Finance is billed as one line item on the account's single consolidated Xuda subscription, not as a separate subscription.
- A downgrade is refused while the account owns more finance accounts than the new plan allows, and the message names how many to remove.
- An accepted downgrade takes effect at the end of the period already paid for, so the account keeps its current tier until Stripe transitions the schedule.
- All four Finance Stripe price ids are placeholders today, so
finance_set_planrefuses any paid tier withcode: -402and the message that the plan is not billable yet. Onlyfinance_freecan be activated at the moment.
finance_ambassador_apply
Finance Ambassador Apply
Submits a xuda.network ambassador or mentor application for the caller and emails the operator review address.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
role |
string | Yes | Either ambassador or mentor. |
country |
string | Yes | Country the partner covers. |
city |
string | No | City the partner covers. |
links |
object | No | Object of profile links (linkedin, github, youtube, website). |
cv_url |
string | No | Link to the applicant CV. |
specialties |
string | No | Areas the applicant specializes in. |
note |
string | No | Free text note to the review team. |
Notes
- Auth:
clearance: user. - An account that is already a partner is told so, and a second application while one is under review is refused.
- Re-applying after a decline reuses the same application document rather than creating a second one.
- Side effect: an operator notification email is sent to the review address, which defaults to
[email protected]. - The role decides the commission rate on approval: 1500 basis points, 15 percent, for an ambassador, and 2000 basis points, 20 percent, for a mentor.
finance_ambassador_status
Finance Ambassador Status
Returns the caller's partner state: whether they are a partner, their application status (1 submitted, 3 approved, 4 declined) with role, country, city and any decline reason, their delegate finance account, their commission rate in basis points, and the connected account commission would be paid into.
Availability: Dashboard session
Parameters
This method takes no parameters.
Notes
- Auth:
clearance: user. - It self-heals on read: an approved partner who has no delegate seat is granted one here, and a seat granted before the rate card is backfilled with its partner role.
- A negotiated rate is never reset. The role rate is only written back when the seat still carries the old flat 2000 basis points.
- Rate resolution order is: a per-account
commission_bps, then the configured per-role map, then the role rate card, then the configured ambassador default, then the ambassador default rate.
finance_commission_balance
Finance Commission Balance
Returns what a partner has earned and whether it can be paid: currency, total accrued, how many invoices it spans, total already paid out, the connected account it would be paid into, a reason it is blocked when there is one, the partner role and rate, the payout minimum, whether a payout can be requested right now, any open request, and the individual invoice rows behind the total.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
target_uid |
string | No | Partner to read. Superuser only; omit to read your own balance. |
Notes
- Auth:
clearance: user. Reading another account's balance additionally requires the caller to be insuperuser_account_ids, re-checked in the handler rather than trusted from the layer above. - Commission accrues on
invoice.paidand reverses proportionally oncharge.refunded, so the balance can go down as well as up. - The payout minimum is 5000 minor units, 50.00 USD, unless configured otherwise.
- Amounts are in minor units.
finance_request_payout
Finance Request Payout
Lets a partner ask to be paid their accrued commission. Raising a request emails the operator address with the amount, the destination and the exact call that fulfills it.
Availability: Dashboard session
Parameters
This method takes no parameters.
Notes
- Auth:
clearance: user. The caller must hold a delegate seat. - Refused below the payout minimum, with both numbers spelled out in dollars.
- Refused when there is no active connected account to pay into. A partner needs an ordinary
connectfinance account with Stripe onboarding finished, because commission is paid into their own Stripe account. - Refused when a request is already open, because asking twice does not get anyone paid sooner and two open requests for the same money read as two payouts due.
- Requesting does not move money. An operator fulfills it with
finance_payout_commission.
finance_ambassador_applications
Finance Ambassador Applications
Lists partner applications for the review queue, pending first, each with the commission rate approving it would grant.
Availability: Operator only
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
stat |
number | No | Application status to filter to. |
limit |
number | No | Maximum applications to return, capped at 500. |
Notes
- Auth:
clearance: admin, and the handler re-checks that the caller is insuperuser_account_ids. - Application status values are 1 submitted, 3 approved and 4 declined.
finance_ambassador_decision
Finance Ambassador Decision
Approves or declines an application. Approving flags the account as a partner, grants the delegate seat and notifies them; declining mints a single-use appeal token.
Availability: Operator only
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
application_id |
string | Yes | Application to decide. |
approve |
boolean | Yes | True to approve, false to decline. |
reason |
string | No | Reason for the decision, shown to the applicant on a decline. |
Notes
- Auth:
clearance: admin, with the superuser re-check in the handler. - A Xuda Verify gate is run against the applicant on the approval path only, per role, and it fails open so a verify outage cannot block a human reviewer.
- Approval publishes the
network_partner_approvedaccount notification; a decline publishesnetwork_partner_declinedand includes the single-use appeal link.
finance_commission_payable
Finance Commission Payable
Every partner with commission owed, sorted by amount, with email, currency, invoice count, whether it is payable, why not, role and whether they have requested it.
Availability: Operator only
Parameters
This method takes no parameters.
Notes
- Auth:
clearance: admin, with the superuser re-check in the handler. - This is the read behind the Payouts tab of the finance admin console.
finance_payout_commission
Finance Payout Commission
Pays a partner as a Stripe transfer into their own connected account and settles the invoice rows it covers.
Availability: Operator only
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
target_uid |
string | Yes | Partner to pay. |
dry_run |
boolean | No | True to compute the batch without moving money. |
Notes
- Auth:
clearance: admin, with the superuser re-check in the handler. - Idempotency: the payout document is written before the transfer, and the Stripe idempotency key is derived from the exact set of invoice rows being settled, so a replay cannot pay the same batch twice.
- A mixed-currency batch is refused outright rather than silently paying only the majority currency.
- Settled invoice rows move to
commission_stat: 3and carry the payout id. - Publishes the
network_partner_commission_paidaccount notification.
finance_admin_lookup_account
Finance Admin Lookup Account
Reads any account's finance accounts, and their documents when a finance account is named.
Availability: Operator only
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
target_uid |
string | Yes | Account whose finance data to read. |
finance_account_id |
string | No | Finance account whose documents to read. |
object |
string | No | Filter documents to one object type. |
limit |
number | No | Maximum documents to return, capped at 200. |
Notes
- Auth:
clearance: admin, with the superuser re-check in the handler. - Every read is logged as a security-flagged audit line against the subject's account, not the operator's, so the person whose books were opened is the one who can see that it happened.
finance_admin_find_seller
Finance Admin Find Seller
Finds an account by email fragment or account id so support can start from whatever the customer supplied.
Availability: Operator only
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
query |
string | Yes | Email fragment or account id, at least 3 characters. |
Notes
- Auth:
clearance: admin, with the superuser re-check in the handler. - A query shorter than 3 characters is refused.
finance_platform_overview
Finance Platform Overview
Xuda's own money, explicitly not the seller suite: platform Stripe balance, MRR and plan mix computed from account documents and the plan catalog, invoices and refunds over the last 30 days, and total partner commission accrued and paid.
Availability: Operator only
Parameters
This method takes no parameters.
Notes
- Auth:
clearance: admin, with the superuser re-check in the handler. - This reads the Xuda platform Stripe account. It never touches a seller's connected account.
finance_ambassador_appeal
Finance Ambassador Appeal
A declined applicant appeals using the single-use token from their decline notification. The appeal re-opens the application and files a ticket on the Xuda desk so a human sees it. It is public and token-gated on purpose, because the applicant may not be signed in when they click the link in their email.
Availability: Public endpoint
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
application_id |
string | Yes | Application being appealed. |
token |
string | Yes | Single-use appeal token from the decline notification. |
reason |
string | Yes | The applicant's case, at least 10 characters. |
Notes
- Auth: none. The appeal token is the credential and it is carried in the body.
- Reached through the Xuda router at
POST /api/network/appeal, which is what the public appeal page at/network/appealposts to. That page is rendered with the token and application id already in its query string. - Idempotency: the token is single use, so a second appeal on the same token is refused.
- The support ticket it opens is deduped on the application reference, so a retry does not produce a second ticket.
reasonshorter than 10 characters is refused.
Errors
Every method returns { code, data }. code is 1 on success and negative on failure. The codes Finance uses:
| Code | Meaning |
|---|---|
-400 |
Bad request, or an unhandled failure inside the handler surfaced with its message. |
-401 |
No session on a method that requires one. |
-402 |
A plan gate refused the call, or the payment side refused a plan change. |
-403 |
Ownership or clearance refusal, including the superuser re-check on an operator method. |
-404 |
The finance account, document or account record was not found. |
What produces a -402. Five separate gates can return it:
| Gate | Flag | Cheapest tier that carries it | Methods affected |
|---|---|---|---|
| Finance account allowance | finance_accounts |
Free allows 1, Starter 2, Growth 5, Scale 20 | create_finance_account, and finance_set_plan as a downgrade guard |
| Recurring billing | subscriptions |
Growth | finance_create_subscription |
| Payment links | payment_links |
Starter | finance_create_payment_link |
| Coupons | coupons |
Starter | finance_create_coupon |
| Stripe Tax | stripe_tax |
Scale | finance_add_customer_tax_id, finance_delete_customer_tax_id, finance_set_product_tax_code, and all four tax methods |
| Customer billing portal | billing_portal |
Scale | finance_create_portal_session |
A refusal names the cheapest tier carrying the flag rather than telling you to upgrade in the abstract.
Refunds and credit notes are never gated. finance_refund_payment and finance_create_credit_note are excluded from the tier gate by design, because giving money back and correcting an issued invoice are obligations to your customer, not features to sell.
The membership plan gate is separate. Exactly one Finance method, create_stripe_account_link, carries min_plan: "pro" and is refused by the platform's generic membership gate rather than by a Finance flag. create_finance_account checks the same Pro rank inside its own handler specifically so it can exempt xuda.network partners.
Delegate seat refusals are not plan errors. A delegate seat may only create a customer and a quote, and may finalize and send the invoice its accepted quote produced. Everything else, including invoice creation, void, refund, credit note, coupon, product, price, payment link, billing portal and all tax methods, is refused with copy written for a partner rather than a generic error.
Known defect. finance_create_tax_registration returns code: -400 with the message "_FIN_EU_COUNTRIES is not defined" for any country other than the US, because the non-US branch references an undefined constant in the committed repo. US state registrations take the other branch and work.
Rate Limits
Finance declares no rate limits of its own. Two bounds are worth knowing because they shape how much you get back per call rather than how often you may call:
| Scope | Bound |
|---|---|
Documents returned by finance_list_documents |
capped at 200 per call, paginate with skip |
| Stale documents refreshed from Stripe per list call | 25 |
| Checkout sessions pulled in when listing orders | 50, abandoned sessions skipped |
| Tax code catalog pages fetched | 10 pages of 100 |
Documents returned by finance_admin_lookup_account |
capped at 200 |
Applications returned by finance_ambassador_applications |
capped at 500 |
Beyond these, Stripe's own API rate limits apply to every call, since every write reaches Stripe.
Idempotency
- Mirror writes are idempotent by construction. A
finance_documentid is derived deterministically from the finance account id plus the Stripe id, so a webhook arriving before, during or after the creating call lands on the same document rather than producing a duplicate. - Partner payouts cannot pay twice.
finance_payout_commissionwrites its payout record before the transfer and derives the Stripe idempotency key from the exact set of invoice rows being settled. - Payout requests are single-open.
finance_request_payoutrefuses while a request is already open. - Appeal tokens are single use. A second
finance_ambassador_appealon the same token is refused, and the support ticket it opens is deduped on the application reference. - Document creation is not idempotent.
finance_create_invoice,finance_create_quote,finance_refund_paymentand the rest will happily create a second object if you call them twice. There is no client-supplied idempotency key on these methods, so deduplicate on your side.
Webhooks
Finance does not publish webhooks of its own. It consumes Stripe's.
stripe_webhook verifies an incoming event against two secrets in turn, the platform account endpoint secret and a Connect endpoint secret, because a seller's invoice, quote, subscription or checkout raises its event on their own connected account and an account-only endpoint never sees it at all. The Finance mirror runs before the main event switch on any event matching invoice, quote, customer.subscription, credit_note, charge.refunded or checkout.session:
| Event | What Finance does with it |
|---|---|
checkout.session.* |
Refreshes the order if it is known, otherwise adopts it onto the finance account that owns the payment link behind it. |
charge.refunded |
Recomputes a delegate invoice's commission against what was actually kept, proportionally for a partial refund. |
invoice.* |
Refreshes the mirror row by Stripe id. An invoice not in the mirror is adopted onto whichever finance account owns its subscription. invoice.paid additionally accrues partner commission. |
quote.* |
Refreshes the mirror row by Stripe id. |
customer.subscription.* |
Refreshes the mirror row by Stripe id. |
credit_note.* |
Refreshes the mirror row by Stripe id. |
Webhooks are not the only path that keeps the mirror correct. Every list read re-reads non-terminal documents directly from Stripe, bounded to 25 per call, so a missed or out-of-order webhook cannot leave a document, or a commission accrual, wrong indefinitely.
Finance also publishes four account notification topics through the notification module rather than over HTTP: network_partner_approved, network_partner_declined, network_partner_commission_accrued and network_partner_commission_paid.
There are no crons. No scheduled job touches Finance.
A Note On The Operator Surface
The seven methods labeled Availability: Operator only above are documented for completeness, not as an integration target. They require admin clearance and each one re-checks superuser membership inside its own handler, so an ordinary session cannot reach them even with the right clearance claim from the layer above. They back the four tabs of the finance admin console: the partner application queue, the payout list, the seller lookup and the Xuda platform overview. Operator lookups of a seller's books are audited against the seller's own account.
A Note On Availability
Finance is live on the Xuda dev environment and is not on production yet. Two things gate that: the live-mode Stripe webhook configuration, which needs a Connect endpoint, the additional event types and the Connect signing secret, and the Finance plan prices, which are placeholders in configuration today. Because of the second, only the Free tier can be activated at present and finance_set_plan refuses any paid tier with code: -402.
Two further gaps are worth knowing before you plan around them. The Free tier's advertised limit of 25 documents a month is declared in configuration but is not enforced anywhere in code, so do not treat it as a hard stop in either direction. And finance_create_payment_link still has no dashboard button, so links must be created programmatically once the API surface opens up; once created they are listed, opened and attached to a contact from the Payments screen like any other finance document.