codeDEVELOPER DOCS

Developer Integration Guide

Capture, withdraw and evidence consent across your stack — widget, REST API, or SDK.

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

MethodEndpointDescription
POST/api/v1/consentCreate 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/subscribeRegister event webhook

webhookWebhook Events

consent.granted

User has granted consent

HIGH
consent.withdrawn

User has withdrawn consent

CRITICAL
consent.expiring

Consent expiring within 30 days

MEDIUM
dsr.completed

Data subject request fulfilled

HIGH
breach.detected

Potential data breach detected

CRITICAL
audit.updated

Audit log entry created

LOW