quickstart.js
import { MyConsent, ConsentLevel } from '@myconsent/sdk';
// Initialize the SDK
const client = new MyConsent({
tenantId: process.env.MYCONSENT_TENANT_ID,
region: 'IN',
apiVersion: 'v1'
});
// Create a contextual consent receipt
const receipt = await client.consent.create({
userId: 'user_abc123',
purposes: [
ConsentLevel.GRANULAR_BIO,
ConsentLevel.SENSITIVE_DATA,
ConsentLevel.CROSS_BORDER
],
retention: {
period: '1Y',
autoDelete: true,
onWithdrawal: 'immediate'
},
context: {
ipAddress: 'request.ip',
userAgent: 'request.userAgent',
timestamp: new Date().toISOString()
}
});
// Subscribe to consent events
client.events.on('consent.granted', (evt) => {
console.log('Consent granted:', evt.receiptId);
receipt.audit(evt); // Immutable logging
});
client.events.on('consent.withdrawn', async (evt) => {
await client.data.erase(evt.userId, {
scope: 'all',
proof: true // Returns deletion certificate
});
});api
RESTful API
Full GraphQL & REST API for every consent operation. Webhooks for real-time event streaming.
devices
Multi-Platform SDKs
Native support for React, Vue, iOS, Android, and IoT devices. Zero-config deployment.
security
Enterprise Security
OAuth2, JWT and mTLS, with envelope-encrypted key management and rotation.
httpAPI Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/consent | Create a new consent receipt |
| GET | /api/v1/consent/{id} | Retrieve consent details |
| DELETE | /api/v1/consent/{id} | Withdraw and erase consent |
| GET | /api/v1/audit/{id} | Retrieve audit trail |
| POST | /api/v1/dsr/{userId} | Process data subject request |
| POST | /api/v1/webhook/subscribe | Register event webhook |
webhookWebhook Events
consent.grantedUser has granted consent
HIGHconsent.withdrawnUser has withdrawn consent
CRITICALconsent.expiringConsent expiring within 30 days
MEDIUMdsr.completedData subject request fulfilled
HIGHbreach.detectedPotential data breach detected
CRITICALaudit.updatedAudit log entry created
LOW