> For the complete documentation index, see [llms.txt](https://developers.didomi.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.didomi.io/api-and-platform/consents/events/create-consent-event.md).

# Create consent event

When an end-user gives consent to a set of purposes or vendors, create a consent event to register the user choices by calling the [`POST /consents/events`](https://api.didomi.io/docs/#/consents%2Fevents/post_consents_events) endpoint.

* [Create consent event overview](#create-consent-event-overview)
* [One-click consent event](#consent-propagation)
* [Attach proofs to consent event](#attach-proofs-to-consent-event)

{% hint style="info" %}
[Click here](/api-and-platform/consents/events/consent-event-approvals.md) if your consent events require approvals to learn more about pending consent events.
{% endhint %}

### Create consent event overview

A consent event consists of a set of partial choices, related to a specific regulation, from a user that will be merged into the user consent status. You can also send additional user information like a new ID or custom metadata. When pushing consent events, you do not need to know the prior consent status of the user and the consent information you are pushing will be automatically merged into the user consent status of the `Users` endpoints.

{% hint style="info" %}
By default, consent events are stored under GDPR regulation. In order to register end-user choices for another regulation, you need to specify it in the request's payload.
{% endhint %}

Below is an example of an end-user giving consent to the purpose "purpose\_id":

```javascript
POST /consents/events?organization_id={organization_id}

BODY
{
  "user": {
    "organization_user_id": "user@domain.com",
    "metadata": {
      "custom_key": "value"
    }
  },
  
  /**
  * regulation is optional
  * if regulation is not specified, 
  * the consent will be stored under GDPR regulation
  */  
  "regulation": "cpra" // gdpr...
  
  "consents": {
    "purposes": [
      {
        "id": "purpose_id",
        "enabled": true
      }
    ]
  }
}
```

You can specify the `user.organization_user_id` field with your own organization user ID.\
If you do not specify any user ID, a random ID will be automatically created for the user.

[Click here](https://didomi.stoplight.io/docs/didomi-api/a091cdc785c01-create-a-new-event) to view the API specification for this endpoint.

### One-click consent <a href="#consent-propagation" id="consent-propagation"></a>

When a selected purpose has one-click consent enabled in your Preference Management Platform (PMP) configuration tree, the API automatically applies propagation logic when processing events. This means that when an end-user accepts or rejects a purpose with propagation enabled:

* The API automatically sets all multi-choice preference values for that purpose
* The event is enriched with `propagation: true` on the purpose
* Each preference value includes a `from_propagation` flag indicating whether it was set by propagation (`true`) or explicitly by the user (`false`)
* Explicit end-user choices in the same request always take precedence over propagated values

**Example:**

If you submit an event enabling a purpose that has propagation configured, the stored event includes all propagated preference values:

```javascript
// Request submitted
POST /consents/events?organization_id={organization_id}
{
  "user": { "organization_user_id": "user@domain.com" },
  "consents": {
    "purposes": [{
      "id": "purpose-1",
      "enabled": true,
      "values": {
        "preference-2": { "value": "" }  // User explicitly deselected this
      }
    }]
  }
}

// Event stored (with propagation applied)
{
  "consents": {
    "purposes": [{
      "id": "purpose-1",
      "enabled": true,
      "propagation": true,
      "values": {
        "preference-1": { "value": "value-1,value-2", "from_propagation": true },
        "preference-2": { "value": "", "from_propagation": false },  // User choice preserved
        "preference-3": { "value": "value-5", "from_propagation": true },
        "preference-4": { "value": "value-6,value-7,value-8", "from_propagation": true }
      }
    }]
  }
}
```

For more information about one-click consent, see the [Configuration Tree documentation](/api-and-platform/data-manager/configuration-tree.md#consent-propagation).

### Attach proofs to consent event

If you are collecting physical proofs of consents from your end-users (signatures, forms, etc.), you can attach them to the created events. Add your files as [base64-encoded data URIs](https://en.wikipedia.org/wiki/Data_URI_scheme) in the `proofs` property:

```javascript
POST /consents/events?organization_id={organization_id}

BODY
{
  "user": {
    "organization_user_id": "user@domain.com",
    "metadata": {
      "custom_key": "value"
    }
  },
  
  "consents": {
    "purposes": [
      {
        "id": "purpose_id",
        "enabled": true
      }
    ]
  },
  
  "proofs": [
    {
      "filename": "proof.png",
      "file: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="
    }
  ]      
}
```

Files must be smaller than 10mb and their type must be one of the following formats: PDF, PNG, JPG, GIF, DOCX, DOC, MSG. You can attach a maximum of 5 proofs per event.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.didomi.io/api-and-platform/consents/events/create-consent-event.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
