Changing a user's sourceΒΆ
Below is a sample function written in python showing how to change the source of a user.
(If you prefer to change the source of a user's action, see how to change the source of an action.)
import requests
AK_USERNAME = '' # Enter your username
AK_PASSWORD = '' # Enter your password
AK_DOMAIN = 'docs.actionkit.com'
def change_user_source(user_id, source):
""" Updates the user at user_id with the new source
"""
endpoint = 'user'
# Get the action by its ID
response = requests.patch(
'https://{0}:{1}@{2}/rest/v1/{3}/{4}/'.format(
AK_USERNAME,
AK_PASSWORD,
AK_DOMAIN,
endpoint,
user_id
),
json={
"source": source
}
)
if response.status_code == 202:
return "Successfully changed source to {0} on user #{1}".format(
source,
user_id
)
With that function defined, you'll be able to use change_user_source()
with a given user_id and source, like: change_user_source(123456, 'ad-campaign')
which will change the source for user ID 123456 to 'ad-campaign'.