---
updatedAt: 2025-12-15T10:07:01.000Z
agentTools:
  projectIndex: https://developer.onetrust.com/onetrust/llms.txt
---

# Creating a Collection Point and Retrieving Consent

```python Python
import requests
api_host = "https://app.onetrust.com"
access_token = "Insert your Access Token here"
headers = {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Authorization": "Bearer " + access_token
}


url = api_host + "/api/access/v1/external/organizations"
organizations_response = requests.get(url, headers=headers).json()
print(organizations_response['organizationId'])


url = api_host + "/api/consentmanager/v1/custompreferences"
payload = {
    "Options": ["Daily", "Weekly", "Monthly"],
    "DefaultLanguage": True,
    "Language": "en-US",
    "Name": "Email Frequencies",
    "Description": "Options for different frequencies to receive emails",
    "Required": True,
    "DisplayAs": "BUTTONS",
    "SelectionType": "SINGLE_CHOICE"
}
custompreferences_response = requests.post(url, json=payload, headers=headers).json()
print(custompreferences_response)


url = api_host + "/api/consentmanager/v1/purposes"
payload = {
    "ConsentLifeSpan": 7889238,
    "DefaultLanguage": "en-us",
    "Description": "Collect customer emails for marketing purposes",
    "Name": "Marketing Communication",
}
purposes_response = requests.post(url, json=payload, headers=headers).json()
print(purposes_response)


url = api_host + "/api/consentmanager/v1/purposes/" + purposes_response['Id']
payload = {
    "Name": purposes_response['Label'],
    "Description": purposes_response['Description'],
    "CustomPreferenceIds": [custompreferences_response['Id']],
    "ConsentLifeSpan": 7889238,
    "Status": "DRAFT",
    "Version": purposes_response['Version']
}
purposes_response = requests.put(url, json=payload, headers=headers).json()
print(purposes_response)


url = api_host + "/api/consentmanager/v1/collectionpoints"
payload = {
    "Name": "Web Form Collection Point",
    "Description": "Collecting data for Marketing and Promotion Purposes",
    "DataElements": ["Email", "FirstName", "LastName"],
    "CollectionPointType": "WEB_FORM",
    "ConsentType": "FORMSUBMIT",
    "OrganizationId": organizations_response['organizationId'],
    "PurposeIdsWithVersion": [
        {
            "Id": purposes_response['Id'],
            "Version": purposes_response['Version']
        }
    ],
    "IsDynamicCollectionPoint": False,
    "NewSdkIntegrationEnabled": True,
    "IdentifierDataElementId": "0c16784a-6291-4e94-8740-c01520ec1d72",
    "PreferenceCenterGuid": custompreferences_response['Id']
}
collectionpoints_response = requests.post(url, json=payload, headers=headers).json()
print(collectionpoints_response)


url = api_host + "/api/consentmanager/v1/collectionpoints/" + collectionpoints_response['Id'] + "/token?version=" + str(collectionpoints_response['Version'])
collectionpointtoken_response = requests.get(url, headers=headers).json()
print(collectionpointtoken_response['token'])


url = "https://privacyportal.onetrust.com/request/v1/consentreceipts"
payload = {
    "requestInformation": collectionpointtoken_response['token'],
    "identifier": "CookieID",
    "test": True,
    "purposes": [
        {
            "Id": purposes_response['Id'],
            "Version": purposes_response['Version'],
            "Preferences": []
        }
    ],
    "dsDataElements": {
        "Email": "user@onetrust.com",
        "FirstName": "John",
        "LastName": "Doe"
    }
}
consentreceipts_response = requests.post(url, json=payload, headers=headers).json()
print(consentreceipts_response)


url = api_host + "/rest/api/preferences/v3/datasubjects/profile"
headers.update({"identifier": "CookieID"})
datasubject_response = requests.get(url, headers=headers).json()
print(datasubject_response)

```

```json Response Example
// Step 2: Line 13
b7d17fc8-889f-472e-8c74-f1169821e7e7
// Step 3: Line 28
{'Id': '453006f3-bc2a-471a-b205-2aed93a75e07', 'Name': 'Email Frequencies', 'Description': 'Options for different frequencies to receive emails', 'SelectionType': 'SINGLE_CHOICE', 'DisplayAs': 'BUTTONS', 'CreatedDate': '2022-04-29T14:30:14.575374Z', 'UpdatedDate': '2022-04-29T14:30:14.652632Z', 'NumberOfOptions': 3, 'Required': True, 'NumberOfLanguages': 1, 'DefaultLanguage': 'en-US', 'Disabled': False, 'Options': [{'Id': 'bdac1379-e47c-45ae-a3e0-848e864dc470', 'Label': 'Daily', 'Order': 0, 'IsDefault': False, 'CanDelete': True, 'Disabled': False}, {'Id': '2040dba5-2069-4780-acca-444c65bc24f9', 'Label': 'Weekly', 'Order': 1, 'IsDefault': False, 'CanDelete': True, 'Disabled': False}, {'Id': 'e21eabe3-a712-4417-8811-c61db7592c4d', 'Label': 'Monthly', 'Order': 2, 'IsDefault': False, 'CanDelete': True, 'Disabled': False}], 'Languages': [{'Name': 'Email Frequencies', 'Description': 'Options for different frequencies to receive emails', 'Language': 'en-US', 'Default': True, 'Options': [{'Id': 'bdac1379-e47c-45ae-a3e0-848e864dc470', 'Label': 'Daily', 'Order': 0, 'IsDefault': False, 'CanDelete': True, 'Disabled': False}, {'Id': '2040dba5-2069-4780-acca-444c65bc24f9', 'Label': 'Weekly', 'Order': 1, 'IsDefault': False, 'CanDelete': True, 'Disabled': False}, {'Id': 'e21eabe3-a712-4417-8811-c61db7592c4d', 'Label': 'Monthly', 'Order': 2, 'IsDefault': False, 'CanDelete': True, 'Disabled': False}]}], 'Organizations': []}
// Step 4: Line 39
{'Id': 'c50d0577-bcc3-42b6-94d5-c2207468fecd', 'Label': 'Marketing Communication', 'Description': 'Collect customer emails for marketing purposes', 'Status': 'DRAFT', 'Version': 1, 'RetireOnDate': None, 'ParentPurposeId': None, 'ExternalReference': None, 'PurposeType': 'STANDARD', 'ConsentLifeSpan': 7889238, 'Languages': None, 'Topics': [], 'CustomPreferences': [], 'Organizations': [], 'ExpiryDateType': 'LAST_TRANSACTION_DATE', 'attributeValues': {}, 'attributes': None, 'EnableGeolocation': False}
// Step 5: Line 52
{'Id': 'c50d0577-bcc3-42b6-94d5-c2207468fecd', 'Label': 'Marketing Communication', 'Description': 'Collect customer emails for marketing purposes', 'Status': 'DRAFT', 'Version': 1, 'RetireOnDate': None, 'ParentPurposeId': None, 'ExternalReference': None, 'PurposeType': 'STANDARD', 'ConsentLifeSpan': 7889238, 'Languages': [{'Name': 'Marketing Communication', 'Description': 'Collect customer emails for marketing purposes', 'Language': 'en-us', 'Default': True}], 'Topics': [], 'CustomPreferences': [{'Id': 'e1df7c1c-5567-4a51-a5fc-886730681792', 'Name': 'Email Frequencies', 'CustomPreferenceOptions': [{'Id': 'bdac1379-e47c-45ae-a3e0-848e864dc470', 'Label': 'Daily', 'Order': 0, 'IsDefault': False}, {'Id': '2040dba5-2069-4780-acca-444c65bc24f9', 'Label': 'Weekly', 'Order': 1, 'IsDefault': False}, {'Id': 'e21eabe3-a712-4417-8811-c61db7592c4d', 'Label': 'Monthly', 'Order': 2, 'IsDefault': False}]}], 'Organizations': [], 'ExpiryDateType': 'LAST_TRANSACTION_DATE', 'attributeValues': {}, 'attributes': None, 'EnableGeolocation': False}
// Step 6: Line 75
{'jwtToken': None, 'noticesWithVersions': [], 'Id': 'd238c9ac-9451-4fd9-b43a-2661d4c267ea', 'Version': 1, 'Name': 'Web Form Collection Point', 'CollectionPointType': 'WEB_FORM', 'ConsentType': 'FORMSUBMIT', 'Status': 'DRAFT', 'SubjectIdentifier': 'Cookie Unique Id', 'IdentifierDataElement': {'Id': '0c16784a-6291-4e94-8740-c01520ec1d72', 'Label': 'Cookie Unique Id', 'IsIdentifier': True, 'Languages': [], 'NumberOfLanguages': 0, 'CreatedDate': '2022-02-14T09:07:22.813Z', 'UpdatedDate': '2022-04-13T17:33:42.737Z', 'CollectionPoints': 0, 'CollectionPointsWithoutRetired': 0, 'totalActivePreferenceCenters': 0, 'PreferenceCenters': 0, 'canEdit': True, 'canDelete': True, 'DataElementFields': {'DataElementType': 'USER_INPUT', 'DisplayAs': 'NONE', 'DataElementOptions': None}, 'AllowMultiValue': False, 'PIInfo': True, 'Organizations': []}, 'CreateDate': '2022-04-29T14:30:16.563782', 'FirstReceiptOn': None, 'ReceiptCount': 0, 'Description': 'Collecting data for Marketing and Promotion Purposes', 'WebFormUrl': None, 'PrivacyPolicyUrl': None, 'DataControllerName': None, 'RightToWithdraw': None, 'HowToWithdraw': None, 'OtherInformation': None, 'ActivationDate': None, 'OrganizationId': 'b7d17fc8-889f-472e-8c74-f1169821e7e7', 'DoubleOptIn': False, 'RedirectUrl': None, 'IABVendorId': None, 'NoConsentTransactions': False, 'LastSdkIntegrationDate': None, 'Language': None, 'Languages': [], 'HostedSDK': True, 'ShowWarning': False, 'SendConsentEmail': False, 'PreferenceCenter': {'Id': None, 'Name': None, 'OrganizationName': None, 'Template': None}, 'ResponsibleUserId': None, 'ResponsibleGroupId': None, 'LastActivityDate': None, 'WarningReason': [], 'ConsentIntegration': False, 'EnableNewConsentIntegration': False, 'IsAuthenticationRequired': False, 'CreatedBy': '7812d864-1892-4d40-81f7-d9e0b0735d40', 'LastModifiedBy': '7812d864-1892-4d40-81f7-d9e0b0735d40', 'ReconfirmActivePurpose': False, 'OverrideActivePurpose': True, 'PublishedBy': None, 'IsDynamicCollectionPoint': False, 'DoiEmailToParent': False, 'NewSdkIntegrationEnabled': True, 'consentDOICancelOption': False, 'DOISendConfirmationEmail': False, 'Disabled': False, 'EnablePublishEvent': False, 'EnablePrimaryIdentifier': False, 'PrimaryIdentifierType': None, 'EnableGeolocation': False, 'DisableReports': False, 'DataElements': ['Email', 'FirstName', 'LastName'], 'IdentifierTypes': [], 'AllowMultipleIdentifierTypes': False, 'DataElementsTranslation': {}, 'CanCreateNewVersion': False, 'attributes': {}, 'HostedWebForm': None, 'includeParameter': False, 'includeIdentifierParameter': False, 'CookieConsentUpdate': None, 'ParentIdentifierTypes': [], 'Purposes': [{'Id': 'c50d0577-bcc3-42b6-94d5-c2207468fecd', 'Label': 'Marketing Communication', 'Description': 'Collect customer emails for marketing purposes', 'Status': 'DRAFT', 'NewVersionAvailable': True, 'Type': 'STANDARD', 'LifeSpan': 7889238, 'Version': 1, 'ParentPurposeId': None, 'ExternalReference': None, 'CreatedBy': '7812D864-1892-4D40-81F7-D9E0B0735D40', 'CreatedDate': '2022-04-29T14:30:15.320Z', 'UpdatedBy': '7812D864-1892-4D40-81F7-D9E0B0735D40', 'UpdatedDate': '2022-04-29T14:30:15.320Z', 'PublishedBy': None, 'PublishedDate': None, 'Topics': [], 'CustomPreferences': [{'Id': '453006f3-bc2a-471a-b205-2aed93a75e07', 'Name': 'Email Frequencies', 'Description': 'Options for different frequencies to receive emails', 'SelectionType': 'SINGLE_CHOICE', 'DisplayAs': 'BUTTONS', 'CreatedDate': None, 'UpdatedDate': None, 'NumberOfOptions': None, 'Required': True, 'NumberOfLanguages': None, 'DefaultLanguage': None, 'Disabled': False, 'Options': [{'Id': 'bdac1379-e47c-45ae-a3e0-848e864dc470', 'Label': 'Daily', 'Order': 0, 'IsDefault': False, 'CanDelete': True, 'Disabled': False}, {'Id': '2040dba5-2069-4780-acca-444c65bc24f9', 'Label': 'Weekly', 'Order': 1, 'IsDefault': False, 'CanDelete': True, 'Disabled': False}, {'Id': 'e21eabe3-a712-4417-8811-c61db7592c4d', 'Label': 'Monthly', 'Order': 2, 'IsDefault': False, 'CanDelete': True, 'Disabled': False}], 'Languages': [], 'Organizations': [], 'PurposeCustomPreferenceId': 'e1df7c1c-5567-4a51-a5fc-886730681792'}], 'Organizations': [], 'attributes': None, 'PurposeIdWithVersion': 'c50d0577-bcc3-42b6-94d5-c2207468fecd:1', 'PurposeLanguages': [], 'EnableGeolocation': False}]}
// Step 7: Line 80
eyJhbGciOiJSUzUxMiJ9eyJvdEp3dFZlcnNpb24iOjEsInByb2Nlc3NJZCI6ImQyMzhjOWFjLTk0NTEtNGZkOS1iNDNhLTI2NjFkNGMyNjdlYSIsInByb2Nlc3NWZXJzaW9uIjoxLCJpYXQiOiIyMDIyLTA0LTI5VDE0OjMwOjE2LjU0IiwibW9jIjoiV0VCX0ZPUk0iLCJwb2xpY3lfdXJpIjpudWxsLCJzdWIiOiJDb29raWUgVW5pcXVlIElkIiwiaXNzIjpudWxsLCJ0ZW5hbnRJZCI6IjMzZGY1OTBlLTNmZDUtNDRiZC1hNTBmLTM3MjI5ODgwMjFlYyIsImRlc2NyaXB0aW9uIjoiQ29sbGVjdGluZyBkYXRhIGZvciBNYXJrZXRpbmcgYW5kIFByb21vdGlvbiBQdXJwb3NlcyIsImNvbnNlbnRUeXBlIjoiRk9STVNVQk1JVCIsImFsbG93Tm90R2l2ZW5Db25zZW50cyI6ZmFsc2UsImRvdWJsZU9wdEluIjpmYWxzZSwicHVycG9zZXMiOlt7ImlkIjoiYzUwZDA1NzctYmNjMy00MmI2LTk0ZDUtYzIyMDc0NjhmZWNkIiwidmVyc2lvbiI6MSwicGFyZW50SWQiOm51bGwsInRvcGljcyI6W10sImN1c3RvbVByZWZlcmVuY2VzIjpbeyJpZCI6ImUxZGY3YzFjLTU1NjctNGE1MS1hNWZjLTg4NjczMDY4MTc5MiIsImlzUmVxdWlyZWQiOnRydWUsIm9wdGlvbnMiOlsiYmRhYzEzNzktZTQ3Yy00NWFlLWEzZTAtODQ4ZTg2NGRjNDcwIiwiMjA0MGRiYTUtMjA2OS00NzgwLWFjY2EtNDQ0YzY1YmMyNGY5IiwiZTIxZWFiZTMtYTcxMi00NDE3LTg4MTEtYzYxZGI3NTkyYzRkIl19XSwiZW5hYmxlR2VvbG9jYXRpb24iOmZhbHNlfV0sIm5vdGljZXMiOltdLCJkc0RhdGFFbGVtZW50cyI6WyJFbWFpbCIsIkZpcnN0TmFtZSIsIkxhc3ROYW1lIl0sImF1dGhlbnRpY2F0aW9uUmVxdWlyZWQiOmZhbHNlLCJyZWNvbmZpcm1BY3RpdmVQdXJwb3NlIjpmYWxzZSwib3ZlcnJpZGVBY3RpdmVQdXJwb3NlIjp0cnVlLCJkeW5hbWljQ29sbGVjdGlvblBvaW50IjpmYWxzZSwiYWRkaXRpb25hbElkZW50aWZpZXJzIjpbIkVtYWlsIl0sIm11bHRpcGxlSWRlbnRpZmllclR5cGVzIjpmYWxzZSwiZW5hYmxlUGFyZW50UHJpbWFyeUlkZW50aWZpZXJzIjpmYWxzZSwicGFyZW50UHJpbWFyeUlkZW50aWZpZXJzVHlwZSI6bnVsbCwiYWRkaXRpb25hbFBhcmVudElkZW50aWZpZXJUeXBlcyI6W10sImVuYWJsZUdlb2xvY2F0aW9uIjpmYWxzZX0=
// Step 8: Line 102
{'receipt': 'Receipt_Token'}
// Step 9: Line 108
{'id': None, 'language': None, 'identifier': 'CookieID', 'lastUpdatedDate': None, 'createdDate': None, 'dataElements': [{'name': 'Email', 'value': 'user@onetrust.com', 'linked': False}, {'name': 'FirstName', 'value': 'John', 'linked': False}, {'name': 'LastName', 'value': 'Doe', 'linked': False}], 'purposes': [{'id': 'bb8c1c09-cda7-43fd-ac9b-e787c6cc4a7f', 'lastReceiptId': None, 'name': None, 'version': None, 'status': 'ACTIVE', 'firstTransactionDate': None, 'lastTransactionDate': None, 'withdrawalDate': None, 'consentDate': '2022-04-28T21:02:55.110988', 'expiryDate': None, 'totalTransactionCount': None, 'topics': [], 'customPreferences': [], 'lastTransactionCollectionPointId': None, 'lastTransactionCollectionPointVersion': None, 'lastUpdatedDate': '2022-04-28T21:02:55.110988', 'lastInteractionDate': '2022-04-28T21:02:55.110988', 'attributes': None}, {'id': '0ad041b8-b046-4df7-931e-437827d4c869', 'lastReceiptId': None, 'name': None, 'version': None, 'status': 'ACTIVE', 'firstTransactionDate': None, 'lastTransactionDate': None, 'withdrawalDate': None, 'consentDate': '2022-04-28T20:45:06.042976', 'expiryDate': None, 'totalTransactionCount': None, 'topics': [], 'customPreferences': [], 'lastTransactionCollectionPointId': None, 'lastTransactionCollectionPointVersion': None, 'lastUpdatedDate': '2022-04-28T20:45:06.042976', 'lastInteractionDate': '2022-04-28T20:45:06.042976', 'attributes': None}, {'id': '851cb4ee-bdb4-40df-a538-34470d567e53', 'lastReceiptId': None, 'name': None, 'version': None, 'status': 'ACTIVE', 'firstTransactionDate': None, 'lastTransactionDate': None, 'withdrawalDate': None, 'consentDate': '2022-04-28T21:01:58.412265', 'expiryDate': None, 'totalTransactionCount': None, 'topics': [], 'customPreferences': [], 'lastTransactionCollectionPointId': None, 'lastTransactionCollectionPointVersion': None, 'lastUpdatedDate': '2022-04-28T21:01:58.412265', 'lastInteractionDate': '2022-04-28T21:01:58.412265', 'attributes': None}, {'id': 'f2d4a8c6-a0a1-4d05-b0a6-78ad68de2127', 'lastReceiptId': None, 'name': None, 'version': None, 'status': 'ACTIVE', 'firstTransactionDate': None, 'lastTransactionDate': None, 'withdrawalDate': None, 'consentDate': '2022-04-28T20:47:20.496829', 'expiryDate': None, 'totalTransactionCount': None, 'topics': [], 'customPreferences': [], 'lastTransactionCollectionPointId': None, 'lastTransactionCollectionPointVersion': None, 'lastUpdatedDate': '2022-04-28T20:47:20.496829', 'lastInteractionDate': '2022-04-28T20:47:20.496829', 'attributes': None}, {'id': 'c23dd8f8-d987-4ade-8ec1-6ab04aa6f49d', 'lastReceiptId': None, 'name': None, 'version': None, 'status': 'ACTIVE', 'firstTransactionDate': None, 'lastTransactionDate': None, 'withdrawalDate': None, 'consentDate': '2022-04-28T20:55:42.557622', 'expiryDate': None, 'totalTransactionCount': None, 'topics': [], 'customPreferences': [], 'lastTransactionCollectionPointId': None, 'lastTransactionCollectionPointVersion': None, 'lastUpdatedDate': '2022-04-28T20:55:42.557622', 'lastInteractionDate': '2022-04-28T20:55:42.557622', 'attributes': None}, {'id': '990f76de-9b28-4c40-a9d5-1d5f0cfcef88', 'lastReceiptId': None, 'name': None, 'version': None, 'status': 'ACTIVE', 'firstTransactionDate': None, 'lastTransactionDate': None, 'withdrawalDate': None, 'consentDate': '2022-04-28T20:58:27.401509', 'expiryDate': None, 'totalTransactionCount': None, 'topics': [], 'customPreferences': [], 'lastTransactionCollectionPointId': None, 'lastTransactionCollectionPointVersion': None, 'lastUpdatedDate': '2022-04-28T20:58:27.401509', 'lastInteractionDate': '2022-04-28T20:58:27.401509', 'attributes': None}], 'testDataSubject': None}
```

# Update Host & Token

<!-- python@1-9 -->

In this step, we set up your authentication headers to invoke the REST method. If needed, update the `api_host` with your OneTrust application hostname. Add your [OAuth Access Token](https://developer.onetrust.com/onetrust/recipes/generate-oauth-access-token) for the `access_token` parameter.

# Obtain the Organization ID

<!-- python@10-14 -->

Use the [retrieve organization structure](/onetrust/reference/organizationtreestructureusingget) *GET* request to fetch the list of all organizations in your tenant. This list displays the organizations in a tree-style. In this example, we leverage the root organization's ID. This value will be used in a later step when creating the Collection Point.

<details>
  <summary>Expand to see example response</summary>


```json
{
    "organizationId": "b7d17fc8-889f-472e-8c74-f1169821e7e7",
    "externalId": null,
    "parentOrganizationId": null,
    "parentExternalId": null,
    "name": "OneTrust",
    "defaultApprover": "user@onetrust.com",
    "defaultLanguageCode": "en-us",
    "description": null,
    "children": [
        {
            "organizationId": "2b2b9898-4a00-46e1-a562-5d5d08d93dc9",
            "externalId": "onetrustchild",
            "parentOrganizationId": "b7d17fc8-889f-472e-8c74-f1169821e7e7",
            "parentExternalId": null,
            "name": "OneTrust Child",
            "defaultApprover": "user@onetrust.com",
            "defaultLanguageCode": "en-us",
            "description": null,
            "children": []
        }
    ]
}
```

</details>

# Create Custom Preferences

<!-- python@15-29 -->

Use the [Create Custom Preference](/onetrust/reference/createcustompreferenceusingpost) *POST* request to create a new custom preference which will be added to the Purpose in the next steps. 

<details>
  <summary>Expand to see example response</summary>


```json
{
    "Id": "453006f3-bc2a-471a-b205-2aed93a75e07",
    "Name": "Email Frequency",
    "Description": "Options for different frequencies to receive emails",
    "SelectionType": "SINGLE_CHOICE",
    "DisplayAs": "BUTTONS",
    "CreatedDate": "2022-04-29T14:30:14.575374Z",
    "UpdatedDate": "2022-04-29T14:30:14.652632Z",
    "NumberOfOptions": 3,
    "Required": true,
    "NumberOfLanguages": 1,
    "DefaultLanguage": "en-US",
    "Disabled": false,
    "Options": [
        {
            "Id": "bdac1379-e47c-45ae-a3e0-848e864dc470",
            "Label": "Daily",
            "Order": 0,
            "IsDefault": false,
            "CanDelete": true,
            "Disabled": false
        },
        {
            "Id": "2040dba5-2069-4780-acca-444c65bc24f9",
            "Label": "Weekly",
            "Order": 1,
            "IsDefault": false,
            "CanDelete": true,
            "Disabled": false
        },
        {
            "Id": "e21eabe3-a712-4417-8811-c61db7592c4d",
            "Label": "Monthly",
            "Order": 2,
            "IsDefault": false,
            "CanDelete": true,
            "Disabled": false
        }
    ],
    "Languages": [
        {
            "Name": "Email Frequency",
            "Description": "Options for different frequencies to receive emails",
            "Language": "en-US",
            "Default": true,
            "Options": [
                {
                    "Id": "bdac1379-e47c-45ae-a3e0-848e864dc470",
                    "Label": "Daily",
                    "Order": 0,
                    "IsDefault": false,
                    "CanDelete": true,
                    "Disabled": false
                },
                {
                    "Id": "2040dba5-2069-4780-acca-444c65bc24f9",
                    "Label": "Weekly",
                    "Order": 1,
                    "IsDefault": false,
                    "CanDelete": true,
                    "Disabled": false
                },
                {
                    "Id": "e21eabe3-a712-4417-8811-c61db7592c4d",
                    "Label": "Monthly",
                    "Order": 2,
                    "IsDefault": false,
                    "CanDelete": true,
                    "Disabled": false
                }
            ]
        }
    ],
    "Organizations": []
}
```

</details>

# Create a new Purpose

<!-- python@30-40 -->

Use the [Create Purpose](/onetrust/reference/createpurposeusingpost) *POST* request to create a new Purpose. The Purpose will be created in the `DRAFT` state and will have a version set to `1`.

<details>
  <summary>Expand to see example response</summary>


```json
{
    "Id": "c50d0577-bcc3-42b6-94d5-c2207468fecd",
    "Label": "Marketing Communication",
    "Description": "Collect customer emails for marketing purposes",
    "Status": "DRAFT",
    "Version": 1,
    "RetireOnDate": null,
    "ParentPurposeId": null,
    "ExternalReference": null,
    "PurposeType": "STANDARD",
    "ConsentLifeSpan": 7889238,
    "Languages": null,
    "Topics": [],
    "CustomPreferences": [],
    "Organizations": [],
    "ExpiryDateType": "LAST_TRANSACTION_DATE",
    "attributeValues": {},
    "attributes": null,
    "EnableGeolocation": false
}
```

</details>

# Associate Custom Preference with Processing Purpose

<!-- python@41-53 -->

Use the [Edit Purpose](/onetrust/reference/editpurposeusingput) *PUT* request to associate the Custom Preference created earlier. 

You can use the [Publish Purpose](/onetrust/reference/publishpurposeusingput) *PUT* request to publish the `DRAFT` Purpose. Please note you can replace this step in a later step by leveraging the [Update Collection Point](/onetrust/reference/editcollectionpointusingput) *PUT* request to change the Collection Point's status from `DRAFT` to `ACTIVE`. Setting the Collection Point to `ACTIVE` will also update any `DRAFT` Processing Purposes to become `ACTIVE`. Note, you can still test and modify Purposes and Collection Points while in the `DRAFT` state. We will work with a `DRAFT` Purpose and Collection Point in this example. 

<details>
  <summary>Expand to see example response</summary>


```json
{
    "Id": "c50d0577-bcc3-42b6-94d5-c2207468fecd",
    "Label": "Marketing Communication",
    "Description": "Collect customer emails for marketing purposes",
    "Status": "DRAFT",
    "Version": 1,
    "RetireOnDate": null,
    "ParentPurposeId": null,
    "ExternalReference": null,
    "PurposeType": "STANDARD",
    "ConsentLifeSpan": 7889238,
    "Languages": [
        {
            "Name": "Marketing Communication",
            "Description": "Collect customer emails for marketing purposes",
            "Language": "en-us",
            "Default": true
        }
    ],
    "Topics": [],
    "CustomPreferences": [
        {
            "Id": "e1df7c1c-5567-4a51-a5fc-886730681792",
            "Name": "Email Frequency",
            "CustomPreferenceOptions": [
                {
                    "Id": "bdac1379-e47c-45ae-a3e0-848e864dc470",
                    "Label": "Daily",
                    "Order": 0,
                    "IsDefault": false
                },
                {
                    "Id": "2040dba5-2069-4780-acca-444c65bc24f9",
                    "Label": "Weekly",
                    "Order": 1,
                    "IsDefault": false
                },
                {
                    "Id": "e21eabe3-a712-4417-8811-c61db7592c4d",
                    "Label": "Monthly",
                    "Order": 2,
                    "IsDefault": false
                }
            ]
        }
    ],
    "Organizations": [],
    "ExpiryDateType": "LAST_TRANSACTION_DATE",
    "attributeValues": {},
    "attributes": null,
    "EnableGeolocation": false
}
```

</details>

# Create the Collection Point

<!-- python@54-76 -->

Use the [Create Collection Point](/onetrust/reference/createcollectionpointusingpost) *POST* request to create a new Collection Point. You will leverage the `organizationId`, preference `Id`, and purpose `Id` and `Version` from the previous steps. 

The newly created Collection Point will be in the `DRAFT` state and will have a version set to `1`. You can leverage the [Update Collection Point](/onetrust/reference/editcollectionpointusingput) *PUT* request to change the Collection Point's status from `DRAFT` to `ACTIVE`. Setting the Collection Point to `ACTIVE` will also update any `DRAFT` Processing Purposes to become `ACTIVE`. You can still test and modify Collection Points while in the `DRAFT` state. 

For `IdentifierDataElementId` you can find the Data Element Identifier by navigating to the Data Elements page (https://app.onetrust.com/consent/data-elements) in OneTrust and then finding the `Id` in the hyperlink for the Data Element.

> 🚧 Warning
> The Data Element Identifier used cannot also be used as a Data Element.

<details>
  <summary>Expand to see example response</summary>


```json
{
    "jwtToken": null,
    "noticesWithVersions": [],
    "Id": "d238c9ac-9451-4fd9-b43a-2661d4c267ea",
    "Version": 1,
    "Name": "Web Form Collection Point",
    "CollectionPointType": "WEB_FORM",
    "ConsentType": "FORMSUBMIT",
    "Status": "DRAFT",
    "SubjectIdentifier": "Cookie Unique Id",
    "IdentifierDataElement": {
        "Id": "0c16784a-6291-4e94-8740-c01520ec1d72",
        "Label": "Cookie Unique Id",
        "IsIdentifier": true,
        "Languages": [],
        "NumberOfLanguages": 0,
        "CreatedDate": "2022-02-14T09:07:22.813Z",
        "UpdatedDate": "2022-04-13T17:33:42.737Z",
        "CollectionPoints": 0,
        "CollectionPointsWithoutRetired": 0,
        "totalActivePreferenceCenters": 0,
        "PreferenceCenters": 0,
        "canEdit": true,
        "canDelete": true,
        "DataElementFields": {
            "DataElementType": "USER_INPUT",
            "DisplayAs": "null",
            "DataElementOptions": null
        },
        "AllowMultiValue": false,
        "PIInfo": true,
        "Organizations": []
    },
    "CreateDate": "2022-04-29T14:30:16.563782",
    "FirstReceiptOn": null,
    "ReceiptCount": 0,
    "Description": "Collecting data for Marketing and Promotion Purposes",
    "WebFormUrl": null,
    "PrivacyPolicyUrl": null,
    "DataControllerName": null,
    "RightToWithdraw": null,
    "HowToWithdraw": null,
    "OtherInformation": null,
    "ActivationDate": null,
    "OrganizationId": "b7d17fc8-889f-472e-8c74-f1169821e7e7",
    "DoubleOptIn": false,
    "RedirectUrl": null,
    "IABVendorId": null,
    "NoConsentTransactions": false,
    "LastSdkIntegrationDate": null,
    "Language": null,
    "Languages": [],
    "HostedSDK": true,
    "ShowWarning": false,
    "SendConsentEmail": false,
    "PreferenceCenter": {
        "Id": null,
        "Name": null,
        "OrganizationName": null,
        "Template": null
    },
    "ResponsibleUserId": null,
    "ResponsibleGroupId": null,
    "LastActivityDate": null,
    "WarningReason": [],
    "ConsentIntegration": false,
    "EnableNewConsentIntegration": false,
    "IsAuthenticationRequired": false,
    "CreatedBy": "7812d864-1892-4d40-81f7-d9e0b0735d40",
    "LastModifiedBy": "7812d864-1892-4d40-81f7-d9e0b0735d40",
    "ReconfirmActivePurpose": false,
    "OverrideActivePurpose": true,
    "PublishedBy": null,
    "IsDynamicCollectionPoint": false,
    "DoiEmailToParent": false,
    "NewSdkIntegrationEnabled": true,
    "consentDOICancelOption": false,
    "DOISendConfirmationEmail": false,
    "Disabled": false,
    "EnablePublishEvent": false,
    "EnablePrimaryIdentifier": false,
    "PrimaryIdentifierType": null,
    "EnableGeolocation": false,
    "DisableReports": false,
    "DataElements": [
        "Email",
        "FirstName",
        "LastName"
    ],
    "IdentifierTypes": [],
    "AllowMultipleIdentifierTypes": false,
    "DataElementsTranslation": {},
    "CanCreateNewVersion": false,
    "attributes": {},
    "HostedWebForm": null,
    "includeParameter": false,
    "includeIdentifierParameter": false,
    "CookieConsentUpdate": null,
    "ParentIdentifierTypes": [],
    "Purposes": [
        {
            "Id": "c50d0577-bcc3-42b6-94d5-c2207468fecd",
            "Label": "Marketing Communication",
            "Description": "Collect customer emails for marketing purposes",
            "Status": "DRAFT",
            "NewVersionAvailable": true,
            "Type": "STANDARD",
            "LifeSpan": 7889238,
            "Version": 1,
            "ParentPurposeId": null,
            "ExternalReference": null,
            "CreatedBy": "7812D864-1892-4D40-81F7-D9E0B0735D40",
            "CreatedDate": "2022-04-29T14:30:15.320Z",
            "UpdatedBy": "7812D864-1892-4D40-81F7-D9E0B0735D40",
            "UpdatedDate": "2022-04-29T14:30:15.320Z",
            "PublishedBy": null,
            "PublishedDate": null,
            "Topics": [],
            "CustomPreferences": [
                {
                    "Id": "453006f3-bc2a-471a-b205-2aed93a75e07",
                    "Name": "Email Frequency",
                    "Description": "Options for different frequencies to receive emails",
                    "SelectionType": "SINGLE_CHOICE",
                    "DisplayAs": "BUTTONS",
                    "CreatedDate": null,
                    "UpdatedDate": null,
                    "NumberOfOptions": null,
                    "Required": true,
                    "NumberOfLanguages": null,
                    "DefaultLanguage": null,
                    "Disabled": false,
                    "Options": [
                        {
                            "Id": "bdac1379-e47c-45ae-a3e0-848e864dc470",
                            "Label": "Daily",
                            "Order": 0,
                            "IsDefault": false,
                            "CanDelete": true,
                            "Disabled": false
                        },
                        {
                            "Id": "2040dba5-2069-4780-acca-444c65bc24f9",
                            "Label": "Weekly",
                            "Order": 1,
                            "IsDefault": false,
                            "CanDelete": true,
                            "Disabled": false
                        },
                        {
                            "Id": "e21eabe3-a712-4417-8811-c61db7592c4d",
                            "Label": "Monthly",
                            "Order": 2,
                            "IsDefault": false,
                            "CanDelete": true,
                            "Disabled": false
                        }
                    ],
                    "Languages": [],
                    "Organizations": [],
                    "PurposeCustomPreferenceId": "e1df7c1c-5567-4a51-a5fc-886730681792"
                }
            ],
            "Organizations": [],
            "attributes": null,
            "PurposeIdWithVersion": "c50d0577-bcc3-42b6-94d5-c2207468fecd:1",
            "PurposeLanguages": [],
            "EnableGeolocation": false
        }
    ]
}
```

</details>

# Retrieve Collection Point Token

<!-- python@77-81 -->

Use the [Get Collection Point Token](/onetrust/reference/gettokenusingget) *GET* request to retrieve the token for the Collection Point based on the `Id` and `Version`. 

<details>
  <summary>Expand to see example response</summary>


```json
{
  "token": "eyJhbGciOiJSUzUxMiJ9eyJvdEp3dFZlcnNpb24iOjEsInByb2Nlc3NJZCI6ImQyMzhjOWFjLTk0NTEtNGZkOS1iNDNhLTI2NjFkNGMyNjdlYSIsInByb2Nlc3NWZXJzaW9uIjoxLCJpYXQiOiIyMDIyLTA0LTI5VDE0OjMwOjE2LjU0IiwibW9jIjoiV0VCX0ZPUk0iLCJwb2xpY3lfdXJpIjpudWxsLCJzdWIiOiJDb29raWUgVW5pcXVlIElkIiwiaXNzIjpudWxsLCJ0ZW5hbnRJZCI6IjMzZGY1OTBlLTNmZDUtNDRiZC1hNTBmLTM3MjI5ODgwMjFlYyIsImRlc2NyaXB0aW9uIjoiQ29sbGVjdGluZyBkYXRhIGZvciBNYXJrZXRpbmcgYW5kIFByb21vdGlvbiBQdXJwb3NlcyIsImNvbnNlbnRUeXBlIjoiRk9STVNVQk1JVCIsImFsbG93Tm90R2l2ZW5Db25zZW50cyI6ZmFsc2UsImRvdWJsZU9wdEluIjpmYWxzZSwicHVycG9zZXMiOlt7ImlkIjoiYzUwZDA1NzctYmNjMy00MmI2LTk0ZDUtYzIyMDc0NjhmZWNkIiwidmVyc2lvbiI6MSwicGFyZW50SWQiOm51bGwsInRvcGljcyI6W10sImN1c3RvbVByZWZlcmVuY2VzIjpbeyJpZCI6ImUxZGY3YzFjLTU1NjctNGE1MS1hNWZjLTg4NjczMDY4MTc5MiIsImlzUmVxdWlyZWQiOnRydWUsIm9wdGlvbnMiOlsiYmRhYzEzNzktZTQ3Yy00NWFlLWEzZTAtODQ4ZTg2NGRjNDcwIiwiMjA0MGRiYTUtMjA2OS00NzgwLWFjY2EtNDQ0YzY1YmMyNGY5IiwiZTIxZWFiZTMtYTcxMi00NDE3LTg4MTEtYzYxZGI3NTkyYzRkIl19XSwiZW5hYmxlR2VvbG9jYXRpb24iOmZhbHNlfV0sIm5vdGljZXMiOltdLCJkc0RhdGFFbGVtZW50cyI6WyJFbWFpbCIsIkZpcnN0TmFtZSIsIkxhc3ROYW1lIl0sImF1dGhlbnRpY2F0aW9uUmVxdWlyZWQiOmZhbHNlLCJyZWNvbmZpcm1BY3RpdmVQdXJwb3NlIjpmYWxzZSwib3ZlcnJpZGVBY3RpdmVQdXJwb3NlIjp0cnVlLCJkeW5hbWljQ29sbGVjdGlvblBvaW50IjpmYWxzZSwiYWRkaXRpb25hbElkZW50aWZpZXJzIjpbIkVtYWlsIl0sIm11bHRpcGxlSWRlbnRpZmllclR5cGVzIjpmYWxzZSwiZW5hYmxlUGFyZW50UHJpbWFyeUlkZW50aWZpZXJzIjpmYWxzZSwicGFyZW50UHJpbWFyeUlkZW50aWZpZXJzVHlwZSI6bnVsbCwiYWRkaXRpb25hbFBhcmVudElkZW50aWZpZXJUeXBlcyI6W10sImVuYWJsZUdlb2xvY2F0aW9uIjpmYWxzZX0="
}
```

</details>

# Create Receipts from a Collection Point

<!-- python@82-103 -->

Use the [Create Receipts](/onetrust/reference/createconsentreceiptusingpost) *POST* request to submit requests to store data subject consent transactions. We will leverage the Collection Point token to populate the `requestInformation` parameter. 
In most cases further authorization is not required, however instructions for setting up authenticated consent can be found [here](https://my.onetrust.com/s/article/UUID-b359a104-1900-9ac9-7765-ee08c8047f1d) when needed.

> 📘Note
> The `url` will have `privacyportal` preceding the environment name. For example: 
> - https://privacyportal.onetrust.com/request/v1/consentreceipts
> - https://privacyportal-eu.onetrust.com/request/v1/consentreceipts
> - https://privacyportaluat.onetrust.com/request/v1/consentreceipts
> - https://privacyportaluateu.onetrust.com/request/v1/consentreceipts
> - https://privacyportaltrial.onetrust.com/request/v1/consentreceipts

This example leverages the `test` flag, indicating this request is for testing. Note, that if the Collection Point is in `DRAFT` state, like in this example, the `test` flag always be set to `True`. 

Ensure the `identifier` matches the Data Element Identifier used in the previous steps. 

<details>
  <summary>Expand to see example response</summary>


```json
{
    "receipt": "Receipt_Token"
}
```

</details>

# Get Data Subject Profile using Identifier

<!-- python@104-109 -->

Use the [Get Data Subject Profile](/onetrust/reference/getv3datasubjectsprofileusingget) *GET* request to retrieve a single data subject profile by passing the identifier in the header. 

> 👍 Tip
> This API is designed to be used in synchronous workflows and will remain available during maintenance periods.

<details>
  <summary>Expand to see example response</summary>


```json
{
    "id": null,
    "language": null,
    "identifier": "CookieID",
    "lastUpdatedDate": null,
    "createdDate": null,
    "dataElements": [
        {
            "name": "Email",
            "value": "user@onetrust.com",
            "linked": false
        },
        {
            "name": "FirstName",
            "value": "John",
            "linked": false
        },
        {
            "name": "LastName",
            "value": "Doe",
            "linked": false
        }
    ],
    "purposes": [
        {
            "id": "bb8c1c09-cda7-43fd-ac9b-e787c6cc4a7f",
            "lastReceiptId": null,
            "name": null,
            "version": null,
            "status": "ACTIVE",
            "firstTransactionDate": null,
            "lastTransactionDate": null,
            "withdrawalDate": null,
            "consentDate": "2022-04-28T21:02:55.110988",
            "expiryDate": null,
            "totalTransactionCount": null,
            "topics": [],
            "customPreferences": [],
            "lastTransactionCollectionPointId": null,
            "lastTransactionCollectionPointVersion": null,
            "lastUpdatedDate": "2022-04-28T21:02:55.110988",
            "lastInteractionDate": "2022-04-28T21:02:55.110988",
            "attributes": null
        },
        {
            "id": "0ad041b8-b046-4df7-931e-437827d4c869",
            "lastReceiptId": null,
            "name": null,
            "version": null,
            "status": "ACTIVE",
            "firstTransactionDate": null,
            "lastTransactionDate": null,
            "withdrawalDate": null,
            "consentDate": "2022-04-28T20:45:06.042976",
            "expiryDate": null,
            "totalTransactionCount": null,
            "topics": [],
            "customPreferences": [],
            "lastTransactionCollectionPointId": null,
            "lastTransactionCollectionPointVersion": null,
            "lastUpdatedDate": "2022-04-28T20:45:06.042976",
            "lastInteractionDate": "2022-04-28T20:45:06.042976",
            "attributes": null
        },
        {
            "id": "851cb4ee-bdb4-40df-a538-34470d567e53",
            "lastReceiptId": null,
            "name": null,
            "version": null,
            "status": "ACTIVE",
            "firstTransactionDate": null,
            "lastTransactionDate": null,
            "withdrawalDate": null,
            "consentDate": "2022-04-28T21:01:58.412265",
            "expiryDate": null,
            "totalTransactionCount": null,
            "topics": [],
            "customPreferences": [],
            "lastTransactionCollectionPointId": null,
            "lastTransactionCollectionPointVersion": null,
            "lastUpdatedDate": "2022-04-28T21:01:58.412265",
            "lastInteractionDate": "2022-04-28T21:01:58.412265",
            "attributes": null
        },
        {
            "id": "f2d4a8c6-a0a1-4d05-b0a6-78ad68de2127",
            "lastReceiptId": null,
            "name": null,
            "version": null,
            "status": "ACTIVE",
            "firstTransactionDate": null,
            "lastTransactionDate": null,
            "withdrawalDate": null,
            "consentDate": "2022-04-28T20:47:20.496829",
            "expiryDate": null,
            "totalTransactionCount": null,
            "topics": [],
            "customPreferences": [],
            "lastTransactionCollectionPointId": null,
            "lastTransactionCollectionPointVersion": null,
            "lastUpdatedDate": "2022-04-28T20:47:20.496829",
            "lastInteractionDate": "2022-04-28T20:47:20.496829",
            "attributes": null
        },
        {
            "id": "c23dd8f8-d987-4ade-8ec1-6ab04aa6f49d",
            "lastReceiptId": null,
            "name": null,
            "version": null,
            "status": "ACTIVE",
            "firstTransactionDate": null,
            "lastTransactionDate": null,
            "withdrawalDate": null,
            "consentDate": "2022-04-28T20:55:42.557622",
            "expiryDate": null,
            "totalTransactionCount": null,
            "topics": [],
            "customPreferences": [],
            "lastTransactionCollectionPointId": null,
            "lastTransactionCollectionPointVersion": null,
            "lastUpdatedDate": "2022-04-28T20:55:42.557622",
            "lastInteractionDate": "2022-04-28T20:55:42.557622",
            "attributes": null
        },
        {
            "id": "990f76de-9b28-4c40-a9d5-1d5f0cfcef88",
            "lastReceiptId": null,
            "name": null,
            "version": null,
            "status": "ACTIVE",
            "firstTransactionDate": null,
            "lastTransactionDate": null,
            "withdrawalDate": null,
            "consentDate": "2022-04-28T20:58:27.401509",
            "expiryDate": null,
            "totalTransactionCount": null,
            "topics": [],
            "customPreferences": [],
            "lastTransactionCollectionPointId": null,
            "lastTransactionCollectionPointVersion": null,
            "lastUpdatedDate": "2022-04-28T20:58:27.401509",
            "lastInteractionDate": "2022-04-28T20:58:27.401509",
            "attributes": null
        }
    ],
    "testDataSubject": null
}
```

</details>