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

# Building your Own Preference Center UI

```python Python
import requests
api_host = "https://app.onetrust.com"
access_token = "Insert your Access Token here"
preference_center_id = "56857100-657f-464d-b58b-64735f5bdab4"
identifier = "gpburdell@onetrust.com"
headers = {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Authorization": "Bearer " + access_token
}


if not preference_center_id:
    url = api_host + "/api/consentmanager/v2/preferencecenters?name=&purposeGuid=&status=&page=0&size=20&sort=createdDate,desc" # max page size 2000
    preference_list = requests.get(url, headers=headers).json()
    centers = preference_list["content"]
    for center in centers:
        print(center["name"], "|", center["id"])
    print(preference_list["content"])
    input("\nSelect a Preference Center above. \nUpdate preference_center_id with the GUID. \nRe-run script. \nPress Control + C to exit script.")

    
url = api_host + "/api/consentmanager/v2/preferencecenters/"+preference_center_id+"/schema"
root_schema = requests.get(url, headers=headers).json()
print(root_schema)


pages = root_schema["pages"]
page_schema = []
for page in pages:
    url = api_host + "/api/consentmanager/v2/preferencecenterpage/"+page["id"]+"/schema"
    page_schema.append(requests.get(url, headers=headers).json())
print(page_schema)


url = api_host + "/api/consentmanager/v1/preferencecenters/"+preference_center_id+"/datasubjects/preferences?identifier="+identifier
ds_details = requests.get(url, headers=headers).json()
print(ds_details)


headers.update({"identifier": identifier})
url = api_host + "/api/consentmanager/v1/preferencecenters/"+preference_center_id+"/datasubjects/preferences"
payload = {
    "Purposes": [
        {
            "Id": "de70ffa2-f860-442a-902c-a916fa28aebd",
            "Topics": [],
            "CustomPreferences": []
        }
    ],
    "DsDataElements": {
        "Address": "1738 OneTrust Drive",
        "State": "Georgia",
        "City": "Atlanta"
    },
    "Language": "en-US"
}
update_response = requests.put(url, json=payload, headers=headers).json()
print(update_response)


url = api_host + "/api/consentmanager/v1/preferencecenters/"+preference_center_id+"/datasubjects/preferences"
withdraw_response = requests.delete(url, headers=headers).json()
print(withdraw_response)

```

```json Response Example
// Step 2: Line 18
Schema API Recipe Preference Center | 56857100-657f-464d-b58b-64735f5bdab4
G.P. Burdell Foundation | 57833f27-ad86-47de-910d-a118d034c60f
ACME Preference Center | ca4b68d9-ed30-45a1-be78-f413113ce47c
// Step 2: Line 19
[
    {
        "id": "56857100-657f-464d-b58b-64735f5bdab4",
        "name": "Schema API Recipe Preference Center",
        "organizationName": "Preference Management",
        "template": "MULTIPAGE",
        "publishedDate": "2022-07-20T18:42:36.17",
        "status": "ACTIVE",
        "createdDate": "2022-07-20T14:45:32.923"
    },
    {
        "id": "57833f27-ad86-47de-910d-a118d034c60f",
        "name": "G.P. Burdell Foundation",
        "organizationName": "Preference Management",
        "template": "MULTIPAGE",
        "publishedDate": "2022-04-29T17:11:16.887",
        "status": "ACTIVE",
        "createdDate": "2022-04-29T17:07:58.203"
    },
    {
        "id": "ca4b68d9-ed30-45a1-be78-f413113ce47c",
        "name": "ACME Preference Center",
        "organizationName": "Preference Management",
        "template": "MULTIPAGE",
        "publishedDate": "2021-12-28T19:00:24.743",
        "status": "ACTIVE",
        "createdDate": "2021-12-09T19:55:43.79"
    }
]
// Step 2: Line 20
Select a Preference Center above. 
Update preference_center_id with the GUID. 
Re-run script. 
Press Control + C to exit script.
// Step 3: Line 25
{
    "pages": [
        {
            "id": "1ae6761c-3f2c-47a6-acb2-e32da075acb8",
            "order": 0,
            "navigationEnabled": true,
            "displaySubscribeSettings": true,
            "displayUnsubscribeAll": true,
            "displaySubscribeAll": false,
            "languages": [
                {
                    "name": "Marketing Communications",
                    "language": "en-us",
                    "isDefault": true
                }
            ]
        }
    ],
    "defaultLanguage": "en-us",
    "languages": [
        {
            "language": "en-us",
            "isDefault": true
        }
    ],
    "preferenceCenterSettings": {
        "languages": {
            "en-us": {
                "changePreferencesLabel": "Change Preferences",
                "unsubscribedBadgeLabel": "Unsubscribed",
                "purposeToggleActiveLabel": "On",
                "unsubscribeSuccessLabel": "You have successfully unsubscribed.",
                "ssoLoginTitle": "Log in with SSO",
                "subscribedBadgeLabel": "Subscribed",
                "unsubscribeAllLabel": "Unsubscribe All",
                "title": "Your Preferences",
                "reasonsMessage": "We are so sad to see you go! Please indicate the reason for your unsubscription and we will work to improve our service.",
                "reasonsLabel": "Unsubscribe Reason",
                "topicsLabel": "Topics",
                "purposeToggleInactiveLabel": "Off",
                "loginTitle": "Preferences Login",
                "updateErrorLabel": "Sorry, something went wrong. Please try again.",
                "subscriptionSettingsLabel": "Subscription Settings",
                "languageSelector": "Language",
                "companyLogo": "Company Logo",
                "notificationPurposeLabel": "Send notifications about changes to preferences",
                "emailLoginError": "Failed to send login request.",
                "reasonsTitle": "Unsubscribe Successful",
                "notificationPurposeDescription": "Opting out will stop notifications acknowledging consent or changing consent preferences from being sent. Does not impact notices that request a confirmation of consent.",
                "selectIdentifierLabel": "Select data subject identifier",
                "emailPlaceholder": "user@email.com",
                "undoChangesLabel": "Undo Changes",
                "subscriptionStatusLabel": "Last Saved Status",
                "emailInputTitle": "E-Mail",
                "subscribeAllLabel": "Subscribe to All",
                "sendRequest": "Send",
                "updateSuccessLabel": "Thank you! Your preferences have been submitted. Please allow a few minutes for these to be updated."
            }
        }
    },
    "enableMultipleIdentities": false,
    "displayUnsubscribeAll": false,
    "displaySubscribeAll": true,
    "displayNotificationPurpose": true,
    "displaySubscribeSettings": true,
    "notificationPurpose": {
        "id": "cb29b383-0aaa-440b-9669-69e7acd269d7",
        "order": null,
        "languages": [
            {
                "name": "Send Notifications about Changes to Preferences",
                "description": "Opting out will stop notifications acknowledging consent or changing consent preferences from being sent. Does not impact notices which request confirmation of consent.",
                "language": "en-us",
                "isDefault": true
            }
        ],
        "label": "Send Notifications about Changes to Preferences",
        "description": "Opting out will stop notifications acknowledging consent or changing consent preferences from being sent. Does not impact notices which request confirmation of consent.",
        "version": 1,
        "topics": [],
        "customPreferences": [],
        "visibility": null
    },
    "displayPageLevelSubscribeSettings": false,
    "autoCheckTopics": false,
    "updateNotOptedOutToActiveStatus": false
}
// Step 4: Line 33
[
    {
        "id": "1ae6761c-3f2c-47a6-acb2-e32da075acb8",
        "order": 0,
        "isHidden": false,
        "navigationEnabled": true,
        "displaySubscribeSettings": true,
        "displayUnsubscribeAll": true,
        "displaySubscribeAll": false,
        "sections": [
            {
                "id": "8691c55d-90d6-46fe-ac0f-2c9b87dd5615",
                "identifierType": "",
                "isHeaderHidden": false,
                "order": 0,
                "purposes": [
                    {
                        "id": "4e9ead0d-e7f3-4f31-a369-c0756cad45e5",
                        "order": 0,
                        "languages": [
                            {
                                "name": "Email Communication",
                                "description": "Receive email communications from OT Kicks",
                                "language": "en-us",
                                "isDefault": true
                            }
                        ],
                        "label": "OT Kicks - Emails Purpose",
                        "description": "Receive email communications from OT Kicks",
                        "version": 2,
                        "topics": [],
                        "customPreferences": [],
                        "visibility": "VISIBLE_TO_ALL"
                    },
                    {
                        "id": "de70ffa2-f860-442a-902c-a916fa28aebd",
                        "order": 1,
                        "languages": [
                            {
                                "name": "Automated Text Messages",
                                "description": "Receive automated text messages from OT Kicks",
                                "language": "en-us",
                                "isDefault": true
                            }
                        ],
                        "label": "OT Kicks - Automated Text Messages Purpose",
                        "description": "Receive automated text messages from OT Kicks",
                        "version": 1,
                        "topics": [],
                        "customPreferences": [],
                        "visibility": "VISIBLE_TO_ALL"
                    }
                ],
                "customDataElements": [
                    {
                        "id": "4a4380cc-f283-4b8a-a8b9-4bba82323a1a",
                        "order": 2,
                        "languages": [],
                        "name": "Address",
                        "hidden": false,
                        "readOnly": false,
                        "required": false,
                        "displayAs": null,
                        "dataElementType": "USER_INPUT",
                        "dataElementOptions": [],
                        "allowMultiValue": false
                    },
                    {
                        "id": "3e7fcc3a-1113-4c6f-a4cf-aa3a93ad977f",
                        "order": 3,
                        "languages": [],
                        "name": "City",
                        "hidden": false,
                        "readOnly": false,
                        "required": false,
                        "displayAs": null,
                        "dataElementType": "USER_INPUT",
                        "dataElementOptions": [],
                        "allowMultiValue": false
                    },
                    {
                        "id": "d95d808f-bd08-4464-a3bd-7099b8c8da60",
                        "order": 4,
                        "languages": [],
                        "name": "State",
                        "hidden": false,
                        "readOnly": false,
                        "required": false,
                        "displayAs": "null",
                        "dataElementType": "STATE",
                        "dataElementOptions": [],
                        "allowMultiValue": false
                    }
                ],
                "elements": [],
                "languages": [
                    {
                        "name": "Marketing Communications",
                        "language": "en-us",
                        "isDefault": true
                    }
                ],
                "isSubscriptionSettings": false
            },
            {
                "id": "d0163147-33c0-4444-8106-7e417c89eba0",
                "identifierType": "",
                "isHeaderHidden": false,
                "order": 1,
                "purposes": [],
                "customDataElements": [],
                "elements": [],
                "languages": [],
                "isSubscriptionSettings": true
            }
        ],
        "languages": [
            {
                "name": "Marketing Communications",
                "language": "en-us",
                "isDefault": true
            }
        ]
    }
]
// Step 5: Line 38
{
    "messages": [],
    "DataSubjectId": "gpburdell@onetrust.com",
    "Language": "en-US",
    "Purposes": [
        {
            "Id": "cb29b383-0aaa-440b-9669-69e7acd269d7",
            "Label": "Send Notifications about Changes to Preferences",
            "Description": "Opting out will stop notifications acknowledging consent or changing consent preferences from being sent. Does not impact notices which request confirmation of consent.",
            "Status": "ACTIVE",
            "TransactionStatus": "OPT_OUT",
            "ExternalReference": null,
            "Topics": [],
            "CustomPreferences": []
        },
        {
            "Id": "de70ffa2-f860-442a-902c-a916fa28aebd",
            "Label": "OT Kicks - Automated Text Messages Purpose",
            "Description": "Receive automated text messages from OT Kicks",
            "Status": "ACTIVE",
            "TransactionStatus": "WITHDRAWN",
            "ExternalReference": null,
            "Topics": [],
            "CustomPreferences": []
        },
        {
            "Id": "4e9ead0d-e7f3-4f31-a369-c0756cad45e5",
            "Label": "OT Kicks - Emails Purpose",
            "Description": "Receive email communications from OT Kicks",
            "Status": "ACTIVE",
            "TransactionStatus": "WITHDRAWN",
            "ExternalReference": null,
            "Topics": [],
            "CustomPreferences": []
        }
    ],
    "Status": 200,
    "DsDataElements": {
        "Address": "1738 OneTrust Way",
        "State": "Georgia",
        "City": "Atlanta"
    },
    "unsubscribeAll": false
}
// Step 6: Line 59
{
    "Purposes": [
        {
            "Id": "de70ffa2-f860-442a-902c-a916fa28aebd",
            "Status": true,
            "ReceiptGuid": "75468fd5-4901-47f5-bc90-863a48b0147f",
            "Messages": [
                "Purpose updated"
            ]
        }
    ],
    "Language": "en-US"
}
// Step 7: Line 64
{
    "Purposes": [
        {
            "Id": "de70ffa2-f860-442a-902c-a916fa28aebd",
            "Status": true,
            "ReceiptGuid": "9d98c732-8db8-4f9a-975c-21cffb0e008d",
            "Messages": [
                "Purpose withdrawn"
            ]
        }
    ]
}
```

# Update Host & Token

<!-- python@1-11 -->

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.
Update the other variables as well:
- **preference_center_id**: The GUID of the Preference Center whose schema we will retrieve. Preference Centers are the interface data subjects use to give and withdraw consent for purposes, topics, and custom preferences. Refer to Step 2 if you need help finding the Preference Center GUID. 
- **identifier**: The data subject identifier. We will retrieve this data subject's consent from the preference center.

> 🚧 Implementation
>These OneTrust APIs are meant to be used only on the backend servers, not on the frontend. On the frontend user interface (UI), the customer is responsible for handling authentication in order to display preferences using the data received from the OneTrust APIs. However, it's crucial not to use OneTrust API Keys or Client Credentials on the frontend to prevent users from gaining unauthorized access to the OneTrust APIs.

# [Optional] Get List of Preference Centers

<!-- python@12-21 -->

Use the [Get List of Preference Centers](/onetrust/reference/getpreferencecentersusingget) *GET* request to retrieve a list of Preference Centers. 

By default, this example will allow you to retrieve a list of configured Preference Centers. You can leverage additional query parameters to filter your search further. You can use `name`, `purposeGuid`, `status`, and `sort`. `name` works as a search parameter and will return all matches. 

<details><summary>Expand for more details about pagination</summary>

The `size` and `page` query parameters can be used to paginate the response (list of Preference Centers). The `size` parameter defines the number of Preference Centers to be returned on each page. The `page` parameter defines the page number. The first page and default page is page number `0`. The `size` parameter is optional and the default value is `20`, but cannot exceed `2000`. If you input a value greater than `2000`, then `2000` will be used for the size.

> 📘 **Note:** 
> When dealing with pagination programmatically, it's best practice to obtain `totalPages`, `size`, `numberOfElements`, etc. directly from the first response. This way, if you passed in a size that is not supported, you can work with the value/size which is being used. Pagination was not implemented in this example but other recipes do have full examples. 
</details>

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


```json
{
    "content": [
        {
            "id": "56857100-657f-464d-b58b-64735f5bdab4",
            "name": "Schema API Recipe Preference Center",
            "organizationName": "Preference Management",
            "template": "MULTIPAGE",
            "publishedDate": "2022-07-20T18:42:36.17",
            "status": "ACTIVE",
            "createdDate": "2022-07-20T14:45:32.923"
        },
        {
            "id": "57833f27-ad86-47de-910d-a118d034c60f",
            "name": "G.P. Burdell Foundation",
            "organizationName": "Preference Management",
            "template": "MULTIPAGE",
            "publishedDate": "2022-04-29T17:11:16.887",
            "status": "ACTIVE",
            "createdDate": "2022-04-29T17:07:58.203"
        },
        {
            "id": "ca4b68d9-ed30-45a1-be78-f413113ce47c",
            "name": "ACME Preference Center",
            "organizationName": "Preference Management",
            "template": "MULTIPAGE",
            "publishedDate": "2021-12-28T19:00:24.743",
            "status": "ACTIVE",
            "createdDate": "2021-12-09T19:55:43.79"
        }
    ],
    "pageable": {
        "sort": {
            "empty": false,
            "unsorted": false,
            "sorted": true
        },
        "offset": 0,
        "pageNumber": 0,
        "pageSize": 20,
        "paged": true,
        "unpaged": false
    },
    "unfilteredTotalElements": 0,
    "size": 20,
    "number": 0,
    "sort": {
        "empty": false,
        "unsorted": false,
        "sorted": true
    },
    "first": true,
    "numberOfElements": 3,
    "totalElements": 3,
    "last": true,
    "totalPages": 1,
    "empty": false
}
```

</details>

# Retrieve Preference Center Root Schema

<!-- python@22-26 -->

Use the [Get Preference Center Root Schema](/onetrust/reference/getrootschemausingget) *GET* request to retrieve a Preference Center Root Schema for a given multi-page Preference Center UUID. This API is useful to fetch the schema of a Preference Center for building out your custom UI. 

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


```json
{
    "pages": [
        {
            "id": "1ae6761c-3f2c-47a6-acb2-e32da075acb8",
            "order": 0,
            "navigationEnabled": true,
            "displaySubscribeSettings": true,
            "displayUnsubscribeAll": true,
            "displaySubscribeAll": false,
            "languages": [
                {
                    "name": "Marketing Communications",
                    "language": "en-us",
                    "isDefault": true
                }
            ]
        }
    ],
    "defaultLanguage": "en-us",
    "languages": [
        {
            "language": "en-us",
            "isDefault": true
        }
    ],
    "preferenceCenterSettings": {
        "languages": {
            "en-us": {
                "changePreferencesLabel": "Change Preferences",
                "unsubscribedBadgeLabel": "Unsubscribed",
                "purposeToggleActiveLabel": "On",
                "unsubscribeSuccessLabel": "You have successfully unsubscribed.",
                "ssoLoginTitle": "Log in with SSO",
                "subscribedBadgeLabel": "Subscribed",
                "unsubscribeAllLabel": "Unsubscribe All",
                "title": "Your Preferences",
                "reasonsMessage": "We are so sad to see you go! Please indicate the reason for your unsubscription and we will work to improve our service.",
                "reasonsLabel": "Unsubscribe Reason",
                "topicsLabel": "Topics",
                "purposeToggleInactiveLabel": "Off",
                "loginTitle": "Preferences Login",
                "updateErrorLabel": "Sorry, something went wrong. Please try again.",
                "subscriptionSettingsLabel": "Subscription Settings",
                "languageSelector": "Language",
                "companyLogo": "Company Logo",
                "notificationPurposeLabel": "Send notifications about changes to preferences",
                "emailLoginError": "Failed to send login request.",
                "reasonsTitle": "Unsubscribe Successful",
                "notificationPurposeDescription": "Opting out will stop notifications acknowledging consent or changing consent preferences from being sent. Does not impact notices that request a confirmation of consent.",
                "selectIdentifierLabel": "Select data subject identifier",
                "emailPlaceholder": "user@email.com",
                "undoChangesLabel": "Undo Changes",
                "subscriptionStatusLabel": "Last Saved Status",
                "emailInputTitle": "E-Mail",
                "subscribeAllLabel": "Subscribe to All",
                "sendRequest": "Send",
                "updateSuccessLabel": "Thank you! Your preferences have been submitted. Please allow a few minutes for these to be updated."
            }
        }
    },
    "enableMultipleIdentities": false,
    "displayUnsubscribeAll": false,
    "displaySubscribeAll": true,
    "displayNotificationPurpose": true,
    "displaySubscribeSettings": true,
    "notificationPurpose": {
        "id": "cb29b383-0aaa-440b-9669-69e7acd269d7",
        "order": null,
        "languages": [
            {
                "name": "Send Notifications about Changes to Preferences",
                "description": "Opting out will stop notifications acknowledging consent or changing consent preferences from being sent. Does not impact notices which request confirmation of consent.",
                "language": "en-us",
                "isDefault": true
            }
        ],
        "label": "Send Notifications about Changes to Preferences",
        "description": "Opting out will stop notifications acknowledging consent or changing consent preferences from being sent. Does not impact notices which request confirmation of consent.",
        "version": 1,
        "topics": [],
        "customPreferences": [],
        "visibility": null
    },
    "displayPageLevelSubscribeSettings": false,
    "autoCheckTopics": false,
    "updateNotOptedOutToActiveStatus": false
}
```

</details>

# Retrieve Preference Center Page Schema

<!-- python@27-34 -->

Use the [Get Preference Center Page Schema](/onetrust/reference/getpreferencecenterpageschemausingget) *GET* request to retrieve a Preference Center Page Schema for a given multi-page Preference Center UUID. This API is useful to fetch the schema of a Preference Center for building out your custom UI. 

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

```json
[
    {
        "id": "1ae6761c-3f2c-47a6-acb2-e32da075acb8",
        "order": 0,
        "isHidden": false,
        "navigationEnabled": true,
        "displaySubscribeSettings": true,
        "displayUnsubscribeAll": true,
        "displaySubscribeAll": false,
        "sections": [
            {
                "id": "8691c55d-90d6-46fe-ac0f-2c9b87dd5615",
                "identifierType": "",
                "isHeaderHidden": false,
                "order": 0,
                "purposes": [
                    {
                        "id": "4e9ead0d-e7f3-4f31-a369-c0756cad45e5",
                        "order": 0,
                        "languages": [
                            {
                                "name": "Email Communication",
                                "description": "Receive email communications from OT Kicks",
                                "language": "en-us",
                                "isDefault": true
                            }
                        ],
                        "label": "OT Kicks - Emails Purpose",
                        "description": "Receive email communications from OT Kicks",
                        "version": 2,
                        "topics": [],
                        "customPreferences": [],
                        "visibility": "VISIBLE_TO_ALL"
                    },
                    {
                        "id": "de70ffa2-f860-442a-902c-a916fa28aebd",
                        "order": 1,
                        "languages": [
                            {
                                "name": "Automated Text Messages",
                                "description": "Receive automated text messages from OT Kicks",
                                "language": "en-us",
                                "isDefault": true
                            }
                        ],
                        "label": "OT Kicks - Automated Text Messages Purpose",
                        "description": "Receive automated text messages from OT Kicks",
                        "version": 1,
                        "topics": [],
                        "customPreferences": [],
                        "visibility": "VISIBLE_TO_ALL"
                    }
                ],
                "customDataElements": [
                    {
                        "id": "4a4380cc-f283-4b8a-a8b9-4bba82323a1a",
                        "order": 2,
                        "languages": [],
                        "name": "Address",
                        "hidden": false,
                        "readOnly": false,
                        "required": false,
                        "displayAs": null,
                        "dataElementType": "USER_INPUT",
                        "dataElementOptions": [],
                        "allowMultiValue": false
                    },
                    {
                        "id": "3e7fcc3a-1113-4c6f-a4cf-aa3a93ad977f",
                        "order": 3,
                        "languages": [],
                        "name": "City",
                        "hidden": false,
                        "readOnly": false,
                        "required": false,
                        "displayAs": null,
                        "dataElementType": "USER_INPUT",
                        "dataElementOptions": [],
                        "allowMultiValue": false
                    },
                    {
                        "id": "d95d808f-bd08-4464-a3bd-7099b8c8da60",
                        "order": 4,
                        "languages": [],
                        "name": "State",
                        "hidden": false,
                        "readOnly": false,
                        "required": false,
                        "displayAs": "null",
                        "dataElementType": "STATE",
                        "dataElementOptions": [],
                        "allowMultiValue": false
                    }
                ],
                "elements": [],
                "languages": [
                    {
                        "name": "Marketing Communications",
                        "language": "en-us",
                        "isDefault": true
                    }
                ],
                "isSubscriptionSettings": false
            },
            {
                "id": "d0163147-33c0-4444-8106-7e417c89eba0",
                "identifierType": "",
                "isHeaderHidden": false,
                "order": 1,
                "purposes": [],
                "customDataElements": [],
                "elements": [],
                "languages": [],
                "isSubscriptionSettings": true
            }
        ],
        "languages": [
            {
                "name": "Marketing Communications",
                "language": "en-us",
                "isDefault": true
            }
        ]
    }
]
```

</details>

# Get Data Subject's Current Status for Preference Center

<!-- python@35-39 -->

Use the [Get Data Subject Status for a given Preference Center](/onetrust/reference/getdatasubjectpurposesbyidentifierusingget_1) *GET* request to retrieve the current status of a Data Subject for a given Preference Center UUID and Data Subject identifier.

The returned information can be used to pre-populate your custom UI fields with the Data Subject's current preferences and data elements. 

> 🚧 **No Transactions Found Error** 
> No Transactions were found for Data Subject : gpburdell@onetrust.com with PurposeGuids : [4e9ead0d-e7f3-4f31-a369-c0756cad45e5, de70ffa2-f860-442a-902c-a916fa28aebd, cb29b383-0aaa-440b-9669-69e7acd269d7].
> Ensure you account for HTTP 400 errors when pre-populating your custom UI fields. If the Data Subject has not consented for the purposes tied to the Preference Center a 400 is returned. 

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

```json
{
    "messages": [],
    "DataSubjectId": "gpburdell@onetrust.com",
    "Language": "en-US",
    "Purposes": [
        {
            "Id": "cb29b383-0aaa-440b-9669-69e7acd269d7",
            "Label": "Send Notifications about Changes to Preferences",
            "Description": "Opting out will stop notifications acknowledging consent or changing consent preferences from being sent. Does not impact notices which request confirmation of consent.",
            "Status": "ACTIVE",
            "TransactionStatus": "OPT_OUT",
            "ExternalReference": null,
            "Topics": [],
            "CustomPreferences": []
        },
        {
            "Id": "de70ffa2-f860-442a-902c-a916fa28aebd",
            "Label": "OT Kicks - Automated Text Messages Purpose",
            "Description": "Receive automated text messages from OT Kicks",
            "Status": "ACTIVE",
            "TransactionStatus": "WITHDRAWN",
            "ExternalReference": null,
            "Topics": [],
            "CustomPreferences": []
        },
        {
            "Id": "4e9ead0d-e7f3-4f31-a369-c0756cad45e5",
            "Label": "OT Kicks - Emails Purpose",
            "Description": "Receive email communications from OT Kicks",
            "Status": "ACTIVE",
            "TransactionStatus": "WITHDRAWN",
            "ExternalReference": null,
            "Topics": [],
            "CustomPreferences": []
        }
    ],
    "Status": 200,
    "DsDataElements": {
        "Address": "1738 OneTrust Way",
        "State": "Georgia",
        "City": "Atlanta"
    },
    "unsubscribeAll": false
}

```

</details>

# Update Data Subject's Preferences or Data Elements

<!-- python@40-60 -->

Use the [Update the Preferences of a Data Subject for a given Preference Center](/onetrust/reference/updatepreferencesfordatasubjectapiusingput) *PUT* request to update a Data Subject's preferences including purposes, topics, custom preferences, or data elements. 

You will need to pass the updates from your custom UI to this API call. 

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


```json
{
    "Purposes": [
        {
            "Id": "de70ffa2-f860-442a-902c-a916fa28aebd",
            "Status": true,
            "ReceiptGuid": "75468fd5-4901-47f5-bc90-863a48b0147f",
            "Messages": [
                "Purpose updated"
            ]
        }
    ],
    "Language": "en-US"
}
```

</details>

# Withdraw Consent for Data Subject

<!-- python@61-65 -->

Use the [Withdraw Consent for all Purposes](/onetrust/reference/withdrawpreferencesapiusingdelete) *DELETE* request to withdraw consent for all Purposes (excludes Notification Opt-out Purpose) in the Preference Center.

If a Data Subject wishes to withdraw consent, you can call this API endpoint on behalf of the Data Subject to withdraw consent for all Purposes. 

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


```json
{
    "Purposes": [
        {
            "Id": "de70ffa2-f860-442a-902c-a916fa28aebd",
            "Status": true,
            "ReceiptGuid": "9d98c732-8db8-4f9a-975c-21cffb0e008d",
            "Messages": [
                "Purpose withdrawn"
            ]
        }
    ]
}
```

</details>