Didomi - Developers documentation
  • Introduction
  • SDKs
    • Introduction
    • Web SDK
      • Getting started
      • Tags and vendors management
        • Tags management
          • Events & Variables
            • Deprecated
            • Custom events
          • Tag managers
            • Adobe Launch/DTM
            • Eulerian
            • Google Tag Manager
              • Configure the Didomi / GTM integration
              • Didomi's GTM template
            • Tealium
            • Other tag managers
        • Custom Didomi <script> tags
        • Third-party integrations
          • Google Ad Manager / AdSense
            • GDPR via Non-Personalized Ads
              • Share consent and load/refresh ads
              • Share consent without loading or refreshing ads
            • US states laws
          • Google Consent Mode V2
          • Kameleoon
          • Piano Analytics (AT Internet)
          • Prebid
            • GDPR via IAB TCF
            • US states laws
          • Salesforce DMP (Krux)
        • IAB frameworks
        • Programmatic API
      • Configuration
        • Bots (SEO & Performance tools)
        • Configuration by URL
        • Cookies and storage
        • Custom domains for events
        • Notice
          • Behavior
          • Interactions
          • Look and feel
        • Preferences
        • Theme
      • AB tests
      • Custom domain
        • Domain delegation
        • Reverse proxy
      • Share consents between domains
      • Share consents across devices
      • Pass user choices in query string
      • Serve Didomi assets from your domain
      • Reference
        • API
          • Deprecated
        • Events
      • Performance
      • Versions
    • Mobile and TV SDKs
      • Android and Android TV
        • Setup
        • Logging
        • Reference
          • API
            • Deprecated
          • Events
        • Versions
      • iOS and tvOS
        • Setup
        • Logging
        • App Tracking Transparency (iOS 14.5+)
        • Reference
          • API
            • Deprecated
          • Events
        • Versions
      • Unity
        • Setup
        • Reference
        • Versions
        • Troubleshooting
      • React Native
        • Setup
        • Reference
          • Deprecated
        • Versions
      • Flutter
        • Setup
        • Reference
        • Versions
      • Consent notice
        • Getting started
        • Customize the notice
        • Customize the preferences popup
        • Customize the theme & UI
        • Load notice by ID
      • Third-party SDKs
      • Share consents across devices
      • Share consent with WebViews
      • Google Consent Mode v2
      • FAQ
    • AMP SDK
      • Blocking Behaviors
        • Load immediately on page load
        • Load only after consent (positive or negative)
        • Load only after positive consent
      • Consent status for vendors
    • Help & Support
  • API
    • Introduction
      • Authentication
      • Errors
      • Pagination
      • Filters
      • Caching
      • Rate limiting
      • Quotas
      • Translations
    • Data Manager
      • Regulations
      • Configuration Tree
      • Purposes
        • Purposes & Vendors Numerical IDs
      • Preferences Library
      • User Rights
    • Widgets
      • Consent notices
        • Notices
        • Configurations
        • Multi-Regulation Configurations
          • Migration of Existing Notices and API Updates
        • Deployments
        • Tutorials
          • Create and publish a consent notice
          • Create and publish a multi-regulation consent notice
      • Privacy widgets
        • Create a widget
        • Retrieve widgets
        • Edit a widget
          • Content & Design
            • Themes & Shapes
            • Components
              • auth
              • dsar_form
              • footer
              • header
              • preference
              • preference_value
              • save
              • section
              • sections
            • Options
          • Purposes & preferences
          • Settings
        • Deploy a Widget
          • Use your own subdomain
          • Use your own domain
          • Implement an embeddable widget on your website
        • Authentication
          • Manage authentication providers
          • Authenticate your end-user
        • Archive a widget
        • Headless widgets
          • Public Methods
          • Custom elements
          • Custom events
          • Event listeners
        • Tutorial
          • Launch a Preference Center from a mobile app
    • Compliance Reports
      • Properties
      • Reports
      • CSV format reference
      • Websites
    • Consents and Preferences
      • Events
        • Generate IAB TCF consent string
      • Links
      • Proofs
      • Tokens
      • Secrets
      • Users
      • Tutorial
        • Collect and operate data
    • Privacy Requests
      • Requests
      • Notes
      • Links
      • Emails
  • Integrations
    • Introduction
      • Quotas
    • Generic integrations
      • Batch export
        • Destinations
          • AWS S3 Bucket (owned by Didomi)
          • GCP Storage Bucket
        • Exported data
          • Notices consents
        • Logs
      • Webhooks
      • Batch import
      • Analytics export
        • Destinations
          • AWS S3 Bucket (owned by Didomi)
          • GCP Storage Bucket
    • Third-party apps
      • CMP integrations
        • Didomi-mParticle integration for your CMP
        • Deploy Didomi’s SDK for your Adobe Commerce website
      • Preference Management Platform integrations
        • Actito
        • Adobe Campaign Classic
        • Adobe Experience Cloud
        • Adobe Marketo Engage
        • Adobe Source Connector
        • Braze
        • Dotdigital
        • Hubspot
        • Mailchimp
        • Microsoft Dynamics 365
        • Salesforce Marketing Cloud
        • Salesforce Sales & Service Cloud
        • Selligent
        • Brevo (ex Sendinblue)
    • Tutorials
      • Configure a HTTP webhook
      • Configure a batch export
      • Configure an analytics export
    • Emailing
      • Configurations
        • Actito Email
        • Actito SMS
        • Adobe Campaign Classic
        • Adobe Campaign Standard
      • Emails
        • Templates
        • Manage your templates
Powered by GitBook
On this page
  • Create a consent notice
  • Modify the notice configuration
  • Get the ID of the draft configuration
  • Modify the draft configuration
  • Publish the notice
  • What's next?
  1. API
  2. Widgets
  3. Consent notices
  4. Tutorials

Create and publish a consent notice

PreviousTutorialsNextCreate and publish a multi-regulation consent notice

Last updated 1 year ago

This tutorial will walk you through the steps necessary to create a notice, modify its configuration, and publish it.

Note: If you're looking to create a multi-regulation configuration please instead.

Create a consent notice

To create a consent notice, send a POST /widgets/notices request with the name of the notice to create and the ID of the organization that the notice belongs to:

const bent = require("bent");

const organizationId = "<organizationId>";
const token = "<token>"; // Get a token by authenticating in the API (https://developers.didomi.io/api/introduction/authentication)

const client = {
  post: bent(
    "POST",
    "https://api.didomi.io/v1",
    "json",
    {
      Authorization: `Bearer ${token}`,
    },
    201
  ),
};

(async () => {
  console.log(
    `Creating a notice for organization ${organizationId} ...`
  );

  const notice = await client.post("/widgets/notices", {
    organization_id: organizationId,
    name: "My consent notice",
  });

  console.log(`Notice with ID ${notice.id} created!`);
})();
POST https://api.didomi.io/v1/widgets/notices

BODY
{
    "organization_id": "didomi",
    "name": "My consent notice"
}

The API will return a response similar to:

{
    "name": "My consent notice",
    "archived_at": null,
    "organization_id": "didomi",
    "id": "7wmRYUH6",
    "created_at": "2021-03-27T08:38:10.831Z",
    "updated_at": "2021-03-27T08:38:10.831Z",
    "version": 0
}

Modify the notice configuration

The API automatically created a draft configuration when a notice was created. To update the notice configuration, you must first get the ID of the draft configuration and then modify that draft configuration.

Get the ID of the draft configuration

To get the ID of the draft configuration, get the list of all configurations:

const bent = require("bent");

const organizationId = "<organizationId>";
const noticeId = "<noticeId>";
const token = "<token>"; // Get a token by authenticating in the API (https://developers.didomi.io/api/introduction/authentication)

const client = {
  get: bent("GET", "https://api.didomi.io/v1", "json", {
    Authorization: `Bearer ${token}`,
  }),
  patch: bent("PATCH", "https://api.didomi.io/v1", "json", {
    Authorization: `Bearer ${token}`,
  }),
  post: bent(
    "POST",
    "https://api.didomi.io/v1",
    "json",
    {
      Authorization: `Bearer ${token}`,
    },
    201
  ),
};

(async () => {
  console.log(
    `Querying the organization: ${organizationId} and the notice: ${noticeId}`
  );

  // Get the notice configs for the organization and notice
  console.log("Getting the latest draft config ...");
  const request = await client.get(
    `/widgets/notices/configs?organization_id=${organizationId}&notice_id=${noticeId}`
  );
  const noticeConfigs = request.data;

  // Filter the notice configs to get the draft config.
  const draftConfig = noticeConfigs.filter((e) => e.deployed_at === null).pop();
  const draftConfigId = draftConfig.id;
})();
GET https://api.didomi.io/v1/widgets/notices/configs?organization_id=didomi&notice_id=7wmRYUH6

{
    "total": 1,
    "limit": 100,
    "skip": 0,
    "data": [
        {
            "deployed_at": null,
            "custom_json": {},
            "config": { ... },
            "default": false,
            "platform": "web",
            "targets": [],
            "text_mode": "approved",
            "text_id": "W37f3Bmd",
            "full_atp": false,
            "enable_ignore_consent_before": false,
            "ignore_consent_before": null,
            "negative_action": "button",
            "disagree_button_style": "primary",
            "country": null,
            "notice_deny_applies_to_li": true,
            "preferences_deny_applies_to_li": true,
            "consent_duration": 12,
            "consent_duration_unit": "months",
            "notice_id": "7wmRYUH6",
            "organization_id": "didomi",
            "id": "7bKP4CRr",
            "created_at": "2021-03-27T08:38:15.248Z",
            "updated_at": "2021-03-27T08:38:15.248Z",
            "version": 0
        }
    ]
}

The configuration is called "draft" because its deployed_at field is null which indicates that this configuration has not been published before and can be modified.

Modify the draft configuration

To modify the draft configuration, send a PATCH request with the updated configuration:

const bent = require("bent");
const { merge } = require("lodash");

const organizationId = "<organizationId>";
const noticeId = "<noticeId>";
const token = "<token>"; // Get a token by authenticating in the API (https://developers.didomi.io/api/introduction/authentication)

const client = {
  get: bent("GET", "https://api.didomi.io/v1", "json", {
    Authorization: `Bearer ${token}`,
  }),
  patch: bent("PATCH", "https://api.didomi.io/v1", "json", {
    Authorization: `Bearer ${token}`,
  }),
  post: bent(
    "POST",
    "https://api.didomi.io/v1",
    "json",
    {
      Authorization: `Bearer ${token}`,
    },
    201
  ),
};

(async () => {
  console.log(
    `Querying the organization: ${organizationId} and the notice: ${noticeId}`
  );

  // Get the notice configs for the organization and notice
  console.log("Getting the latest draft config ...");
  const request = await client.get(
    `/widgets/notices/configs?organization_id=${organizationId}&notice_id=${noticeId}`
  );
  const noticeConfigs = request.data;

  // Filter the notice configs to get the draft config.
  const draftConfig = noticeConfigs.filter((e) => e.deployed_at === null).pop();
  const draftConfigId = draftConfig.id;

  // Modify the notice configuration
  console.log("Updating the latest draft config ...");
  await client.patch(
    `/widgets/notices/configs/${draftConfigId}`,
    merge(draftConfig, {
      consent_duration: 6, // Change the consent duration for the notice
      consent_duration_unit: "months",
    })
  );
})();
PATCH https://api.didomi.io/v1/widgets/notices/configs/7bKP4CRr

{
    "platform": "app",
    "consent_duration": 6,
    "consent_duration_unit": "months"
}

Publish the notice

Now that our notice is configured as we want it to be, we need to publish it so that our modified configuration appears in the actual notice on the website or app.

To publish a notice, we need to create a new deployment for that notice:

const bent = require("bent");
const { merge } = require("lodash");

const organizationId = "<organizationId>";
const noticeId = "<noticeId>";
const token = "<token>"; // Get a token by authenticating in the API (https://developers.didomi.io/api/introduction/authentication)

const client = {
  get: bent("GET", "https://api.didomi.io/v1", "json", {
    Authorization: `Bearer ${token}`,
  }),
  patch: bent("PATCH", "https://api.didomi.io/v1", "json", {
    Authorization: `Bearer ${token}`,
  }),
  post: bent(
    "POST",
    "https://api.didomi.io/v1",
    "json",
    {
      Authorization: `Bearer ${token}`,
    },
    201
  ),
};

(async () => {
  console.log(
    `Querying the organization: ${organizationId} and the notice: ${noticeId}`
  );

  // Get the notice configs for the organization and notice
  console.log("Getting the latest draft config ...");
  const request = await client.get(
    `/widgets/notices/configs?organization_id=${organizationId}&notice_id=${noticeId}`
  );
  const noticeConfigs = request.data;

  // Filter the notice configs to get the draft config.
  const draftConfig = noticeConfigs.filter((e) => e.deployed_at === null).pop();
  const draftConfigId = draftConfig.id;

  // Modify the notice configuration
  console.log("Updating the latest draft config ...");
  await client.patch(
    `/widgets/notices/configs/${draftConfigId}`,
    merge(draftConfig, {
      consent_duration: 6, // Change the consent duration for the notice
      consent_duration_unit: "months",
    })
  );

  // Publish the notice configuration
  console.log("Publishing the draft config ...");
  const response = await client.post(`/widgets/notices/deployments`, {
    notice_id: noticeId,
    organization_id: organizationId,
    production_config_id: draftConfigId,
    message: "Message describing the content of the update to the notice",
  });

  console.log(`Your deployment is a ${response.status}!`);
})();
POST https://api.didomi.io/v1/widgets/notices/deployments

BODY
{
    "notice_id": "7wmRYUH6",
    "organization_id": "didomi",
    "production_config_id": "7bKP4CRr",
    "message": "Description of changes included in my deployment"
}

The production_config_id should be the ID of the draft config you are publishing. message is a text field that can be used to indicate information on what changes are included in your deployment.

The API responds with the status of your deployment:

{
    "message": "Description of changes included in my deployment",
    "notice_id": "7wmRYUH6",
    "production_config_id": "7bKP4CRr",
    "organization_id": "didomi",
    "status": "success",
    "status_message": null,
    "id": "itBtwnxM",
    "created_at": "2021-03-27T08:53:07.467Z",
    "updated_at": "2021-03-27T08:53:07.467Z",
    "version": 0
}

What's next?

As we are working with a newly created notice in this tutorial, we can assume that it has a single associated configuration and that it is a draft. If you are working with an existing notice that might have been published before and would have multiple configurations, .

The Didomi API allows managing all aspects of consent notices and their configurations.

see here
Read more about the entities to learn how to do more complex operations.
read our documentation to find the current draft documentation