### Example Request to Get RSA Public Key Source: https://developers.zalo.me/docs/zbs-template-message/gui-tin-template-qua-sdt/api-gui-tin-qua-sdt/api-gui-tin-voi-he-ma-hoa-rsa This example demonstrates how to retrieve the existing RSA public key using a GET request. The access token is required for authentication. ```bash curl -X GET -H "Content-Type: application/json" -d "https://business.openapi.zalo.me/rsa/key/get" ``` -------------------------------- ### Example Request Source: https://developers.zalo.me/docs/zbs-template-message/quan-ly-template/template-api/api-lay-thong-tin-danh-gia-cua-khach-hang This example demonstrates how to make a GET request to retrieve customer rating information for a specific template within a given time range. Ensure you have the necessary 'Manage Message Template' permission. ```curl curl -X GET -H "Content-Type: application/json" "https://business.openapi.zalo.me/rating/get?template_id=203972&from_time=1616673095659&to_time=1616673271320&offset=0&limit=1" ``` -------------------------------- ### Example Request to Generate RSA Public Key Source: https://developers.zalo.me/docs/zbs-template-message/gui-tin-template-qua-sdt/api-gui-tin-qua-sdt/api-gui-tin-voi-he-ma-hoa-rsa This example shows how to make a GET request to the API endpoint for generating an RSA key pair. Ensure you include the necessary access token in the header. ```bash curl -X GET -H "Content-Type: application/json" -d "https://business.openapi.zalo.me/rsa/key/gen" ``` -------------------------------- ### Example GET Request Source: https://developers.zalo.me/docs/zbs-template-message/quan-ly-template/template-api/api-lay-du-lieu-mau-cua-template This snippet shows how to make a GET request to the API to retrieve sample data for a specific template ID. ```curl curl \ -X GET \ -H "Content-Type: application/json" \ "https://business.openapi.zalo.me/template/sample-data?template_id=12345" ``` -------------------------------- ### Example Request Source: https://developers.zalo.me/docs/zalo-notification-service/truy-xuat-thong-tin/lay-thong-tin-quota-zns This is an example of an HTTP GET request to retrieve ZNS quota information. Ensure you include the 'access_token' in the header for authentication. ```curl curl \ -X GET \ -H "Content-Type: application/json" "https://business.openapi.zalo.me/message/quota" ``` -------------------------------- ### Example Response Source: https://developers.zalo.me/docs/zbs-template-message/quan-ly-template/template-api/api-lay-du-lieu-mau-cua-template This is an example of a successful response from the API, containing sample data for the requested template. ```json { "message": "Success", "data": { "balance_debt": 2000, "due_date": "01/01/1970", "number_debt": 2000, "customer_name": "customer_name_sample" }, "error": 0 } ``` -------------------------------- ### Original Header Example Source: https://developers.zalo.me/docs/social-api/tham-khao/dpop This is an example of the original header structure before normalization. ```json { "typ": "dpop+jwt", "alg": "RS256", "jwk": { "alg": "RS256", "kty": "RSA", "n": "wFs8GqrXoKw8wog-D3UlporwN0RpQa5NcPdteJ_fFpZROvPrn3nKrqJut8S6f_W75WozWslmZZCSsqkYNWli87GXZoPLeyEBYqxgIRFNmJQN-dYz6uF95XSPtbn1tdSBYjzgZpBKpYXaOesaL2ZOeh2h_n1fzt8I47PEpLoKafuW8IhYk9WY6y04ZhMWFfDptbGlCJ8QeHaj_Tm1kCSgEvWgt4Z9JRWNsfQjk9atqiRP9ceU_bqk_i3AK5MqFmiXqyiVn-EV2E0O_KxG6389HelpzibIdUSnHKpEfhHyyJy2wrnFVvyu02VoUaixZLuj5nZQOJsdrkOGoxy9ggqtDw", "e": "AQAB" } } ``` -------------------------------- ### Original Payload Example Source: https://developers.zalo.me/docs/social-api/tham-khao/dpop This is an example of the original payload structure before normalization. ```json { "htu": "https://oauth.zaloapp.com/v4/access_token", "htm": "POST", "iat": 1751877103 } ``` -------------------------------- ### Example Request Source: https://developers.zalo.me/docs/zbs-template-message/gui-tin-template-qua-sdt/api-truy-xuat-thong-tin-gui-tin-qua-sdt/api-lay-thong-tin-trang-thai-gui-tin-qua-sdt This snippet shows how to make a GET request to the API to retrieve message status. Ensure you replace 'message_id' and 'phone' with actual values. ```curl curl -X GET -H "Content-Type: application/json" "https://business.openapi.zalo.me/message/status?message_id=message_id&phone=phone" ``` -------------------------------- ### Example Request Data for Template Source: https://developers.zalo.me/docs/zalo-notification-service/quan-ly-tai-san/chinh-sua-template Example of data structure for a template, including a date field with a sample value and a note for moderation. ```json { "name": "date", "sample_value": "19/01/1999" } ], "note": "ghi chú kiểm duyệt", "tracking_id": "abc123" } ``` -------------------------------- ### Example Response Source: https://developers.zalo.me/docs/zalo-notification-service/truy-xuat-thong-tin/lay-thong-tin-quota-zns This is an example of a successful response from the ZNS quota API. It details the daily quota, remaining quota, and promotional quota information. ```json { "data": { "dailyQuota": 500, "remainingQuota": 499, "dailyQuotaPromotion": null, "remainingQuotaPromotion": null, "monthlyPromotionQuota": 125, "remainingMonthlyPromotionQuota": 124, "estimatedNextMonthPromotionQuota" :2000 }, "error": 0, "message": "success" } ``` -------------------------------- ### Get List of Followers Source: https://developers.zalo.me/docs/sdk/dotnet-sdk/tai-lieu/official-account-api Retrieve a paginated list of users who follow your Official Account. This example fetches the first 20 followers starting from offset 0. ```csharp JObject result = client.getListFollower(0, 20); ``` -------------------------------- ### Initialize ZaloAppClient Source: https://developers.zalo.me/docs/sdk/dotnet-sdk/tai-lieu/social-api Instantiate ZaloAppClient with your application's credentials. Ensure you replace placeholders with your actual appId, secretKey, and callbackUrl. ```csharp ZaloAppInfo appInfo = new ZaloAppInfo(appId, "secretKey", "callbackUrl"); ZaloAppClient appClient = new ZaloAppClient(appInfo); ``` -------------------------------- ### app-config.json Configuration Example Source: https://developers.zalo.me/docs/official-account/extension/advanced/app-config-json This JSON file configures basic settings for an extension, including the application title, debug mode, and zone-specific configurations. It specifies which zones are enabled and, for admin zones, which roles have access. ```json { "app": { "title": "ProjectName" }, "debug": false, "zones": { "admin-dashboard-primary-area-block": { "enable": true }, "admin-profile-config-action": { "enable": true }, "user-profile-config-block": { "enable": true }, "admin-chat-message-profile-block": { "enable": true, "roles": [ "MANAGER", "MODERATOR" ] }, "admin-chat-message-toolbar-action": { "enable": true, "roles": [ "MANAGER", "MODERATOR" ] } }, "listCSS": [], "listSyncJS": [], "listAsyncJS": [] } ``` -------------------------------- ### Example GET Request for Template Info Source: https://developers.zalo.me/docs/zalo-notification-service/ngung-ho-tro/lay-thong-tin-chi-tiet-template-v1 This snippet shows how to make a GET request to the Zalo Business API to retrieve details for a specific template ID. ```curl curl \ -X GET \ -H "Content-Type: application/json" \ "https://business.openapi.zalo.me/template/info?template_id=12345" ``` -------------------------------- ### Example GET Request for Pending Members Source: https://developers.zalo.me/docs/official-account/nhom-chat-gmf/quan-ly/getlistpendingmember This snippet shows how to make a GET request to the listpendinginvite endpoint. Ensure you replace placeholders like and provide the necessary group_id. ```curl curl --request GET 'https://openapi.zalo.me/v3.0/oa/group/listpendinginvite?group_id=f414c8f76fa586fbdfb4&offset=0&count=5' \ --header 'access_token: ' ``` -------------------------------- ### Example HTTP GET Request for OA Information Source: https://developers.zalo.me/docs/official-account/quan-ly/quan-ly-thong-tin-oa/lay-thong-tin-zalo-official-account This snippet demonstrates how to make a GET request to the Zalo API endpoint to retrieve OA details. Ensure you include your access token in the header. ```curl curl \ -X GET \ -H 'access_token: ' \ "https://openapi.zalo.me/v2.0/oa/getoa" ``` -------------------------------- ### Initialize Zalo SDK and Handle Callbacks in AppDelegate Source: https://developers.zalo.me/docs/sdk/ios-sdk/tich-hop/xcode Initialize the Zalo SDK with your App ID in `application(_:didFinishLaunchingWithOptions:)` and handle Zalo callbacks in `application(_:open:options:)`. Ensure you have your Zalo App ID defined in `Constant.ZALO_APP_ID`. ```swift import UIKit import ZaloSDK @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { /// 0a. Init zalo sdk ZaloSDK.sharedInstance().initialize(withAppId: Constant.ZALO_APP_ID) return true } func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { /// 0b. Receive callback from zalo return ZDKApplicationDelegate.sharedInstance().application(app, open: url, options: options) } } ``` -------------------------------- ### Get Group Info Request Example Source: https://developers.zalo.me/docs/official-account/nhom-chat-gmf/quan-ly/get_group_info This snippet shows how to make a GET request to the Zalo API to retrieve information about a specific group. Ensure you have the necessary 'access_token' and the 'group_id' of the target group. ```curl curl --request GET 'https://openapi.zalo.me/v3.0/oa/group/getgroup?group_id=f414c8f76fa586fbdfb4' \ --header 'access_token: ' ``` -------------------------------- ### Example Response for User Information Fields Source: https://developers.zalo.me/docs/official-account/quan-ly/quan-ly-truong-thong-tin-nguoi-dung/lay-danh-sach-truong-thong-tin This is an example of the JSON response you will receive when successfully fetching user information fields. It includes details for both system and custom fields. ```json { "error": 0, "message": "success", "data": { "fields": [ { "key": "user_id", "name": "User ID", "description": "ID của KH trên hệ thống Zalo OA, mỗi KH sẽ có 1 ID duy nhất", "status": "active", "data_type": "id", "value_unique": true, "field_type": "system" }, { "key": "ten_hien_thi", "name": "Tên Hiển Thị", "description": "Tên hiển thị của người dùng", "status": "active", "data_type": "text", "value_unique": false, "field_type": "oa_custom" } ] } } ``` -------------------------------- ### Example Request to Get Agent and Branch Info Source: https://developers.zalo.me/docs/official-account/goi-thoai/tao-link-goi-thoai/lay-thong-tin-agent-branch This snippet shows how to make a GET request to the Zalo Official Account API to retrieve agent and branch information. Ensure you have the necessary access token. ```curl curl --location 'https://openapi.zalo.me/v3.0/oa/call/getmccinfo' \ --header 'access_token: ' \ --header 'Content-Type: application/json' ``` -------------------------------- ### Initialize Zalo SDK and Handle URL Callback Source: https://developers.zalo.me/docs/sdk/ios-sdk-196 Initialize the Zalo SDK with your App ID and handle incoming URLs from the Zalo app. This code should be placed in your AppDelegate. ```swift import UIKit import ZaloSDK @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any[]?) -> Bool { /// 0a. Init zalo sdk ZaloSDK.sharedInstance().initialize(withAppId: Constant.ZALO_APP_ID) return true } func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any[] = [:[]) -> Bool { /// 0b. Receive callback from zalo return ZDKApplicationDelegate.sharedInstance().application(app, open: url, options: options) } } ``` -------------------------------- ### Sample Request URL for Video Content Source: https://developers.zalo.me/docs/official-account/noi-dung/noi-dung-dang-video/lay-danh-sach-noi-dung-dang-video This is an example URL to fetch video content. Ensure you include necessary parameters like offset, limit, and type. ```http https://openapi.zalo.me/v2.0/article/getslice?offset=0&limit=5&type=video ``` -------------------------------- ### Create an Article with a Video Cover Source: https://developers.zalo.me/docs/official-account/noi-dung/noi-dung-dang-bai-viet Example of configuring a video as the cover for an article. The cover_view can be 'horizontal', 'vertical', or 'square'. ```json { "cover_type": "video", "cover_view": "horizontal", "video_id": "video_id", "status": "show" } ``` -------------------------------- ### Example GET Request for Template Info Source: https://developers.zalo.me/docs/zalo-notification-service/truy-xuat-thong-tin/lay-thong-tin-chi-tiet-template This snippet shows how to make a GET request to the /template/info/v2 endpoint to retrieve details for a specific template ID. Ensure you include your access token and the template_id in the query parameters. ```curl curl \ -X GET \ -H "Content-Type: application/json" \ "https://business.openapi.zalo.me/template/info/v2?template_id=12345" ``` -------------------------------- ### Cài đặt Zalo DotNet SDK trên Windows Source: https://developers.zalo.me/docs/sdk/dotnet-sdk/tai-lieu/bat-dau-nhanh Sử dụng lệnh Install-Package để cài đặt SDK trên hệ điều hành Windows. ```powershell Install-Package vng.zalo.ZaloDotNetSDK -Version 2.1.2 ``` -------------------------------- ### Example cURL Request to Get Messages Source: https://developers.zalo.me/docs/official-account/tin-nhan/quan-ly-tin-nhan/lay-thong-tin-tin-nhan-trong-mot-hoi-thoai Use this cURL command to make a GET request to retrieve messages from a conversation. Ensure you replace `` with your valid access token and adjust `user_id`, `offset`, and `count` as needed. ```bash curl -X GET -H 'access_token: ' 'https://openapi.zalo.me/v2.0/oa/conversation?data={"user_id":2512523625412515,"offset":0,"count":5}' ``` -------------------------------- ### Example Request to Get Zalo Form Data Source: https://developers.zalo.me/docs/official-account/quan-ly/quan-ly-form-zalo-ads/lay-noi-dung-form-zalo-ads Use this cURL command to make a GET request to retrieve form data. Ensure you replace placeholders with your actual access token, form ID, and time range. ```curl curl \ -X GET \ -H 'access_token: ' 'https://openapi.zalo.me/v2.0/oa/form/get?form_id=&from_time=1621137100&to_time=1623689999&offset=0&limit=200' ``` -------------------------------- ### Create Video Article Source: https://developers.zalo.me/docs/sdk/java-sdk/tai-lieu/article-api This snippet demonstrates how to create a video article. Ensure you provide a valid video ID and access token. ```java Map headers = new HashMap<>(); headers.put("access_token", access_token); JsonObject videoArticle = new JsonObject(); videoArticle.addProperty("type", "video"); videoArticle.addProperty("title", "article test"); videoArticle.addProperty("description", "description"); videoArticle.addProperty("video_id", "video_id"); videoArticle.addProperty("avatar", "https://developers.zalo.me/web/static/zalo.png"); videoArticle.addProperty("comment", "show"); JsonObject excuteRequest = client.excuteRequest("https://openapi.zalo.me/v2.0/article/create", "POST", null, videoArticle, headers, null); ``` -------------------------------- ### Example cURL Request to Get OA ZNS Quality Source: https://developers.zalo.me/docs/zalo-notification-service/truy-xuat-thong-tin/lay-thong-tin-chat-luong-gui-zns-hien-tai-cua-oa This snippet demonstrates how to make a GET request to the Zalo Business API to retrieve the current ZNS sending quality for an OA. Ensure you include the 'access_token' in the header for authentication. ```bash curl \ -X GET \ -H "Content-Type: application/json" "https://business.openapi.zalo.me/quality" ``` -------------------------------- ### Example Group Info Response Source: https://developers.zalo.me/docs/official-account/nhom-chat-gmf/quan-ly/get_group_info This is an example of the JSON response received after successfully querying group information. It includes details about the group, associated assets, and current settings. ```json { "data": { "group_info": { "group_id": "a57a91e562b78be9d2a6", "group_link": "https://zalo.me/g/zkfgeb641", "name": "b52", "group_description": "", "avatar": "http://s120.ava.grp.talk.zdn.vn/default", "status": "enabled", "total_member": 2, "max_member": "10", "auto_delete_date":"10/11/2024" }, "asset_info":{ "asset_type": "gmf10", "asset_id": "asset_id", "valid_through": "10/10/2024", "auto_renew": "true" }, "group_setting": { "lock_send_msg": false, "join_appr": true, "enable_msg_history": true, "enable_link_join": true } }, "error": 0, "message": "Success" } ``` -------------------------------- ### Check Journey Token HTTP Request Example Source: https://developers.zalo.me/docs/zalo-notification-service/gui-tin-zns/gui-zns-journey This cURL command demonstrates how to check the validity of a ZNS Journey Token by sending a GET request to the API. ```bash curl --location --request GET 'https://business.openapi.zalo.me/journey/check-token' \ --header 'Content-Type: application/json' \ --header 'access_token: access_token' \ --header 'journey_token: journey_token' ``` -------------------------------- ### Initialize ZaloClient Source: https://developers.zalo.me/docs/sdk/dotnet-sdk/tai-lieu/official-account-api Initializes the ZaloClient with an access token. ```APIDOC ## Initialize ZaloClient ### Description Initializes the ZaloClient with an access token. ### Code Example ```csharp ZaloClient client = new ZaloClient(access_token); ``` ``` -------------------------------- ### Example API Response for Template Details Source: https://developers.zalo.me/docs/zalo-notification-service/truy-xuat-thong-tin/lay-thong-tin-chi-tiet-template This is an example of a successful response when requesting template information. It includes details about the template's ID, name, status, parameters, buttons, and pricing. ```json { "error": 0, "message": "Success", "data": { "templateId": "12345", "templateName": "Test tạo mẫu tin từ trang admin - dạng bảng", "status": "ENABLE", "listParams": [ { "name": "payment_link", "require": true, "type": "STRING", "maxLength": 30, "minLength": 0, "acceptNull": false } ], "listButtons": [ { "type": 1, "title": "Truy cập website", "content": "https://zalo.cloud/zns" }, { "type": 2, "title": "Gọi CSKH", "content": "0858808xxxx" } ], "timeout": 7200000, "previewUrl": "https://account.zalo.cloud/znspreview/c1t6Wk43sxXTiLPyC__hXQ==", "templateQuality": "HIGH", "templateTag": "IN_TRANSACTION", "price_sdt": "800", "price_uid": "560", "price": "800" } } ``` -------------------------------- ### Callback URL with Authorization Code Source: https://developers.zalo.me/docs/social-api/tham-khao/user-access-token-v4 This example shows the structure of the HTTP GET request to your callback URL after a user grants permission, including the received authorization code and state. ```url https://yourdomain.com/abc?code=&state=xxxx&code_challenge=xxxx ``` -------------------------------- ### Cài đặt Zalo DotNet SDK trên Linux Source: https://developers.zalo.me/docs/sdk/dotnet-sdk/tai-lieu/bat-dau-nhanh Sử dụng lệnh Install-Package để cài đặt SDK trên hệ điều hành Linux. ```powershell Install-Package vng.zalo.ZaloDotNetSDK -Version 2.0.2 ``` -------------------------------- ### Get Current User Information Source: https://developers.zalo.me/docs/social-api/tai-lieu/tong-quan This example demonstrates how to retrieve information about the currently logged-in user using the Social API. It requires an access token and allows specifying desired fields. ```APIDOC ## GET /v2.0/me ### Description Retrieves information about the current user. ### Method GET ### Endpoint https://graph.zalo.me/v2.0/me ### Parameters #### Query Parameters - **accesstoken** (string) - Required - The access token for authentication. - **fields** (string) - Optional - A comma-separated list of fields to retrieve (e.g., `id,name,picture`). ### Request Example ```json { "example": "https://graph.zalo.me/v2.0/me?accesstoken={...}&fields=[...]" } ``` ### Response #### Success Response (200) - **id** (string) - The user's unique identifier. - **name** (string) - The user's name. - **picture** (string) - The URL to the user's profile picture. #### Response Example ```json { "example": "{\"id\":\"123456789\", \"name\":\"John Doe\", \"picture\":\"https://graph.zalo.me/images/user.jpg\"}" } ``` ``` -------------------------------- ### Example cURL Request Source: https://developers.zalo.me/docs/official-account/tin-nhan/quan-ly-tin-nhan/lay-thong-tin-tin-nhan-gan-nhat This snippet demonstrates how to make a GET request to the `listrecentchat` API endpoint to retrieve the latest messages. It includes the necessary access token and query parameters for offset and count. ```curl curl \ -X GET \ -H 'access_token: ' 'https://openapi.zalo.me/v2.0/oa/listrecentchat?data={"offset":0,"count":5}' ``` -------------------------------- ### Response for Welcome Message to Follower Source: https://developers.zalo.me/docs/official-account/tin-nhan/tin-tu-van/gui-tin-tu-van-theo-mau-yeu-cau-thong-tin-nguoi-dung Example response when sending a welcome message to a user who has followed the Official Account. It shows quota details for welcome messages. ```json { "data": { "quota": { "quota_type": "welcome_msg", "remain": "2", "total": "3" }, "message_id": "63ecf43f0df7dba892e6", "user_id": "2512523625412515", "sent_time": "1626926349402" }, "error": 0, "message": "Success" } ``` -------------------------------- ### Example Request to Get Customer Ratings Source: https://developers.zalo.me/docs/zalo-notification-service/truy-xuat-thong-tin/lay-thong-tin-danh-gia-cua-khach-hang Use this cURL command to fetch customer feedback data for a specific template ID within a given time range. Ensure you have the necessary access token and parameters. ```curl curl \ -X GET \ -H "Content-Type: application/json" \ "https://business.openapi.zalo.me/rating/get?template_id=203972&from_time=1616673095659&to_time=1616673271320&offset=0&limit=1" ``` -------------------------------- ### Upload Video for Article Source: https://developers.zalo.me/docs/sdk/java-sdk/tai-lieu/article-api Prepare to upload a video for an article using the 'preparevideo' endpoint. This requires specifying the file path. ```java Map headers = new HashMap<>(); headers.put("access_token", access_token); Map files = new HashMap<>(); File file = new File("/path/to/file"); files.put("file", file); JsonObject excuteRequest = client.excuteRequest("https://openapi.zalo.me/v2.0/article/upload_video/preparevideo", "POST", null, null, headers, files); ``` -------------------------------- ### Create Article Source: https://developers.zalo.me/docs/sdk/dotnet-sdk/tai-lieu/article-api Creates a new article with text, image, and video content. Ensure you provide valid URLs or IDs for media. ```csharp List body = new List(); body.Add(new ParagraphText("content")); body.Add(new ParagraphImage("https://stc-developers.zdn.vn/zalo.png", "caption")); body.Add(new ParagraphVideo(null, "1cd9ac28936d7a33237c", "https://stc-developers.zdn.vn/zalo.png")); //Chỉ cần 1 trong 2 param url tới video hoặc video id //body.Add(new ParagraphProduct("product_id")); Article article = new Article("title", "description", new CoverVideo(ArticleStatus.SHOW, CoverViewVideoType.HORIZONTAL, "1cd9ac28936d7a33237c"), "hienhh", body, new List(), "", ArticleStatus.SHOW, ArticleStatus.SHOW); JObject result = client.createArticle(article); ```