IDN SAAS WhatsApp API send - nxtele/nxcloud-doc-en GitHub Wiki

Send Message

Initiate WhatsApp message sending via API.

  • URL: https://api-idn.nxlink.ai/saas/wa/send
  • Method: POST
  • Content-Type: application/json
  • Requires authentication: Yes

Request Parameters

Header Parameters

Parameter Type Required Example Description
accessKey String Yes fme2na3kdi3ki User identity key
ts String Yes 1655710885431 Timestamp in milliseconds. Max allowed time drift is 60 seconds.
bizType String Yes 2 WhatsApp business type, fixed value "2"
action String Yes mt WhatsApp action, fixed value "mt"
sign String Yes 6e9506557d1f289501d333ee2c365826 Signature, see common auth rules

Body Parameters

Parameter Type Required Example Description
tenant_id Long Yes 1 Tenant ID
appkey String Yes pem28kje Application appkey
business_phone String Yes 86158xxxx1795 WhatsApp sender number with country code
messaging_product String Yes whatsapp Must be "whatsapp"
recipient_type String Yes individual Must be "individual"
to String No 86158xxxx1795 Recipient WhatsApp number with country code. You can include either to (phone number) or recipient (BSUID or parent BSUID) in the request. If both are included, to (phone number) takes precedence.
recipient String No HK.73374xxxx5265 Recipient BSUID, for example HK.73374xxxx5265. You can include either to (phone number) or recipient (BSUID or parent BSUID) in the request. If both are included, to (phone number) takes precedence.
type String Yes template Supported type: template
template JsonObject Yes - Template content, required when type=template

Template Message Parameters

Parameter Type Required Example Description
template JsonObject Yes - Template content
  • template object:
Parameter Type Required Example Description
name String Yes - Template name
language JsonObject Yes - Template language
components array[component] No - Component variable list
  • language object:
Parameter Type Required Example Description
code String Yes - Language code
policy String Yes - Fixed value: deterministic
  • component object:
Parameter Type Required Example Description
type String Yes - Component type: header, body, button
parameters array[parameter] No - Parameters list
  • parameter object:
Parameter Type Required Example Description
type String Yes - For header: image; for body: text; for button URL: text; for COPY_CODE: coupon_code
sub_type String No - Button type when component type=button: URL, COPY_CODE
text String No - Required when type=text
image JsonObject No - Required when type=image
coupon_code String No - Required when type=coupon_code
  • image object:
Parameter Type Required Example Description
link String Yes - Image URL (HTTP/HTTPS)
  • component additional:
Parameter Type Required Example Description
index int No - Required when type=button and sub_type=URL with variables in URL; must match template position

Request Examples

Template Message Example

Template Message 1 (template variables) template-1

{
    "tenant_id" : 1,
    "appkey": "f543ertg",
    "business_phone": "185xxxx8399",
    "messaging_product": "whatsapp",
    "recipient_type": "individual",
    "to": "86136xxxx9759",
    "type": "template",
    "template": {
        "name": "text_template",
        "language": {
            "code": "en_US",
            "policy": "deterministic"
        },
        "components": [
            {
                "type": "header",
                "parameters": [
                    {
                        "type": "image",
                        "image": {
                            "link": "https://imglink"
                        }
                    }
                ]
            },
            {
                "type": "body",
                "parameters": [
                    {"type": "text", "text": "David"},
                    {"type": "text", "text": "China"}
                ]
            }
        ]
    }
}

Template Message 2 (button variables) template-2

{
    "tenant_id": 1,
    "appkey": "f543ertg",
    "business_phone": "185xxxx8399",
    "messaging_product": "whatsapp",
    "recipient_type": "individual",
    "to": "86136xxxx9759",
    "type": "template",
    "template": {
        "name": "test_00045",
        "language": {
            "code": "pt_BR",
            "policy": "deterministic"
        },
        "components": [
            {
                "type": "button",
                "sub_type": "url",
                "index": 0,
                "parameters": [
                    {
                        "type": "text",
                        "text": "85xxxx"
                    }
                ]
            },
            {
                "type": "button",
                "sub_type": "url",
                "index": 1,
                "parameters": [
                    {
                        "type": "text",
                        "text": "Firstxxxx"
                    }
                ]
            }
        ]
    }
}

Template Message 3

{
  "tenant_id": 123,
  "appkey": "8exxxxyos",
  "business_phone": "852xxxx867",
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "86136xxxx759",
  "type": "template",
  "template": {
    "name": "template_name",
    "language": {
      "code": "en_US",
      "policy": "deterministic"
    },
    "components": [
      {
        "type": "body",
        "parameters": [
          {
            "type": "text",
            "text": "David"
          },
          {
            "type": "text",
            "text": "China"
          },
          {
            "type": "text",
            "text": "China"
          },
          {
            "type": "text",
            "text": "86138XXX"
          }
        ]
      }
    ]
  }
}

Response Parameters

Parameter Type Description
code Integer Result code
data JsonObject Result data
message String Message
traceId String Trace ID

data object

Parameter Type Description
message_id String Message ID

Response Example

{
    "code": 0,
    "message": "",
    "data": {
        "message_id": "wamid.edcf691d49c04b939c8e3331f07f9cd1"
    },
    "traceId": "xxxx"
}

Response Codes

code message solution
0 Success -
-1 Failure Contact support
1000~100X Authentication failed See authentication section
21058 Parameter error tenant_id required
21059 Parameter error app_key required
21060 Parameter error business_phone required
21061 Parameter error to (recipient) required
21062 Parameter error type required, allowed [template]
21063 Parameter error template required
22020 Business error Customer does not exist
22041 Business error Cloud platform send failed
22042 Business error WhatsApp send failed
22049 Business error business_phone={0} not found
22089 Business error Number unavailable (No Core App)
22090 Business error Invalid number
22091 Business error Not a WhatsApp user
22092 Business error Language pack not found: {0}
22093 Business error Template not found
22123 Business error Recipient phone error
22124 Business error App does not exist / unavailable
22122 Business error No country price for the app
22125 Business error Insufficient balance
22126 Business error WhatsApp number not bound to app
22141 Business error WhatsApp send failed, see message field
23025 Business error Template not found or low quality

Language Codes

Language Code Language Code Language Code
Afrikaans af Greek el Portuguese (BR) pt_BR
Albanian sq Gujarati gu Portuguese (POR) pt_PT
Arabic ar Hebrew he Punjabi pa
Azerbaijani az Hindi hi Romanian ro
Bengali bn Hungarian hu Russian ru
Bulgarian bg Indonesian id Serbian sr
Catalan ca Irish ga Slovak sk
Chinese (CHN) zh_CN Italian it Slovenian sl
Chinese (HKG) zh_HK Japanese ja Spanish es
Chinese (TAI) zh_TW Kannada kn Spanish (ARG) es_AR
Croatian hr Kazakh kk Spanish (SPA) es_ES
Czech cs Korean ko Spanish (MEX) es_MX
Danish da Lao lo Swahili sw
Dutch nl Latvian lv Swedish sv
English en Lithuanian lt Tamil ta
English (UK) en_GB Macedonian mk Telugu te
English (US) en_US Malay ms Thai th
Estonian et Marathi mr Turkish tr
Filipino fil Norwegian nb Ukrainian uk
Finnish fi Persian fa Urdu ur
French fr Polish pl Uzbek uz
German de Vietnamese vi - -