Create and publish a multi-regulation consent notice
This tutorial will walk you through the steps necessary to create a multi-regulation notice, modify its configuration, and publish it.
Please be aware that requests for multi-regulation notices specify the v:"2" header value; don't forget to include this in your API requests to the /widgets/notices and /widgets/notices/configs endpoints.
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:
constbent=require("bent");constorganizationId="didomi";constheaders= { Authorization:`Bearer ${token}`, v:"2",};constclient= { post:bent("POST","https://api.didomi.io/v1","json", headers,201 ),};(async () => {console.log(`Creating a notice for organization ${organizationId} ...`);constnotice=awaitclient.post("/widgets/notices", { organization_id: organizationId, name:"My consent notice", });console.log(`Notice with ID ${notice.id} created!`);})();
The API will return a response similar to:
Modify the notice's draft multi-regulation 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:
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.
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, read our documentation to find the current draft documentation.
Modify the draft configuration
To modify the draft configuration, send a PATCH request with the updated configuration. In this example, we change the cross-regulation defaults for consent duration to 12 months and include CPRA as a targeted regulation for California, United States.
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.
It is not necessary to set the v:"2" header when deploying, the /widgets/notices/deployments endpoint does not require it.
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: