A collection of methods for managing users. Authentication can differ for each, pay attention to the headers. Request body is a JSON object, but placeholders for data types instead of concrete samples might be used like so: <UUID> or "…" for strings.
Registers and logs in a new user. Response will contain DeviceSession.accessToken which you should put to the request header.
Path:
POST /users
Request body:
{
"name": "…",
"username": "…",
"password": "…",
"deviceInfo": <DeviceInfo>
}
Response: UserInfo object.
See also: DeviceInfo
Logs in user from a particular device. Response will contain DeviceSession.accessToken which you should put to the request header.
Path:
POST /users/login
Headers:
Authorization: Basic <username:password>
Request body:
{
"deviceInfo": <DeviceInfo>
}
Response: UserInfo object.
See also: DeviceInfo, DeviceSession
Gets all the information of the current user.
Path:
GET /users/me
Headers:
Authorization: Bearer <token>
Response: UserInfo object.
Logs out user and invalidates DeviceSession.accessToken.
Path:
POST /users/me/logout
Headers:
Authorization: Bearer <token>
Response: OK
See also: DeviceSession
Changes password for the user. Requires both DeviceSession.accessToken and the old password.
Path:
PUT /users/me/changePassword
Headers:
Authorization: Bearer <token>
Request body:
{
"oldPassword": "…",
"newPassword": "…"
}
Response: OK
Sets the account key which is necessary for restoration of the account in case of password loss.
Path:
PUT /users/me/setAccountKey
Headers:
Authorization: Bearer <token>
Request body:
{
"password": "…",
"accountKey": "…"
}
Response: OK
Resets user's password in case of a valid account key provided.
Path:
PUT /users/resetPassword
Request body:
{
"userId": <Int>,
"accountKey": "…",
"newPassword": "…"
}
Response: OK
Updates user's information, such as name and about.
Path:
PUT /users/me
Headers:
Authorization: Bearer <token>
Request body:
{
"name": "…",
"about": "…"
}
Response: OK
Updates user's device session information, such as deviceName and deviceToken.
Path:
PUT /users/me/device
Headers:
Authorization: Bearer <token>
Request body:
{
"deviceName": "…", // f.e. "My laptop"
"deviceToken": "…" // Push token (APNS or Android)
}
Response: OK
Gets all the public information about a user.
Path:
GET /users/<id>
Response: UserInfo object.
Looks for people by their name or username using substring.
Path:
GET /users/?s=foo
Response: an array of UserInfo objects.
Adds a photo to the current user. Media should be uploaded beforehand. See Files section.
Path:
POST /users/me/photos
Headers:
Authorization: Bearer <token>
Request body:
{
"photo": {
"id": <UUID>, // should be obtained beforehand by uploading a file
"fileType": "png",
"fileSize": 100000 // in bytes
}
}
Response: OK
Deletes the photo from the current user together with all the media.
Path:
DELETE /users/me/photos/<UUID>
Headers:
Authorization: Bearer <token>
Response: OK
Deletes user with all the associated data (created chats, messages, settings etc.). Can't be undone. Use with caution.
Path:
DELETE /users/me
Headers:
Authorization: Basic <username:password>
Response: OK