Platforms / Zalo

Zalo API

Publish articles on a Zalo Official Account and answer the messages people send it.

At a glance

Platform id
zalo
Connects
Official Account
Sign-in
OAuth: the user approves on the platform's own page
Post types
Article (text, optional cover image) · Message to one follower (text, one image)

Capabilities

What Zalo supports here
PublishingPartly
SchedulingYes
CommentsNo
Direct messagesYes
MentionsNo
ReviewsNo
AnalyticsPartly

Required on every post

  • Article title: the top-level title or, when there is none, the whole text. It must fit in 150 characters or the target fails (it is never cut).

Options

Send these in platform_data.zalo on the post, or flat in a target's own platform_data (the target's keys win). See Publishing.

platform_data options for Zalo
KeyTypeWhat it does
modearticle | messageDefault: message when recipient_id is set, else article.
recipient_idstringZalo user id to message (mode message).
titlestringArticle title, up to 150 characters. The post's top-level title wins.
authorstringArticle author. Default: the OA name.
descriptionstringArticle summary. Default: the start of the text.
coverURLCover image. Default: the post's first image; none makes a text-only article.

Limits

  • Text 2,000 characters; one image.
  • Zalo gets 10 seconds to create the article, then the target fails with platform.zalo.article_processing (the article may still appear).

Text over the limit fails validation before anything is sent. The caps of this server are explained in Rate limits.

Good to know

  • An administrator of the Official Account signs in; each sign-in connects one OA.
  • Access tokens last about 25 hours and are renewed automatically; each refresh token works once. Disconnecting here does not revoke access on Zalo.
  • Replies are Zalo consultation messages: they reach only people who interacted with the OA in the last 7 days (free within 48 hours, Zalo may charge after that). Otherwise the send fails with platform.zalo.not_deliverable.
  • Replies can be text (up to 2,000 characters), a JPG or PNG image up to 1 MB, a sticker by its id, up to 5 buttons, or a contact-request card. Reactions and typing indicators are not available.
  • The inbox gets new messages by webhook; a sync adds the 10 most recent messages, the most Zalo returns.
  • Articles finish publishing on Zalo a few seconds after they are sent; published articles can be deleted but not edited.

Publish with the API

curl https://api.zaynstack.com/v1/posts \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{
    "text": "Hello from SocialWire",
    "media": [{ "type": "image", "source_type": "url", "source": "https://example.com/file.jpg" }],
    "targets": [{ "account_id": "<Zalo account id>" }],
    "publish_now": true
  }'

An operation Zalo cannot do answers 501 resource.not_supported. Agents can do the same through the MCP server.

Connection errors

A connection that fails comes back to your redirect_uri with status=error, error=<code> and error_description, or as the error of the connect call. All codes: Connect accounts.

Connection error codes for Zalo
CodeMeaning
account.already_linkedThe brand already holds a different account on this platform, or the account belongs to another brand while lock_accounts_to_brand is on.
billing.brands_limitNo brand_id was sent, so a new brand was needed, and the plan has no room for another brand.

Webhook events

Every platform sends the post.* and account.* events. Zalo also sends:

  • dm.received

Webhook events and their payloads

Not supported yet

  • Comments, reviews and mentions: Zalo has no API for them.
  • Editing published articles.

Developer setup (self-hosting)

Only the operator of this server does this, once. Users then just click Connect.

  1. developers.zalo.me → create an app and link your Official Account.
  2. Add the Callback address below as the OA callback URL, and verify its domain in the Zalo portal (DNS TXT record, HTML file or meta tag): without the verified domain Zalo refuses the redirect.
  3. Set the Webhook address below and turn on the user_send_* message events.
  4. Put the app ID and secret into ZALO_APP_ID / ZALO_APP_SECRET (and the OA secret key into ZALO_OA_SECRET_KEY for webhook signatures).
Callback address
https://api.zaynstack.com/api/connect/zalo/callback
Webhook address
https://api.zaynstack.com/api/hooks/zalo
Server variables
ZALO_APP_ID, ZALO_APP_SECRET
Developer console
Zalo developer console

Permissions requested

  • Official Account permissions granted on the Zalo consent page

When a reconnect grants fewer permissions than before, an account.updated event with change permissions_reduced is sent. Accounts connected before a permission was added keep working but must reconnect to use the features it unlocks.

Before anyone can connect (review)

  1. Official Account verification by Zalo (Vietnamese business documents).

Typical wait: 1-2 weeks. Until then the app works for your own accounts and the testers you add in the console.

Other platforms

Free to start

Your next post can go everywhere at once.

No card. Connect a profile, send a post, see it land.