SDK reference
Public entry points, modules, configuration, and error contracts in @mayarin/sdk.
Generated from the SDK source. Prose and examples live on the module pages: server, browser, payments, commerce, webhooks.
Server configuration
secretKeystring
Secret key minted on the dashboard (`/api-keys`). Server-side only.
string
baseUrlstring
string
preset?"merchant"
"merchant" | undefined
fetch?function
((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined
generateIdempotencyKey?function
(() => string) | undefined
Server client
commerceobject
CommerceModule
paymentobject
PaymentModule
x402object
Agent-endpoint management (#269). Registration only — the request-time surface is keyless.
{ readonly resources: X402ResourcesModule; }
transportobject
Raw typed transport. The escape hatch until a module covers a route.
Transport
presetobject
Preset
Shared client configuration
Both entry points extend this: the base URL, the preset, and the two injectable effects.
baseUrlstring
string
preset?"merchant"
"merchant" | undefined
fetch?function
((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined
generateIdempotencyKey?function
(() => string) | undefined
Browser configuration
The browser entry point creates a client configured with an optional publishable key. There is no field for a secret.
publishableKey?string
Publishable key minted on the dashboard. Safe in a browser bundle: it identifies the merchant and reaches only catalog read and cart checkout. Without one, only the keyless buyer routes answer.
string | undefined
baseUrlstring
string
preset?"merchant"
"merchant" | undefined
fetch?function
((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined
generateIdempotencyKey?function
(() => string) | undefined
Browser client
commerceobject
PublishableCommerceModule
transportobject
Raw typed transport. The escape hatch until a module covers a route.
Transport
presetobject
Preset
Request options
query?Readonly<Record<string, union>>
Readonly<Record<string, string | number | boolean | undefined>> | undefined
idempotencyKey?string
Caller-supplied key for a write. The transport generates one when absent.
string | undefined
signal?object
AbortSignal | undefined
Transport
The escape hatch until a module covers a route. Keeps the /v1 prefix, version header, auth, idempotency, and error mapping.
getfunction
<T>(path: string, options?: RequestOptions) => Promise<T>
postfunction
<T>(path: string, body?: unknown, options?: RequestOptions) => Promise<T>
patchfunction
<T>(path: string, body: unknown, options?: RequestOptions) => Promise<T>
deletefunction
A write: gets an `Idempotency-Key` like every non-GET. A 204 resolves to `undefined`.
<T>(path: string, options?: RequestOptions) => Promise<T>
Error contract
codestring
string
statusnumber
HTTP status of the response, or 0 when no response arrived.
number
retryableunion
Whether retrying the same request unchanged can succeed later.
boolean
detailsRecord<string, unknown>
Record<string, unknown>
namestring
string
messagestring
string
stack?string
string | undefined
cause?unknown
unknown
Payment module
createIntentfunction
(body: CreatePaymentIntentBody, options?: RequestOptions) => Promise<PaymentIntentDto>
getIntentfunction
(id: string, options?: RequestOptions) => Promise<PaymentIntentDto>
confirmIntentfunction
(id: string, options?: RequestOptions) => Promise<PaymentDto>
getfunction
(id: string, options?: RequestOptions) => Promise<PaymentDto>
getContractCallfunction
(id: string, options?: RequestOptions) => Promise<ContractCallDto>
Commerce module
productsobject
{ readonly create: (body: CreateProductBody, options?: RequestOptions) => Promise<ProductDto>; readonly list: (merchantId?: string, options?: RequestOptions) => Promise<readonly ProductDto[]>; readonly get: (id: string, options?: RequestOptions) => Promise<ProductDto>; readonly update: (id: string, body: UpdateProductBody, options?: RequestOptions) => Promise<ProductDto>; }
cartsobject
{ readonly checkout: (body: CheckoutCartBody, options?: RequestOptions) => Promise<PaymentIntentDto & { url: string; }>; }
paymentLinksobject
{ readonly create: (body: CreatePaymentLinkBody, options?: RequestOptions) => Promise<PaymentLinkDto>; readonly list: (merchantId?: string, options?: RequestOptions) => Promise<readonly PaymentLinkDto[]>; readonly get: (id: string, options?: RequestOptions) => Promise<PaymentLinkDto>; readonly rails: (id: string, options?: RequestOptions) => Promise<PaymentRailsDto>; readonly disable: (id: string, options?: RequestOptions) => Promise<PaymentLinkDto>; readonly checkout: (id: string, body?: CheckoutPaymentLinkBody, options?: RequestOptions) => Promise<PaymentIntentDto>; }
invoicesobject
{ readonly create: (body: CreateInvoiceBody, options?: RequestOptions) => Promise<InvoiceDto>; readonly list: (merchantId?: string, options?: RequestOptions) => Promise<readonly InvoiceDto[]>; readonly get: (id: string, options?: RequestOptions) => Promise<InvoiceViewDto>; readonly update: (id: string, body: EditInvoiceBodyDto, options?: RequestOptions) => Promise<InvoiceDto>; readonly issue: (id: string, body: IssueInvoiceBodyDto, options?: RequestOptions) => Promise<InvoiceDto>; readonly void: (id: string, options?: RequestOptions) => Promise<InvoiceDto>; readonly checkout: (id: string, body?: CheckoutInvoiceBody, options?: RequestOptions) => Promise<PaymentIntentDto>; }
subscriptionsobject
Recurring plans (#296), send-to-pay: every cycle Mayarin issues the subscriber an invoice and emails its pay link. Payments on a cycle carry `metadata.subscriptionId` into the `payment.*` webhooks.
{ readonly create: (body: CreateSubscriptionBody, options?: RequestOptions) => Promise<SubscriptionDto>; readonly list: (options?: RequestOptions) => Promise<readonly SubscriptionDto[]>; readonly get: (id: string, options?: RequestOptions) => Promise<{ subscription: SubscriptionDto; cycles: readonly InvoiceViewDto[]; }>; readonly pause: (id: string, options?: RequestOptions) => Promise<SubscriptionDto>; readonly resume: (id: string, options?: RequestOptions) => Promise<SubscriptionDto>; readonly cancel: (id: string, options?: RequestOptions) => Promise<SubscriptionDto>; }
Publishable commerce module
The subset a publishable key reaches: catalog read and cart checkout.
productsPick<object, union>
Pick<{ readonly create: (body: CreateProductBody, options?: RequestOptions) => Promise<ProductDto>; readonly list: (merchantId?: string, options?: RequestOptions) => Promise<readonly ProductDto[]>; readonly get: (id: string, options?: RequestOptions) => Promise<ProductDto>; readonly update: (id: string, body: UpdateProductBody, options?: RequestOptions) => Promise<ProductDto>; }, "list" | "get">
cartsobject
{ readonly checkout: (body: CheckoutCartBody, options?: RequestOptions) => Promise<PaymentIntentDto & { url: string; }>; }
Webhook verification
payloadstring
string
signaturestring
string
secretstring
string
now?object
Date | undefined
toleranceSeconds?number
number | undefined
Presets
name"merchant"
"merchant"
openAmountLinksfalse
Payment links created with no amount let the payer type one.
false
checkout"catalog"
The commerce surface the integration leans on.
"catalog"