Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Account Management

Joanna Rozestwinska edited this page Mar 11, 2015 · 9 revisions

This API handles Accounts and User related operations

Create an Account

Important: After creating account, user Authorization token must be refreshed to access the new account data.

Param Type Description Value
Authorization HTTP Header Access Token Authorization: Bearer eyJ0eXAi....
Content-Type HTTP Header Type of body content application/json
Request
POST /accounts
{
    "name": "AccountName"
}

Response 201 CREATED (application/json)
{ 
    "name":"AccountName",
    "healthTimePeriod":86400,
    "created":1406919627586,
    "updated":1406919627586,
    "exec_interval":300,
    "base_line_exec_interval":86400,
    "cd_model_frequency":604800,
    "cd_execution_frequency":600,
    "data_retention":0,
    "id":"321ef007-8449-477f-9ea0-d702d77e64b9"
}

Get Account information

Param Type Description Value
Authorization HTTP Header Access Token Authorization: Bearer eyJ0eXAi....
Content-Type HTTP Header Type of body content application/json
accountId URL Slug The ID of an Account. In order to obtain the Account Id, we need first obtain an Authorization Token and then get the Authorization Token Info 534da46c820cb9f74a0d3de6
Request
GET /accounts/{accountId}

Response 200 OK (application/json)
{
    "name": "AccountName",
    "healthTimePeriod": 86400,
    "created": 1404415261310,
    "updated": 1404415261310,
    "exec_interval": 120,
    "base_line_exec_interval": 86400,
    "cd_model_frequency": 604800,
    "cd_execution_frequency": 600,
    "data_retention": 0,
    "attributes":{
        "phone":"123456789",
        "another_attribute":"another_value"
    },
    "id": "321ef007-8449-477f-9ea0-d702d77e64b9"
}

Get Account Activation Code

The Account Activation Code is the transient activation code that can be used to activate devices for the account. It expires after one hour.

Param Type Description Value
Authorization HTTP Header Access Token Authorization: Bearer eyJ0eXAi....
accountId URL Slug The ID of an Account 321ef007-8449-477f-9ea0-d702d77e64b9
Request
GET /accounts/{accountId}/activationcode

Response 200 OK (application/json)
{
    "activationCode": "CgSVoHee",
    "timeLeft": 1404418861
}

Renew Account Activation Code

Forces the renewal of the Account Activation Code.

Param Type Description Value
Authorization HTTP Header Access Token Authorization: Bearer eyJ0eXAi....
accountId URL Slug The ID of an Account 321ef007-8449-477f-9ea0-d702d77e64b9
Request
PUT /accounts/{accountId}/activationcode/refresh

Response 200 OK (application/json)
{
    "activationCode": "bBnvBWrT",
    "timeLeft": 1404419896
}

Update an Account

Param Type Description Value
Authorization HTTP Header Access Token Authorization: Bearer eyJ0eXAi....
Content-Type HTTP Header Type of body content application/json
accountId URL Slug The ID of an Account 321ef007-8449-477f-9ea0-d702d77e64b9
Request
PUT /accounts/{accountId}
{
    "name": "NEWAccountName",
    "healthTimePeriod": 86400,        
    "exec_interval": 120,
    "base_line_exec_interval": 86400,
    "cd_model_frequency": 604800,
    "cd_execution_frequency": 600,
    "data_retention": 0,
    "attributes":{
        "phone":"123456789",
        "another_attribute":"another_value",
        "new":"next_string_value"
    },
    "id": "321ef007-8449-477f-9ea0-d702d77e64b9"
}

Response 200 OK

Delete an Account.

Deletes an Account and all its data.

Param Type Description Value
Authorization HTTP Header Access Token Authorization: Bearer eyJ0eXAi....
accountId URL Slug The ID of an Account 321ef007-8449-477f-9ea0-d702d77e64b9
Request
DELETE /accounts/{accountId}

Response 204 NO CONTENT

Change another user privileges to your account (you need to be an admin)

You can upgrade a standard user of your account (who currently has "user" privileges - default for invited users) to an admin. To do so, you have to be an admin of account for which you want to upgrade another user's access.

Param Type Description Value
Authorization HTTP Header Access Token Authorization: Bearer eyJ0eX...
accountId URL Slug The ID of an Account 321ef007-8449-477f-9ea0-d702d77e64b9
userId URL Slug The ID of User you would like to add account for 53e95985c8406a147700b94d
role Param Role of a user for your account "user" or "admin"
Request
PUT /accounts/{accountId}/users/{userId}
{
    "id": "{userId}",
    "accounts": {
        "{accountId}": "{role}"
    }
}    
Response 200

Remember that user can be promoted from user to admin, but admin privileges cannot be revoked.