User Update


Request Details

Item Value
Description Update an existing CrowdTwist user, you must perform an HTTP PUT request with a JSON object.
Method PUT
Endpoint https://api.crowdtwist.com/v2/users/[user_id]?api_key=[api_key]&id_type=[id_type]
Content Type: JSON (application/json)


Request

Field Name Sample Value Required Format Notes
URL PARAMETERS
user_id alice@crowdtwist.com Yes String Unique ID of the user for whom activities will be returned:
Options:
– Email Address
– Facebook User ID
– Twitter User ID
– CrowdTwist ID
– Third Party ID
– Username
– Mobile Phone Number
QUERY STRING PARAMETERS
api_key QWERTYUIOP Yes String  
id_type email No String Type of ID being Sent:
Options:
– email
– facebook_user_id
– twitter_user_id
– id (CrowdTwist ID) – default ID if id_type is not specified
– third_party_id
– username
– mobile_phone_number
REQUEST BODY: Standard CrowdTwist User Object
Field Name Sample Value Required Format Notes
first_name Mike Yes String User’s first name
last_name Smith Yes String User’s last name
date_of_birth   Yes Number User’s date of birth
email_address alice@crowdtwist.com Yes Email Email address currently associated with user in CrowdTwist platform
email_is_verified 1 Yes Boolean Boolean indicating if user’s email address is verified Example values: 0, 1 (default: 1).
postal_code   Yes String US Postal Code
There is validation logic that doesn’t allow city, country, etc when a postal_code is provided. This means that for domestic addresses ONLY postal_code can be provided.
Canadian Postal Code
A valid postal code must be provided if a value of “CA” is received in the country_code parameter. If a city_id is also provided it will not be validated.
username mikesmith No String CrowdTwist system ID associated with user
password abcdef No String User password
third_party_id 103997 No String Unique value within client’s systems
city_id 834694 No for US & CA, Yes for other programs Number Internal CrowdTwist city ID value. Lookup table provided on request by the CrowdTwist team.
city_name London No  String English city name
country_code US   Number Internal CrowdTwist country ID value
country_code should follow the ISO 3166-1 alpha 2 standard. Note, ISO 3166-1 alpha 2 standard isn’t a numeric value, it’s a 2 character alpha value read more.
facebook_access_token   No String Facebook access token
facebook_user_id 1226136555 No String Facebook ID associated with
fsq_access_token   No String FourSquare access token
fsq_user_id   No String Foursquare ID associated with user in CrowdTwist platform
gender_id 1 No  Number Internal CrowdTwist gender ID value. Use the ID values below to populate this field.
  1 = Female
  2 = Male
  0 = Null
middle_name   No String User middle name
mobile_phone_number 2127177932 No Number Users mobile phone number must be unique.
receive_email_updates 1 No Boolean Boolean indicating if should receive email updates Example values: 0, 1 (default: 1) updates from CrowdTwist platform
custom_data {
“register_id” : “1”,
“cashier_id” : “2”
}
No Object Client-defined attributes can be sent via the custom_data request object. The “custom_data” section sent in the User Update request body must contain the entire set of custom attributes for the user.
Attribute Names:
  employee_id
  cashier_id
  register_id
  store_loc
  plcc
  cardholder_status
  tier – used for client defined tiers only
  user_operation – used to determine whether api call was user create or user update
  subscriber_type


Custom_Data Requirements
The custom_data field will contain a list of key-value data pairs that are specified by the client. Note: If there are key(s) that were not identified by the client to CrowdTwist, then the unknown key(s) will not be saved and will result in an error response.

  • Attribute names can be up to 100 character long
  • Attribute values can be up to 512 characters long
  • Any attributes to be sent need to be known by CrowdTwist prior to integration.

For example:

  • {“error”: “input_error”, “message”: “No custom attributes setup for client 12.”}
  • {“error”: “input_error”, “message”: “Unrecognized attribute name bar for client 12.”}

Sample Request

curl -X PUT
https://api.crowdtwist.com/v2/users/alice@crowdtwist.com?api_key=QWERTYUIOP&id_type=email
{
  "email_address": "alice@crowdtwist.com",
  "last_name": "Twist",
  "first_name": "Alice",
  "postal_code": "10010",
  "date_of_birth": 344754000,
  "username": "alicetwist",
  "email_is_verified": 1,
  "send_verify_email": 0,
  "sign_up_channel_id": 1,
  "custom_data": {
    "register_id": "1",
    "cashier_id": "2"
  }
}
curl -X PUT
https://api.crowdtwist.com/v2/users/alice@crowdtwist.com?api_key=QWERTYUIOP&id_type=email
{
  "email_address": "alice@crowdtwist.com",
  "last_name": "Twist",
  "first_name": "Alice",
  "postal_code": "10010",
  "date_of_birth": 344754000,
  "username": "alicetwist",
  "email_is_verified": 1,
  "send_verify_email": 0,
  "sign_up_channel_id": 1,
  "custom_data": {
    "register_id": "1",
    "cashier_id": "2"
  }
}


Sample Successful Response

{
  "id": 11601,
  "first_name": "Alice",
  "middle_name": null,
  "last_name": "Twist",
  "date_of_birth": null,
  "email_address": "alice@crowdtwist.com",
  "email_is_verified": true,
  "username": "alicetwist",
  "mobile_phone_number": null,
  "third_party_id": null,
  "is_active": true,
  "gender_id": null,
  "gender": null,
  "extra_data": null,
  "continent": "North America",
  "country": "United States",
  "us_region": "Northeast",
  "ca_province": null,
  "state": "NY",
  "city": "New York City",
  "street_address_1": null,
  "street_address_2": null,
  "postal_code": "10010",
  "receive_email_updates": true,
  "date_receive_email_opt_in": 1461706842,
  "date_receive_email_opt_out": null,
  "total_points": 2000,
  "redeemable_points": 2000,
  "num_points_purchased": 0,
  "facebook_access_token": null,
  "facebook_user_id": null,
  "date_fb_token_expires": null,
  "twitter_oauth_token": null,
  "twitter_oauth_token_secret": null,
  "google_access_token": null,
  "google_refresh_token": null,
  "google_user_id": null,
  "yahoo_access_token": null,
  "yahoo_access_token_secret": null,
  "yahoo_session_handle": null,
  "yahoo_user_id": null,
  "activity_stream_opt_in": true,
  "store_id": null,
  "date_last_login": null,
  "date_last_updated": 1461777590,
  "date_created": 1461706842,
  "rank": null,
  "weekly_rank": null,
  "monthly_rank": null,
  "salt": null,
  "hash_algorithm_id": "1",
  "lang_pref": "en",
  "referral_url": "",
  "fan_level": "Bronze",
  "sign_up_channel_id": 1,
  "custom_data": {
    "register_id": "1",
    "cashier_id": "2"
  }
}
{
  "id": 11601,
  "first_name": "Alice",
  "middle_name": null,
  "last_name": "Twist",
  "date_of_birth": null,
  "email_address": "alice@crowdtwist.com",
  "email_is_verified": true,
  "username": "alicetwist",
  "mobile_phone_number": null,
  "third_party_id": null,
  "is_active": true,
  "gender_id": null,
  "gender": null,
  "extra_data": null,
  "continent": "North America",
  "country": "United States",
  "us_region": "Northeast",
  "ca_province": null,
  "state": "NY",
  "city": "New York City",
  "street_address_1": null,
  "street_address_2": null,
  "postal_code": "10010",
  "receive_email_updates": true,
  "date_receive_email_opt_in": 1461706842,
  "date_receive_email_opt_out": null,
  "total_points": 2000,
  "redeemable_points": 2000,
  "num_points_purchased": 0,
  "facebook_access_token": null,
  "facebook_user_id": null,
  "date_fb_token_expires": null,
  "twitter_oauth_token": null,
  "twitter_oauth_token_secret": null,
  "google_access_token": null,
  "google_refresh_token": null,
  "google_user_id": null,
  "yahoo_access_token": null,
  "yahoo_access_token_secret": null,
  "yahoo_session_handle": null,
  "yahoo_user_id": null,
  "activity_stream_opt_in": true,
  "store_id": null,
  "date_last_login": null,
  "date_last_updated": 1461777590,
  "date_created": 1461706842,
  "rank": null,
  "weekly_rank": null,
  "monthly_rank": null,
  "salt": null,
  "hash_algorithm_id": "1",
  "lang_pref": "en",
  "referral_url": "",
  "fan_level": "Bronze",
  "sign_up_channel_id": 1,
  "custom_data": {
    "register_id": "1",
    "cashier_id": "2"
  }
}

Error Response Codes

Error Message Message
input_error Returned whenever the request is missing required fields, including situations in which the body is malformed (e.g. HTTP method not supported, receipt not found, etc.). Sample Messages:
  “Invalid data sent.”
  “first_name is invalid”
  “last_name is invalid”
  “email_address already taken”
  “No custom attributes setup for client 12.”
  “Unrecognized attribute name bar for client 12.”
internal_error HTTP error status code is returned due to an error that occurred in the backend. internal_error: unexpected error occurred in the CrowdTwist backend