Account Binding and Unbinding

Last updated: 2021-06-02 17:14:41

    API Description

    Request method: POST

    plaintext
    Service URL/v3/device/account/batchoperate
    

    API service URLs correspond to service access points one to one. Please select the service URL corresponding to the service access point of your application.

    Feature: this is an async API that is only responsible for task delivery, with real-time operation currently unsupported.

    Parameters

    Request parameters

    Parameter Type Required Description
    operator_type Integer Yes Operation type. Value range: [1,5] as detailed below:
  • 1: bind a token to one more account.
  • 2: bind a token to another account in an overriding manner.
  • 3: unbind a token from multiple accounts.
  • 4: unbind a token from all accounts.
  • 5: unbind an account from all tokens.
  • platform String Yes Client platform type
  • Android: Android
  • iOS: Apple
  • account_list Array No List of account IDs. This parameter is valid and required when operator_type is 5. Each element contains the account and account_type parameters.
    Example:
    [{"account":"926@126.com"},{"account":"1527000000"}]
    token_list Array No List of device IDs. This parameter is valid and required when operator_type is 4.
    token_accounts Array No This parameter is valid and required when operator_type is 1, 2, or 3. Up to 20 tokens can be set in each call. Each token_account consists of 1 token and 1 account_list. Example:
    [{"token":"token1","account_list":[{"account":"926@126.com"},{"account":"1527000000"}],
    {"token":"token2","account_list":[{"account":"926@163.com",{"account":"1527000001"}]}]
    Note:

    As the token append account API was seldom used and confusing to developers, it has been disused since October 26, 2020. If you used it previously, it will be replaced by the Token clearAndAppendAccount API.

    Response parameters

    Parameter Type Description
    ret_code Integer Error code. For more information, please see Server-Side Error Codes.
    err_msg String Error message
    result Array Operation status code corresponding to each token or account ["0","1008006"]

    Samples

    Sample request

    • Bind a token to one more account
      json
      {
       "operator_type": 1,
       "platform": "android",
       "token_accounts": [
           {
               "token": "token1",
               "account_list": [
                   {
                       "account": "926@126.com"
                   },
                   {
                       "account": "1527000000"
                   }
               ]
           },
           {
               "token": "token2",
               "account_list": [
                   {
                       "account": "926@163.com"
                   },
                   {
                       "account": "1527000001"
                   }
               ]
           }
       ]
      }
      
    • Bind a token to another account in an overriding manner
      json
      {
       "operator_type": 2,
       "platform": "android",
       "token_accounts": [
           {
               "token": "token1",
               "account_list": [
                   {
                       "account": "926@126.com"
                   },
                   {
                       "account": "1527000000"
                   }
               ]
           },
           {
               "token": "token2",
               "account_list": [
                   {
                       "account": "926@163.com"
                   },
                   {
                       "account": "1527000001"
                   }
               ]
           }
       ]
      }
      
    • Unbind a token from an account
      json
      {
       "operator_type": 3,
       "platform": "android",
       "token_accounts": [
           {
               "token": "token1",
               "account_list": [
                   {
                       "account": "926@126.com"
                   },
                   {
                       "account": "1527000000"
                   }
               ]
           },
           {
               "token": "token2",
               "account_list": [
                   {
                       "account": "926@163.com"
                   },
                   {
                       "account": "1527000001"
                   }
               ]
           }
       ]
      }
      
    • Unbind a token from all accounts
      json
      {
       "operator_type": 4,
       "platform": "android",
       "token_list": [
           "token1",
           "token2",
           "token3"
       ]
      }
      
    • Unbind an account from all tokens
      json
      {
       "operator_type": 5,
       "platform": "android",
       "account_list": [
           {
               "account": "926@126.com"
           },
           {
               "account": "1527000000"
           }
       ]
      }
      

    Sample response

    Bind a token to one more account

     json
    {
       "result": [
           "ok",
           "ok"
       ],
       "ret_code": 0,
       "err_msg": "ok"
    }