Page tree
Skip to end of metadata
Go to start of metadata

In Smartenit ecosystem, users can belong to one or several accounts, this enables the account owner to share control over devices or other API resources in a secure way, it also allows companies to track activity for support staff.

curl -X POST
    -d '{"username":"new_user@smartenit.com","password":"my_strong_password","profile":{"name":"John","last_name":"Smith"}}'
    --header 'Accept: application/json'
    --header 'Authorization: Bearer ACCESS_TOKEN'
    'https://api.smartenit.io/v2/users'
 
* Please note ACCESS_TOKEN above is normally obtained via grant_type: "client_credentials"

Response:

{
    "message":"Resource created successfully",
    "data":{
        "_id":"507f1f77bcf86cd799439011",
        "username":"john.smith@smartenit.com",
        "profile":{
            "name":"John",
            "last_name":"Smith"
        },
        "accounts":[
            {
                "id":"507f191e810c19729de860ea",
                "roles":[
                    "account_owner"
                ]
            }
        ],
        "created_at":"2016-01-19T06:01:17.171Z"
    }
}

When a new user is registered, an account will be created for that user. Using the accounts resource, you can check the content of the account just created with the id 507f191e810c19729de860ea:

curl -X GET
    --header 'Accept: application/json'
    --header 'Authorization: Bearer YOUR_ACCESS_TOKEN'
    'https://api.smartenit.io/v2/accounts/507f191e810c19729de860ea'

Response:

{
    "_id":"507f191e810c19729de860ea",
    "name":"Jhon Smith's Account",
    "created_at":"2016-01-19T06:01:17.171Z"
}

Read information about account users

An account owner can check information about users registered on his account:

curl -X GET
    --header 'Accept: application/json'
    --header 'Authorization: Bearer ACCOUNT_OWNER_ACCESS_TOKEN'
    'https://api.smartenit.io/v2/users'

Response:

{
    "message":"Resources found",
    "data":[
        {
            "_id":"507f1f77bcf86cd799439011",
            "username":"mary.smith@smartenit.com",
            "profile":{
                "name":"Mary",
                "last_name":"Smith"
            },
             "accounts":[
                {
					"name":"Jhon Smith's Account",
                    "id":"507f191e810c19729de860ea",
                    "roles":[
                        "account_guest"
                    ]
                }
            ],
            "created_at":"2016-01-19T06:01:17.171Z"
        },
        ...
    ]
}
  • No labels