Docs
JavaScript SDK
Install, client, methods, tag gate and receipt verification.
npm i @tripticonsent/sdkClient
import { TripticonsentClient } from '@tripticonsent/sdk';
const tc = new TripticonsentClient({
baseUrl: 'https://api.tripticonsent.com',
apiKey: 'pk_live_…', // sk_live_… on a server
cacheTtlMs: 60_000, // optional
});Methods
recordConsent(params, { idempotencyKey })·recordConsentBatch(records)·recordPreferences(params)getConsentState(subject, { purpose?, fresh? })·getPreferences(subject)— ETag-cachedgetPurposes({ locale? })·getPurpose(key, { locale? })·getPreferenceTemplate()·getPolicy({ country? })getTcString(subject)·getConsentMode(subject)·applyConsentMode(subject, gtag)getReceipt(id)·verifyReceipt(receipt)— Ed25519 offline via Web CryptocreateSubject·addIdentifier·mergeSubjects·createDataRequest— requiresk_
Tag gate
// load your scripts only once the subject has granted one of these purposes
await tc.gate('email:user@example.com', ['analytics'], () => loadAnalytics());
// after your banner writes new consent:
tc.notifyConsentChanged();