Common fields description
Input parameters
Parameter | Type | Required | Example | Description |
appId | String | Yes | ONEX570DA89211721 | Application ID |
workspaceId | String | Yes | default | Workspace ID |
tenantId | String | Yes | LZFPEFIM | Tenant ID |
Output parameters
Parameter | Type | Example | Description |
requestId | String | B589F4F4-CD68-3CE5-BDA0-6597F33E23916512 | Request ID |
success | boolean | true | Indicates whether the request was successful |
code | String | 100 | Response code |
msg | String | SUCCESS | The returned message |
data | Object | - | Result content |
currentPage | int | 1 | The current page number |
pageSize | int | 100 | Number of records per page |
totalSize | int | 80 | Total number |
The output parameters of the "Create template, Delete template, Paged query, Single query" APIs are all display in Data format.
Only the Paged query API includes the parameters: currentPage, pageSize, totalSize.
Response codes
Response code | Result message | Description |
100 | SUCCESS | The operation was successful |
3022 | TEMPLATE_NOT_EXIST | Template not found |
3028 | INVALID_PARAM | Please check the parameters |
3036 | TEMPLATE_ALREADY_EXIST | Template already exists |
8011 | FLOW_CONTROL_ERROR | Traffic control |
8012 | INVALID_INSTANCE_ID | Check the AppID and WorkspaceID |
8013 | INVALID_TENANT_ID | Invalid TenantID |
8014 | ACCOUNT_NO_PERMISSION | You do not have the required permissions |
9000 | SYSTEM_ERROR | System error |
Create a template
A maximum of 100 templates can be created for one App.
Input parameters
Parameter | Type | Required | Example | Description |
templateName | String | Yes | Test template | Template name, created in the console. Note The template name cannot contain commas. |
descInfo | String | Yes | Template description | Template description |
title | String | Yes | Template title | Title. If it is a placeholder, it needs to be wrapped with |
content | String | Yes | Template content | Content. If it is a placeholder, it needs to be wrapped with |
uri | String | No |
| Jump URL |
variables | String | No |
| Placeholder fields, separated by commas |
showStyle | long | No | 0 | Silent mode:
|
imageUrls | String | No |
| When pushStyle=2, it indicates the URL of the large image. In JSON format, the default value of defaultUrl is obtained by default. If you need to distinguish the vendors, you can change the key to oppoUrl, miuiUrl, hmsUrl, honorUrl, harmonyosUrl, etc |
iconUrls | String | No |
| When pushStyle=2, it indicates the icon address. In JSON format, the default value of defaultUrl is obtained by default. If you need to distinguish the vendors, you can change the key to iosUrl, oppoUrl, miuiUrl, etc. |
pushStyle | int | No | 0 | Display style:
|
jumpAction | int | No | 0 | Action type after clicking:
|
Output parameters
Data | |||
Parameter | Type | Example | Description |
data | String | 8346 | Template ID |
Example
import com.alibaba.fastjson.JSON;
import com.aliyun.mpaas20201028.Client;
import com.aliyun.mpaas20201028.models.CreateTemplateRequest;
import com.aliyun.mpaas20201028.models.CreateTemplateResponse;
import com.aliyun.teaopenapi.models.Config;
public static void main(String[] args) throws Exception {
// The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. We recommend that you use a RAM user to call API operations or perform routine O&M.
// We recommend that you do not save your AccessKey ID and AccessKey secret in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account is compromised.
// In this example, the AccessKey ID and AccessKey secret are saved as environment variables. You can also save the AccessKey pair in the configuration file based on your business requirements.
// We recommend that you configure environment variables first.
Config config = new Config();
// Required: Your AccessKey ID
config.setAccessKeyId(System.getenv("MPAAS_AK_ENV"));
// Required: Your AccessKey Secret
config.setAccessKeySecret(System.getenv("MPAAS_SK_ENV"));
// the REGION_ID and Endpoint of mPaaS, taking Hangzhou Non-Financial area as an example
config.setRegionId("cn-hangzhou");
config.setEndpoint("mpaas.cn-hangzhou.aliyuncs.com");
Client client = new Client(config);
CreateTemplateRequest request = new CreateTemplateRequest();
request.setAppId("ONEX570DA89211721");
request.setWorkspaceId("test");
request.setTenantId("xxx");
request.setTemplateName("Create a test template");
request.setContent("Test template content");
request.setTitle("Test template title");
request.setDescInfo("Test template description");
CreateTemplateResponse response = client.createTemplate(request);
System.out.println("response==>"+JSON.toJSONString(response));
} Delete a template
Input parameters
Parameter | Type | Required | Example | Description |
templateId | String | No | 8346 | Either template ID or templateName (higher priority) |
templateName | String | No | Test | Template name or templateId |
Output parameters
Data is null.
Example
import com.alibaba.fastjson.JSON;
import com.aliyun.mpaas20201028.Client;
import com.aliyun.mpaas20201028.models.DeleteTemplateRequest;
import com.aliyun.mpaas20201028.models.DeleteTemplateResponse;
import com.aliyun.teaopenapi.models.Config;
public static void main(String[] args) throws Exception {
// The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. We recommend that you use a RAM user to call API operations or perform routine O&M.
// We recommend that you do not save your AccessKey ID and AccessKey secret in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account is compromised.
// In this example, the AccessKey ID and AccessKey secret are saved as environment variables. You can also save the AccessKey pair in the configuration file based on your business requirements.
// We recommend that you configure environment variables first.
Config config = new Config();
// Required: Your AccessKey ID
config.setAccessKeyId(System.getenv("MPAAS_AK_ENV"));
// Required: Your AccessKey Secret
config.setAccessKeySecret(System.getenv("MPAAS_SK_ENV"));
// the REGION_ID and Endpoint of mPaaS, taking Hangzhou Non-Financial area as an example
config.setRegionId("cn-hangzhou");
config.setEndpoint("mpaas.cn-hangzhou.aliyuncs.com");
Client client = new Client(config);
DeleteTemplateRequest request = new DeleteTemplateRequest();
request.setAppId("ONEX570DA89211721");
request.setWorkspaceId("test");
request.setTenantId("xxx");
request.setTemplateName("Create a test template");
DeleteTemplateResponse response = client.deleteTemplate(request);
System.out.println("response==>"+JSON.toJSONString(response));
}Paged query
Input parameters
Parameter | Type | Required | Example | Description |
currentPage | int | No | 1 | Current page number, default is 1 |
pageSize | int | No | 100 | Number of records per page, default is 100 |
Output parameters
Data type is List<Template>.
Template | |||
Parameter | Type | Example | Description |
id | String | 8346 | Template ID |
name | String | Test | Template name |
descInfo | String | Template description | Template description |
title | String | Template title | Title |
content | String | Template content | Content |
uri | String |
| Jump URL |
variables | String |
| Placeholder fields |
showStyle | String | 0 | Silent mode |
imageUrls | String |
| Large image URL |
iconUrls | String |
| Icon URL |
pushStyle | String | 0 | Display style |
action | String | 0 | Action type after clicking |
gmtCreate | String | 1587376706000 | The time when the template was created |
gmtModified | String | 1587376706000 | The time when the template was modified |
Example
import com.alibaba.fastjson.JSON;
import com.aliyun.mpaas20201028.Client;
import com.aliyun.mpaas20201028.models.ListTemplatePageRequest;
import com.aliyun.mpaas20201028.models.ListTemplatePageResponse;
import com.aliyun.teaopenapi.models.Config;
public static void main(String[] args) throws Exception {
// The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. We recommend that you use a RAM user to call API operations or perform routine O&M.
// We recommend that you do not save your AccessKey ID and AccessKey secret in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account is compromised.
// In this example, the AccessKey ID and AccessKey secret are saved as environment variables. You can also save the AccessKey pair in the configuration file based on your business requirements.
// We recommend that you configure environment variables first.
Config config = new Config();
// Required: Your AccessKey ID
config.setAccessKeyId(System.getenv("MPAAS_AK_ENV"));
// Required: Your AccessKey Secret
config.setAccessKeySecret(System.getenv("MPAAS_SK_ENV"));
// the REGION_ID and Endpoint of mPaaS, taking Hangzhou Non-Financial area as an example
config.setRegionId("cn-hangzhou");
config.setEndpoint("mpaas.cn-hangzhou.aliyuncs.com");
Client client = new Client(config);
ListTemplatePageRequest request = new ListTemplatePageRequest();
request.setAppId("ONEX570DA89211721");
request.setWorkspaceId("test");
request.setTenantId("xxx");
request.setCurrentPage(1);
request.setPageSize(2);
ListTemplatePageResponse response = client.listTemplatePage(request);
System.out.println("response==>"+JSON.toJSONString(response));
}Single query
Input parameters
Parameter | Type | Required | Example | Description |
templateId | String | No | 8346 | Either template ID or templateName (higher priority) |
templateName | String | No | Test | Template name or templateId |
Output parameters
Data type is Template.
Template | |||
Parameter | Type | Example | Description |
id | String | 8346 | Template ID |
name | String | Test | Template name |
descInfo | String | Template description | Template description |
title | String | Template title | Title |
content | String | Template content | Content |
uri | String |
| Link URL |
variables | String |
| Placeholder fields |
showStyle | String | 0 | Silent mode |
imageUrls | String |
| Large image URL |
iconUrls | String |
| Icon URL |
pushStyle | String | 0 | Display style |
action | String | 0 | Action type after clicking |
gmtCreate | String | 1587376706000 | The time when the template was created |
gmtModified | String | 1587376706000 | The time when the template was modified |
Example
import com.alibaba.fastjson.JSON;
import com.aliyun.mpaas20201028.Client;
import com.aliyun.mpaas20201028.models.GetTemplateRequest;
import com.aliyun.mpaas20201028.models.GetTemplateResponse;
import com.aliyun.teaopenapi.models.Config;
public static void main(String[] args) throws Exception {
// The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. We recommend that you use a RAM user to call API operations or perform routine O&M.
// We recommend that you do not save your AccessKey ID and AccessKey secret in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account is compromised.
// In this example, the AccessKey ID and AccessKey secret are saved as environment variables. You can also save the AccessKey pair in the configuration file based on your business requirements.
// We recommend that you configure environment variables first.
Config config = new Config();
// Required: Your AccessKey ID
config.setAccessKeyId(System.getenv("MPAAS_AK_ENV"));
// Required: Your AccessKey Secret
config.setAccessKeySecret(System.getenv("MPAAS_SK_ENV"));
// the REGION_ID and Endpoint of mPaaS, taking Hangzhou Non-Financial area as an example
config.setRegionId("cn-hangzhou");
config.setEndpoint("mpaas.cn-hangzhou.aliyuncs.com");
Client client = new Client(config);
GetTemplateRequest request = new GetTemplateRequest();
request.setAppId("ONEX570DA89211721");
request.setWorkspaceId("test");
request.setTenantId("xxx");
request.setTemplateName("Test template");
GetTemplateResponse response = client.getTemplate(request);
System.out.println("response==>"+JSON.toJSONString(response));
}