Skip to content

Affonso Schemas

github-actions[bot] edited this page Dec 2, 2026 · 1 revision

Affonso Schemas

Public Guardian schemas and their types, exported from @tundraconnect/affonso/schemas (and re-exported from the package root).

import {
  AffiliateSchemaObject,
  CreateConversionRequestSchemaObject,
  WebhookEventSchemaObject,
} from '@tundraconnect/affonso/schemas';

const [error, request] = CreateConversionRequestSchemaObject.safeParse({
  customer_id: 'cus_123',
  sale_amount: 99,
  external_event_id: 'in_2026_000145',
});
console.log(error, request, AffiliateSchemaObject, WebhookEventSchemaObject);

Every <Thing>SchemaObject has a matching <Thing>Schema type.

Request schemas are strict

Request schemas reject unknown fields instead of dropping them, so a typo never silently loses a value, and numbers and booleans must not arrive as strings. Response schemas are the opposite: they pass unknown fields through, so an additive change on Affonso's side never fails a read.

Requests

Export Used for
CreateAffiliateRequestSchemaObject POST /affiliates body.
UpdateAffiliateRequestSchemaObject PUT /affiliates/{id} body.
InvoiceDetailsUpdateSchemaObject invoice_details on an affiliate update.
PayoutDetailsSchemaObject payout_details on an affiliate create/update.
CreateReferralRequestSchemaObject POST /referrals body.
UpdateReferralRequestSchemaObject PUT /referrals/{id} body.
CreateCommissionRequestSchemaObject POST /commissions body.
UpdateCommissionRequestSchemaObject PUT /commissions/{id} body.
CreateBonusRequestSchemaObject POST /commissions/bonus body.
UpdatePayoutRequestSchemaObject PUT /payouts/{id} body (camelCase).
CreateCouponRequestSchemaObject POST /coupons body.
TrackClickRequestSchemaObject POST /clicks body (camelCase).
RecordSignupRequestSchemaObject POST /signups body.
CreateConversionRequestSchemaObject POST /conversions body.
RefundConversionRequestSchemaObject POST /conversions/{id}/refund body.

Responses

Export Used for
AffiliateSchemaObject An affiliate, and the copy embedded by expand=affiliate.
AffiliatePromoCodeSchemaObject One promoCodes entry (expand=promoCodes).
InvoiceDetailsSchemaObject invoiceDetails (expand=invoiceDetails).
AffiliatePayoutMethodSchemaObject payoutMethod (expand=payoutMethod).
PortalTokenSchemaObject createPortalToken result.
ReferralSchemaObject A referral; also recordSignup's result.
ReferralStatsSchemaObject stats on getReferral(id, { includeStats: true }).
CommissionSchemaObject A commission transaction.
BonusSchemaObject createBonus result.
PayoutSchemaObject A payout (camelCase).
PayoutTransactionSchemaObject One transactions entry of getPayout.
CouponSchemaObject A coupon.
CouponProviderRecordSchemaObject One provider_records entry.
ClickSchemaObject trackClick result (camelCase).
ConversionSchemaObject createConversion / refundConversion result.
ProgramSchemaObject getProgram result.
WebhookEventSchemaObject A webhook delivery's { id, type, createdAt, data } envelope.
PaginationSchemaObject A page-numbered list's raw pagination block (both spellings).
ErrorResponseSchemaObject Affonso's { success: false, error } failure envelope.
MetadataSchemaObject Free-form metadata JSON.

Enums

Export Values
AFFILIATE_STATUSES / AffiliateStatusSchemaObject pending, approved, rejected (requests).
PARTNERSHIP_STATUSES PENDING, APPROVED, REJECTED (responses; null = no partnership yet).
PAYOUT_METHODS paypal, wise, payoneer, paxum, webmoney, skrill, wire_transfer, bitcoin, ethereum, alipay, wechat, manual, none.
AFFILIATE_EXPANDS promoCodes, commissionOverrides, invoiceDetails, payoutMethod.
REFERRAL_STATUSES / ReferralStatusSchemaObject lead, trialing, customer, active, canceled, rejected.
COMMISSION_STATUSES / CommissionStatusSchemaObject pending, pending_manual_approval, ready_for_payment, paid, declined (settable).
COMMISSION_REPORTED_STATUSES The above plus processing_payout, refunded, dispute.
SALES_STATUSES / SalesStatusSchemaObject open, complete, trialing, failed, refunded, partial_refunded.
COMMISSION_EXPANDS affiliate, affiliate_program, referral.
PAYOUT_STATUSES / PayoutStatusSchemaObject pending, processing, completed, failed, cancelled.
COUPON_DISCOUNT_TYPES percentage, fixed.
COUPON_DURATIONS forever, once, repeating.
CONVERSION_INTERVALS monthly, yearly.
WEBHOOK_EVENT_TYPES Every documented affiliate.*, referral.*, transaction.*, payout.* and coupon.* event.

Where Affonso's documentation disagrees with itself

The schemas take the tolerant reading where the vendor docs are inconsistent:

  • Pagination spelling. Affiliates, payouts and coupons document totalPages / hasNextPage; commissions document total_pages / has_next_page. Both are accepted and the client normalizes them.
  • Update Payout's response. Its field table is snake_case while its example (and every other payout endpoint) is camelCase. The schema is camelCase.
  • Embedded copies are slimmer. A coupon's embedded affiliate has no partnership_status; a commission's embedded referral has no name or metadata; an idempotent recordSignup replay omits customer_id. Those fields are optional.
  • Webhook payloads. data is camelCase for most families but snake_case for coupon events, and statuses are UPPERCASE where the REST API's are lowercase. data is therefore left open.

← Back to Affonso

Clone this wiki locally