B2BService class (accessed via client.b2B) is the buyer-facing entry point for wholesale (B2B) commerce: a business buyer requests a quote, accepts it into a purchase order, tracks fulfilment, and pays invoices on terms.
Every method here acts on the signed-in buyer’s own records. Supplier-side work — pricing a quote, confirming a purchase order, recording shipments, and setting credit — happens in the supplier’s admin, not through this API. B2B endpoints are available only on a supplier deployment.
How wholesale works in Tybrite
A wholesale order moves through a fixed sequence, and each step maps to one or two methods here.- Request for quote (RFQ). The buyer asks a supplier to price a set of items and quantities —
createRfq. The supplier prices it into a quote. - Quote. A priced offer the buyer can accept or reject —
getQuote,acceptQuote,rejectQuote. A quote may carry a validity date, after which it expires. - Purchase order (PO). Accepting a quote creates a purchase order — the buyer’s commitment. It carries the buyer’s payment terms (prepaid, or net 15 / 30 / 60 days). Track it with
getPurchaseOrder/listPurchaseOrders. - Invoice. When the supplier confirms the purchase order, a terms invoice is issued. The buyer sees it with
getInvoice/listInvoices, and the supplier records payment against it when payment is received — in full or in parts. An invoice past its due date is marked overdue.
createDirectOrder places an order in one call at the buyer’s own agreed prices — the self-serve equivalent of the flow above. The request-for-quote path remains for negotiated or bespoke orders.
Every method requires the API key plus the buyer’s session — either an
xAuthToken (a session token from client.authentication.login) or an xExternalAuth assertion if you run your own identity provider. Provide one of the two on every call.The create calls (createRfq, createDirectOrder) require an idempotencyKey — a unique value per action, so a retried request is never applied twice.The typical integration flow
Direct checkout
createDirectOrder(options)
Places a wholesale order for an approved buyer in one call, without the request-for-quote round trip — the self-serve path for routine reorders at the buyer’s own agreed prices.
Send only the items and quantities. Galactic Core prices every line itself against the buyer’s wholesale price list (their per-buyer price, their group’s price, or the store default), enforces each item’s minimum order quantity and pack size, and computes the totals. Any price sent by the client is ignored. An item with no wholesale price for this buyer, a quantity below its minimum order quantity, or a quantity that is not a whole multiple of its pack size, is rejected with a clear reason.
Tax is resolved on the server too. When you include a structured shipping address, tax is calculated accurately for the destination; otherwise the store’s configured rate applies, and a tax-exempt buyer is charged no tax. The response’s tax_amount is the resolved tax, and total / amount are tax-inclusive.
How the order settles depends on the supplier’s policy for this buyer:
-
On terms — the order is confirmed and a terms invoice is issued (subject to the buyer’s credit limit). The response’s
settlementis"terms", withinvoice_id,invoice_number, anddue_date. The supplier records payment against the invoice when it is received. -
Pay now — the order is created awaiting payment. The response’s
settlementis"pay_now", with anorder_idandamount. Complete the payment through the payment flow (client.payments.initializePaymentthenverifyPayment) using thatorder_id, exactly as for a normal online order. -
Held for approval — the order total reaches the supplier’s approval threshold. The response’s
settlementis"pending_approval", with anapproval_id; no order or invoice exists yet. Once a second approver signs it off, the order proceeds on terms or as an invoice due for payment. -
requestBody.items— an array of{ variant_id, quantity }(required, non-empty). Do not send prices. -
requestBody.note— an optional note on the order. -
requestBody.shipping_address— an optional free-text shipping address. -
requestBody.shipping_address_parts— an optional structured shipping address (line1,city,region,country,postal_code). Supply it so tax is calculated for the destination. -
requestBody.currency— the order currency (e.g."USD"). -
idempotencyKey— required. -
xTimestamp/xSignature— required unless the store has turned order signing off (on by default); when sent, the signature is always verified. A signed direct order is signed like a standard order:xTimestampis the current Unix time in milliseconds, andxSignatureis the Base64 HMAC-SHA256 of`${xTimestamp}.${rawJsonBody}`using the store’s signing secret. See Signing requests.
Response (terms)
Response (pay now, tax calculated for the destination)
Requests for quote
createRfq(options)
Requests a quote for a set of items and quantities. The supplier prices it into a quote you can later accept.
requestBody.line_items— an array of{ variant_id, quantity, note? }(required, non-empty).requestBody.note— an optional message to the supplier.requestBody.expires_at— an optional expiry for the request.idempotencyKey— required.
{ data: B2bRfq }), including its rfq_number (for example RFQ-20260711-4f0c2a): the reference the supplier sees for the same request. It is assigned on creation and never changes.
listRfqs(options)
Returns your own requests for quote, newest first ({ data: B2bRfq[] }).
getRfq(options)
Returns one of your requests for quote by id.
Quotes
getQuote(options)
Returns a quote addressed to you by id, including its quote_number (for example Q-20260711-8d31b7, the reference the supplier sees), priced line items, totals, and validity date.
acceptQuote(options)
Accepts a sent quote and creates a purchase order from it. The purchase order then awaits the supplier’s confirmation before an invoice is issued. Returns { data: { quote_id, purchase_order_id, po_number } }. When the quote total reaches the supplier’s approval threshold the response is { data: { quote_id, approval_pending: true, approval_id } }, and the purchase order is created once the approval is granted.
rejectQuote(options)
Rejects a quote by id.
Purchase orders
listPurchaseOrders(options)
Returns your own purchase orders, newest first ({ data: B2bPurchaseOrder[] }).
getPurchaseOrder(options)
Returns one of your purchase orders by id, including its status (issued, confirmed, partially_fulfilled, fulfilled, cancelled), line items, totals, and payment terms.
Invoices
listInvoices(options)
Returns your own invoices, newest first ({ data: B2bInvoice[] }). Each carries its status (issued, partially_paid, paid, overdue, void), amount, amount paid, and due date. Amounts are in major currency units (200 is 200.00 in the invoice currency), as on every other B2B figure.
getInvoice(options)
Returns one of your invoices by id.
payInvoice(options)
Opens an online payment for one of the buyer’s invoices and returns payment_url, the supplier’s hosted payment page. The buyer pays there through one of the supplier’s own payment providers; no card details pass through the page. The invoice is updated only once the provider confirms the payment: to partially_paid while a balance remains, then paid, and the b2b.invoice.partially_paid and b2b.invoice.paid webhook events follow. Each payment frees the buyer’s credit by the amount paid.
id— the invoice id.requestBody.amount— optional; the amount to pay now, from 0.01 up to the open balance. Omitted, the full balance.
#t= and is valid until expires_at (24 hours). Responses: 400 invalid_amount for an amount below 0.01 or above the balance, 404 for an invoice the buyer does not own, 409 invoice_not_payable for an invoice already paid or voided, and 403 for a publishable key or a customer without a wholesale account.
Response
Approvals
A supplier can hold a wholesale purchase above an approval threshold until someone at the buying business approves it. When the buyer orders through the API with no store of its own, its approvers decide those holds with these two methods. Each acts on the person behind the session; the person who placed an order can never approve it.listB2BApprovals(options)
Returns the purchases waiting for a decision on the wholesale accounts the signed-in person approves for, newest first ({ data: B2bApproval[] }). Each entry carries the amount in major currency units (2500 is 2500.00 in currency), the currency, the status and can_decide, which is false for an order this person placed. Requires exactly one of xAuthToken, xExternalAuth or xIdpToken.
Response
decideB2BApproval(options)
Records the signed-in approver’s decision on one held purchase. Approving a pay-now purchase makes the order payable; rejecting it releases nothing. Deciding an approval that is already decided returns it unchanged. Requires a secret key.
id— the approval id.requestBody.decision—approvedorrejected.requestBody.reason— optional; a note of up to 500 characters kept with the decision.
400 for any other decision, 403 for a publishable key, a person who is not an approver of the account, or the person who placed the order, and 404 for an approval this person cannot see.
Response

