PUT Users
Updates a user with new attributes.
Endpoint URL: https://api.carnivalmobile.com/v6/users/:user_id
Parameters
Path Parameters
Name | Type | Required | Definition |
---|---|---|---|
user_id | string | Yes | The Sailthru Mobile user ID |
Body Parameters
Name | Type | Required | Definition |
---|---|---|---|
user | object | Yes | JSON model of User Attributes |
Examples
Date
Copy
# Single attribute
curl -X PUT -u :$API_KEY -d \
'{
"user": {
"custom": {
"my_date": {
"value": "2012-04-23T18:25:00Z",
"type" : "date" }
}
}
}' -H 'Content-Type: application/json' -H 'Accept: application/json' https://api.carnivalmobile.com/v6/users/$user_id
# Array
curl -X PUT -u :$API_KEY -d \
'{
"user": {
"custom": {
"my_dates_key": {
"value": ["2012-04-23T18:25:00Z", "2012-05-23T18:25:00Z"],
"type": "date" }
}
}
}' -H 'Content-Type: application/json' -H 'Accept: application/json' https://api.carnivalmobile.com/v6/users/$user_id
String
Copy
# Single attribute
curl -X PUT -H "Accept: application/json" -u :API_KEY -d \
'{
"user": {
"custom": {
"my_string_key": {
"value": "My string value",
"type" : "string" }
}
}
}' -H 'Content-Type: application/json' -H 'Accept: application/json' https://api.carnivalmobile.com/v6/users/:user_id
# Array
curl -X PUT -u :API_KEY -d \
'{
"user": {
"custom": {
"my_strings_key": {
"value": ["Hello", "there"],
"type" : "string" }
}
}
}' -H 'Content-Type: application/json' -H 'Accept: application/json' https://api.carnivalmobile.com/v6/users/:user_id
Boolean
Copy
# Booleans can only be set as single attributes
curl -X PUT -H "Accept: application/json" -u :API_KEY -d \
'{
"user": {
"custom": {
"my_boolean_key": {
"value": true,
"type": "boolean" }
}
}
}' -H 'Content-Type: application/json' -H 'Accept: application/json' https://api.carnivalmobile.com/v6/users/:user_id
Floan
Copy
# Single attribute
curl -X PUT -H "Accept: application/json" -u :API_KEY -d \
'{
"user":{
"custom": {
"my_float_key": {
"value": 2.14,
"type": "float" }
}
}
}' -H 'Content-Type: application/json' -H 'Accept: application/json' https://api.carnivalmobile.com/v6/users/:user_id
# Array
curl -X PUT -u :API_KEY -d \
'{
"user": {
"custom": {
"my_floats_key": {
"value": [23.2, 3.141],
"type": "float" }
}
}
}' -H 'Content-Type: application/json' -H 'Accept: application/json' https://api.carnivalmobile.com/v6/users/:user_id
Integer
Copy
# Single attribute
curl -X PUT -H "Accept: application/json" -u :API_KEY -d \
'{
"user" :{
"custom": {
"my_integer_key": {
"value": 123,
"type": "integer" }
}
}
}' -H 'Content-Type: application/json' -H 'Accept: application/json' https://api.carnivalmobile.com/v6/users/:user_id
# Array
curl -X PUT -u :API_KEY -d \
'{
"user": {
"custom": {
"my_integers_key": {
"value": [23, 3],
"type": "integer" }
}
}
}' -H 'Content-Type: application/json' -H 'Accept: application/json' https://api.carnivalmobile.com/v6/users/:user_id
Multiple Types
Copy
# You can set multiple attributes in the same request
curl -X PUT -H "Accept: application/json" -u :API_KEY -d \
'{
"user": {
"custom": {
"release_date": {
"value": "1965-12-03T01:15:00Z",
"type" : "date" },
"favorite_song": {
"value": "Drive My Car",
"type" : "string" },
"starred_tracks": {
"value": [1, 6, 11],
"type": "integer" }
}
}
}' -H 'Content-Type: application/json' -H 'Accept: application/json' https://api.carnivalmobile.com/v6/users/:user_id
Result Format
202 Accepted
Copy
{
"custom": {
"my key 1": {
"value": "custom attribute value",
"type": "string" }
}
}
401 Unauthorized
Copy
{
"error":"unauthorized"}
403 Forbidden
Copy
{
"error":"your api client does not have the correct roles"}
404 Note Found
Copy
{}
// No user was found for this user id
This endpoint updates an existing user with new attributes. Upon a successful request, existing attributes are merged (not replaced) with the attributes you sent in the request. If a User ID exists across multiple devices, all the devices belonging to that User ID will be updated.
Valid Types
Data type | Ranges/valid values | Example | Notes | Can be sent as array |
---|---|---|---|---|
integer
|
-2,147,483,647 to 2,147,483,647 |
12 , 24 , 25 |
Floating point numbers are accepted but they will be truncated to an
integer . If you wish to keep the decimal part, use float instead.
Values out of range will be discarded.
|
Yes
|
float
|
Single-precision 32-bit IEEE 754 floating point.
|
12.343 , 123.33 |
Floats greater than 32-bit will be converted to scientific notation.
|
Yes
|
string
|
UTF-8 character encoding
|
Cody , gold , A string with a , comma |
Maximum 255 characters long
|
Yes
|
date
|
ISO 8601, e.g.
YYYY-MM-ddTHH:mm:ssZ |
2017-02-06T18:25:32+0300
|
|
Yes
|
boolean
|
true or false |
|
No
|
Custom Attribute Limits
There are limits in place on the maximum number of custom attributes allowed as well as the length (size) of strings and arrays.
- A maximum of 50 custom attributes is allowed per device. If you exceed this amount any new attributes being set will be discarded.
- String values that have more than 255 characters will be truncated. The limitation is on the character length, not on the size in bytes.
- Arrays with more than 50 elements will be truncated.
Key Name Restrictions
There are some restrictions in place on the key name, these are:
- Only letters, numbers, underscore and dash are valid characters.
- Leading spaces will be removed.
" my_string_key "
will become"my_string_key"
. - Invalid characters other than spaces and dots will be removed.
"my_string_key~~~~"
will become"my_string_key"
. - Spaces and dots will be replaced for underscores.
"my string.key"
will become"my_string_key"
. - Keys will be truncated to a maximum of 255 characters.
- Invalid keys (including keys exclusively made of invalid characters) will simply be discarded and no error will be returned.