{"openapi":"3.1.0","info":{"title":"AgentRef REST API","version":"1.0.0","description":"REST API v1 for merchants and affiliates. Authentication via API keys (Authorization: Bearer ak_...)."},"servers":[{"url":"/api/v1","description":"Current API version"}],"security":[{"ApiKeyAuth":[]}],"tags":[{"name":"Auth"},{"name":"Onboarding"},{"name":"Programs"},{"name":"Merchant"},{"name":"Applications"},{"name":"Affiliates"},{"name":"Me"},{"name":"Coupons"},{"name":"Invites"},{"name":"Conversions"},{"name":"Payouts"},{"name":"Flags"},{"name":"Billing"},{"name":"Marketplace"},{"name":"Notifications"},{"name":"Webhooks"},{"name":"Docs"},{"name":"Meta"}],"paths":{"/programs":{"get":{"tags":["Programs"],"operationId":"listPrograms","summary":"List programs","parameters":[{"$ref":"#/components/parameters/CursorParam"},{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PageSizeParam"},{"$ref":"#/components/parameters/OffsetParam"},{"name":"status","in":"query","schema":{"type":"string","enum":["active","paused","archived"]}}],"responses":{"200":{"description":"Programs list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Program"}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}},"required":["data","meta"]}}}},"401":{"$ref":"#/components/responses/ErrorResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"}}},"post":{"tags":["Programs"],"operationId":"createProgram","summary":"Create program","parameters":[{"$ref":"#/components/parameters/IdempotencyKeyHeader"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateProgramInput"}}}},"responses":{"201":{"description":"Program created","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Program"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}},"400":{"$ref":"#/components/responses/ErrorResponse"},"401":{"$ref":"#/components/responses/ErrorResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"}}}},"/programs/{id}":{"get":{"tags":["Programs"],"operationId":"getProgram","summary":"Get program by id","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"responses":{"200":{"description":"Program details","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ProgramDetail"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}},"404":{"$ref":"#/components/responses/ErrorResponse"}}},"patch":{"tags":["Programs"],"operationId":"updateProgram","summary":"Update program","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateProgramInput"}}}},"responses":{"200":{"description":"Updated program","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Program"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}},"400":{"$ref":"#/components/responses/ErrorResponse"},"404":{"$ref":"#/components/responses/ErrorResponse"}}},"delete":{"tags":["Programs"],"operationId":"archiveProgram","summary":"Archive program","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"responses":{"200":{"description":"Archived program","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Program"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}},"404":{"$ref":"#/components/responses/ErrorResponse"}}}},"/programs/{id}/connect-stripe":{"post":{"tags":["Programs"],"operationId":"connectProgramStripe","summary":"Connect Stripe for a specific program","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"method":{"type":"string","enum":["oauth_url"],"default":"oauth_url"}}}}}},"responses":{"200":{"description":"Program-scoped Stripe connect result","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ConnectProgramStripeResponse"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}},"400":{"$ref":"#/components/responses/ErrorResponse"},"404":{"$ref":"#/components/responses/ErrorResponse"},"409":{"$ref":"#/components/responses/ErrorResponse"}}},"delete":{"tags":["Programs"],"operationId":"disconnectProgramStripe","summary":"Disconnect Stripe for a specific program","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"responses":{"200":{"description":"Program-scoped Stripe disconnect result","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/DisconnectProgramStripeResponse"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}},"404":{"$ref":"#/components/responses/ErrorResponse"}}}},"/programs/{id}/marketplace":{"patch":{"tags":["Programs","Marketplace"],"operationId":"updateProgramMarketplace","summary":"Update marketplace visibility and listing details for a program","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["private","draft","public"]},"applicationAccess":{"type":"string","enum":["open","invite_only"]},"autoApproveAffiliates":{"type":"boolean"},"category":{"type":"string","maxLength":64},"description":{"type":"string","maxLength":500},"logoUrl":{"type":"string","format":"uri"}}}}}},"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"},"400":{"$ref":"#/components/responses/ErrorResponse"},"404":{"$ref":"#/components/responses/ErrorResponse"}}}},"/programs/{id}/affiliates":{"get":{"tags":["Programs","Affiliates"],"operationId":"listProgramAffiliates","summary":"List affiliates for a program","parameters":[{"$ref":"#/components/parameters/UuidPathId"},{"name":"includeBlocked","in":"query","schema":{"type":"boolean","default":false}},{"name":"source","in":"query","description":"Filter affiliates by application source","schema":{"type":"string","enum":["browser","api","mcp","invite","import"]}},{"$ref":"#/components/parameters/CursorParam"},{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PageSizeParam"},{"$ref":"#/components/parameters/OffsetParam"}],"responses":{"200":{"description":"Affiliates list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Affiliate"}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}},"required":["data","meta"]}}}}}}},"/programs/{id}/stats":{"get":{"tags":["Programs"],"operationId":"getProgramStats","summary":"Get program stats","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"responses":{"200":{"description":"Program stats","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ProgramStats"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}}}}},"/programs/{id}/tracking/status":{"get":{"tags":["Programs"],"operationId":"getProgramTrackingStatus","summary":"Get tracking diagnostics status for a program","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"responses":{"200":{"description":"Tracking diagnostics status","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ProgramTrackingStatusResponse"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}},"404":{"$ref":"#/components/responses/ErrorResponse"}}}},"/merchant":{"get":{"tags":["Merchant"],"operationId":"getMerchant","summary":"Get merchant account profile","responses":{"200":{"description":"Merchant account profile","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/MerchantProfile"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}}}},"patch":{"tags":["Merchant"],"operationId":"updateMerchant","summary":"Update merchant account profile","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateMerchantInput"}}}},"responses":{"200":{"description":"Updated merchant account profile","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/MerchantProfile"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}}}}},"/merchant/notifications":{"get":{"tags":["Merchant"],"operationId":"getMerchantNotifications","summary":"Get merchant notification preferences","responses":{"200":{"description":"Notification preferences","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/NotificationPreferences"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}},"401":{"$ref":"#/components/responses/ErrorResponse"}}},"put":{"tags":["Merchant"],"operationId":"updateMerchantNotifications","summary":"Update merchant notification preferences","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateNotificationPreferencesInput"}}}},"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"},"400":{"$ref":"#/components/responses/ErrorResponse"}}}},"/affiliates":{"get":{"tags":["Affiliates"],"operationId":"listAffiliates","summary":"List affiliates","parameters":[{"name":"programId","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"includeBlocked","in":"query","schema":{"type":"boolean","default":false}},{"name":"search","in":"query","description":"Search affiliates by name or email (max 120 chars)","schema":{"type":"string","maxLength":120}},{"name":"sortBy","in":"query","description":"Sort field","schema":{"type":"string","enum":["createdAt","totalClicks","totalRevenue","name"]}},{"name":"sortOrder","in":"query","description":"Sort direction","schema":{"type":"string","enum":["asc","desc"],"default":"desc"}},{"name":"status","in":"query","description":"Filter by affiliate status","schema":{"type":"string","enum":["approved","blocked"]}},{"name":"source","in":"query","description":"Filter affiliates by application source","schema":{"type":"string","enum":["browser","api","mcp","invite","import"]}},{"$ref":"#/components/parameters/CursorParam"},{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PageSizeParam"},{"$ref":"#/components/parameters/OffsetParam"}],"responses":{"200":{"description":"Affiliates list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Affiliate"}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}},"required":["data","meta"]}}}}}}},"/applications":{"get":{"tags":["Applications"],"operationId":"listApplications","summary":"List affiliate applications","parameters":[{"name":"programId","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"search","in":"query","description":"Search applications by applicant name or email (max 120 chars)","schema":{"type":"string","maxLength":120}},{"name":"status","in":"query","description":"Filter by application status","schema":{"type":"string","enum":["pending","approved","declined","withdrawn","blocked"]}},{"name":"source","in":"query","description":"Filter applications by submission source","schema":{"type":"string","enum":["browser","api","mcp","invite","import"]}},{"$ref":"#/components/parameters/CursorParam"},{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PageSizeParam"},{"$ref":"#/components/parameters/OffsetParam"}],"responses":{"200":{"description":"Applications list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Application"}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}},"required":["data","meta"]}}}}}}},"/applications/{id}":{"get":{"tags":["Applications"],"operationId":"getApplication","summary":"Get application by id","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"responses":{"200":{"description":"Application details","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Application"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}}}}},"/applications/{id}/approve":{"post":{"tags":["Applications"],"operationId":"approveApplication","summary":"Approve application and create affiliate membership","parameters":[{"$ref":"#/components/parameters/UuidPathId"},{"$ref":"#/components/parameters/IdempotencyKeyHeader"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"note":{"type":"string","maxLength":500}}}}}},"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"}}}},"/applications/{id}/decline":{"post":{"tags":["Applications"],"operationId":"declineApplication","summary":"Decline an application","parameters":[{"$ref":"#/components/parameters/UuidPathId"},{"$ref":"#/components/parameters/IdempotencyKeyHeader"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"note":{"type":"string","maxLength":500}}}}}},"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"}}}},"/applications/{id}/block":{"post":{"tags":["Applications"],"operationId":"blockApplication","summary":"Block an application","parameters":[{"$ref":"#/components/parameters/UuidPathId"},{"$ref":"#/components/parameters/IdempotencyKeyHeader"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"note":{"type":"string","maxLength":500}}}}}},"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"}}}},"/affiliates/{id}":{"get":{"tags":["Affiliates"],"operationId":"getAffiliate","summary":"Get affiliate by id","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"responses":{"200":{"description":"Affiliate details","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Affiliate"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}}}}},"/affiliates/{id}/block":{"post":{"tags":["Affiliates"],"operationId":"blockAffiliate","summary":"Block affiliate","parameters":[{"$ref":"#/components/parameters/UuidPathId"},{"$ref":"#/components/parameters/IdempotencyKeyHeader"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","maxLength":500}}}}}},"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"}}}},"/affiliates/{id}/unblock":{"post":{"tags":["Affiliates"],"operationId":"unblockAffiliate","summary":"Unblock affiliate","parameters":[{"$ref":"#/components/parameters/UuidPathId"},{"$ref":"#/components/parameters/IdempotencyKeyHeader"}],"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"}}}},"/conversions":{"get":{"tags":["Conversions"],"operationId":"listConversions","summary":"List conversions","parameters":[{"name":"programId","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"affiliateId","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"status","in":"query","schema":{"type":"string","enum":["pending","approved","partially_refunded","rejected","refunded"]}},{"name":"from","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"to","in":"query","schema":{"type":"string","format":"date-time"}},{"$ref":"#/components/parameters/CursorParam"},{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PageSizeParam"},{"$ref":"#/components/parameters/OffsetParam"}],"responses":{"200":{"description":"Conversions list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Conversion"}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}},"required":["data","meta"]}}}}}}},"/conversions/stats":{"get":{"tags":["Conversions"],"operationId":"getConversionStats","summary":"Get conversion stats","parameters":[{"name":"programId","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"period","in":"query","schema":{"type":"string","enum":["7d","30d","90d","all"]}}],"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"}}}},"/conversions/recent":{"get":{"tags":["Conversions"],"operationId":"getRecentConversions","summary":"Get recent conversions","parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":20}}],"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"}}}},"/payouts":{"get":{"tags":["Payouts"],"operationId":"listPayouts","summary":"List payouts","parameters":[{"name":"programId","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"affiliateId","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"status","in":"query","schema":{"type":"string","enum":["pending","processing","completed","failed"]}},{"name":"from","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"to","in":"query","schema":{"type":"string","format":"date-time"}},{"$ref":"#/components/parameters/CursorParam"},{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PageSizeParam"},{"$ref":"#/components/parameters/OffsetParam"}],"responses":{"200":{"description":"Payouts list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Payout"}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}},"required":["data","meta"]}}}}}},"post":{"tags":["Payouts"],"operationId":"createPayout","summary":"Create manual payout record","parameters":[{"$ref":"#/components/parameters/IdempotencyKeyHeader"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"affiliateId":{"type":"string","format":"uuid"},"programId":{"type":"string","format":"uuid"},"notes":{"type":"string"}},"required":["affiliateId","programId"]}}}},"responses":{"201":{"$ref":"#/components/responses/SuccessObjectResponse"},"400":{"$ref":"#/components/responses/ErrorResponse"}}}},"/payouts/pending":{"get":{"tags":["Payouts"],"operationId":"listPendingPayoutAffiliates","summary":"List affiliates eligible for payout","parameters":[{"name":"programId","in":"query","schema":{"type":"string","format":"uuid"}},{"$ref":"#/components/parameters/CursorParam"},{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PageSizeParam"},{"$ref":"#/components/parameters/OffsetParam"}],"responses":{"200":{"description":"Pending payout affiliates","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","additionalProperties":true}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}},"required":["data","meta"]}}}}}}},"/payouts/stats":{"get":{"tags":["Payouts"],"operationId":"getPayoutStats","summary":"Get payout stats","parameters":[{"name":"programId","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"period","in":"query","schema":{"type":"string","enum":["7d","30d","90d","all"]}}],"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"}}}},"/flags":{"get":{"tags":["Flags"],"operationId":"listFlags","summary":"List fraud flags","parameters":[{"name":"status","in":"query","schema":{"type":"string","enum":["open","reviewed","dismissed","confirmed"]}},{"name":"type","in":"query","schema":{"type":"string","enum":["suspicious_activity","self_referral","high_click_frequency","conversion_anomaly","manual_review"]}},{"name":"affiliateId","in":"query","schema":{"type":"string","format":"uuid"}},{"$ref":"#/components/parameters/CursorParam"},{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PageSizeParam"},{"$ref":"#/components/parameters/OffsetParam"}],"responses":{"200":{"description":"Flags list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","additionalProperties":true}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}},"required":["data","meta"]}}}}}}},"/flags/stats":{"get":{"tags":["Flags"],"operationId":"getFlagStats","summary":"Get fraud flag stats","responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"}}}},"/flags/{id}/resolve":{"post":{"tags":["Flags"],"operationId":"resolveFlag","summary":"Resolve fraud flag","parameters":[{"$ref":"#/components/parameters/UuidPathId"},{"$ref":"#/components/parameters/IdempotencyKeyHeader"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["reviewed","dismissed","confirmed"]},"note":{"type":"string","maxLength":500},"blockAffiliate":{"type":"boolean","default":false}},"required":["status"]}}}},"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"},"400":{"$ref":"#/components/responses/ErrorResponse"},"404":{"$ref":"#/components/responses/ErrorResponse"}}}},"/billing":{"get":{"tags":["Billing"],"operationId":"getBillingOverview","summary":"Get billing overview","responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"}}}},"/billing/tiers":{"get":{"tags":["Billing"],"operationId":"listBillingTiers","summary":"List available billing tiers","responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"}}}},"/billing/subscribe":{"post":{"tags":["Billing"],"operationId":"startBillingSubscription","summary":"Start billing subscription checkout","parameters":[{"$ref":"#/components/parameters/IdempotencyKeyHeader"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"tier":{"type":"string","enum":["starter","growth","pro","scale"]}},"required":["tier"]}}}},"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"},"400":{"$ref":"#/components/responses/ErrorResponse"}}}},"/onboarding/merchant":{"post":{"tags":["Onboarding"],"operationId":"upsertOnboardingMerchantProfile","summary":"Set merchant profile data during onboarding","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"companyName":{"type":"string","minLength":1,"maxLength":120}},"required":["companyName"]}}}},"responses":{"200":{"description":"Updated onboarding merchant profile","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/OnboardingMerchantProfileResponse"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}},"403":{"$ref":"#/components/responses/ErrorResponse"}}}},"/onboarding/complete":{"post":{"tags":["Onboarding"],"operationId":"completeOnboarding","summary":"Finalize onboarding (requires full key and active state)","responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"},"400":{"$ref":"#/components/responses/ErrorResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"}}}},"/me":{"get":{"tags":["Me"],"operationId":"getCurrentApiIdentity","summary":"Get current API key identity and owner overview","responses":{"200":{"description":"Current API key identity","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"oneOf":[{"$ref":"#/components/schemas/MeMerchantIdentity"},{"$ref":"#/components/schemas/MeAffiliateIdentity"}]},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}},"401":{"$ref":"#/components/responses/ErrorResponse"}}}},"/me/programs":{"get":{"tags":["Me"],"operationId":"listMyPrograms","summary":"List programs for the authenticated affiliate key","responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"}}}},"/me/programs/{programId}":{"get":{"tags":["Me"],"operationId":"getMyProgramDetails","summary":"Get affiliate program details for the authenticated key","parameters":[{"name":"programId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"},"404":{"$ref":"#/components/responses/ErrorResponse"}}}},"/me/earnings":{"get":{"tags":["Me"],"operationId":"getMyEarningsOverview","summary":"Get earnings summary for authenticated affiliate key","responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"}}}},"/me/earnings/{programId}":{"get":{"tags":["Me"],"operationId":"listMyProgramEarnings","summary":"List earnings entries for a specific program","parameters":[{"name":"programId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"period","in":"query","required":false,"schema":{"type":"string","enum":["7d","30d","90d","all"],"default":"30d"}},{"$ref":"#/components/parameters/CursorParam"},{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PageSizeParam"},{"$ref":"#/components/parameters/OffsetParam"}],"responses":{"200":{"description":"Earnings list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","additionalProperties":true}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}},"required":["data","meta"]}}}}}}},"/me/payouts":{"get":{"tags":["Me"],"operationId":"listMyPayouts","summary":"List payouts for authenticated affiliate key","parameters":[{"$ref":"#/components/parameters/CursorParam"},{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PageSizeParam"},{"$ref":"#/components/parameters/OffsetParam"}],"responses":{"200":{"description":"Payouts list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Payout"}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}},"required":["data","meta"]}}}}}}},"/me/links":{"get":{"tags":["Me"],"operationId":"listMyLinks","summary":"List affiliate links for authenticated key","responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"}}},"post":{"tags":["Me"],"operationId":"createMyLink","summary":"Create a new affiliate link","parameters":[{"$ref":"#/components/parameters/IdempotencyKeyHeader"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"targetUrl":{"type":"string","format":"uri"}},"required":["name"]}}}},"responses":{"201":{"$ref":"#/components/responses/SuccessObjectResponse"},"400":{"$ref":"#/components/responses/ErrorResponse"}}}},"/me/links/{id}":{"patch":{"tags":["Me"],"operationId":"updateMyLink","summary":"Update an affiliate link","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"targetUrl":{"type":"string","format":"uri"},"isActive":{"type":"boolean"}}}}}},"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"}}},"delete":{"tags":["Me"],"operationId":"deleteMyLink","summary":"Delete an affiliate link","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"},"404":{"$ref":"#/components/responses/ErrorResponse"}}}},"/me/clicks":{"get":{"tags":["Me"],"operationId":"getMyClickStats","summary":"Get click stats for authenticated affiliate key","parameters":[{"name":"startDate","in":"query","schema":{"type":"string"}},{"name":"endDate","in":"query","schema":{"type":"string"}}],"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"}}}},"/me/payout-info":{"get":{"tags":["Me"],"operationId":"getMyPayoutInfo","summary":"Get payout information for authenticated affiliate key","responses":{"200":{"description":"Payout info","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/PayoutInfo"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}},"401":{"$ref":"#/components/responses/ErrorResponse"}}},"patch":{"tags":["Me"],"operationId":"updateMyPayoutInfo","summary":"Update payout information for authenticated affiliate key","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdatePayoutInfoInput"}}}},"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"},"400":{"$ref":"#/components/responses/ErrorResponse"}}}},"/programs/{id}/coupons":{"get":{"tags":["Programs","Coupons"],"operationId":"listProgramCoupons","summary":"List coupons for a program","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"}}},"post":{"tags":["Programs","Coupons"],"operationId":"createProgramCoupon","summary":"Create coupon for a program","parameters":[{"$ref":"#/components/parameters/UuidPathId"},{"$ref":"#/components/parameters/IdempotencyKeyHeader"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"affiliateId":{"type":"string","format":"uuid"},"code":{"type":"string","minLength":3,"maxLength":20},"expiresAt":{"type":"string","format":"date-time"}},"required":["affiliateId","code"]}}}},"responses":{"201":{"$ref":"#/components/responses/SuccessObjectResponse"},"409":{"$ref":"#/components/responses/ErrorResponse"}}}},"/coupons/{id}":{"delete":{"tags":["Coupons"],"operationId":"deleteCoupon","summary":"Delete coupon","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"},"404":{"$ref":"#/components/responses/ErrorResponse"}}}},"/programs/{id}/invites":{"get":{"tags":["Programs","Invites"],"operationId":"listProgramInvites","summary":"List invites for a program","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"}}},"post":{"tags":["Programs","Invites"],"operationId":"createProgramInvite","summary":"Create invite for a program","parameters":[{"$ref":"#/components/parameters/UuidPathId"},{"$ref":"#/components/parameters/IdempotencyKeyHeader"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","maxLength":100},"email":{"type":"string","format":"email"},"isPublic":{"type":"boolean","default":false},"usageLimit":{"type":"integer","minimum":1,"maximum":1000},"expiresInDays":{"type":"integer","minimum":1,"maximum":365},"trackingCode":{"type":"string","minLength":3,"maxLength":50,"pattern":"^[a-zA-Z0-9_-]+$","description":"Custom tracking code for the invite link"},"skipOnboarding":{"type":"boolean","description":"Skip onboarding flow when affiliate claims invite"}}}}}},"responses":{"201":{"$ref":"#/components/responses/SuccessObjectResponse"}}}},"/invites/{token}":{"get":{"tags":["Invites"],"operationId":"getInviteByToken","summary":"Get invite details by public token","security":[],"parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"},"404":{"$ref":"#/components/responses/ErrorResponse"}}}},"/invites/{token}/claim":{"post":{"tags":["Invites"],"operationId":"claimInvite","summary":"Claim invite with authenticated API key owner","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"201":{"$ref":"#/components/responses/SuccessObjectResponse"},"400":{"$ref":"#/components/responses/ErrorResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"}}}},"/marketplace/programs":{"get":{"tags":["Marketplace"],"operationId":"listMarketplacePrograms","summary":"Discover public marketplace programs","parameters":[{"name":"category","in":"query","required":false,"schema":{"type":"string"}},{"name":"minCommission","in":"query","required":false,"schema":{"type":"number","minimum":0,"maximum":100}},{"name":"minEpc","in":"query","required":false,"schema":{"type":"number","minimum":0}},{"name":"sort","in":"query","required":false,"schema":{"type":"string","enum":["epc","conversionRate","commission","newest"]}},{"$ref":"#/components/parameters/CursorParam"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":50}},{"$ref":"#/components/parameters/PageParam"},{"name":"pageSize","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":50}},{"$ref":"#/components/parameters/OffsetParam"}],"responses":{"200":{"$ref":"#/components/responses/SuccessArrayResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"}}}},"/marketplace/apply/{programId}":{"post":{"tags":["Marketplace"],"operationId":"applyToMarketplaceProgram","summary":"Apply to a marketplace program as authenticated affiliate","parameters":[{"name":"programId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","maxLength":1000}}}}}},"responses":{"200":{"$ref":"#/components/responses/SuccessObjectResponse"},"201":{"$ref":"#/components/responses/SuccessObjectResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"},"404":{"$ref":"#/components/responses/ErrorResponse"}}}},"/webhooks":{"get":{"tags":["Webhooks"],"operationId":"listWebhookEndpoints","summary":"List outbound webhook endpoints for the authenticated merchant","parameters":[{"name":"programId","in":"query","required":false,"schema":{"type":"string","format":"uuid"},"description":"When provided, only program-scoped endpoints for this program are returned."}],"responses":{"200":{"description":"Webhook endpoint list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/WebhookEndpoint"}},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}},"401":{"$ref":"#/components/responses/ErrorResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"}}},"post":{"tags":["Webhooks"],"operationId":"createWebhookEndpoint","summary":"Create an outbound webhook endpoint","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateWebhookEndpointInput"}}}},"responses":{"201":{"description":"Webhook endpoint created","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/WebhookSecretResponse"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}},"400":{"$ref":"#/components/responses/ErrorResponse"},"401":{"$ref":"#/components/responses/ErrorResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"},"409":{"$ref":"#/components/responses/ErrorResponse"}}}},"/webhooks/{id}":{"get":{"tags":["Webhooks"],"operationId":"getWebhookEndpoint","summary":"Get an outbound webhook endpoint by id","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"responses":{"200":{"description":"Webhook endpoint","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/WebhookEndpoint"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}},"401":{"$ref":"#/components/responses/ErrorResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"},"404":{"$ref":"#/components/responses/ErrorResponse"}}},"patch":{"tags":["Webhooks"],"operationId":"updateWebhookEndpoint","summary":"Update an outbound webhook endpoint","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateWebhookEndpointInput"}}}},"responses":{"200":{"description":"Updated webhook endpoint","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/WebhookEndpoint"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}},"400":{"$ref":"#/components/responses/ErrorResponse"},"401":{"$ref":"#/components/responses/ErrorResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"},"404":{"$ref":"#/components/responses/ErrorResponse"}}},"delete":{"tags":["Webhooks"],"operationId":"deleteWebhookEndpoint","summary":"Disable an outbound webhook endpoint","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"responses":{"200":{"description":"Webhook endpoint disabled","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}},"401":{"$ref":"#/components/responses/ErrorResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"},"404":{"$ref":"#/components/responses/ErrorResponse"}}}},"/webhooks/{id}/rotate-secret":{"post":{"tags":["Webhooks"],"operationId":"rotateWebhookEndpointSecret","summary":"Rotate the signing secret for an outbound webhook endpoint","parameters":[{"$ref":"#/components/parameters/UuidPathId"}],"responses":{"200":{"description":"Webhook secret rotated","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/WebhookSecretResponse"},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}},"400":{"$ref":"#/components/responses/ErrorResponse"},"401":{"$ref":"#/components/responses/ErrorResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"},"404":{"$ref":"#/components/responses/ErrorResponse"}}}},"/docs":{"get":{"tags":["Docs"],"operationId":"getApiDocumentationUi","summary":"Hosted API documentation UI","security":[],"responses":{"200":{"description":"HTML documentation page","content":{"text/html":{"schema":{"type":"string"}}}}}}}},"components":{"securitySchemes":{"ApiKeyAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"Use API key as Bearer token, for example: Bearer ak_live_xxx"}},"parameters":{"UuidPathId":{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},"CursorParam":{"name":"cursor","in":"query","required":false,"schema":{"type":"string"}},"LimitParam":{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100}},"PageParam":{"name":"page","in":"query","required":false,"schema":{"type":"integer","minimum":1}},"PageSizeParam":{"name":"pageSize","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100}},"OffsetParam":{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0}},"IdempotencyKeyHeader":{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string"},"description":"Client generated idempotency key (recommended for create/financial operations)."}},"responses":{"ErrorResponse":{"description":"Error response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"SuccessObjectResponse":{"description":"Success response","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","additionalProperties":true},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["data","meta"]}}}}},"schemas":{"RequestMeta":{"type":"object","properties":{"requestId":{"type":"string"}},"required":["requestId"]},"PaginatedMeta":{"type":"object","properties":{"total":{"type":"integer"},"page":{"type":"integer"},"pageSize":{"type":"integer"},"hasMore":{"type":"boolean"},"nextCursor":{"type":"string"},"requestId":{"type":"string"}},"required":["total","page","pageSize","hasMore","requestId"]},"ErrorResponse":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":true}},"required":["code","message"]},"meta":{"$ref":"#/components/schemas/RequestMeta"}},"required":["error","meta"]},"Program":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"merchantId":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":["string","null"]},"slug":{"type":"string"},"website":{"type":["string","null"],"format":"uri"},"landingPageUrl":{"type":["string","null"],"format":"uri"},"portalSlug":{"type":["string","null"]},"portalTheme":{"type":"string","enum":["classic","ocean","ember"]},"status":{"type":"string","enum":["active","paused","archived"]},"marketplaceStatus":{"type":"string","enum":["private","draft","public"]},"applicationAccess":{"type":"string","enum":["open","invite_only"]},"marketplaceCategory":{"type":["string","null"]},"marketplaceDescription":{"type":["string","null"]},"marketplaceLogoUrl":{"type":["string","null"],"format":"uri"},"commissionType":{"type":"string","enum":["one_time","recurring","recurring_limited"]},"commissionPercent":{"type":"integer"},"commissionLimitMonths":{"type":["integer","null"]},"commissionHoldDays":{"type":"integer"},"cookieDuration":{"type":"integer"},"trackingRequiresConsent":{"type":["boolean","null"]},"trackingParamAliases":{"type":["array","null"],"items":{"type":"string"}},"payoutThreshold":{"type":"integer"},"payoutFrequency":{"type":"string","enum":["weekly","monthly","quarterly"]},"currency":{"type":"string"},"autoApproveAffiliates":{"type":"boolean"},"termsUrl":{"type":["string","null"],"format":"uri"},"stripeAccountId":{"type":["string","null"]},"stripeAccountDisplayName":{"type":["string","null"]},"stripeConnectedAt":{"type":["string","null"],"format":"date-time"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","merchantId","name","description","slug","website","landingPageUrl","portalSlug","portalTheme","status","marketplaceStatus","applicationAccess","marketplaceCategory","marketplaceDescription","marketplaceLogoUrl","commissionType","commissionPercent","commissionLimitMonths","commissionHoldDays","cookieDuration","trackingRequiresConsent","trackingParamAliases","payoutThreshold","payoutFrequency","currency","autoApproveAffiliates","termsUrl","stripeAccountId","stripeAccountDisplayName","stripeConnectedAt","createdAt","updatedAt"]},"ProgramDetail":{"allOf":[{"$ref":"#/components/schemas/Program"},{"type":"object","properties":{"readiness":{"$ref":"#/components/schemas/ProgramReadiness"}},"required":["readiness"]}]},"ProgramReadiness":{"type":"string","enum":["setup","partial","ready"]},"ConnectProgramStripeResponse":{"type":"object","properties":{"connected":{"type":"boolean"},"method":{"type":"string","enum":["oauth_url"]},"programId":{"type":"string","format":"uuid"},"programReadiness":{"$ref":"#/components/schemas/ProgramReadiness"},"authUrl":{"type":"string","format":"uri"},"message":{"type":"string"}},"required":["connected","method","programId","message"]},"DisconnectProgramStripeResponse":{"type":"object","properties":{"success":{"type":"boolean"},"programId":{"type":"string","format":"uuid"}},"required":["success","programId"]},"TrackingVerificationWarning":{"type":"object","properties":{"code":{"type":"string"},"severity":{"type":"string","enum":["info","warning"]},"message":{"type":"string"}},"required":["code","severity","message"]},"TrackingVerificationRecentClick":{"type":"object","properties":{"affiliateCode":{"type":"string"},"createdAt":{"type":"string","format":"date-time"},"entryHost":{"type":["string","null"]}},"required":["affiliateCode","createdAt","entryHost"]},"TrackingVerificationInstallStatus":{"type":"object","properties":{"createdAt":{"type":"string","format":"date-time"},"entryHost":{"type":["string","null"]}},"required":["createdAt","entryHost"]},"ProgramTrackingStatusResponse":{"type":"object","properties":{"programId":{"type":"string","format":"uuid"},"status":{"type":"object","properties":{"stripeConnected":{"type":"boolean"},"trackingScriptVerified":{"type":"boolean"},"websiteConfigured":{"type":"boolean"},"trackingDomain":{"type":["string","null"]},"trackingRequiresConsent":{"type":"boolean"},"cookieDuration":{"type":"integer"}},"required":["stripeConnected","trackingScriptVerified","websiteConfigured","trackingDomain","trackingRequiresConsent","cookieDuration"]},"stats":{"type":"object","properties":{"clicksLast7Days":{"type":"object","properties":{"total":{"type":"integer"},"redirect":{"type":"integer"},"direct":{"type":"integer"}},"required":["total","redirect","direct"]},"conversionsLast30Days":{"type":"object","properties":{"total":{"type":"integer"},"clickToken":{"type":"integer"},"coupon":{"type":"integer"}},"required":["total","clickToken","coupon"]},"stripeEventsLast30Days":{"type":"object","properties":{"total":{"type":"integer"},"succeeded":{"type":"integer"},"skipped":{"type":"integer"}},"required":["total","succeeded","skipped"]}},"required":["clicksLast7Days","conversionsLast30Days","stripeEventsLast30Days"]},"recent":{"type":"object","properties":{"lastRedirectClick":{"anyOf":[{"$ref":"#/components/schemas/TrackingVerificationRecentClick"},{"type":"null"}]},"lastDirectClick":{"anyOf":[{"$ref":"#/components/schemas/TrackingVerificationRecentClick"},{"type":"null"}]},"lastTrackingVerification":{"anyOf":[{"$ref":"#/components/schemas/TrackingVerificationInstallStatus"},{"type":"null"}]}},"required":["lastRedirectClick","lastDirectClick","lastTrackingVerification"]},"health":{"type":"object","properties":{"scriptInstalled":{"$ref":"#/components/schemas/TrackingVerificationHealthStep"},"referralClickReceived":{"$ref":"#/components/schemas/TrackingVerificationHealthStep"},"stripeEventReceived":{"$ref":"#/components/schemas/TrackingVerificationHealthStep"},"conversionAttributed":{"$ref":"#/components/schemas/TrackingVerificationHealthStep"},"blockingReason":{"type":["string","null"]}},"required":["scriptInstalled","referralClickReceived","stripeEventReceived","conversionAttributed","blockingReason"]},"warnings":{"type":"array","items":{"$ref":"#/components/schemas/TrackingVerificationWarning"}},"summary":{"type":"string"}},"required":["programId","status","stats","recent","health","warnings","summary"]},"TrackingVerificationHealthStep":{"type":"object","properties":{"complete":{"type":"boolean"},"reason":{"type":["string","null"]},"updatedAt":{"type":["string","null"],"format":"date-time"}},"required":["complete","reason","updatedAt"]},"OnboardingMerchantProfileResponse":{"type":"object","properties":{"merchantId":{"type":"string","format":"uuid"},"companyName":{"type":"string"}},"required":["merchantId","companyName"]},"MeMerchantIdentity":{"type":"object","properties":{"key":{"type":"object","properties":{"ownerType":{"type":"string","enum":["merchant"]},"ownerId":{"type":"string","format":"uuid"},"keyType":{"type":"string","enum":["onboarding","full"]},"scopes":{"type":"array","items":{"type":"string"}}},"required":["ownerType","ownerId","keyType","scopes"]},"account":{"type":"object","properties":{"billingTier":{"type":"string"},"billingRequirementStatus":{"type":"string","enum":["not_required","required","grace_period","restricted","active"]},"trustLevel":{"type":["string","null"]},"isSuspended":{"type":"boolean"}},"required":["billingTier","billingRequirementStatus","trustLevel","isSuspended"]},"owner":{"type":"object","properties":{"merchantId":{"type":"string","format":"uuid"},"companyName":{"type":"string"},"accountOnboardingCompleted":{"type":"boolean"},"onboardingStep":{"type":"integer"}},"required":["merchantId","companyName","accountOnboardingCompleted","onboardingStep"]},"programs":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"slug":{"type":"string"},"status":{"type":"string","enum":["active","paused","archived"]},"marketplaceStatus":{"type":"string","enum":["private","draft","public"]},"readiness":{"$ref":"#/components/schemas/ProgramReadiness"},"website":{"type":["string","null"],"format":"uri"},"landingPageUrl":{"type":["string","null"],"format":"uri"},"stripeConnectedAt":{"type":["string","null"],"format":"date-time"}},"required":["id","name","slug","status","marketplaceStatus","readiness","website","landingPageUrl","stripeConnectedAt"]}}},"required":["key","account","owner","programs"]},"MeAffiliateIdentity":{"type":"object","properties":{"key":{"type":"object","properties":{"ownerType":{"type":"string","enum":["affiliate"]},"ownerId":{"type":"string","format":"uuid"},"keyType":{"type":"string","enum":["onboarding","full"]},"scopes":{"type":"array","items":{"type":"string"}}},"required":["ownerType","ownerId","keyType","scopes"]},"account":{"type":"object","properties":{"billingTier":{"type":"string"},"trustLevel":{"type":["string","null"]},"isSuspended":{"type":"boolean"}},"required":["billingTier","trustLevel","isSuspended"]},"owner":{"type":"object","properties":{"affiliateId":{"type":"string","format":"uuid"},"code":{"type":"string"},"isApproved":{"type":"boolean"},"isBlocked":{"type":"boolean"},"trustLevel":{"type":["string","null"]},"programId":{"type":"string","format":"uuid"},"programName":{"type":"string"},"merchantCompanyName":{"type":"string"}},"required":["affiliateId","code","isApproved","isBlocked","trustLevel","programId","programName","merchantCompanyName"]}},"required":["key","account","owner"]},"Affiliate":{"type":"object","additionalProperties":true},"Application":{"type":"object","additionalProperties":true},"Merchant":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string","format":"uuid"},"companyName":{"type":"string"},"website":{"type":["string","null"],"format":"uri"},"logoUrl":{"type":["string","null"],"format":"uri"},"stripeAccountId":{"type":["string","null"]},"stripeConnectedAt":{"type":["string","null"],"format":"date-time"},"billingTier":{"type":"string"},"stripeCustomerId":{"type":["string","null"]},"stripeSubscriptionId":{"type":["string","null"]},"billingRequirementStatus":{"type":"string","enum":["not_required","required","grace_period","restricted","active"]},"billingRequiredSince":{"type":["string","null"],"format":"date-time"},"billingGraceUntil":{"type":["string","null"],"format":"date-time"},"paymentStatus":{"type":"string"},"lastPaymentFailedAt":{"type":["string","null"],"format":"date-time"},"defaultCookieDuration":{"type":"integer"},"defaultPayoutThreshold":{"type":"integer"},"timezone":{"type":"string"},"trackingRequiresConsent":{"type":"boolean"},"trackingParamAliases":{"type":"array","items":{"type":"string"}},"state":{"type":"string","enum":["onboarding","active","verified"]},"notificationPreferences":{"type":["object","null"],"additionalProperties":{"type":"boolean"}},"onboardingCompleted":{"type":"boolean"},"onboardingStep":{"type":"integer"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","userId","companyName","website","logoUrl","stripeAccountId","stripeConnectedAt","billingTier","stripeCustomerId","stripeSubscriptionId","billingRequirementStatus","billingRequiredSince","billingGraceUntil","paymentStatus","lastPaymentFailedAt","defaultCookieDuration","defaultPayoutThreshold","timezone","trackingRequiresConsent","trackingParamAliases","state","notificationPreferences","onboardingCompleted","onboardingStep","createdAt","updatedAt"]},"Conversion":{"type":"object","additionalProperties":true},"Payout":{"type":"object","additionalProperties":true},"ProgramStats":{"type":"object","properties":{"programId":{"type":"string","format":"uuid"},"programName":{"type":"string"},"status":{"type":"string","enum":["active","paused","archived"]},"totalRevenue":{"type":"integer"},"totalConversions":{"type":"integer"},"totalCommissions":{"type":"integer"},"pendingCommissions":{"type":"integer"},"activeAffiliates":{"type":"integer"},"conversionsByStatus":{"type":"object","properties":{"pending":{"type":"integer"},"approved":{"type":"integer"},"partially_refunded":{"type":"integer"},"rejected":{"type":"integer"},"refunded":{"type":"integer"}},"required":["pending","approved","partially_refunded","rejected","refunded"]}},"required":["programId","programName","status","totalRevenue","totalConversions","totalCommissions","pendingCommissions","activeAffiliates","conversionsByStatus"]},"NotificationPreferences":{"type":"object","properties":{"newAffiliate":{"type":"boolean"},"newConversion":{"type":"boolean"},"commissionApproved":{"type":"boolean"},"payoutProcessed":{"type":"boolean"},"weeklyDigest":{"type":"boolean"}},"required":["newAffiliate","newConversion","commissionApproved","payoutProcessed","weeklyDigest"]},"UpdateNotificationPreferencesInput":{"type":"object","properties":{"newAffiliate":{"type":"boolean"},"newConversion":{"type":"boolean"},"commissionApproved":{"type":"boolean"},"payoutProcessed":{"type":"boolean"},"weeklyDigest":{"type":"boolean"}}},"MerchantProfile":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string","format":"uuid"},"companyName":{"type":"string"},"logoUrl":{"type":["string","null"],"format":"uri"},"billingAddressLine1":{"type":["string","null"]},"billingAddressLine2":{"type":["string","null"]},"billingCity":{"type":["string","null"]},"billingState":{"type":["string","null"]},"billingPostalCode":{"type":["string","null"]},"billingCountry":{"type":["string","null"]},"billingVatId":{"type":["string","null"]},"billingTaxId":{"type":["string","null"]},"selfBillingConsentAt":{"type":["string","null"],"format":"date-time"},"billingTier":{"type":"string"},"billingRequirementStatus":{"type":"string","enum":["not_required","required","grace_period","restricted","active"]},"paymentStatus":{"type":"string"},"lastPaymentFailedAt":{"type":["string","null"],"format":"date-time"},"defaultCookieDuration":{"type":"integer"},"defaultPayoutThreshold":{"type":"integer"},"timezone":{"type":"string"},"trackingRequiresConsent":{"type":"boolean"},"trackingParamAliases":{"type":"array","items":{"type":"string"}},"notificationPreferences":{"type":["object","null"],"additionalProperties":{"type":"boolean"}},"onboardingCompleted":{"type":"boolean"},"onboardingStep":{"type":"integer"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","userId","companyName","logoUrl","billingAddressLine1","billingAddressLine2","billingCity","billingState","billingPostalCode","billingCountry","billingVatId","billingTaxId","selfBillingConsentAt","billingTier","billingRequirementStatus","paymentStatus","lastPaymentFailedAt","defaultCookieDuration","defaultPayoutThreshold","timezone","trackingRequiresConsent","trackingParamAliases","notificationPreferences","onboardingCompleted","onboardingStep","createdAt","updatedAt"]},"PayoutInfo":{"type":"object","properties":{"payoutMethod":{"type":["string","null"],"enum":["paypal","bank_transfer",null]},"paypalEmail":{"type":["string","null"],"format":"email"},"bankAccountHolder":{"type":["string","null"]},"bankIban":{"type":["string","null"]},"bankBic":{"type":["string","null"]},"firstName":{"type":["string","null"]},"lastName":{"type":["string","null"]},"addressLine1":{"type":["string","null"]},"addressLine2":{"type":["string","null"]},"city":{"type":["string","null"]},"state":{"type":["string","null"]},"postalCode":{"type":["string","null"]},"vatId":{"type":["string","null"]}},"required":["payoutMethod","paypalEmail","bankAccountHolder","bankIban","bankBic","firstName","lastName","addressLine1","addressLine2","city","state","postalCode","vatId"]},"UpdatePayoutInfoInput":{"type":"object","properties":{"payoutMethod":{"type":"string","enum":["paypal","bank_transfer"]},"paypalEmail":{"type":"string","format":"email"},"bankAccountHolder":{"type":"string","maxLength":100},"bankIban":{"type":"string","maxLength":34},"bankBic":{"type":"string","maxLength":11},"firstName":{"type":"string","maxLength":100},"lastName":{"type":"string","maxLength":100},"addressLine1":{"type":"string","maxLength":200},"addressLine2":{"type":"string","maxLength":200},"city":{"type":"string","maxLength":100},"state":{"type":"string","maxLength":100},"postalCode":{"type":"string","maxLength":20},"vatId":{"type":"string","maxLength":50}},"required":["payoutMethod"]},"WebhookEventType":{"type":"string","enum":["program.created","program.updated","affiliate.joined","affiliate.approved","affiliate.blocked","affiliate.unblocked","conversion.created","conversion.refunded","payout.created","payout.processing","payout.completed","payout.failed","flag.resolved"]},"WebhookEndpoint":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"url":{"type":"string","format":"uri"},"status":{"type":"string","enum":["active","disabled"]},"programId":{"type":["string","null"],"format":"uuid"},"schemaVersion":{"type":"integer","enum":[2],"default":2},"subscribedEvents":{"type":"array","items":{"$ref":"#/components/schemas/WebhookEventType"}},"secretLastFour":{"type":["string","null"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"disabledAt":{"type":["string","null"],"format":"date-time"}},"required":["id","name","url","status","programId","schemaVersion","subscribedEvents","secretLastFour","createdAt","updatedAt","disabledAt"]},"CreateWebhookEndpointInput":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"url":{"type":"string","format":"uri"},"programId":{"type":"string","format":"uuid"},"subscribedEvents":{"type":"array","minItems":1,"items":{"$ref":"#/components/schemas/WebhookEventType"}}},"required":["name","url","subscribedEvents"]},"UpdateWebhookEndpointInput":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"url":{"type":"string","format":"uri"},"programId":{"type":["string","null"],"format":"uuid"},"subscribedEvents":{"type":"array","minItems":1,"items":{"$ref":"#/components/schemas/WebhookEventType"}}}},"WebhookSecretResponse":{"type":"object","properties":{"endpoint":{"$ref":"#/components/schemas/WebhookEndpoint"},"signingSecret":{"type":"string"}},"required":["endpoint","signingSecret"]},"CreateProgramInput":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"description":{"type":"string","maxLength":500},"website":{"type":"string","format":"uri"},"landingPageUrl":{"type":"string","format":"uri"},"commissionType":{"type":"string","enum":["one_time","recurring","recurring_limited"]},"commissionPercent":{"type":"number","minimum":1,"maximum":100},"commissionLimitMonths":{"type":"number","minimum":1,"maximum":36},"cookieDuration":{"type":"number","minimum":1,"maximum":365},"payoutThreshold":{"type":"number","minimum":1000,"maximum":100000},"payoutFrequency":{"type":"string","enum":["weekly","monthly","quarterly"]},"marketplaceStatus":{"type":"string","enum":["private","draft","public"]},"applicationAccess":{"type":"string","enum":["open","invite_only"]},"marketplaceCategory":{"type":"string","maxLength":64},"marketplaceDescription":{"type":"string","maxLength":500},"marketplaceLogoUrl":{"type":"string","format":"uri"},"autoApproveAffiliates":{"type":"boolean"},"portalSlug":{"type":"string","minLength":3,"maxLength":63,"pattern":"^[a-z0-9-]+$"},"currency":{"type":"string","minLength":3,"maxLength":5}},"required":["name","commissionType","commissionPercent"]},"UpdateProgramInput":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"description":{"type":"string","maxLength":500},"website":{"type":"string","format":"uri"},"landingPageUrl":{"type":"string","format":"uri"},"status":{"type":"string","enum":["active","paused","archived"]},"commissionType":{"type":"string","enum":["one_time","recurring","recurring_limited"]},"commissionPercent":{"type":"number","minimum":1,"maximum":100},"commissionLimitMonths":{"type":"number","minimum":1,"maximum":36},"cookieDuration":{"type":"number","minimum":1,"maximum":365},"payoutThreshold":{"type":"number","minimum":1000,"maximum":100000},"payoutFrequency":{"type":"string","enum":["weekly","monthly","quarterly"]},"applicationAccess":{"type":"string","enum":["open","invite_only"]},"autoApproveAffiliates":{"type":"boolean"},"portalSlug":{"anyOf":[{"type":"string","minLength":3,"maxLength":63,"pattern":"^[a-z0-9-]+$"},{"type":"null"}]},"currency":{"type":"string","minLength":3,"maxLength":5}}},"UpdateMerchantInput":{"type":"object","properties":{"companyName":{"type":"string","minLength":1,"maxLength":100},"logoUrl":{"anyOf":[{"type":"string","format":"uri"},{"type":"string","enum":[""]}]},"billingAddressLine1":{"anyOf":[{"type":"string","maxLength":200},{"type":"string","enum":[""]}]},"billingAddressLine2":{"anyOf":[{"type":"string","maxLength":200},{"type":"string","enum":[""]}]},"billingCity":{"anyOf":[{"type":"string","maxLength":100},{"type":"string","enum":[""]}]},"billingState":{"anyOf":[{"type":"string","maxLength":100},{"type":"string","enum":[""]}]},"billingPostalCode":{"anyOf":[{"type":"string","maxLength":20},{"type":"string","enum":[""]}]},"billingCountry":{"anyOf":[{"type":"string","maxLength":2},{"type":"string","enum":[""]}]},"billingVatId":{"anyOf":[{"type":"string","maxLength":50},{"type":"string","enum":[""]}]},"billingTaxId":{"anyOf":[{"type":"string","maxLength":50},{"type":"string","enum":[""]}]},"selfBillingConsent":{"type":"boolean"},"timezone":{"type":"string"},"defaultCookieDuration":{"type":"number","minimum":1,"maximum":365},"defaultPayoutThreshold":{"type":"number","minimum":1000,"maximum":100000},"trackingRequiresConsent":{"type":"boolean"},"trackingParamAliases":{"type":"array","items":{"type":"string","minLength":1,"maxLength":64},"maxItems":10}}}}}}