Logo Site EngageLab Mark Colored TransparentDocument
Search

Tag Alias API

The Device API is used to query, set, update, and delete a device's tag and alias information on the server side. When using it, be careful to avoid having tags set on the server side overwritten by the client side.

  • If you are not familiar with tag and alias logic, it is recommended that you use only one side: either the client side or the server side.
  • If both sides are used at the same time, make sure your application can properly handle tag and alias synchronization.

For detailed information about tags and aliases, please refer to the API documentation for the corresponding client platform.

Constraints and Rules for TAG Usage

  • TAG quantity limit: Under a single appkey, you can create up to 100,000 Tags.
  • TAG length limit: The maximum length of each Tag is 40 bytes. Valid characters include letters (case-sensitive), numbers, underscores, and Chinese characters.
  • Device TAG binding limit: Each device can be bound to up to 100 Tags.
  • Device quantity limit: Under a single Tag, you can add up to 100,000 devices.

If you are a paid plan user and would like to adjust the usage limits for a paid AppKey, please contact our sales team at Sales@engagelab.com.

Constraints and Rules for alias Usage

  • Device and alias mapping relationship: One alias can correspond to only one device and cannot correspond to multiple devices. Likewise, each device can map to only one alias within the appkey scope and cannot map to multiple aliases.
  • alias quantity limit: Under a single appkey, you can create up to 100,000 aliases.
  • alias length limit: The maximum length of each alias is 40 bytes. Valid characters include letters (case-sensitive), numbers, underscores, and Chinese characters.

If you are a paid plan user and would like to adjust the usage limits for a paid AppKey, please contact our sales team at Sales@engagelab.com.

API Overview

The Device API is used to query, set, update, and delete a device's tag and alias information on the server side.

It includes three groups of APIs: device, tag, and alias. Among them:

  • device is used to query/set various properties of a device, including tags and alias;
  • tag is used to query/set/delete device tags;
  • alias is used to query/set/delete device aliases.

Another key piece of information you need is the registration ID:

The device's registration_id is obtained after client integration. For details, see the Web API documentation.

The server side does not provide an API to obtain the device's registration_id value. Developers need to obtain the registration ID from the client side and upload it to the developer server for storage.

Query the Number of Tags Under an AppKey

Endpoint

GET /v4/tags_count
              
              GET /v4/tags_count

            
This code block in the floating window

Request Example

Request Headers

GET /v4/tags_count Authorization: Basic (base64 auth string) Accept: application/json
              
              GET /v4/tags_count
Authorization: Basic (base64 auth string)
Accept: application/json

            
This code block in the floating window

Request Example

curl -X GET http://127.0.0.1/v4/tags_count?tags=tag1&tags=tag2&platform=ios -u "appKey:appSecret"
              
              curl -X GET http://127.0.0.1/v4/tags_count?tags=tag1&tags=tag2&platform=ios -u "appKey:appSecret"

            
This code block in the floating window

Request Parameters

  • tags: Queries the specified tag strings. Required. Up to 1000 tags can be queried in a single request (tags=tag1&tags=tag2&tags=tag3).
  • platform: Queries the specified platform. Required. Valid values are android, ios, hmos, and web. Other values are not allowed.

Response Example

  • A successful response returns a JSON object containing a tagsCount field, which is a collection of key-value pairs where the key is the tag name and the value is the count under that tag.
  • If the request fails, a JSON object containing error information is returned. The code field indicates the error code, and the message field indicates the error message.

Successful Response

{ "tagsCount": { "tag1": 0, "tag2": 1, "tag3": 2 } }
              
              {
  "tagsCount": {
    "tag1": 0,
    "tag2": 1,
    "tag3": 2
  }
}

            
This code block in the floating window

Failed Response

{ "error": { "code": 21008, "message": "app_key is not a 24 size string or does not exist" } }
              
              {
  "error": {
    "code": 21008,
    "message": "app_key is not a 24 size string or does not exist"
  }
}

            
This code block in the floating window

Query a Device's Alias and Tags

  • Gets all properties of the current device, including tags and alias.

Endpoint

GET /v4/devices/{registration_id}
              
              GET /v4/devices/{registration_id}

            
This code block in the floating window

Request Example

Request Headers

GET /v4/devices/{registration_id} Authorization: Basic (base64 auth string) Accept: application/json
              
              GET /v4/devices/{registration_id}
Authorization: Basic (base64 auth string)
Accept: application/json

            
This code block in the floating window

Request Parameters

  • registration_id: Required. The device's registration_id.

Response Example

Successful Response

HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
              
              HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

            
This code block in the floating window

Response Data

{ "tags": ["tag1", "tag2"], "alias": "alias1" }
              
              {
  "tags": ["tag1", "tag2"],
  "alias": "alias1"
}

            
This code block in the floating window
  • If the statistical item cannot be found, it is null; otherwise, it is the value of the statistical item.

Set a Device's Alias and Tags

  • Updates the specified properties of the current device. Currently supports tags and alias.

Endpoint

POST /v4/devices/{registration_id}
              
              POST /v4/devices/{registration_id}

            
This code block in the floating window

Request Example

Request Headers

POST /v4/devices/{registration_id} Authorization: Basic (base64 auth string) Accept: application/json
              
              POST /v4/devices/{registration_id}
Authorization: Basic (base64 auth string)
Accept: application/json

            
This code block in the floating window

Request Data

{ "tags": { "add": ["tag1", "tag2"], "remove": ["tag3", "tag4"] }, "alias": "alias1" }
              
              {
  "tags": {
    "add": ["tag1", "tag2"],
    "remove": ["tag3", "tag4"]
  },
  "alias": "alias1"
}

            
This code block in the floating window

Request Parameters

  • registration_id: Required. The device's registration_id.
  • tags: Supports add, remove, or an empty string. When the tags parameter is an empty string, it means all tags will be cleared. add/remove is used to add or remove the specified tags.
  • alias: Updates the device's alias property. When the alias is an empty string, the alias of the specified device is deleted.

Response Example

Successful Response

HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
              
              HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

            
This code block in the floating window

Response Data

success
              
              success

            
This code block in the floating window

Failed Response

{ "error": { "code": 27002, "message": "unknown error" } }
              
              {
  "error": {
    "code": 27002,
    "message": "unknown error"
  }
}

            
This code block in the floating window

Query the Tag List

  • Gets the list of all tags in the current application.

Endpoint

GET /v4/tags/
              
              GET /v4/tags/

            
This code block in the floating window

Request Example

Request Headers

GET /v4/tags/ Authorization: Basic (base64 auth string) Accept: application/json
              
              GET /v4/tags/
Authorization: Basic (base64 auth string)
Accept: application/json

            
This code block in the floating window

Request Parameters

  • None

Response Example

Successful Response

HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
              
              HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

            
This code block in the floating window

Response Data

{ "tags": ["tag1", "tag2"] }
              
              {
  "tags": ["tag1", "tag2"]
}

            
This code block in the floating window
  • If the statistical item cannot be found, it is null; otherwise, it is the value of the statistical item.

Query the Binding Relationship Between a Device and a Tag

  • Queries whether a device belongs to a tag.

Endpoint

GET /v4/tags/{tag_value}/registration_ids/{registration_id}
              
              GET /v4/tags/{tag_value}/registration_ids/{registration_id}

            
This code block in the floating window

Request Example

Request Headers

GET /v4/tags/{tag_value}/registration_ids/090c1f59f89 Authorization: Basic (base64 auth string) Accept: application/json
              
              GET /v4/tags/{tag_value}/registration_ids/090c1f59f89
Authorization: Basic (base64 auth string)
Accept: application/json

            
This code block in the floating window

Request Parameters

  • tag_value: Required. The tag to query.
  • registration_id: Required. The device's registration_id.

Response Example

Successful Response

HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
              
              HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

            
This code block in the floating window

Response Data

{"result": true}
              
              {"result": true}

            
This code block in the floating window

Update a Tag

  • Adds or removes devices for a tag.

Endpoint

POST /v4/tags/{tag_value}
              
              POST /v4/tags/{tag_value}

            
This code block in the floating window

Request Example

Request Headers

POST /v4/tags/{tag_value} Authorization: Basic (base64 auth string) Accept: application/json
              
              POST /v4/tags/{tag_value}
Authorization: Basic (base64 auth string)
Accept: application/json

            
This code block in the floating window

Request Data

{ "registration_ids": { "add": ["registration_id1", "registration_id2"], "remove": ["registration_id1", "registration_id2"] } }
              
              {
  "registration_ids": {
    "add": ["registration_id1", "registration_id2"],
    "remove": ["registration_id1", "registration_id2"]
  }
}

            
This code block in the floating window

Request Parameters

  • tag_value: Required. The tag to query.
  • action: Operation type, with two options: "add" and "remove", indicating whether this request is to add or remove.
  • registration_ids: The device registration_id values to be added or removed.
  • add/remove: Supports up to 1000 items each.

Response Example

Successful Response

HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
              
              HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

            
This code block in the floating window

Response Data

success
              
              success

            
This code block in the floating window

Failed Response

{ "error": { "code": 27005, "message": "registration id is illegal", "data": "{\"invalid_regids\":[\"18071adc021ff8df80\",\"100d85592955c1f1058\"]}" } }
              
              {
  "error": {
    "code": 27005,
    "message": "registration id is illegal",
    "data": "{\"invalid_regids\":[\"18071adc021ff8df80\",\"100d85592955c1f1058\"]}"
  }
}

            
This code block in the floating window

Delete a Tag

Deletes a tag and the association between the tag and devices.

Endpoint

DELETE /v4/tags/{tag_value}
              
              DELETE /v4/tags/{tag_value}

            
This code block in the floating window

Request Example

Request Headers

DELETE /v4/tags/{tag_value}?platform=web Authorization: Basic (base64 auth string) Accept: application/json
              
              DELETE /v4/tags/{tag_value}?platform=web
Authorization: Basic (base64 auth string)
Accept: application/json

            
This code block in the floating window

Request Parameters

  • tag_value: Required. The tag to query.
  • platform: Optional. If omitted, the default is all platforms.

Response Example

Successful Response

HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
              
              HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

            
This code block in the floating window

Response Data

success
              
              success

            
This code block in the floating window

Failed Response

{ "error": { "code": 27002, "message": "unknown error" } }
              
              {
  "error": {
    "code": 27002,
    "message": "unknown error"
  }
}

            
This code block in the floating window

Query an Alias (Binding Relationship with a Device)

GET /v4/aliases/{alias_value} Get the device under the specified alias.
              
              GET /v4/aliases/{alias_value}
Get the device under the specified alias.

            
This code block in the floating window

Query an Alias

  • Gets the device under the specified alias.

Endpoint

GET /v4/aliases/{alias_value}
              
              GET /v4/aliases/{alias_value}

            
This code block in the floating window

Request Example

Request Headers

GET /v4/aliases/{alias_value}?platform=web Authorization: Basic (base64 auth string) Accept: application/json
              
              GET /v4/aliases/{alias_value}?platform=web
Authorization: Basic (base64 auth string)
Accept: application/json

            
This code block in the floating window

Request Parameters

  • alias_value: Required. The alias to query.
  • platform: Optional. If omitted, the default is all platforms.

Response Example

Successful Response

HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
              
              HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

            
This code block in the floating window

Response Data

{ "registration_ids": ["registration_id1", "registration_id2"] }
              
              {
  "registration_ids": ["registration_id1", "registration_id2"]
}

            
This code block in the floating window
  • If the statistical item cannot be found, it is null; otherwise, it is the value of the statistical item.

Delete an Alias

Deletes an alias and the binding relationship between the alias and devices.

DELETE /v4/aliases/{alias_value}
              
              DELETE /v4/aliases/{alias_value}

            
This code block in the floating window

Request Example

Request Headers

DELETE /v4/aliases/{alias_value}?platform=web Authorization: Basic (base64 auth string) Accept: application/json
              
              DELETE /v4/aliases/{alias_value}?platform=web
Authorization: Basic (base64 auth string)
Accept: application/json

            
This code block in the floating window

Request Parameters

  • alias_value: Required. The alias to delete.
  • platform: Optional. If omitted, the default is all platforms.

Response Example

  • Success
success
              
              success

            
This code block in the floating window
  • Failure
{ "error": { "code": 27002, "message": "unknown error" } }
              
              {
  "error": {
    "code": 27002,
    "message": "unknown error"
  }
}

            
This code block in the floating window

Get User Online Status

Endpoint

POST /v4/devices/status/
              
              POST /v4/devices/status/

            
This code block in the floating window

Request Example

Request Headers

POST /v4/devices/status/ Authorization: Basic (base64 auth string) Accept: application/json
              
              POST /v4/devices/status/
Authorization: Basic (base64 auth string)
Accept: application/json

            
This code block in the floating window

Request Data

{ "registration_ids": [ "010b81b3582", "0207870f1b8", "0207870f9b8" ] }
              
              {
  "registration_ids": [
    "010b81b3582",
    "0207870f1b8",
    "0207870f9b8"
  ]
}

            
This code block in the floating window

Request Parameters

  • registration_ids: The user registration_id values for which online status is needed. Up to 1000 registration_id values are supported per query.
  • This API can be called only for AppKeys that have applied for and enabled this service.

Response Example

Successful Response

HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
              
              HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

            
This code block in the floating window

Response Data

[ { "regid": "010b81b3582", "online": true }, { "regid": "0207870f1b8", "online": false, "last_online_time": "2014-12-16 10:57:07" }, { "regid": "0207870f9b8", "online": false } ]
              
              [
  {
    "regid": "010b81b3582",
    "online": true
  },
  {
    "regid": "0207870f1b8",
    "online": false,
    "last_online_time": "2014-12-16 10:57:07"
  },
  {
    "regid": "0207870f9b8",
    "online": false
  }
]

            
This code block in the floating window

Response Data

  • online
    • true: online within the last 10 minutes
    • false: not online within the last 10 minutes
  • last_online_time
    • when online is true, this field is not returned
    • when online is false and this field is not returned, it means the last online time was more than two days ago
  • For invalid regid values or regid values that do not belong to the appkey, validation will fail.

TAG/alias Quota Information Query API

Queries the relevant quota information for the specified AppKey, platform, and tag. No more than 1000 tags can be queried at a time.

Endpoint

GET /v4/tags/quota-info?tags=tag1&platform=android Authorization: Basic (base64 auth string) Accept: application/json
              
              GET /v4/tags/quota-info?tags=tag1&platform=android
Authorization: Basic (base64 auth string)
Accept: application/json

            
This code block in the floating window

Request Example

curl --location 'https://webpushapi-sgp.engagelab.com/v4/tags/quota-info?platform=android&tags=tag1&tags=tag2' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic YjA2MTBmZGE0M2JmNmFkMTczNGNjMWY2OmQyNGMzZDk1Yzk1M2M3YmFkNzRkM2Q5YQ=='
              
              curl --location 'https://webpushapi-sgp.engagelab.com/v4/tags/quota-info?platform=android&tags=tag1&tags=tag2' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic YjA2MTBmZGE0M2JmNmFkMTczNGNjMWY2OmQyNGMzZDk1Yzk1M2M3YmFkNzRkM2Q5YQ=='

            
This code block in the floating window

Successful Response

{ "data": { "totalTagQuota": 100000, "useTagQuota": 1, "totalAliasQuota": 100000, "useAliasQuota": 3, "tagUidQuotaDetail": [ { "tagName": "tag1", "totalUidQuota": 100000, "useUidQuota": 0 }, { "tagName": "tag2", "totalUidQuota": 100000, "useUidQuota": 0 } ] } }
              
              {
  "data": {
    "totalTagQuota": 100000,
    "useTagQuota": 1,
    "totalAliasQuota": 100000,
    "useAliasQuota": 3,
    "tagUidQuotaDetail": [
      {
        "tagName": "tag1",
        "totalUidQuota": 100000,
        "useUidQuota": 0
      },
      {
        "tagName": "tag2",
        "totalUidQuota": 100000,
        "useUidQuota": 0
      }
    ]
  }
}

            
This code block in the floating window

Response Field Descriptions:

  • totalTagQuota: Indicates the total quota for the number of tags under the application.
  • useTagQuota: Indicates the used tag quota.
  • totalAliasQuota: Indicates the total quota for the number of aliases under the application.
  • useAliasQuota: Indicates the used alias quota.
  • tagUidQuota: Indicates the quota for the number of devices under a single tag.
  • useUidQuota: Indicates the detailed number of devices bound to each tag.

Failed Response

{ "error": { "code": 27002, "message": "Invalid parameters" } }
              
              {
  "error": {
    "code": 27002,
    "message": "Invalid parameters"
  }
}

            
This code block in the floating window

HTTP Status Codes

Reference document: Http-Status-Code

Business Response Codes

Code Description Detailed Explanation HTTP Status Code
21004 Authentication error invalid appkey 401
27000 System memory error please try again 500
27001 Parameter error validation information is empty 401
27002 Parameter error invalid parameter 400
27004 Parameter error validation failed 401
27005 Parameter error invalid regisID format 400
21008 Parameter error app_key is not a 24-character string or does not exist 400
27010 Parameter error alias is already bound to another regid 400
27011 System limit the number of tags bound to the device exceeds the limit; a single device can be bound to at most 100 Tags 401
27012 Parameter error the Tag to be bound to the device does not exist 401
27013 Parameter error the number of tags under the application exceeds the limit; a single application can create up to 100,000 Tags 401
27014 System limit the number of uid under the tag exceeds the limit; a single Tag can be bound to at most 100,000 devices 401
27015 Parameter error the Alias bound to the device does not exist 401
27016 System limit the number of aliases under the application exceeds the limit; a single application can create up to 100,000 Aliases 401
27017 Parameter error tag length exceeds 40 characters 401
Icon Solid Transparent White Qiyu
Contact Sales