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";
const sdk = await YieldFiSDK.create({
gatewayUrl: "https://gw.yield.fi",
});
const accessToken = localStorage.getItem("accessToken");
// Record terms of service acceptance
const consent = await sdk.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.
Next Steps
API Reference - Explore all available APIs
Examples - See complete examples
Last updated