FORMAT: 1A
User API Creates, Deletes, Updates, Searches HashtagSell users
The version resource is useful for retrieving status and uptime as well as current version for the postings API
User API version information.
-
Response 200 (application/json)
-
Body
{ "name": "hashtagsell-user-api", "version": "0.1.0", "memory": { "free": "63 MB", "total": "8.59 GB" }, "os": { "arch": "x64", "hostname": "NewBradBookPro.local" }, "uptime": "10 seconds" }
-
The auth resources will create new users and login existing users.
Register a new user with system. Does not create new user if email already in system.
To create a user, send JSON with the appropriate values
-
Request (application/json)
{ "email": "brad@domain.com", "isAdmin" : "true", //defaults to false "password" : "password", "phone" : "123-456-7891" //optional "firstName" : "Brad", "lastName" : "Davis" }
-
Response 201
{ "__v": 0, "email": "brad@domain.com", "isAdmin": true, "firstName": "Brad", "lastName": "Davis", "phone": "123-456-7891", "userId": "9d62c28604644275b905b6980c0732da", //handled by api "modifiedAt": "2015-07-27T18:58:39.249Z", //handled by api "createdAt": "2015-07-27T18:58:39.249Z", //handled by api "iat": 1438023549, //Issue At Time "exp": 1438109949, //Token expiration, default is 24 hours "token": "eyJ0eXAiOiJKV1QiL....3m6r_9DkA6lozE" //token should be stored by client }
Logs in user with their username and password. Returns a token that must be used in all subsequent queries thereafter.
To login a user, send JSON with the appropriate values. The token returned must be included in all subsequent requests thereafter to make full use of APIs (see exampled DELETE user).
-
Request (application/json)
{ "email": "brad@domain.com", "password" : "password" }
-
Response 200
{ "__v": 0, "email": "brad@domain.com", "isAdmin": true, "firstName": "Brad", "lastName": "Davis", "phone": "123-456-7891", "userId": "9d62c28604644275b905b6980c0732da", //handled by api "modifiedAt": "2015-07-27T18:58:39.249Z", //handled by api "createdAt": "2015-07-27T18:58:39.249Z", //handled by api "iat": 1438023549, //Issue At Time "exp": 1438109949, //Token expiration, default is 24 hours "token": "eyJ0eXAiOiJKV1QiL....3m6r_9DkA6lozE" //token should be stored by client }
The user resources will update a user, delete a user, and search for a user/users. All resources here are protected and require a valid user token.
Create, login, and delete a user
-
Model (application/json)
-
Body
{ userId : { index: true, required: true, type: String }, firstName : { required : false, type : String }, lastName : { required : false, type : String }, email : { index : true, required : true, type : String }, password : { required : true, type: String }, phone: { required: false, type: String }, isAdmin : { required : true, type : Boolean } }
-
-
Request (application/json)
-
Headers
x-access-token: token here
-
Body
{ "email":"brad@domain.com", "token" : "token here" }
-
-
Response 204