Batch import

If you are importing existing consent events that were collected outside of the Didomi platform, we support two options for on-boarding a high numbers of events:

HTTP requests

You can use our regular POST /consent/events to import up to 100 events per request by sending a JSON-encoded array of events instead of a single event in the body of the request.

Example:

POST /consents/events?organization_id={organization_id}

BODY
[
    {
        "id": "9556b7f5-ae22-4616-97f9-3f61e22f0ec7",
        "created_at": "2020-06-03T21:28:55Z",
        "user": {
            "organization_user_id": "user1@domain.com",
            "metadata": {
            "custom_key": "value"
            }
        },
        
        "consents": {
            "purposes": [
                {
                    "id": "purpose_id",
                    "enabled": true
                }
            ]
        }
    },
    {
        "id": "593aa0a9-5e2e-4305-8e78-9b9e11da0224",
        "created_at": "2020-06-03T21:28:55Z",
        "user": {
            "organization_user_id": "user2@domain.com",
            "metadata": {
            "custom_key": "value"
            }
        },
        
        "consents": {
            "purposes": [
                {
                    "id": "purpose_id",
                    "enabled": false
                }
            ]
        }
    }
]

We recommend adding a unique ID for every event in the id field as that guarantees that events are never imported twice. You can also add a creation date in the created_at field to import events that were collected in the past and keep their original collection date.

The full schema for a consent event is supported. You can read more about creating consent events and their schema in our Guide or our API documentation.

If you are importing consent events already present in your systems and there is no need for these events to be forwarded to your integrations, you can add the query parameter $disable_integrations=true to your request to disable such forwarding.

File-based import

If you are trying to import a very high number of events and HTTP requests are impractical, you can send files containing all the events to import to Didomi. Didomi can import millions of events through this method. Get in touch with our Support team (support@didomi.io) to import events via this method.

Format

Didomi can import consent events in files formatted as newline-delimited JSON (one JSON object per line), and compressed as GZIP. We expect the file extension .json.gz.

Every line of the file to import should contain a consent event encoded as an independent JSON object with the same schema as events sent to our API for creation. Events can be split into multiple files if needed and files must be compressed before sending them to Didomi .

Example of a file that can be imported by Didomi:

{"id":"081d9d78-fd2a-442a-a429-f16c9c8958a4","created_at":"2020-06-03T21:28:55Z","user":{"organization_user_id":"user1@domain.com","metadata":{"custom_key":"value"}},"consents":{"purposes":[{"id":"purpose_id","enabled":true}]}}
{"id":"5188b92e-ce05-4207-8cbd-79fc0e9a535e","created_at":"2020-06-03T21:28:55Z","user":{"organization_user_id":"user2@domain.com","metadata":{"custom_key":"value"}},"consents":{"purposes":[{"id":"purpose_id","enabled":true}]}}
{"id":"e1a4980c-569f-4f5f-9d98-9b5d9c782b8a","created_at":"2020-06-03T21:28:55Z","user":{"organization_user_id":"user3@domain.com","metadata":{"custom_key":"value"}},"consents":{"purposes":[{"id":"purpose_id","enabled":true}]}}
{"id":"ba56d4c6-3409-4304-a0c5-5148fc9888b9","created_at":"2020-06-03T21:28:55Z","user":{"organization_user_id":"user4@domain.com","metadata":{"custom_key":"value"}},"consents":{"purposes":[{"id":"purpose_id","enabled":true}]}}
{"id":"1580da97-b47c-4d48-86de-f5478c8b75c6","created_at":"2020-06-03T21:28:55Z","user":{"organization_user_id":"user5@domain.com","metadata":{"custom_key":"value"}},"consents":{"purposes":[{"id":"purpose_id","enabled":true}]}}
{"id":"c5c6306d-bf3c-4efe-9e6b-d39daba1d92a","created_at":"2020-06-03T21:28:55Z","user":{"organization_user_id":"user6@domain.com","metadata":{"custom_key":"value"}},"consents":{"purposes":[{"id":"purpose_id","enabled":true}]}}
{"id":"f0353dc8-e13c-46bc-bd16-f89c74490ce9","created_at":"2020-06-03T21:28:55Z","user":{"organization_user_id":"user7@domain.com","metadata":{"custom_key":"value"}},"consents":{"purposes":[{"id":"purpose_id","enabled":true}]}}
{"id":"0f8a748f-49c9-47e0-afe6-1fd37c47fcf3","created_at":"2020-06-03T21:28:55Z","user":{"organization_user_id":"user8@domain.com","metadata":{"custom_key":"value"}},"consents":{"purposes":[{"id":"purpose_id","enabled":true}]}}
{"id":"20880f5b-055f-4ad4-9464-22d0d5a6b814","created_at":"2020-06-03T21:28:55Z","user":{"organization_user_id":"user9@domain.com","metadata":{"custom_key":"value"}},"consents":{"purposes":[{"id":"purpose_id","enabled":true}]}}
{"id":"556becaf-8f5f-405a-933e-6f0071bd6ab4","created_at":"2020-06-03T21:28:55Z","user":{"organization_user_id":"user10@domain.com","metadata":{"custom_key":"value"}},"consents":{"purposes":[{"id":"purpose_id","enabled":true}]}}

As part of the newline-delimited format, the encoded JSON data is NOT an array and must not start with [ or end with ]. Every line of the file is an independent JSON object and the file is read by splitting every line and processing every line independently.

We recommend adding a unique ID for every event in the id field as that guarantees that events are never imported twice. You can also add a creation date in the created_at field to import events that were collected in the past and keep their original collection date.

Last updated