Global account filtering
Bud widgets support global account filtering via the Selected Accounts endpoints. This guide will explain how you can create your own global account filter when displaying widgets within your own application.
Within Bud's widgets, a customer can set a list of selected accounts. When a list is set, only data related to those accounts is taken into consideration on the widgets.
How selected accounts work
Selected accounts are stored per customer. Each time you set the list, it replaces any list already stored for that customer. At least one account must always be selected, so an empty list is never stored or returned.
Retrieve the customer's accounts
Before you set the list of selected accounts, you need to know which accounts the customer has access to. Use the Retrieve Accounts V3 endpoint to fetch them.
Each account in the response includes an account_id. This is the value you use when setting the list of selected accounts.
Each account also includes a suggested_name. This is the suggested label to show alongside the account when you display the list to users, and it is how accounts are referenced within Bud's widgets.
Using account_id and suggested_nameUse
account_idto identify accounts in requests to the Preferences endpoints, andsuggested_nameto label them in your own interface. Using the same label as the widgets keeps the experience consistent for your customers.
With this information, you can render a component that lets customers choose which accounts they want to see data for. The two endpoints below allow you to read and set that selection.
Set the selected accounts
The Modify list of selected accounts endpoint sets the list of accounts selected by the customer. The request body is an array of account_id values.
POST /preferences/v1/selected-accounts
You must identify the customer using either the X-Customer-Id header or the X-Customer-Idempotent-Identifier header.
curl --request POST \
--url https://api-sandbox.thisisbud.com/preferences/v1/selected-accounts \
--header 'Authorization: Bearer <access_token>' \
--header 'X-Client-Id: <client_id>' \
--header 'X-Customer-Id: <customer_id>' \
--header 'content-type: application/json' \
--data '
[
"selected_account_1",
"selected_account_2"
]
'A successful request returns a 204 status code with no response body.
The list is replaced, not appended toEach request replaces the list already stored for the customer. To add or remove an account, send the complete list of accounts that should be selected.
The list must include at least one account_id. If the list is empty, Bud returns a 400 validation error:
{
"operation_id": "preferences_v1_select_accounts_post",
"code_id": "failed_validation",
"message": "Invalid request payload.",
"errors": {
"accounts": "The list of selected accounts cannot be empty"
}
}Retrieve the selected accounts
The Retrieve Selected Accounts User's Preferences endpoint returns the list of accounts currently selected by the customer.
GET /preferences/v1/selected-accounts
You must identify the customer using either the X-Customer-Id header or the X-Customer-Idempotent-Identifier header.
curl --request GET \
--url https://api-sandbox.thisisbud.com/preferences/v1/selected-accounts \
--header 'Authorization: Bearer <access_token>' \
--header 'X-Client-Id: <client_id>' \
--header 'X-Customer-Id: <customer_id>' \
--header 'accept: application/json'A successful request returns a 200 status code and the list of selected account_id values in the data array:
{
"operation_id": "preferences_v1_select_accounts_get",
"data": [
"selected_account_1",
"selected_account_2"
]
}If no list has been stored for the customer, the endpoint returns a 404. An empty list is never returned, as at least one account must always be selected.
Enable syncing across widgets
For a widget to use the customer's selected accounts, append the enable_user_preferences_sync parameter to the widget URL:
https://widgets.thisisbud.com/<widget_path>?token=<token>&enable_user_preferences_sync
The parameter must be added to each widget URL individually, which gives you the flexibility to choose which widgets sync with the customer's preferences and which do not. By default any account selection on individual widgets will also impact any other widget that contains the enable_user_preferences_sync parameter.
Sub-filtering within a widget
If you would like to be able to sub-filter within a widget you can append =receive_only to the enable_user_preferences_sync parameter. By doing this any account selection on this widget will only impact the individual widget, but it will still inherit account selection from the user preferences API.
https://widgets.thisisbud.com/<widget_path>?token=<token>&enable_user_preferences_sync=receive_only
The parameter must be added to each widget URL individually, which gives you the flexibility to choose which widgets can be sub-filtered on.
In order to sub-filter on a widget the customer needs to be able to view a list of accounts. You can enable this by adding the
enable_accounts_filterparameter to the URL. Please check our individual widget guides to understand compatibility with each widget.
Putting it together
To implement your own global account filter:
- Call Retrieve Accounts V3 to fetch the customer's accounts, using
account_idas the identifier andsuggested_nameas the label. - Render a component that lets the customer choose which accounts to include.
- Call the Modify list of selected accounts endpoint with the chosen
account_idvalues. - Append
enable_user_preferences_syncto the URL of each widget that should respect the selection. - Call the Retrieve Selected Accounts endpoint whenever you need to display the customer's current selection.
Updated 10 days ago

