How to update users through API?

You are here:
Estimated reading time: 1 min

Please check API overview before continuing.

User endpoint base is user/ so for version 1 of our API you will use:

https://api.vtcdn.net/v1/user/

Return user information [GET]

GET /{email}
Return example:
{
 "email: "[email protected]",
 "isSubscribed": true,
 "gender": "male",
 "city" : "Paris"
}

Add new user [POST]

Create a new user, if the email does not exists.

POST /
Request example:
{
 "email: "[email protected]",
 "isSubscribed": true,
 "gender": "male"
}

Update user attributes [PUT]

Modify user attributes. Make sure you submit valid data for the attributes, otherwise they will be ignored.

PUT /{email}
Request example:
{
 "isSubscribed": true,
 "gender": "male"
}

We accept upsert for PUT requests, if you pass it as URL param. When upsert is true, it will create the user, if it doesn’t exist, otherwise it will update the object.

PUT /{email}?upsert=true

Responses examples:

Response (HTTP status code: 200).

Successful responses for PUT and POST will also return “object” with the new state.

{
  "results": [{
    "message": "Successfully added new user.",
    "email": "[email protected]"
  }],
  "object": {
      "_id": ...
   }
}

Response (HTTP status code: 404)

{
  "errors": [
    {
      "message": "User not found",
      "description": "This email does not exist in our database."
    }
  ]
}

Response (HTTP status code: 400)

{
  "errors": [
    {
      "message": "Invalid data format/type",
      "description": "Error validating user attributes",
    }
  ]
}
Was this article helpful?
Dislike 0
Views: 67