---
title: "Connect WeChat Official Account"
method: POST
path: "/v1/connect/wechat/credentials"
tags: ["Connect"]
---

# Connect WeChat Official Account

`POST /v1/connect/wechat/credentials`

## Request

- Base URL: `https://zernio.com/api`
- URL: `https://zernio.com/api/v1/connect/wechat/credentials`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/zernio/apis/zernio-api/docs/v1/connect/wechat/credentials/post.ts> (a function with typed inputs; its response is checked against the schema)

Connect a verified WeChat Official Account (Service Account) with its AppID and AppSecret (Weixin Official Accounts Platform > Settings and Development > Basic Configuration).

Before calling this, add every IP from GET /v1/connect/wechat/ip-whitelist to the account's API IP whitelist on the same page. WeChat refuses calls from any other IP, and this endpoint then returns 400 with code `wechat_ip_not_whitelisted`.

The response carries a Server URL, a Token and an EncodingAESKey. Paste them into Server Configuration on the same page, choose Safe mode for message encryption, and enable the configuration. Until then WeChat delivers nothing to Zernio.

Enabling Server Configuration turns off the auto-replies and menus set in the WeChat dashboard.

Reconnecting the same AppID on the same profile keeps the existing Token and EncodingAESKey, so nothing has to be pasted again.
To get your userId for the state parameter, call GET /v1/users which includes a currentUserId field.

## Request body

- object
  - `appId` string, required: The Official Account's AppID (starts with wx).
  - `appSecret` string, required: The Official Account's AppSecret (32 characters).
  - `state` string, required: Required state formatted as {userId}-{profileId}. Get userId from GET /v1/users and profileId from GET /v1/profiles.
  - `displayName` string: Name to show for the account. Defaults to "WeChat Official Account".
  - `redirect_url` string, uri: Optional URL to redirect to after a successful connection.

## Response `200`

WeChat connected

- object
  - `message` string
  - `account` ConnectedMessagingAccount: The account a credentials connect created or updated.
    - `accountId` string
    - `platform` 'line' | 'wechat'
    - `username` string: The LINE basic ID (for example @123abcde) or the WeChat AppID.
    - `displayName` string
    - `isActive` boolean
  - `server` object: Values to paste into Server Configuration in the Official Accounts Platform.
    - `url` string, uri
    - `token` string
    - `encodingAESKey` string
    - `encryptionMode` 'safe'
  - `ipWhitelist` string[]: IPs that must stay on the account's API IP whitelist.
  - `nextSteps` string[]
  - `redirectUrl` string

## Other responses

- `400`: Invalid request. `code` is `wechat_ip_not_whitelisted` when WeChat refused the call because Zernio's IPs are not on the account's API IP whitelist (`details.ips` lists them), and `invalid_field_value` with `param` set to `appId` or `appSecret` when WeChat rejected that value.
- `401`: Missing or invalid API key. `code` is `missing_credentials` when no Authorization header was sent and `invalid_credentials` when the key is unknown, revoked or expired.
- `403`: The connect token was issued for a different profile or platform (INSUFFICIENT_PERMISSIONS).

## Changes

- **2026-11-11** `d908988b0be8`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/zernio/apis/zernio-api/changes/v1/connect/wechat/credentials/post.md)

---

[API](https://skmtc.dev/zernio/apis/zernio-api.md) - [All operations](https://skmtc.dev/zernio/apis/zernio-api/llms.txt) - [OpenAPI document](https://skmtc.dev/zernio/apis/zernio-api/revisions/0dc2e9cbb558?raw)
