For the complete documentation index, see llms.txt. This page is also available as Markdown.
Consent
The YieldFi SDK provides comprehensive APIs for managing user consent records. Consent records are immutable for audit compliance - once recorded, they cannot be deleted or revoked.
Consent Types
The SDK supports the following consent types:
TERMS_OF_SERVICE - User acceptance of terms of service (required)
PRIVACY_POLICY - User acceptance of privacy policy (required)
MARKETING - User consent for marketing communications (optional)
ANALYTICS - User consent for analytics tracking (optional)
COOKIES - User consent for cookie usage (optional)
Recording Consent
Record user consent when they accept terms, policies, or opt-in to features:
import{YieldFiSDK,ConsentType}from"yieldfi-sdk";constsdk=awaitYieldFiSDK.create({gatewayUrl:"https://gw.yield.fi",});constaccessToken=localStorage.getItem("accessToken");// Record terms of service acceptanceconstconsent=awaitsdk.auth.recordConsent(accessToken,{consentType:ConsentType.TERMS_OF_SERVICE,version:"1.0",granted:true,metadata:{documentHash:"0xabc123...",sourceUrl:"https://yield.fi/terms",},});console.log(`Consent recorded: ${consent.consent.id}`);
Getting Consent Records
Get Specific Consent
Get a specific consent record by type and optional version:
Get All User Consents
Get the complete audit trail of all consent records:
Get Consent Status Summary
Get the latest status for each consent type:
Complete Example: Consent Flow
Here's a complete example of implementing a consent flow:
Important Notes
Immutability: Consent records cannot be deleted or revoked once created. This ensures audit compliance.
Versioning: Each consent type can have multiple versions (e.g., Terms v1.0, v2.0). Always record consent for the current version.
Audit Trail: All consent records include:
Timestamp
IP address
User agent
Metadata (document hash, source URL, etc.)
Authentication Required: All consent APIs require a valid access token.
Required Consents: Terms of Service and Privacy Policy are typically required before users can use the platform.
// Get latest consent for a type
const termsConsent = await sdk.auth.getConsent(
accessToken,
ConsentType.TERMS_OF_SERVICE
);
// Get specific version
const termsConsentV1 = await sdk.auth.getConsent(
accessToken,
ConsentType.TERMS_OF_SERVICE,
"1.0"
);
const statuses = await sdk.auth.getConsentStatuses(accessToken);
// Check if user has consented to marketing
const marketingStatus = statuses.data.find(
(s) => s.consentType === ConsentType.MARKETING
);
if (marketingStatus?.granted) {
// User has consented, can send marketing emails
sendMarketingEmail();
} else {
// Show consent banner
showConsentBanner();
}