All Products
Search
Document Center

Chat App Message Service:Send messages via APIs

Last Updated:May 27, 2026

Chat App Message Service provides APIs for creating templates, sending single messages, and sending messages in bulk. This topic uses WhatsApp as an example. Other channel types follow a similar process.

You can call Chat App Message Service APIs in the following ways:

  • Alibaba Cloud OpenAPI Portal

    Debug APIs and get SDK request examples through an interactive interface. Ideal for developers new to Alibaba Cloud.

  • SDK

    SDKs are available for multiple programming languages, such as Java, Go, PHP, and Python. Using an SDK to integrate Chat App Message Service improves development efficiency.

  • Custom encapsulation (not recommended)

    Alibaba Cloud SDKs handle request signing, timeouts, and retries. We recommend using the SDK to reduce development costs. If you must make raw API calls, see SendChatappMessage and Signature examples.

To integrate Chat App Message Service with an SDK, review the APIs on the OpenAPI Portal, then follow the process below to integrate Chat App Message Service:

image

Preparations

Preparation

Description

Reference

Register an Alibaba Cloud account

Complete enterprise identity verification

  • Enterprise identity verification confirms the account holder is an enterprise or government entity.

  • Chat App Message Service does not support individual accounts.

Create an Alibaba Cloud account

Enterprise identity verification

Activate the service

Log on to the Chat App Message Service console, and activate the service.

-

Configure user permissions

Alibaba Cloud accounts have broad permissions. Use a RAM user for API calls and daily operations.

You can check a user's permissions by logging in to the RAM console and clicking the RAM user's name. Ensure the RAM user making the API calls has the necessary permissions for Chat App Message Service:

  • AliyunCamsFullAccess: Full permission to manage Chat App Message Service.

Create a RAM user

Manage RAM user permissions

RAM authorization

AccessKey ID

Log on to the RAM console, and click the RAM user's name to view the AccessKey ID.

Create an AccessKey

AccessKey secret

The AccessKey secret is shown only at creation. If you do not have a local backup, create a new AccessKey pair.

Environment configuration

This example uses Java. For other languages and SDK installation, see Installation Method.

  1. Verify Java 8+ is installed. For detailed instructions, see Set up a Java development environment on Windows.

  2. Install the SDK by configuring Maven dependencies.

    In your Maven project's pom.xml, add the following to <dependencies> and replace the-latest-version with the latest version number. Then reload Maven dependencies.

    <dependency>
      <groupId>com.aliyun</groupId>
      <artifactId>alibabacloud-cams20200606</artifactId>
      <!-- Replace 'the-latest-version' with the latest version number: https://mvnrepository.com/artifact/com.aliyun/alibabacloud-cams20200606 -->
      <version>the-latest-version</version>
    </dependency>
  3. Configure environment variables: To avoid hardcoding your AccessKey pair in code, store credentials in environment variables. After configuration, restart your IDE, command-line interface, and other applications to load the new variables.

  4. Configure a proxy (optional). To route requests through a proxy, configure it in the SDK. Proxy configuration.

Basic API information

API version

2020-06-06

API style

RPC

Service endpoint

(Endpoint)

Public endpoint: cams.ap-southeast-1.aliyuncs.com

Review API parameters before making calls. Online DebuggingAPI Overview

Workflow

image
  1. Create a channel: Go to the Channel Management page.

    1. A channel is the type of path used to send messages. Supported channels: WhatsApp, Viber, Messenger, Instagram, and Email.

    2. Each channel supports only its corresponding message type.

  2. Register and bind a WABA: Call the ChatappBindWaba API to bind a WhatsApp Business Account (WABA).

    • You must have a registered WABA before calling this API. WABAs cannot be registered via API—register through the Chat App Messaging Service console.

    • A WABA (WhatsApp Business Account) is required to send commercial WhatsApp messages. Verified WABAs display a badge that increases customer trust and enhances brand image while reducing interference from fraudulent messages.

  3. Add a number: Call the AddChatappPhoneNumber API to add a number. This phone number will be used to send WhatsApp messages.

    • You can sync the numbers under your bound and approved WABA with the Business Manager (BM) platform by using the ChatappSyncPhoneNumber API.

    • You can migrate phone numbers from other BSPs to Alibaba Cloud. Migrated numbers retain their display name, quality rating, messaging limits, official business account status, and all previously approved high-quality message templates. Use the CreateChatappMigrationInitiate API to initiate migration.

  4. Verify a number: Call the GetChatappVerifyCode API to get a verification code for the number. Then, use the ChatappVerifyAndRegistr API operation to verify the number. After verification, use the GetPhoneNumberVerificationStatus API operation to check the verification status.

  5. Create and design a template: Call the CreateChatappTemplate API to create a template. After the template is created, it is automatically submitted for review. Then, use the GetChatappTemplateDetail API to query the template review details.

  6. Send messages: Call the SendChatappMessage or SendChatappMassMessage API to send messages.

    • Ensure your account has sufficient balance before sending. Pricing.

  7. View message sending details: Receive reports for sent messages through the ChatAppStatus callback (Simple Message Queue | HTTP URL).

  8. Receive mobile originated (MO) messages: Receive inbound messages through the ChatAppInbound callback (Simple Message Queue | HTTP URL).

For more information about API operations, see API overview.

Sample code

The following example sends a message by calling the SendChatappMessage API. Fill in parameters as indicated by the comments.

// This file is auto-generated, don't edit it. Thanks.
package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * <b>description</b> :
     * <p>Initialize the client using credentials.</p>
     * @return Client
     *
     * @throws Exception
     */
    public static com.aliyun.cams20200606.Client createClient() throws Exception {
        // For production environment, we recommend a more secure method that does not hardcode the AccessKey. For details, visit https://www.alibabacloud.com/help/doc-detail/2542825.html.
        com.aliyun.credentials.Client credential = new com.aliyun.credentials.Client();
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                .setCredential(credential);
        // The service endpoint. For details, visit https://api.alibabacloud.com/product/cams.
        config.endpoint = "cams.ap-southeast-1.aliyuncs.com";
        return new com.aliyun.cams20200606.Client(config);
    }

    public static void main(String[] args_) throws Exception {

        com.aliyun.cams20200606.Client client = Sample.createClient();
        java.util.Map<String, String> templateParams = TeaConverter.buildMap(
                //Replace these with the variable names and values from your template
                new TeaPair("name", "Bob"),
                new TeaPair("sex", "Male")
        );
        com.aliyun.cams20200606.models.SendChatappMessageRequest sendChatappMessageRequest = new com.aliyun.cams20200606.models.SendChatappMessageRequest()
                //Parameters for sending the message.
                .setTemplateParams(templateParams)
                .setTemplateCode("XXXXXXXXXXX")
                .setChannelType("whatsapp")
                .setType("template")
                .setLanguage("en")
                .setFrom("XXXXXXXX")
                .setTo("XXXXXXXX")
                .setCustSpaceId("XXXXXXXXXXX");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // If you copy this code to run, print the API return value yourself.
            client.sendChatappMessageWithOptions(sendChatappMessageRequest, runtime);
        } catch (TeaException error) {
            // This is for printing and demonstration purposes only. Handle exceptions carefully and do not ignore them in your project.
            // Error message.
            System.out.println(error.getMessage());
            // Diagnostic address.
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // This is for printing and demonstration purposes only. Handle exceptions carefully and do not ignore them in your project.
            // Error message.
            System.out.println(error.getMessage());
            // Diagnostic address
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }
}

Visit OpenAPI Portal for complete SDK examples in other languages. To make raw API calls, see SendChatappMessage and Signature examples.

Frequently asked questions