### Get Account Balance Source: https://docs.ycloud.com/reference/authentication This example demonstrates how to retrieve your account balance using an API key. The API key should be included in the `X-API-Key` header. ```APIDOC ## GET /v2/balance ### Description Retrieves the account balance. ### Method GET ### Endpoint /v2/balance ### Parameters #### Headers - **X-API-Key** (string) - Required - Your API key for authentication. ### Request Example ```http GET /v2/balance HTTP/1.1 Host: api.ycloud.com X-API-Key: YOUR_API_KEY ``` ### Response #### Success Response (200) - **amount** (number) - The available balance. - **currency** (string) - The currency of the balance. #### Response Example ```json { "amount": 190.07658, "currency": "USD" } ``` #### Error Response (401) - **error** (object) - Contains error details. - **status** (number) - The HTTP status code (401). - **code** (string) - The error code (e.g., "UNAUTHORIZED"). - **message** (string) - A human-readable error message (e.g., "INVALID_API_KEY"). - **requestId** (string) - A unique identifier for the request. #### Response Example ```json { "error": { "status": 401, "code": "UNAUTHORIZED", "message": "INVALID_API_KEY", "requestId": "req_1KjtKI80IKoaJNa6n6p" } } ``` ``` -------------------------------- ### WhatsApp Flow Navigation Response Example Source: https://docs.ycloud.com/reference/whatsapp-flow-endpoint-implementation-guide An example of a response that directs the user to the next screen with specific data, such as user details and selections. ```json { "screen": "NEXT_SCREEN", "data": { "user_name": "John Doe", "selected_option": "premium_plan", "total_amount": 99.99 } } ``` -------------------------------- ### Start a verification Source: https://docs.ycloud.com/reference/verification-send Starts a verification by sending an SMS, voice, or email message to the recipient. This verification is charged once the message is sent successfully. ```APIDOC ## POST /verify/verifications ### Description Starts a verification by sending an SMS, voice, or email message to the recipient. This verification is charged once the message is sent successfully. ### Method POST ### Endpoint /verify/verifications ### Request Body - **VerificationSendRequest** (object) - Required - Verification request that needs to be sent. ### Request Example { "example": "{\"to\": \"+16315551111\", \"channel\": \"sms\"}" } ### Response #### Success Response (200) - **Verification** (object) - The request is successfully accepted. #### Response Example { "example": "{\"id\": \"ve6j7n8i\", \"status\": \"pending\", \"to\": \"+16315551111\", \"channel\": \"sms\", \"sendTime\": \"2022-06-01T12:00:00.000Z\", \"totalPrice\": 0.0085, \"currency\": \"USD\"}" } ``` -------------------------------- ### Example Signed Payload String Source: https://docs.ycloud.com/reference/configure-webhooks This example shows the format of the signed payload string, which is a concatenation of the timestamp, a dot, and the JSON payload. ```shell 1654084800.{"id":"evt_eEVCy8eNqD9EvcFI","type":"whatsapp.message.updated","apiVersion":"v2","createTime":"2023-02-22T12:00:00.000Z","whatsappMessage":{"id":"63f5d602367ea403f8175a6c","wamid":"wamid.BgNODYxN...","status":"failed","errorCode":"100","errorMessage":"Parameter Invalid","whatsappApiError":{"message":"(#100) Invalid parameter","type":"OAuthException","code":"100","fbtrace_id":"AwmiSOCojlAkqvjCTjGt37r","error_data":{"messaging_product":"whatsapp","details":"Parameter Invalid"}},"totalPrice":0,"currency":"USD","bizType":"whatsapp"}} ``` -------------------------------- ### SDP Offer Example for WhatsApp Call Source: https://docs.ycloud.com/reference/whatsapp_call-accept This is an example of a Session Description Protocol (SDP) offer used in initiating a WhatsApp call. It includes details about media types, codecs, and network information. ```sdp v=0 o=- 2239925877841361960 2 IN IP4 127.0.0.1 s=- t=0 0 a=group:BUNDLE audio a=msid-semantic: WMS 0ed5100f-da68-4193-8865-146c1ac7a087 m=audio 9 UDP/TLS/RTP/SAVPF 111 126 c=IN IP4 0.0.0.0 a=rtcp:9 IN IP4 0.0.0.0 a=ice-ufrag:NCH6 a=ice-pwd:ogUYxqJDPNn0C5RFif6UlLz6 a=ice-options:trickle a=fingerprint:sha-256 5B:95:C4:E4:8B:2B:06:B6:DB:FB:2C:08:2F:FD:3B:C7:9C:8D:84:4C:97:8D:84:AC:B2:93:32:B8:20:5C:3C:85 a=setup:active a=mid:audio a=sendrecv a=msid:0ed5100f-da68-4193-8865-146c1ac7a087 bc955459-4bae-4504-99c8-348944c12b6f a=rtcp-mux a=rtpmap:111 opus/48000/2 a=rtcp-fb:111 transport-cc a=fmtp:111 minptime=10;useinbandfec=1 a=rtpmap:126 telephone-event/8000 a=ssrc:436995058 cname:BIzAP4IgR06SrZ1S ``` -------------------------------- ### WhatsApp Template Archived Webhook Example Source: https://docs.ycloud.com/reference/whatsapp-template-reviewed-webhook-examples This example demonstrates the webhook payload received when a WhatsApp template is archived. Archived templates cannot be sent or edited. ```shell curl 'https://YOUR-WEBHOOK-ENDPOINT-URL' \ -H 'Content-Type: application/json' \ -d '{ "id": "evt_eEMtA0PkkyACiS5o", "type": "whatsapp.template.reviewed", "apiVersion": "v2", "createTime": "2024-01-01T12:00:00.000Z", "whatsappTemplate": { "wabaId": "WABA-ID", "name": "template_name", "language": "en", "category": "MARKETING", "status": "ARCHIVED", "reason": "NONE", "statusUpdateEvent": "ARCHIVED" } }' ``` -------------------------------- ### Initiate WhatsApp Call Source: https://docs.ycloud.com/reference/whatsapp_call-connect This snippet demonstrates how to initiate a WhatsApp call. It includes an example of the SDP offer that needs to be sent. ```APIDOC ## Initiate WhatsApp Call ### Description Initiates a WhatsApp call by sending an SDP offer. ### Method POST ### Endpoint /v1/whatsapp/call/connect ### Request Body - **sdp_offer** (string) - Required - The SDP offer for the call. ### Request Example ```json { "sdp_offer": "v=0\r\no=- 4054442297240208280 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS 6c364341-f90d-48e6-b497-76e047e3c31a\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 63 9 0 8 13 110 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Dpsa\r\na=ice-pwd:oVuOd7HKhA8aWTvspLYACWJe\r\na=ice-options:trickle\r\na=fingerprint:sha-256 0A:A9:64:82:AD:D5:31:08:38:71:1C:C0:08:AA:CE:93:22:F4:17:2C:B6:F1:8F:F1:20:71:38:16:37:18:3F:FA\r\na=setup:actpass\r\na=mid:0\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=sendrecv\r\na=msid:6c364341-f90d-48e6-b497-76e047e3c31a fa42cdbe-8696-4ee8-bce0-0919d86a223f\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:111 opus/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=fmtp:111 minptime=10;useinbandfec=1\r\na=rtpmap:63 red/48000/2\r\na=fmtp:63 111/111\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:110 telephone-event/48000\r\na=rtpmap:126 telephone-event/8000\r\na=ssrc:3208712354 cname:bg/Ix8uTnsTsiMoe\r\na=ssrc:3208712354 msid:6c364341-f90d-48e6-b497-76e047e3c31a fa42cdbe-8696-4ee8-bce0-0919d86a223f\r\n" } ``` ### Response #### Success Response (200) - **wacid** (string) - The WhatsApp call ID associated with this calling operation. - **success** (boolean) - Indicates whether the calling operation was successful. #### Response Example ```json { "wacid": "wacid.HBgNNjI4MTM2MTkwNTEzMxUCABEYIDNENjg2OEMzNTFFRDkwRkUxRUE1RTgxNjY1NjJCQUJBHBgNNjI4MzEzODIwNTE1MBUCABUeAA==", "success": true } ``` ``` -------------------------------- ### WhatsApp Template Rejected Webhook Example Source: https://docs.ycloud.com/reference/whatsapp-template-reviewed-webhook-examples This example demonstrates the JSON payload received when a WhatsApp template is rejected. Use this to handle template rejection events in your webhook. ```shell curl 'https://YOUR-WEBHOOK-ENDPOINT-URL' \ -H 'Content-Type: application/json' \ -d '{ "id": "evt_eEMtA0PkkyACiS5o", "type": "whatsapp.template.reviewed", "apiVersion": "v2", "createTime": "2023-02-20T12:00:00.000Z", "whatsappTemplate": { "wabaId": "WABA-ID", "name": "template_name", "language": "en", "category": "MARKETING", "status": "REJECTED", "reason": "SCAM", "statusUpdateEvent": "REJECTED" } }' ``` -------------------------------- ### WhatsApp PMP Mode Webhook Example Source: https://docs.ycloud.com/reference/whatsapp-message-pricing-updates Example of a WhatsApp Message Updated webhook payload when per-message pricing (PMP) is applied. Note the absence of the 'conversation' object and the presence of 'pricingModel': 'PMP' and 'pricingType'. ```json { "id": "evt_djeIQXaQPQyUcRFi", "type": "whatsapp.message.updated", "apiVersion": "v2", "createTime": "2022-03-01T12:00:00.000Z", "whatsappMessage": { "id": "63f5d602367ea403f8175a6c", "wamid": "wamid.BgNODYxN...", "wabaId": "whatsapp-business-account-id", "from": "+447901614024", "to": "+447901614024", "status": "read", "type": "template", "template": { "name": "login_otp", "language": { "code": "862031", "policy": "deterministic" } }, "regionCode": "GB", "pricingCategory": "authentication_international", "pricingModel": "PMP", "pricingType": "regular", "totalPrice": 0.085, "currency": "USD", "createTime": "2022-03-01T12:00:00.000Z", "sendTime": "2022-03-01T12:00:01.000Z", "deliverTime": "2022-03-01T12:00:02.000Z", "readTime": "2022-03-01T12:00:02.000Z", "externalId": "ext_123456" } } ``` -------------------------------- ### Create a WhatsApp template Source: https://docs.ycloud.com/reference/examples Example for creating a WhatsApp template using the YCloud API. ```APIDOC ## POST https://api.ycloud.com/v2/whatsapp/templates ### Description Creates a new WhatsApp template. ### Method POST ### Endpoint https://api.ycloud.com/v2/whatsapp/templates ``` -------------------------------- ### Marketing Template with Video and Call To Action Buttons Source: https://docs.ycloud.com/reference/whatsapp-template-creation-examples This example demonstrates how to create a marketing template that includes a video in the header, text with a variable in the body, text in the footer, and two Call To Action buttons (one PHONE_NUMBER and one URL). ```APIDOC ## POST /v2/whatsapp/templates ### Description Creates a WhatsApp message template with video and Call To Action buttons. ### Method POST ### Endpoint https://api.ycloud.com/v2/whatsapp/templates ### Parameters #### Request Body - **wabaId** (string) - Required - The WhatsApp Business Account ID. - **name** (string) - Required - The name of the template. - **language** (string) - Required - The language of the template (e.g., "en_US"). - **category** (string) - Required - The category of the template (e.g., "MARKETING"). - **components** (array) - Required - An array of template components. - **type** (string) - Required - The type of component (e.g., "HEADER", "BODY", "FOOTER", "BUTTONS"). - **format** (string) - Required for HEADER type - The format of the header content (e.g., "VIDEO"). - **example** (object) - Required for HEADER and BODY types - Example content for the component. - **header_url** (array) - Example URL for video header. - **body_text** (array) - Example text for the body. - **text** (string) - Required for BODY and FOOTER types - The text content of the component. - **buttons** (array) - Required for BUTTONS type - An array of buttons. - **type** (string) - Required - The type of button (e.g., "URL", "PHONE_NUMBER"). - **text** (string) - Required - The text displayed on the button. - **url** (string) - Required for URL type - The URL to open. - **phone_number** (string) - Required for PHONE_NUMBER type - The phone number to call. ### Request Example ```json { "wabaId": "{{WABA-ID}}", "name": "marketing_friday_more", "language": "en_US", "category": "MARKETING", "components": [ { "type": "HEADER", "format": "VIDEO", "example": { "header_url": [ "https://oss-ycloud-publicread.oss-ap-southeast-1.aliyuncs.com/api-docs/sample/sample.mp4" ] } }, { "type": "BODY', "text": "Click the URL bellow to see more about {{1}} campaign.", "example": { "body_text": [ [ "The Friday" ] ] } }, { "type": "FOOTER", "text": "FOOTER-TEXT" }, { "type": "BUTTONS", "buttons": [ { "type": "URL", "text": "Visit website", "url": "https://www.youtube.com/watch?v={{1}}", "example": [ "https://www.youtube.com/watch?v=zvI4cVGWJhM" ] }, { "type": "PHONE_NUMBER", "text": "Call us", "phone_number": "+447901614024" } ] } ] } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "Template created successfully." } ``` ``` -------------------------------- ### Example YCloud-Signature Header Source: https://docs.ycloud.com/reference/configure-webhooks This is an example of the YCloud-Signature header format, which includes a Unix timestamp and an HMAC-SHA256 signature. ```shell YCloud-Signature: t=1654084800,s=8eb70f2acb056c2119acbee8fdd98a889021d9c268bc9ad248a4182c40e31119 ``` -------------------------------- ### Marketing template with image and Quick Reply buttons Source: https://docs.ycloud.com/reference/whatsapp-template-creation-examples This example demonstrates how to create a marketing template that includes an image in the header, text with one variable in the body, text in the footer, and two Quick Reply buttons. ```APIDOC ## POST /v2/whatsapp/templates ### Description Creates a new WhatsApp template. ### Method POST ### Endpoint https://api.ycloud.com/v2/whatsapp/templates ### Request Body - **wabaId** (string) - Required - The WhatsApp Business Account ID. - **name** (string) - Required - The name of the template. - **language** (string) - Required - The language of the template (e.g., "en_US"). - **category** (string) - Required - The category of the template (e.g., "MARKETING"). - **components** (array) - Required - An array of template components. - **type** (string) - Required - The type of component (e.g., "HEADER", "BODY", "FOOTER", "BUTTONS"). - **format** (string) - Optional - The format of the header component (e.g., "IMAGE", "VIDEO", "DOCUMENT", "TEXT"). - **text** (string) - Required for BODY and FOOTER components - The text content of the component. Variables are indicated by {{1}}, {{2}}, etc. - **example** (object) - Optional - Example data for the component. - **header_url** (array) - Required for IMAGE, VIDEO, DOCUMENT headers - An array of sample URLs for the header media. - **body_text** (array) - Required for BODY components with variables - An array of arrays, where each inner array contains sample variable values. - **buttons** (array) - Required for BUTTONS components - An array of button objects. - **type** (string) - Required - The type of button (e.g., "QUICK_REPLY", "URL", "PHONE"). - **text** (string) - Required for QUICK_REPLY buttons - The text displayed on the button. ### Request Example ```json { "wabaId": "{{WABA-ID}}", "name": "marketing_friday", "language": "en_US", "category": "MARKETING", "components": [ { "type": "HEADER", "format": "IMAGE", "example": { "header_url": [ "https://oss-ycloud-publicread.oss-ap-southeast-1.aliyuncs.com/api-docs/sample/sample.jpg" ] } }, { "type": "BODY", "text": "Hi {{1}}, The Black Friday is coming!", "example": { "body_text": [ [ "Joe" ] ] } }, { "type": "FOOTER", "text": "FOOTER-TEXT" }, { "type": "BUTTONS", "buttons": [ { "type": "QUICK_REPLY", "text": "Learn more" }, { "type": "QUICK_REPLY", "text": "Unsubscribe" } ] } ] } ``` ### Notes on Components: * **HEADER format**: Can be `TEXT`, `IMAGE`, `VIDEO`, or `DOCUMENT`. For `TEXT`, use `example.header_text`. For media formats, use `example.header_url` with valid URLs ending in `.jpg`, `.jpeg`, `.png` (for images, max 5MB), `.mp4` (for videos, max 16MB), or `.pdf` (for documents, max 100MB). * **FOOTER**: Supports only text; variables are not supported. * **BUTTONS**: Templates can have up to 10 buttons in total. Quick reply buttons are text-only. If mixing button types, ensure correct grouping (e.g., Quick Reply, Quick Reply, URL, Phone). Invalid groupings like Quick Reply, URL, Quick Reply will result in an error. * If a template has more than three buttons, two will appear initially, with a "See all options" button revealing the rest. ``` -------------------------------- ### WhatsApp Flow Validation Error Response Example Source: https://docs.ycloud.com/reference/whatsapp-flow-endpoint-implementation-guide An example of a response to indicate validation errors to the user, prompting them to correct their input. ```json { "screen": "CURRENT_SCREEN", "data": { "error_message": "Please check your input and try again" } } ``` -------------------------------- ### Create Checkout Button Template Source: https://docs.ycloud.com/reference/whatsapp-template-creation-examples This example demonstrates how to create a marketing template with a checkout button and quick reply options. It supports image headers, variable body text, and footers. ```shell curl 'https://api.ycloud.com/v2/whatsapp/templates' \ -H 'Content-Type: application/json' \ -H 'X-API-Key: {{YOUR-API-KEY}}' \ -d '{ "wabaId": "{{WABA-ID}}", "name": "item_back_in_stock_v1", "language": "en_US", "category": "MARKETING", "components": [ { "type": "header", "format": "image", "example": { "header_url": [ "https://oss-ycloud-publicread.oss-ap-southeast-1.aliyuncs.com/api-docs/sample/sample.jpg" ] } }, { "type": "body", "text": "Hi {{1}}! The {{2}} is back in stock! Order now before it\'s gone!", "example": { "body_text": [ [ "Pablo", "Blue Elf Aloe" ] ] } }, { "type": "footer", "text": "Tap \'Stop\' below to stop back-in-stock reminders." }, { "type": "buttons", "buttons": [ { "type": "order_details", "text": "Buy now" }, { "type": "quick_reply", "text": "Stop" } ] } ] }' ``` -------------------------------- ### Create WhatsApp Marketing Template with Image and Quick Reply Source: https://docs.ycloud.com/reference/whatsapp-template-creation-examples Use this shell command to create a marketing template with an image header, a variable body, a footer, and two Quick Reply buttons. Ensure you replace placeholders like {{YOUR-API-KEY}} and {{WABA-ID}} with your actual credentials. ```shell curl 'https://api.ycloud.com/v2/whatsapp/templates' \ -H 'Content-Type: application/json' \ -H 'X-API-Key: {{YOUR-API-KEY}}' \ -d '{ "wabaId": "{{WABA-ID}}", "name": "marketing_friday", "language": "en_US", "category": "MARKETING", "components": [ { "type": "HEADER", "format": "IMAGE", "example": { "header_url": [ "https://oss-ycloud-publicread.oss-ap-southeast-1.aliyuncs.com/api-docs/sample/sample.jpg" ] } }, { "type": "BODY", "text": "Hi {{1}}, The Black Friday is coming!", "example": { "body_text": [ [ "Joe" ] ] } }, { "type": "FOOTER", "text": "FOOTER-TEXT" }, { "type": "BUTTONS", "buttons": [ { "type": "QUICK_REPLY", "text": "Learn more" }, { "type": "QUICK_REPLY", "text": "Unsubscribe" } ] } ]' } ``` -------------------------------- ### Create WhatsApp Marketing Template with Video and CTA Buttons Source: https://docs.ycloud.com/reference/whatsapp-template-creation-examples Use this `curl` command to create a WhatsApp marketing template. It includes a video header, a body with a variable, a footer, and both a URL and a phone number button. Ensure you replace placeholders like {{YOUR-API-KEY}} and {{WABA-ID}} with your actual credentials. ```shell curl 'https://api.ycloud.com/v2/whatsapp/templates' \ -H 'Content-Type: application/json' \ -H 'X-API-Key: {{YOUR-API-KEY}}' \ -d '{ \ "wabaId": "{{WABA-ID}}", \ "name": "marketing_friday_more", \ "language": "en_US", \ "category": "MARKETING", \ "components": [ \ { \ "type": "HEADER", \ "format": "VIDEO", \ "example": { \ "header_url": [ \ "https://oss-ycloud-publicread.oss-ap-southeast-1.aliyuncs.com/api-docs/sample/sample.mp4" \ ] \ } \ }, \ { \ "type": "BODY", \ "text": "Click the URL bellow to see more about {{1}} campaign.", \ "example": { \ "body_text": [ \ [ \ "The Friday" \ ] \ ] \ } \ }, \ { \ "type": "FOOTER", \ "text": "FOOTER-TEXT" \ }, \ { \ "type": "BUTTONS", \ "buttons": [ \ { \ "type": "URL", \ "text": "Visit website", \ "url": "https://www.youtube.com/watch?v={{1}}", \ "example": [ \ "https://www.youtube.com/watch?v=zvI4cVGWJhM" \ ] \ }, \ { \ "type": "PHONE_NUMBER", \ "text": "Call us", \ "phone_number": "+447901614024" \ } \ ] \ } \ ] \ }' ``` -------------------------------- ### Create WhatsApp Limited-Time Offer Template Source: https://docs.ycloud.com/reference/whatsapp-template-creation-examples This example demonstrates creating a MARKETING template for limited-time offers. It includes an image header, an expiration timer, body text with variables, and two buttons: one for copying a code and another for a URL. Footer components are not supported for this template type. ```shell curl 'https://api.ycloud.com/v2/whatsapp/templates' \ -H 'Content-Type: application/json' \ -H 'X-API-Key: {{YOUR-API-KEY}}' \ -d '{ "wabaId": "{{WABA-ID}}", "name": "limited_time_offer_caribbean_pkg_2023", "language": "en_US", "category": "MARKETING", "components": [ { "type": "HEADER", "format": "IMAGE", "example": { "header_url": [ "https://oss-ycloud-publicread.oss-ap-southeast-1.aliyuncs.com/api-docs/sample/sample.jpg" ] } }, { "type": "LIMITED_TIME_OFFER", "limited_time_offer": { "text": "Expiring offer!", "has_expiration": true } }, { "type": "BODY', "text": "Good news, {{1}}! Use code {{2}} to get 25% off all Caribbean Destination packages!", "example": { "body_text": [ [ "Pablo", "CARIBE25" ] ] } }, { "type": "BUTTONS", "buttons": [ { "type": "COPY_CODE", "example": [ "CARIBE25" ] }, { "type": "URL", "text": "Book now!", "url": "https://awesomedestinations.com/offers?code={{1}}", "example": [ "https://awesomedestinations.com/offers?ref=n3mtql" ] } ] } ] }' ``` -------------------------------- ### WhatsApp Template Paused Webhook Example Source: https://docs.ycloud.com/reference/whatsapp-template-reviewed-webhook-examples This example shows the JSON payload for a WhatsApp template that has been paused. Implement this to manage paused template notifications in your webhook. ```shell curl 'https://YOUR-WEBHOOK-ENDPOINT-URL' \ -H 'Content-Type: application/json' \ -d '{ "id": "evt_eEMtA0PkkyACiS5o", "type": "whatsapp.template.reviewed", "apiVersion": "v2", "createTime": "2023-02-20T12:00:00.000Z", "whatsappTemplate": { "wabaId": "WABA-ID", "name": "template_name", "language": "en", "category": "MARKETING", "status": "PAUSED", "reason": "NONE", "statusUpdateEvent": "PAUSED" } }' ``` -------------------------------- ### Create WhatsApp Marketing Template with GIF Header Source: https://docs.ycloud.com/reference/whatsapp-template-creation-examples This example shows how to create a marketing template that includes a GIF in the header. The `header_url` should point to the publicly accessible URL of your GIF file. ```shell curl 'https://api.ycloud.com/v2/whatsapp/templates' \ -H 'Content-Type: application/json' \ -H 'X-API-Key: {{YOUR-API-KEY}}' \ -d '{ "wabaId": "{{WABA-ID}}", "name": "marketing_friday_more", "language": "en_US", "category": "MARKETING", "components": [ { "type": "HEADER", "format": "GIF", "example": { "header_url": [ "https://oss-ycloud-publicread.oss-ap-southeast-1.aliyuncs.com/api-docs/sample/sample.mp4" ] } }, { "type": "BODY", "text": "hello" } ] }' ``` -------------------------------- ### Contact Attributes Changed Webhook: General Change Example Source: https://docs.ycloud.com/reference/contact-attributes-changed-webhook-examples This example illustrates a change to a standard contact attribute, such as 'waba_id'. It shows the old and new values. ```json { "id": "evt_1234567900", "type": "contact.attributes_changed", "apiVersion": "v2", "createTime": "2024-01-01T12:00:00.000Z", "contactAttributesChanged": { "id": "1824266594102064128", "updateTime": "2024-01-01T12:00:00.000Z", "changedAttributes": { "waba_id": { "oldValue": "waba_old_123456", "newValue": "waba_new_789012", "extra": [ { "action": "CHANGED" } ] } } } } ``` -------------------------------- ### Handle WhatsApp Inbound Welcome Message Webhook Source: https://docs.ycloud.com/reference/whatsapp-inbound-message-webhook-examples This example shows the structure of a `request_welcome` webhook payload. It is triggered when a user initiates a chat for the first time. You can use this to send a custom welcome message. ```shell curl 'https://YOUR-WEBHOOK-ENDPOINT-URL' \ -H 'Content-Type: application/json' \ -d '{ "id": "evt_eF6mVJUj5OWfKXMD", "type": "whatsapp.inbound_message.received", "apiVersion": "v2", "createTime": "2023-02-22T12:00:00.000Z", "whatsappInboundMessage": { "id": "63f71fb8741c165b434292fb", "wamid": "wamid.HBgNOD...", "wabaId": "WABA-ID", "from": "CUSTOMER-PHONE-NUMBER", "fromUserId" : "US.13491208655302741918", "fromParentUserId": "US.11815799212886844830", "customerProfile": { "name": "Joe", "username": "@JoeJoe" }, "to": "BUSINESS-PHONE-NUMBER", "sendTime": "2023-02-22T12:00:00.000Z", "type": "request_welcome" } }' ``` -------------------------------- ### Contact Attributes Changed Webhook: Remove Tags Example Source: https://docs.ycloud.com/reference/contact-attributes-changed-webhook-examples This example shows the payload when tags are removed from a contact. The 'extra' field indicates the 'REMOVED' tag. ```json { "id": "evt_1234567893", "type": "contact.attributes_changed", "apiVersion": "v2", "createTime": "2024-01-01T12:00:00.000Z", "contactAttributesChanged": { "id": "1824266594102064128", "updateTime": "2024-01-01T12:00:00.000Z", "changedAttributes": { "tags": { "oldValue": ["premium", "newsletter", "vip"], "newValue": ["premium", "newsletter"], "extra": [ { "action": "REMOVED", "id": "686dd294334be8606a5bf312", "value": "vip" } ] } } } } ``` -------------------------------- ### Marketing Template with GIF Header Source: https://docs.ycloud.com/reference/whatsapp-template-creation-examples This example shows how to create a marketing template that includes a GIF in the header. This is useful for visually engaging campaigns. ```APIDOC ## POST /v2/whatsapp/templates ### Description Creates a new WhatsApp template with a media header. ### Method POST ### Endpoint /v2/whatsapp/templates ### Request Body - **wabaId** (string) - Required - The WhatsApp Business Account ID. - **name** (string) - Required - The name of the template. - **language** (string) - Required - The language of the template (e.g., "en_US"). - **category** (string) - Required - The category of the template (e.g., "MARKETING"). - **components** (array) - Required - An array of template components. - **type** (string) - Required - The type of component (e.g., "HEADER", "BODY"). - **format** (string) - Required (if type is HEADER) - The format of the header media (e.g., "GIF", "IMAGE", "VIDEO"). - **example** (object) - Required (if type is HEADER) - Example media for the header. - **header_url** (array) - Required - An array containing the URL of the header media. - **text** (string) - Required (if type is BODY) - The text content of the body. ### Request Example ```json { "wabaId": "{{WABA-ID}}", "name": "marketing_friday_more", "language": "en_US", "category": "MARKETING", "components": [ { "type": "HEADER", "format": "GIF", "example": { "header_url": [ "https://oss-ycloud-publicread.oss-ap-southeast-1.aliyuncs.com/api-docs/sample/sample.mp4" ] } }, { "type": "BODY", "text": "hello" } ] } ``` ``` -------------------------------- ### Contact Attributes Changed Webhook: Add Tags Example Source: https://docs.ycloud.com/reference/contact-attributes-changed-webhook-examples This example demonstrates the payload structure when tags are added to a contact. The 'extra' field details the 'ADDED' tag. ```json { "id": "evt_1234567892", "type": "contact.attributes_changed", "apiVersion": "v2", "createTime": "2024-01-01T12:00:00.000Z", "contactAttributesChanged": { "id": "1824266594102064128", "updateTime": "2024-01-01T12:00:00.000Z", "changedAttributes": { "tags": { "oldValue": ["premium", "newsletter"], "newValue": ["premium", "newsletter", "vip"], "extra": [ { "action": "ADDED", "id": "686dd294334be8606a5bf312", "value": "vip" } ] } } } } ``` -------------------------------- ### WhatsApp CBP Mode Webhook Example Source: https://docs.ycloud.com/reference/whatsapp-message-pricing-updates Example of a WhatsApp Message Updated webhook payload when conversation-based pricing (CBP) is applied. Note the presence of the 'conversation' object and 'pricingModel': 'CBP'. ```json { "id": "evt_djeIQXaQPQyUcRFi", "type": "whatsapp.message.updated", "apiVersion": "v2", "createTime": "2022-03-01T12:00:00.000Z", "whatsappMessage": { "id": "63f5d602367ea403f8175a6c", "wamid": "wamid.BgNODYxN...", "wabaId": "whatsapp-business-account-id", "from": "+447901614024", "to": "+447901614024", "status": "read", "type": "template", "template": { "name": "login_otp", "language": { "code": "862031", "policy": "deterministic" } }, "conversation": { "id": "8078ed05301c40a08d3d1845c94ca18b", "type": "REGULAR", "originType": "authentication", "expireTime": "2022-03-02T12:00:00.000Z" }, "regionCode": "GB", "pricingCategory": "authentication_international", "pricingModel": "CBP", "totalPrice": 0.085, "currency": "USD", "createTime": "2022-03-01T12:00:00.000Z", "sendTime": "2022-03-01T12:00:01.000Z", "deliverTime": "2022-03-01T12:00:02.000Z", "readTime": "2022-03-01T12:00:02.000Z", "externalId": "ext_123456" } } ``` -------------------------------- ### Create Coupon Template Source: https://docs.ycloud.com/reference/whatsapp-template-creation-examples This example demonstrates how to create a coupon template using the WhatsApp API. The template includes a body with two variables and a copy code button. ```APIDOC ## POST /v2/whatsapp/templates ### Description Creates a new WhatsApp template. This specific example focuses on a 'MARKETING' category template designed for coupon codes, featuring a copy code button. ### Method POST ### Endpoint /v2/whatsapp/templates ### Parameters #### Request Body - **wabaId** (string) - Required - The WhatsApp Business Account ID. - **name** (string) - Required - The name of the template (e.g., "marketing_coupon"). - **language** (string) - Required - The language of the template (e.g., "en_US"). - **category** (string) - Required - The category of the template (e.g., "MARKETING"). - **components** (array) - Required - An array of template components. - **type** (string) - Required - The type of component (e.g., "BODY", "BUTTONS"). - **text** (string) - Required (for BODY type) - The text content of the body, including variables like {{1}}, {{2}}. - **example** (object) - Optional (for BODY type) - Example values for body variables. - **body_text** (array) - Required if text contains variables - An array of arrays, where each inner array contains example values for the variables in the body text. - **buttons** (array) - Required (for BUTTONS type) - An array of button configurations. - **type** (string) - Required - The type of button (e.g., "COPY_CODE"). - **example** (array) - Required (for COPY_CODE type) - An example of the text string to be copied. ### Request Example ```json { "wabaId": "{{WABA-ID}}", "name": "marketing_coupon", "language": "en_US", "category": "MARKETING", "components": [ { "type": "BODY", "text": "🎉Hi {{1}}, Welcome to our shop!\n🥰I'\''ve been waiting for so long. \n\nThis is your coupon code:\n*{{2}}*\n\nNote that this coupon will expire after 24 hours. \nPlease copy the code via the copy button below. ↓", "example": { "body_text": [ [ "Mike", "12312393" ] ] } }, { "type": "BUTTONS", "buttons": [ { "type": "COPY_CODE", "example": [ "12312393" ] } ] } ] } ``` ### Response #### Success Response (200) (Response structure not explicitly defined in the source, but typically includes confirmation of template creation.) #### Response Example (No example provided in the source.) ### Notes - Copy code buttons copy a text string to the device's clipboard. Templates are limited to one copy code button. - Button text is pre-set and cannot be customized. - Refer to sending a [coupon template message](https://docs.ycloud.com/reference/whatsapp-messaging-examples#coupon-template-message) for related information. ``` -------------------------------- ### Contact Unsubscribe Created Example Source: https://docs.ycloud.com/reference/contact-unsubscribe-created-webhook-examples This example demonstrates the JSON payload structure for the contact.unsubscribe.created webhook event. It includes details about the event, the API version, creation time, and information about the unsubscriber. ```APIDOC ## Contact Unsubscribe Created Example ### Description This example demonstrates the JSON payload structure for the `contact.unsubscribe.created` webhook event. It includes details about the event, the API version, creation time, and information about the unsubscriber. ### Event Payload ```json { "id": "evt_68f8886903683f3481f9707b", "type": "contact.unsubscribe.created", "apiVersion": "v2", "createTime": "2025-10-22T07:31:53.872Z", "unsubscriberChanged": { "id": "68f888692abba5779b565928", "phoneNumber": "+8615166662222", "source": "API", "updateTime": "2025-10-22T07:31:53.864Z" } } ``` ### Notes * The `unsubscriberChanged` object contains the user's mobile phone number information and the unsubscribe time. ```