update
This method is used for managing your own tokens and tokens of users to whom you have access. The method is not used for authorization. To log in, use token/login.
To create, edit or delete the token, use the token/update command:
svc=token/update¶ms={"callMode":<text>,
"userId":<text>,
"h":<text>,
"app":<text>,
"at":<uint>,
"dur":<uint>,
"fl":<uint>,
"p":<text>,
"items":[<long>],
"deleteAll":<bool>|<text>
}
Parameters
The request can contain the following parameters. The required parameters are marked with an asterisk (*).
Name | Description |
---|---|
callMode* | Action you want to perform. To create a token, specify create in this parameter. To edit a token, pass update, and to delete it, pass delete. |
userId | Subuser ID. The parameter is used to manage other user tokens. |
h * | Token name. Consists of 72 characters. This parameter must be used in requests for editing and deleting a token. |
app* | Application name. |
at* | Token activation time, UNIX-time. You can pass 0 in this parameter so that the token is activated immediately after the request is successfully completed. |
dur* | Token duration after activation, seconds. Pass 0 in this parameter to set an infinite duration. |
fl* | Access flags. |
p* | Custom parameters, value must be an object or an array of objects. |
items | List of item IDs to which the token grants access. |
deleteAll | Relevant for callMode:delete Pass 1 or true to delete all the created tokens. |
Tokens are deleted automatically after 100 days of inactivity (even with dur:0).
Example of an object for the parameter p:
"p":"{\"paramA\":\"valueB\"}"
Example of an array of objects for the parameter p:
"p":"[{\"paramA\":\"valueB\"},{\"paramB\":\"valueD\"}]"
Access flags
Value | Description |
---|---|
0x100 | Online tracking. |
0x200 | View access to most data. |
0x400 | Modification of non-sensitive data. |
0x800 | Modification of sensitive data. |
0x1000 | Modification of critical data, including message deletion. |
0x2000 | Communication. |
0xFFFFFFFF | Unlimited operation as an authorized user (allows managing user tokens). |
For further information about token flags, see Tokens.
Response
If the request is completed successfully, a response of the following format is returned:
{
"h":<text>, /* Unique token name, 72 characters. */
"app":<text>, /* Application name. */
"at":<uint>, /* Token activation time, UNIX-time. */
"ct":<uint>, /* Token creation time, UNIX-time. */
"dur":<uint>, /* Token duration after activation, seconds. */
"fl":<uint>, /* Access flags. */
"items":[<long>], /* List of item IDs to which the token grants access. */
"p":<text> /* Custom parameters. The value must be an object or an array of objects. */
}
If the request fails, an error code is returned.
Error codes
Error code | Description |
---|---|
4 | Wrong input parameters. |
1003 | Request limit reached. |
7 | One of the following errors: |