An atomic service calls the service updates sending API to deliver service updates messages.
The service updates capability is supported on phones and tablets.
The message body cannot exceed 4096 bytes. Otherwise, error code 82600005 will be returned.
Protocol: HTTPS POST
Direction: Your server -> Huawei Push Kit server
URL: https://push-api.cloud.huawei.com/v1/[projectId]/service_timeline/send
Data format: Content-Type: application/json
[projectId]: project ID. To obtain the value, sign in to AppGallery Connect, click Development and services, click the desired project, and go to Project settings.
| Parameter | Description | Example |
|---|---|---|
| Authorization | Authentication method: JWT: For details, please refer to Generating a JWT Based on a Service Account. NOTE · The PS256 algorithm must be used to call the service updates API. · You are advised to set the JWT validity period to 3600 seconds, within which a JWT can be reused. · This parameter value is Bearer followed by a space character and then the obtained authentication information. | Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---**** |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| toOpenId | Yes | String | OpenID of a sign-in user. Use the OpenId reported by the device or request user information from the Account Kit server. For details about how to design and integrate the HUAWEI ID sign-in function, please refer to the account usage specifications of atomic services. |
| appId | Yes | String | App ID of an atomic service. The value contains 1 to 64 characters. NOTE [appId]: app ID. Sign in to AppGallery Connect, click Apps/Atomic services, select the required atomic service, and obtain the app ID of the atomic service under Basic information on the App information page. |
| sceneId | Yes | String | Scenario ID. For details, please refer to Service Updates Sending Scenarios. The value contains 1 to 32 characters. |
| subSceneId | Yes | String | Subscenario ID. For details, please refer to Service Updates Sending Scenarios. The value contains 1 to 32 characters. |
| code | Yes | String | · When a user launches the Huawei IAP checkout screen in your atomic service for payment, you can obtain the IAP order No. sysTransOrderNo and use it as the code. · When a user obtains a code via a front-end scenario-specific button, you can use the Service Updates Authorization Code Button to retrieve the code. |
| content | Yes | TimelineStatusContent object. | Status parameter in service updates. For the takeout self-pickup scenario, please refer to Takeout Self-Pickup Structure. For the takeout delivery scenario, please refer to Takeout Delivery Structure. |
Send requests with mandatory and optional parameters based on different states. The following uses the takeout self-pickup scenario as an example.
Request example: preparing
// Request URL
POST "https://push-api.cloud.huawei.com/v1/[projectId]/service_timeline/send"
// Request Header
Content-Type: application/json
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---****
// Request Body
{
"appId": "5**********7",
"toOpenId": "A**********O",
"sceneId": "10001",
"subSceneId": "100010001",
"code": "3**********7",
"content": {
"status": 3,
"orderTime": 1716191520,
"amount": "¥ 18.00",
"productCount": 1,
"productName": "Mango",
"productImg": "image_test_1",
"merchantName": "Store A",
"pickupNumber": "1668",
"pickupTime": "16:08",
"remainOrders": "5 orders/5 cups",
"waitTime": "10-20 minutes",
"button": {
"type": 0,
"text": "Pickup code",
"data": {
"testKey": "testValue"
}
},
"clickAction": {
"type": 0,
"data": {
"testKey": "testValue"
}
},
"appendButtons": [
{
"type": 0,
"text": "Pickup code",
"data": {
"testKey": "testValue"
}
}
]
}
} Request example: pending payment
// Request URL
POST "https://push-api.cloud.huawei.com/v1/[projectId]/service_timeline/send"
// Request Header
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---****
// Request Body
{
"appId": "6**********3",
"toOpenId": "A**********F",
"sceneId": "10001",
"subSceneId": "100010001",
"code": "1**********6",
"content": {
"status": 1,
"orderTime": 1715236319,
"amount": "¥ 5.00",
"productCount": 1,
"productName": "Mango",
"productImg": "image_test_1",
"paymentEndTime": "Pay within 5 minutes",
"merchantName": "Store B",
"button": {
"type": 0,
"text": "Pay now",
"action": "https://***"
},
"clickAction": {
"type": 0,
"action": "https://***"
},
"appendButtons": [
{
"type": 0,
"text": "Pay now",
"action": "https://***"
}
]
}
} | Parameter | Mandatory | Type | Description |
|---|---|---|---|
| code | Yes | String | Response code. |
| msg | Yes | String | Response code description. |
| requestId | Yes | String | Request ID. |
Success response example:
{
"code": "80000000",
"msg": "Success",
"requestId": "157*******006"
} Failure response example:
{
"code": "82600010",
"msg": "status content missing required field",
"requestId": "157*******006"
} | HTTP Response Code | Description | Solution |
|---|---|---|
| 200 | Success. | - |
| 400 | Parameter error. | Check the service response code and locate the fault based on it. |
| 401 | Authentication failure. | Check the Authorization parameter in the HTTP header. |
| 404 | Service not found. | Check the request URL. |
| 500 | Internal service error. | Submit a ticket online. |
| 502 | Connection error. This typically occurs when network connectivity is unstable. | Try again later. If the fault persists, submit a ticket online. |
| 503 | Traffic control. | · Distribute the sending speed evenly. · Spread out push notification delivery to avoid peak sending times. |
| 504 | Gateway timeout. | Try again later. If the fault persists, submit a ticket online. |
Message
Success.
Symptom
Sent successfully.
Possible causes
Sent successfully.
Solution
None.
Message
system error.
Symptom
Internal system error.
Possible causes
An unknown error occurred.
Solution
Message
invalid parameter {errorTips}.
Symptom
Parameter error.
Possible causes
Invalid parameter.
Solution
Verify the request parameters as prompted by the response.
Message
access deny.
Symptom
Service denied.
Possible causes
The service updates sending permission is not enabled.
Solution
Enable the service updates sending permission.
Message
status content blocked.
Symptom
Risk control error.
Possible causes
Some scenario parameters are prohibited.
Solution
Verify that the scenario parameters do not contain prohibited parameters as prompted by the response.
Message
send message failed{errorTips}.
Symptom
Failed to send the service updates message.
Possible causes
There are no online recipients.
The request body size exceeds the default value (4096 bytes).
Solution
Rectify the fault as follows:
Verify that there are online recipients.
Verify that the request body size does not exceed the default value (4096 bytes) and send the message again.
Message
invalid openId.
Symptom
OpenID failed the verification.
Possible causes
The OpenID of the recipient is incorrect.
Solution
Use the OpenId reported by the client or the OpenId in the user information obtained from the Account Kit server.
Message
invalid sceneId or subSceneId.
Symptom
The scenario and subscenario IDs are incorrect.
Possible causes
There is no permission on the scenario and subscenario.
Solution
Send the message based on enabled scenario and subscenario IDs.
Message
invalid code.
Symptom
The authorization code is incorrect.
Possible causes
The transaction order ID is invalid.
The transaction order ID is not activated within the validity period (1 hour).
Solution
Verify the following:
The transaction order ID is valid.
Regenerate the authorization code and push the message again.
Use the IAP order No. (sysTransOrderNo) as the authorization code to push the message again.
Message
invalid scene status.
Symptom
The scenario-specific status is incorrect.
Possible causes
Incorrect request body parameter.
Solution
Verify the request body parameters as prompted by the response. For details, please refer to Service Updates Sending Scenarios.
Message
status content missing required field {errorTips}.
Symptom
Mandatory status parameters are missing.
Possible causes
Mandatory status parameters are missing.
Solution
Verify the request body parameters as prompted by the response. For details, please refer to Service Updates Sending Scenarios.
Message
status content has invalid field {errorTips}.
Symptom
The status parameter format is invalid.
Possible causes
The status parameter format is invalid.
Solution
Verify the request body parameters as prompted by the response.
Message
invalid status transition.
Symptom
Invalid status transition.
Possible causes
Invalid status transition.
Solution
For the takeout self-pickup scenario, verify the request body parameters by referring to the service updates parameter requirements in the self-pickup scenario.
For the takeout delivery scenario, verify the request body parameters by referring to the service updates parameter requirements in the delivery scenario.
Message
user close service.
Symptom
The user disabled the service updates push.
Possible causes
The user disabled the service updates push in this scenario.
Solution
Check whether the service updates switch is turned off. If so, turn on the switch and then call the API. To turn on the service updates switch, swipe right on the home screen to access Assistant·TODAY, touch the avatar to access the Me screen, touch the icon
in the upper right corner of the screen, touch Manage live services, and find the corresponding scenario switch in the Service updates list.
Message
invalid image id.
Symptom
Invalid image resource ID.
Possible causes
The image resource specified by the resource ID does not exist.
Solution
Check whether the image resource specified by the resource ID exists. If not, use image resource hosting to provide the image and obtain the resource ID again.
Message
status refresh frequency reached upper limit.
Symptom
The number of status updates exceeds the upper limit.
Possible causes
The number of status updates exceeds the upper limit.
Solution
Reduce unnecessary status updates.
Message
event expired.
Symptom
Service updates expired.
Possible causes
After the time specified by expireTime elapses, service updates messages are not allowed.
Solution
Set expireTime properly and push the message again.
Message
no authorization device.
Symptom
The user does not have any authorized devices.
Possible causes
The user does not have any authorized devices in this scenario.
Solution
Add an authorized device for this scenario and push the message again.
Paths:
Method 1: Swipe right on the home screen to access Assistant·TODAY, touch the profile picture to access the Me screen, touch the icon
in the upper right corner, go to Settings > Sync service data > This device, and turn on the switch to enable device authorization.
Method 2: Open any atomic service, touch the icon
in the upper right corner, go to Settings > Sync service data > This device, and turn on the switch to enable device authorization.
Message
event already closed.
Symptom
The service updates event has ended.
Possible causes
The event has ended. No more messages can be sent.
Solution
Create a new service updates event to push messages.
Message
code reached upper limit.
Symptom
The number of active authorization codes exceeds the upper limit.
Possible causes
The number of authorization codes pushed to the same user exceeds the upper limit (50).
Solution
Limit the number of authorization codes pushed to a single user to a maximum of 50.