syncBenefit
POST /v1/marketing/benefit/sync
With this API call, an Independent Service Vendor (ISV) can synchronize one type of benefit to our server. Then our server processes the benefit internally and synchronizes it to the super app. After that, the super app releases the benefit manually for users to access.
Note:
- Do not synchronize the benefit in draft status to our server because once synchronized, it is regarded as the final benefit and can be accessed by users.
- The following fields cannot be modified after benefit synchronization:
- clientCode
- benefitContent
- benefitBudget
Structure
A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see:
Request parameters
Field | Data type | Required | Description | Example |
benefitSyncRequestId | String | Yes | Indicates the unique ID assigned by our server to identify a request of benefit synchronization.
Note: This field is an idempotency field. For synchronization requests which are initiated with the same benefitSyncRequestId, our server must return the same result. For details about API idempotency, see the Idempotency chapter. | - |
benefitTemplateId | String | Yes | Indicates the unique ID assigned by our server to identify one type of benefit.
| - |
benefitProductCode | String | Yes | Indicates the product code. The valid value is | - |
benefitTitle | String | Yes | Indicates benefit titles
| - |
benefitBeginTime | String | Yes | Indicates the start time to collect a benefit. The value follows the ISO 8601 standard format. For example, "2019-11-27T12:01:01+08:30". | UTC+05:30: "2019-04-04T12:08:56+05:30" UTC+0: "2019-04-04T12:08:56Z" |
benefitEndTime | String | Yes | Indicates the end time to collect a benefit. The value follows the ISO 8601 standard format. For example, "2019-11-27T12:01:01+08:30". | UTC+05:30: "2019-04-04T12:08:56+05:30" UTC+0: "2019-04-04T12:08:56Z" |
benefitValidPeriod | Yes | Indicates the validity period of a benefit after users collect the benefit. | - | |
clientCode | String | Yes | Indicates codes to identify different super apps. Valid values are:
Note: This field cannot be modified after benefit synchronization. | - |
targetStatus | String | Yes | Indicates the benefit statuses. Valid values are:
| - |
benefitMerchant | Yes | Indicates the merchant information. | - | |
benefitContent | Yes | Indicates the benefit content. Note: This field cannot be modified after benefit synchronization. | - | |
benefitBudget | Yes | Indicates the benefit budget. Note: This field cannot be modified after benefit synchronization. | - | |
benefitCollectRule | Yes | Indicates the rules to collect the benefit. | ||
description | String | No | Indicates the benefit description.
| - |
extendInfo | String | No | Indicates the extended information about this API.
| "{\"k1\":\"v1\",\"k2\":\"v2\"}" |
Response parameters
Field | Data type | Required | Description |
result | Yes | Indicates the request result, such as status and error codes. |
Result process logic
In the response, the result.resultStatus field indicates the result of processing a request. The following table describes each result status:
Result status | Description |
S | Our server has successfully accepted the request for benefit synchronization. The corresponding result.resultCode is |
U | The status of the request for benefit synchronization is unknown. The corresponding result.resultCode is |
F | The request of benefit synchronization failed to be accepted by our server. The corresponding result.resultCode and result.resultMessage are various based on different situations. For details, see the following Error codes section. |
Error codes
Error codes are usually classified into the following categories:
- Common error codes are common across all openAPIs for ISVs.
- API-specific error codes are listed in the following table:
Error code | Result status | Error message | Further action |
BENEFIT_CLOSED | F | The benefit has closed and you cannot synchronize the benefit. | Use another benefit template ID to synchronize a new benefit. |
BENEFIT_EXPIRED | F | The benefit is expired and you cannot synchronize the benefit. | Use another benefit template ID to synchronize the same information as the expired one. |
BENEFIT_SYNC_PROCESSING | U | You cannot synchronize benefits that are synchronizing. | Try again later. |
SPECIFIED_INFO_CANNOT_MODIFY | F | You cannot modify the specified information, including client codes, benefit content, and benefit budget. | - |
BENEFIT_NOT_EXIST | F | The benefit does not exist. | Make sure the status of the benefit is online when you synchronize the benefit to our server for the first time. |
Samples
Request
{
"benefitSyncRequestId": "20211111010101000001234",
"benefitTemplateId": "202001010101011234",
"benefitProductCode": "SPICE_SECRET_VOUCHER",
"benefitTitle": "KFC 10 yuan discount",
"benefitBeginTime": "2019-04-04T12:08:56+05:30",
"benefitEndTime": "2029-04-04T12:08:56+05:30",
"benefitValidPeriod": {
"type": "ABSOLUTE",
"activeTime": "2019-04-04T12:08:56+05:30",
"expireTime": "2019-05-04T12:08:56+05:30",
"activeSeconds": null,
"expireSeconds": null
},
"clientCode": "ALIPAY_CN",
"targetStatus": "ONLINE",
"benefitMerchant": {
"merchantId": "123455667",
"name": "KCF China",
"mcc": "5812",
"logoImage": {
"type": "URL",
"name": "http://www.pic.com/some/pic/url.png"
}
},
"benefitContent": {
"type": "REDUCE_BY",
"thresholdAmount": {
"currency": "USD",
"value": "50000"
},
"amount": {
"currency": "USD",
"value": "1000"
},
"ratio": "",
"giftDescription": ""
},
"benefitBudget": {
"type": "COUNT",
"amount": null,
"count": 300
},
"benefitCollectRule": {
"type":"LIFE_TIME",
"count":1
},
"description": " Voucher:\nKFC 10 yuan discount\n\nUsage Rules:\n1. Valid from Monday to Sunday\n2. Used in stores such as xxx\n3. xxxxxx\n\n",
"extendInfo": "{\"k1\":\"v1\",\"k2\":\"v2\"}"
}
Response
{
"result": {
"resultStatus": "S",
"resultCode": "",
"resultMessage": ""
}
}