Create and publish a consent notice
Tutorial for creating a notice and publishing its configuration.
This tutorial will walk you through the steps necessary to create a notice, modify its configuration, and publish it.

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 will host it:
1
POST https://api.didomi.io/v1/widgets/notices
2
3
BODY
4
{
5
"organization_id": "didomi",
6
"name": "My consent notice"
7
}
Copied!
The API will return a response similar to:
1
{
2
"name": "My consent notice",
3
"archived_at": null,
4
"organization_id": "didomi",
5
"id": "7wmRYUH6",
6
"created_at": "2021-03-27T08:38:10.831Z",
7
"updated_at": "2021-03-27T08:38:10.831Z",
8
"version": 0
9
}
Copied!
Write down the id of the notice (7wmRYUH6 in our example) as you will need it in the following steps.

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:
1
GET https://api.didomi.io/v1/widgets/notices/configs?organization_id=didomi&notice_id=7wmRYUH6
2
3
{
4
"total": 1,
5
"limit": 100,
6
"skip": 0,
7
"data": [
8
{
9
"deployed_at": null,
10
"custom_json": {},
11
"config": { ... },
12
"default": false,
13
"platform": "web",
14
"targets": [],
15
"text_mode": "approved",
16
"text_id": "W37f3Bmd",
17
"full_atp": false,
18
"enable_ignore_consent_before": false,
19
"ignore_consent_before": null,
20
"negative_action": "button",
21
"disagree_button_style": "primary",
22
"country": null,
23
"notice_deny_applies_to_li": true,
24
"preferences_deny_applies_to_li": true,
25
"consent_duration": 12,
26
"consent_duration_unit": "months",
27
"notice_id": "7wmRYUH6",
28
"organization_id": "didomi",
29
"id": "7bKP4CRr",
30
"created_at": "2021-03-27T08:38:15.248Z",
31
"updated_at": "2021-03-27T08:38:15.248Z",
32
"version": 0
33
}
34
]
35
}
Copied!
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.
Write down the id of the configuration (7bKP4CRr in our example) as you will need it in the following steps.
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

The API created a web consent notice by default with a consent duration of 12 months. Let's make it a mobile consent notice with a consent duration of 6 months.
To modify the draft configuration, send a PATCH request with the updated configuration:
1
PATCH https://api.didomi.io/v1/widgets/notices/configs/7bKP4CRr
2
3
{
4
"platform": "app",
5
"consent_duration": 6,
6
"consent_duration_unit": "months"
7
}
Copied!

Publish the notice

Now that our notice is configured as we want it to be, we need to publish it so that the notice can be embedded in a mobile app.
To publish a notice, we need to create a new deployment for that notice:
1
POST https://api.didomi.io/v1/widgets/notices/deployments
2
3
BODY
4
{
5
"notice_id": "7wmRYUH6",
6
"organization_id": "didomi",
7
"production_config_id": "7bKP4CRr",
8
"message": "Description of changes included in my deployment"
9
}
Copied!
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:
1
{
2
"message": "Description of changes included in my deployment",
3
"notice_id": "7wmRYUH6",
4
"production_config_id": "7bKP4CRr",
5
"organization_id": "didomi",
6
"status": "success",
7
"status_message": null,
8
"id": "itBtwnxM",
9
"created_at": "2021-03-27T08:53:07.467Z",
10
"updated_at": "2021-03-27T08:53:07.467Z",
11
"version": 0
12
}
Copied!
Your notice is now ready to be embedded in a mobile app!

What's next?

The Didomi API allows managing all aspects of consent notices and their configurations. Read more about the entities to learn how to do more complex operations.
Last modified 8mo ago