Integration Overview
This guide walks through implementing the complete consent management workflow in your application. We’ll cover collecting consent during onboarding, linking users, checking status, and handling revocations.All examples use the US policy with 5 required consents (including
eSignAct for E-Sign Act compliance). For Global policy, exclude the eSignAct consent.Prerequisites
Before implementing consent management, ensure you have:- Baanx API credentials (
x-client-keyandx-secret-key) - User registration flow in your application
- Ability to track temporary identifiers before user creation
Step 1: Collect Consent During Onboarding
Create a consent set during user registration before address submission finalizes the registration.Use Onboarding ID from Registration
TheonboardingId is obtained from the email verification step of the user registration flow:
Create Consent Set
Response
Validation Rules
The API validates that all required consents are present based on policy type:Consents can have
granted or denied status during creation. Both are valid, but the user’s overall consent status will be incomplete if required consents are denied.Step 2: Link User to Consent Set
After address submission finalizes registration and returns a permanentuserId, link it to the consent set created in Step 1.
When to Link
Call this endpoint after:- ✅ Physical address submitted (
POST /v1/auth/register/address) returnsuserIdandaccessToken - ✅ OR mailing address submitted (
POST /v1/auth/register/mailing-address) returnsuserIdandaccessToken(US users only) - ✅ Registration is complete and you have the
userId
The address endpoints finalize registration. Non-US users and US users with same mailing address get
userId from the address endpoint. US users with different mailing addresses get userId from the mailing address endpoint.Link Request
Response
Step 3: Check Consent Status
Retrieve a user’s consent status to validate compliance or gate features.Short Status Check (Fast)
Get quick status summary:Status Values
Full Consent Details
Get all consent sets with detailed records:- Detailed consent review pages
- User privacy dashboards
- Compliance reporting
- Consent preference management
Step 4: Access Audit Trail
Retrieve complete consent change history for compliance reporting.Paginated Audit Request
Response
Pagination Parameters
Step 5: Revoke Consent
Allow users to withdraw specific consents while maintaining audit trail.Revocation Request
Response
Revocation creates a new consent record with
revoked status. The original consent record is preserved for audit purposes.Post-Revocation Handling
After revocation:- User’s overall consent status may become
incomplete - Check consent status to determine access restrictions
- Prompt user to re-grant consent if needed for service access
Complete Integration Example
Here’s a full TypeScript implementation:Usage Example
Best Practices
Use Registration OnboardingId
Use Registration OnboardingId
Always use the
onboardingId returned from email verification (POST /v1/auth/register/email/verify). Do not generate a new ID - the onboardingId links the consent to the registration session.Store ConsentSetId Temporarily
Store ConsentSetId Temporarily
Store the
consentSetId in your session or database between consent creation (Step 4) and linking (Step 7). You’ll need it to link the consent after address submission returns the userId.Capture Rich Metadata
Capture Rich Metadata
Include IP address, user agent, timestamp, and client version in metadata for comprehensive audit trails:
Handle Errors Gracefully
Handle Errors Gracefully
Implement retry logic for network failures and provide clear user feedback for validation errors:
Use Short Status for Gating
Use Short Status for Gating
For access control and feature gating, use the short status check (no
?full=true) for optimal performance:Monitor Consent Status Changes
Monitor Consent Status Changes
Periodically check consent status and notify users when action is needed (e.g., revoked required consents).
Next Steps
Compliance Guide
Regulatory requirements and audit strategies
Troubleshooting
Common issues and error handling
API Reference
Complete endpoint documentation
Overview
Back to consent management overview