You can get a profile by using an identifier query or by specifying the Zendesk user id of the person associated with the profile. An identifier query returns one profile. A Zendesk user id returns all the profiles associated with the user.

You can also get profiles by profile id. However, because the only way to get a profile id is to request a profile using one of the two methods above, making an additional request by profile id returns duplicate information. If you have a use case for a profile id, see Get profile by profile id in the reference docs.

For information on creating profiles, see Creating profiles.

This article includes curl and Python examples. The Python examples use Python 3.6 or greater and the requests library.

Accessing profiles by identifier query

You can get a specific profile by using an identifier query:

GET /api/v2/user_profiles?identifier={identifier_query}

The identifier query selects a specific profile. Example:

coolbikes:rider:email:[email protected]

The first two items in the query, coolbikes and rider, specify the target profile's source and type properties. The last two items, email and [email protected], specify an identifier in the profile for the person.

All four items are required. For example, you can't specify only a source and a type to try to get all the "rider" profiles at Coolbikes.

For more information, see Using identifier queries with profiles.

Example

Data

curl request

curl "https://coolbikes.zendesk.com/api/v2/user_profiles?identifier=coolbikes:rider:email:[email protected]" \  -v -u devs@coolbikes.com:t1retube5

Python request

import requests

identifier_query = 'coolbikes:rider:email:[email protected]'
url = f'https://coolbikes.zendesk.com/api/v2/user_profiles/events'params = {'identifier': identifier_query}credentials = '[email protected]', 't1retube5'response = requests.get(url, params=params, auth=credentials)if response.status_code != 200:    print(f'{response.status_code}: {response.text}')else:    print(response.json())

Response

Status 200 OK
{  "profile":{    "id": "01E06HXMJ8RJ6C0MR142D6FBSA",    "user_id": "81123613",    "source": "coolbikes",    "type": "rider",    "name": "Jane Doe",    "attributes":{      "favorite_color": "red",      "saddle_height": "85cm"    },    "created_at": "2020-02-03T22:14:48Z",    "updated_at": "2020-02-20T01:20:28Z",    "identifiers":[      {        "type": "email",        "value": "[email protected]"      }    ]  }}

Acccessing profiles by Zendesk user id

Because each profile is associated with a Zendesk user, you can use a Zendesk user id to get all the profiles associated with the user.

GET /api/v2/users/{user_id}/profiles

The request returns a list of all the profiles associated with the user.

See Users in the Zendesk API docs.

Example

Data

  • Zendesk user id:

    "85211553"

curl request

curl https://coolbikes.zendesk.com/api/v2/users/85211553/profiles \  -v -u devs@coolbikes.com:t1retube5

Python request

import requests

user_id = '85211553'
url = f'https://coolbikes.zendesk.com/api/v2/users/{user_id}/profiles'credentials = '[email protected]', 't1retube5'response = requests.get(url, auth=credentials)if response.status_code != 200:    print(f'{response.status_code}: {response.text}')else:    print(response.json())

Response

Status 200 OK
{  "profiles":[    {      "id": "01E06HXMJ8RJ6C0MR142D6FBSA",      "user_id": "81123613",      "source": "coolbikes",      "type": "rider",      "name": "Jane Doe",      "attributes":{        "favorite_color": "red",        "saddle_height": "85cm"      },      "created_at": "2020-02-03T22:14:48Z",      "updated_at": "2020-02-20T01:20:28Z",      "identifiers":[        {          "type": "email",          "value": "[email protected]"        }      ]    },    {      "id": "01E063F8D3BR6FR7104KHYNE41",      "user_id": "81123613",      "source": "acme",      "type": "customer",      "name": "sunshine_user",      "attributes":{        "certification": "player",        "comm_pref": "SMS"      },      "created_at": "2020-02-03T18:02:17Z",      "updated_at": "2020-03-06T22:03:32Z",      "identifiers":[        {          "type": "email",          "value": "[email protected]"        }      ]    }  ]}