{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","results":{"codes":[]},"settings":"","params":[]},"next":{"description":"","pages":[]},"title":"Update User","type":"fn","slug":"update-user","excerpt":"Updates properties on the existing user","body":"These operations provide you with the ability to manage the current user's data. The operations allow for additional user properties to be uploaded to ZetaHub or changed from their current values.\n\nUser Updates are blocking JavaScript calls.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"bt('updateUser', properties, settings={});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nThe `updateUser` call has the following fields:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Field\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"`properties`\",\n    \"1-0\": \"`settings` **optional**\",\n    \"0-1\": \"Object\",\n    \"0-2\": \"A JSON object containing properties to add to the current user\",\n    \"1-1\": \"Object\",\n    \"1-2\": \"Settings specific to this event. Currently supports specification of `onComplete`, `onSuccess`, and `onFailure` callback functions. See Settings below for more information.\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Properties\"\n}\n[/block]\nWhile any JSON data can be supplied as user properties, a few properties are standardized and specially handled by Zeta's systems.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Property\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"`first_name`\",\n    \"1-0\": \"`last_name`\",\n    \"2-0\": \"`name`\",\n    \"3-0\": \"`email`\",\n    \"4-0\": \"`user_id`\",\n    \"5-0\": \"`signed_up_at`\",\n    \"0-1\": \"String\",\n    \"1-1\": \"String\",\n    \"2-1\": \"String\",\n    \"3-1\": \"String\",\n    \"4-1\": \"String\",\n    \"5-1\": \"ISO-8601 Timestamp String\",\n    \"0-2\": \"The first name of the user.\",\n    \"1-2\": \"The last name of the user.\",\n    \"2-2\": \"The full name of the user. Note that unless a user has this property set, the user's name will appear in ZetaHub as a concatenation of their `first_name` and `last_name`.\",\n    \"3-2\": \"The email address of the user.\",\n    \"4-2\": \"A unique identifier for the user.\",\n    \"5-2\": \"The date at which a person signed up.\",\n    \"6-0\": \"`contacts`\",\n    \"6-1\": \"Array of objects\",\n    \"6-2\": \"One or more contacts for this user. Each contact should be a hash/object with `type` and `value` attributes. A `status` is optional and defaults to \\\"new\\\". The `type` can be either \\\"email\\\" or \\\"phone\\\". If the `type` is an \\\"email\\\", it should satisfy standard email format validations. If the `type` is \\\"phone\\\", it should be sent in the ISO E.164 format with the \\\"+\\\" symbol followed by the country code and then the number. The `status` attribute can be used to unsubscribe the contact by sending its value as \\\"inactive\\\" or made active by sending its value as \\\"active\\\".\\n\\nIf a contact with the given `type` and `value` already exists for this user, it will be overwritten with the provided values. Otherwise, it will be added for this user.\"\n  },\n  \"cols\": 3,\n  \"rows\": 7\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Settings\"\n}\n[/block]\nThe `settings` object is used for configuring the `updateUser` call.\n\nThree `settings` objects are currently allowed for updateUser calls using the `p13n.js` library: \n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`onComplete`\",\n    \"h-0\": \"Objecdt\",\n    \"h-1\": \"Description\",\n    \"0-1\": \"This setting allows the caller to specify a callback function once the updateUser function has completed. The function will be called regardless of whether the update to the user was successful or not. The function should have no parameters (nothing will be passed to it).\",\n    \"1-0\": \"`onFailure(error)`\",\n    \"1-1\": \"This setting allows the caller to specify a callback function if the updateUser function has completed with an error. The error raised by the `updateUser` function will be passed into this callback.\",\n    \"2-0\": \"`onSuccess`\",\n    \"2-1\": \"This setting allows the caller to specify a callback function once the updateUser function has completed successfully. The function should have no parameters (nothing will be passed to it).\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"bt('updateUser', \\n   {user_id: 'abcde123'}, \\n   {onComplete: function() \\n    { console.log('User Update Completed!'); }\\n   }\\n  );\",\n      \"language\": \"javascript\",\n      \"name\": \"Sample User Update with onComplete Callback\"\n    },\n    {\n      \"code\": \"bt('updateUser', \\n   {user_id: 'abcde123'}, \\n   {onFailure: function(err) \\n    { console.log('Update completed with error: ' + err); }\\n   }\\n  );\",\n      \"language\": \"javascript\",\n      \"name\": \"Sample User Update with onFailure Callback\"\n    },\n    {\n      \"code\": \"bt('updateUser', \\n   {user_id: 'abcde123'}, \\n   {onSuccess: function() \\n    { console.log('Update completed successfully!'); }\\n   }\\n  );\",\n      \"language\": \"javascript\",\n      \"name\": \"Sample User Update with onSuccess Callback\"\n    }\n  ]\n}\n[/block]","updates":[],"order":3,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"5a9f3d8d13a6400077345718","project":"56aff08c3a5b810d00745d99","version":{"version":"1","version_clean":"1.0.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["56aff08d3a5b810d00745d9d","56aff24f3a5b810d00745da0","56aff25dbc304a0d00ace207","56aff287e0b1e40d00c53798","56aff2b260a37a0d00ed8883","56aff2b8e0b1e40d00c53799","56aff2bd5b1f01170014dc7b","56aff2c9d21e9c0d00b62993","56aff493aef9a21700da0e67","56aff4ce1486990d009c0f64","56aff4da5b1f01170014dc7d","56aff4dfe0b1e40d00c537a2","56aff4e59d32e30d0006d3e9","56aff4e91486990d009c0f65","56aff4f93a5b810d00745da2","56aff4fe9d32e30d0006d3ea","56b91c7ab1e03e0d001057c5","56c4f51aba4a540d0091b9a2","56cd09488c4a331d002c1e44","56d4ec4773dcd20b00fb8769","56e79bc515f96b2200878e54","56ec25c538ff1d2200d56cc2","56ec3a6f36bc8e0e00f190c8","56ec3e308ea7ce0e00a3d8b0","5724d8fe4255580e005938b2","5724dc842ad0bc1700122803","5776ef2a04f7500e0095dc37","57ab9f70b5e8742000e17eb9","57d7117646dcc30e007dd21f","58e6abd5b1eece19008b7d31","59288c65e2653627003e1221","5a8f4797a44f8600128e75ee","5bbf8833eb416300039a2c14","5ea811617bf4b5007328a0af"],"_id":"56aff08c3a5b810d00745d9c","project":"56aff08c3a5b810d00745d99","releaseDate":"2016-02-01T23:55:56.544Z","__v":34,"createdAt":"2016-02-01T23:55:56.544Z"},"category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"Zeta JavaScript Library","slug":"zetahub-javascript-library","order":1,"from_sync":false,"reference":false,"_id":"5a8f4797a44f8600128e75ee","project":"56aff08c3a5b810d00745d99","version":"56aff08c3a5b810d00745d9c","createdAt":"2018-02-22T22:43:35.027Z","__v":0},"user":"566887ff8639090d00759415","createdAt":"2018-03-07T01:17:01.313Z","githubsync":"","__v":0,"parentDoc":null}

Update User

Updates properties on the existing user

These operations provide you with the ability to manage the current user's data. The operations allow for additional user properties to be uploaded to ZetaHub or changed from their current values. User Updates are blocking JavaScript calls. [block:code] { "codes": [ { "code": "bt('updateUser', properties, settings={});", "language": "javascript" } ] } [/block] The `updateUser` call has the following fields: [block:parameters] { "data": { "h-0": "Field", "h-1": "Type", "h-2": "Description", "0-0": "`properties`", "1-0": "`settings` **optional**", "0-1": "Object", "0-2": "A JSON object containing properties to add to the current user", "1-1": "Object", "1-2": "Settings specific to this event. Currently supports specification of `onComplete`, `onSuccess`, and `onFailure` callback functions. See Settings below for more information." }, "cols": 3, "rows": 2 } [/block] [block:api-header] { "title": "Properties" } [/block] While any JSON data can be supplied as user properties, a few properties are standardized and specially handled by Zeta's systems. [block:parameters] { "data": { "h-0": "Property", "h-1": "Type", "h-2": "Description", "0-0": "`first_name`", "1-0": "`last_name`", "2-0": "`name`", "3-0": "`email`", "4-0": "`user_id`", "5-0": "`signed_up_at`", "0-1": "String", "1-1": "String", "2-1": "String", "3-1": "String", "4-1": "String", "5-1": "ISO-8601 Timestamp String", "0-2": "The first name of the user.", "1-2": "The last name of the user.", "2-2": "The full name of the user. Note that unless a user has this property set, the user's name will appear in ZetaHub as a concatenation of their `first_name` and `last_name`.", "3-2": "The email address of the user.", "4-2": "A unique identifier for the user.", "5-2": "The date at which a person signed up.", "6-0": "`contacts`", "6-1": "Array of objects", "6-2": "One or more contacts for this user. Each contact should be a hash/object with `type` and `value` attributes. A `status` is optional and defaults to \"new\". The `type` can be either \"email\" or \"phone\". If the `type` is an \"email\", it should satisfy standard email format validations. If the `type` is \"phone\", it should be sent in the ISO E.164 format with the \"+\" symbol followed by the country code and then the number. The `status` attribute can be used to unsubscribe the contact by sending its value as \"inactive\" or made active by sending its value as \"active\".\n\nIf a contact with the given `type` and `value` already exists for this user, it will be overwritten with the provided values. Otherwise, it will be added for this user." }, "cols": 3, "rows": 7 } [/block] [block:api-header] { "title": "Settings" } [/block] The `settings` object is used for configuring the `updateUser` call. Three `settings` objects are currently allowed for updateUser calls using the `p13n.js` library: [block:parameters] { "data": { "0-0": "`onComplete`", "h-0": "Objecdt", "h-1": "Description", "0-1": "This setting allows the caller to specify a callback function once the updateUser function has completed. The function will be called regardless of whether the update to the user was successful or not. The function should have no parameters (nothing will be passed to it).", "1-0": "`onFailure(error)`", "1-1": "This setting allows the caller to specify a callback function if the updateUser function has completed with an error. The error raised by the `updateUser` function will be passed into this callback.", "2-0": "`onSuccess`", "2-1": "This setting allows the caller to specify a callback function once the updateUser function has completed successfully. The function should have no parameters (nothing will be passed to it)." }, "cols": 2, "rows": 3 } [/block] [block:code] { "codes": [ { "code": "bt('updateUser', \n {user_id: 'abcde123'}, \n {onComplete: function() \n { console.log('User Update Completed!'); }\n }\n );", "language": "javascript", "name": "Sample User Update with onComplete Callback" }, { "code": "bt('updateUser', \n {user_id: 'abcde123'}, \n {onFailure: function(err) \n { console.log('Update completed with error: ' + err); }\n }\n );", "language": "javascript", "name": "Sample User Update with onFailure Callback" }, { "code": "bt('updateUser', \n {user_id: 'abcde123'}, \n {onSuccess: function() \n { console.log('Update completed successfully!'); }\n }\n );", "language": "javascript", "name": "Sample User Update with onSuccess Callback" } ] } [/block]