UserStore

Users

The user object contains basic information about the user. The API allows you to get, create, update, and delete your users.

Create User

Creates a user account with the option to send a registration email. Make sure your mail settings are properly configured in your app dashboard.

Options

send_email
optional, default is false
Send a registration email using mail template and settings configured in your app dashboard.
verify_user
optional, default is false
Generate a verification code for the user. The verification code will only be returned on this request.
verify_url
optional if send_email is true and verify_user is true
Absolute URL to the account verification page on your site. A query parameter 'code' will be passed to your page.

Arguments

email
required
The user's email address.
password
required
The user's password.
username
optional
The user's username.
first_name
optional
The user's first name.
last_name
optional
The user's last name.
Definition
POST https://api.userstore.io/1/users
userstore.users.create(options, user, callback)
Example Request
curl "https://api.userstore.io/1/users?verify_user=true&verify_url=http%3A%2F%2Fexample.com%2Fverify" \
   -u SECRET_KEY: \
   -d [email protected] \
   -d password="Sz4kF^12cpsk"
userstore.users.create(
  {
    verify_user: true,
    verify_url: 'http://example.com/verify'
  },
  {
    email: '[email protected]',
    password: 'Sz4kF^12cpsk'
  },
  function(err, user) {}
);
                  
Object Response
{
  "id": "lFVofRqhZ",
  "email": "[email protected]",
  "username": "johnsmith",
  "first_name": "John",
  "last_name": "Smith",
  "is_active": true,
  "is_email_verified": false,
  "last_signin": "2014-08-04T23:48:34.288Z",
  "updated_at": "2014-08-04T23:46:19.106Z",
  "created_at": "2014-08-04T23:46:19.106Z"
}
                  

List Users

Retrieve a list of users.

If the there are more users to retrieve, a pagination information will be provided to fetch the next or previous set of users.

Arguments

limit
optional, default is 100
Limits the number of results returned.
after
optional
Sets the pagination cursor to get results after the cursor position.
before
optional
Sets the pagination cursor to get results before the cursor position.
Definition
GET https://api.userstore.io/1/users
userstore.users.list(options, callback)
Example Request
curl https://api.userstore.io/1/users?limit=2 \
   -u SECRET_KEY:
userstore.users.list(
  {
    limit: 2
  },
  function(err, users) {}
);
                  
Object Response
{
  "paging": {
    "next": "https://api.userstore.io/1/users?limit=2&after=1407195979106",
    "after": 1407195979106,
    "total_count": 3
  },
  "data": [
    {
      "id": "lFVofRqhZ",
      "email": "[email protected]",
      "username": "johnsmith",
      "first_name": "John",
      "last_name": "Smith",
      "is_active": true,
      "is_email_verified": true,
      "last_signin": "2014-08-04T23:48:34.288Z",
      "updated_at": "2014-08-04T23:46:19.106Z",
      "created_at": "2014-08-04T23:46:19.106Z"
    },
    {
      "id": "lFVofRqhM",
      "email": "[email protected]",
      "username": "joemith",
      "first_name": "Joe",
      "last_name": "Smith",
      "is_active": true,
      "is_email_verified": true,
      "last_signin": "2014-08-04T23:48:34.288Z",
      "updated_at": "2014-08-04T23:46:19.106Z",
      "created_at": "2014-08-04T23:46:19.106Z"
    }
  ]
}
                  

Get User

Retrieve a user by ID, email, or username.

Options

query_by
option, default is id
The field to query by. Options are id (default), email, or username.

Arguments

id
required
Depending on the query_by option, this could be the user's ID, email, or username. Note that the email address should be URL encoded.
Definition
GET https://api.userstore.io/1/users/:ID
userstore.users.get(id, callback)
Example Request
curl https://api.userstore.io/1/users/lFVofRqhZ \
   -u SECRET_KEY:
userstore.users.get(
  'lFVofRqhZ',
  function(err, user) {}
);
                  
Object Response
{
  "id": "lFVofRqhZ",
  "email": "[email protected]",
  "username": "johnsmith",
  "first_name": "John",
  "last_name": "Smith",
  "is_active": true,
  "is_email_verified": true,
  "last_signin": "2014-08-04T23:48:34.288Z",
  "updated_at": "2014-08-04T23:46:19.106Z",
  "created_at": "2014-08-04T23:46:19.106Z"
}
                  

Update User

Update a user.

Options

verify_user
optional, default is false
Generate a verification code for the user if email address changed. The verification code will only be returned on this request.
verify_url
required if verify_user is true
Absolute URL to the account verification page on your site. A parameter 'code' will be passed to your page.

Arguments

id
required
The user's ID.
email
optional
The user's email address.
password
optional
The user's password.
username
optional
The user's username.
first_name
optional
The user's first name.
last_name
optional
The user's last name.
Definition
PUT https://api.userstore.io/1/users/:ID
userstore.users.update(id, options, data, callback)
Example Request
curl "https://api.userstore.io/1/users/lFVofRqhZ?verify_user=true&verify_url=http%3A%2F%2Fexample.com%2Fverify" \
   -u SECRET_KEY: \
   -d first_name=John \
   -d last_name=Smith \
   -X PUT
userstore.users.get(
  'lFVofRqhZ',
  {
    verify_user: true,
    verify_url: 'http://example.com/verify'
  },
  {
    first_name: 'Josh',
    last_name: 'Smith'
  },
  function(err, user) {}
);
                  
Object Response
{
  "first_name": "John",
  "last_name": "Smith",
  "updated_at": "2014-08-04T23:46:19.106Z"
}
                  

Delete User

Permanently deletes the user. This cannot be undone. If successful, the user will be returned.

Options

id
required
The user's ID.
Definition
DELETE https://api.userstore.io/1/users/:ID
userstore.users.delete(id, callback)
Example Request
curl https://api.userstore.io/1/users/lFVofRqhZ \
   -u SECRET_KEY: \
   -X DELETE
userstore.users.delete(
  'lFVofRqhZ',
  function(err, user) {}
);
                  
Object Response
{
  "id": "lFVofRqhZ",
  "email": "[email protected]",
  "username": "johnsmith",
  "first_name": "John",
  "last_name": "Smith",
  "is_active": true,
  "is_email_verified": true,
  "last_signin": "2014-08-04T23:48:34.288Z",
  "updated_at": "2014-08-04T23:46:19.106Z",
  "created_at": "2014-08-04T23:46:19.106Z"
}