Auth
POST /v1/accounts/{a}/auth/disconnect
Close the connection to WeChat but keep the saved login trust.
Scope: login
| Parameter | In | Type | Description |
|---|---|---|---|
a (required) | path | string | Account ID or alias. |
POST /v1/accounts/{a}/auth/login
Start signing the account in with a saved device or a QR code. Poll the returned operation.
Scope: login
| Parameter | In | Type | Description |
|---|---|---|---|
a (required) | path | string | Account ID or alias. |
Idempotency-Key | header | string | Repeating a request with the same key returns the original result instead of repeating the work. |
Request body: LoginRequest
Response: NativeOperation
POST /v1/accounts/{a}/auth/logout-local
Sign the account out on this daemon only, without asking WeChat to revoke the login.
Scope: login
| Parameter | In | Type | Description |
|---|---|---|---|
a (required) | path | string | Account ID or alias. |
POST /v1/accounts/{a}/connect
Connect the signed-in account to WeChat. Poll the returned operation.
Scope: login
| Parameter | In | Type | Description |
|---|---|---|---|
a (required) | path | string | Account ID or alias. |
POST /v1/accounts/{a}/disconnect
Close the connection to WeChat but keep the saved login trust.
Scope: login
| Parameter | In | Type | Description |
|---|---|---|---|
a (required) | path | string | Account ID or alias. |
POST /v1/accounts/{a}/forget-credentials
Delete the saved login credentials of the account. The body must confirm.
Scope: login
| Parameter | In | Type | Description |
|---|---|---|---|
a (required) | path | string | Account ID or alias. |
Idempotency-Key (required) | header | string | Repeating a request with the same key returns the original result instead of repeating the work. |
Request body: NativeForgetRequest
POST /v1/accounts/{a}/login-attempts
Start signing the account in with a saved device or a QR code. Poll the returned operation.
Scope: login
| Parameter | In | Type | Description |
|---|---|---|---|
a (required) | path | string | Account ID or alias. |
Idempotency-Key | header | string | Repeating a request with the same key returns the original result instead of repeating the work. |
Request body: LoginRequest
Response: NativeOperation
DELETE /v1/accounts/{a}/login-attempts/{id}
Cancel a login attempt.
Scope: any valid token
| Parameter | In | Type | Description |
|---|---|---|---|
a (required) | path | string | Account ID or alias. |
id (required) | path | string | Login attempt ID. |
Response: NativeOperation
GET /v1/accounts/{a}/login-attempts/{id}
Show the state of a login attempt.
Scope: any valid token
| Parameter | In | Type | Description |
|---|---|---|---|
a (required) | path | string | Account ID or alias. |
id (required) | path | string | Login attempt ID. |
Response: NativeOperation
POST /v1/accounts/{a}/login-attempts/{id}/cancel
Cancel a login attempt.
Scope: any valid token
| Parameter | In | Type | Description |
|---|---|---|---|
a (required) | path | string | Account ID or alias. |
id (required) | path | string | Login attempt ID. |
Response: NativeOperation
GET /v1/accounts/{a}/login-attempts/{id}/qr
Get the current QR code of a login attempt as a PNG image.
Scope: login
| Parameter | In | Type | Description |
|---|---|---|---|
a (required) | path | string | Account ID or alias. |
id (required) | path | string | Login attempt ID. |
generation | query | integer, nullable | Only return the QR code if it is still this generation. A newer code fails with login_challenge_superseded. |
POST /v1/accounts/{a}/logout
Sign the account out of WeChat. Poll the returned operation.
Scope: login
| Parameter | In | Type | Description |
|---|---|---|---|
a (required) | path | string | Account ID or alias. |
Idempotency-Key (required) | header | string | Repeating a request with the same key returns the original result instead of repeating the work. |
GET /v1/accounts/{a}/operations/{id}/qr
Get the current QR code of a login operation as a PNG image.
Scope: login
| Parameter | In | Type | Description |
|---|---|---|---|
a (required) | path | string | Account ID or alias. |
id (required) | path | string | Operation ID. |
generation | query | integer, nullable | Only return the QR code if it is still this generation. A newer code fails with login_challenge_superseded. |
Types
LoginRequest
Options for signing an account in. Every field is optional.
| Field | Type | Description |
|---|---|---|
allowQr | boolean | Whether a QR code may be shown. When false, only a saved login can be used. The default is true. |
computerName | string | Name this computer gives WeChat while signing in, up to 100 characters. The default is agent-wechat. |
forceQr | boolean | True to skip the saved login and use a QR code, the same as strategy qr. The default is false. |
qrRefresh | QrRefresh | How an expired QR code is replaced. |
strategy | LoginStrategy | How to sign in. The default is auto. |
timeoutSeconds | integer | How long to wait for the sign-in to finish, from 10 to 900 seconds. The default is 300. |
LoginStrategy
How to sign in.
| Value | Description |
|---|---|
| ”auto” | Use the saved login if there is one, and fall back to a QR code if it is missing or rejected. |
| ”saved-device” | Use only the saved login. If it cannot be used, the attempt ends as needs_login without showing a QR code. |
| ”qr” | Always sign in by scanning a QR code. |
NativeForgetRequest
Request to delete the account’s saved login credentials.
| Field | Type | Description |
|---|---|---|
confirm (required) | boolean | Must be true. It confirms that the credentials should be deleted. |
NativeOperation
A background operation such as signing in or out, refreshing contacts or changing a group. Poll it by ID until it finishes.
| Field | Type | Description |
|---|---|---|
accountId (required) | string | ID of the account the operation belongs to. |
createdAt (required) | string | When the operation was created, as an RFC 3339 time. |
id (required) | string | Operation ID. |
kind (required) | string | What the operation does, such as login, logout, sync, metadata, group_mutation, message_recall or media-writeback. |
result (required) | any | Details of the outcome. Its fields depend on kind, and it is empty until the operation has something to report. |
state (required) | string | Where the operation stands, such as queued, running, succeeded, failed or cancelled. Some kinds report more states, for example needs_review, or awaiting_scan and awaiting_approval during a login. |
updatedAt (required) | string | When the operation last changed, as an RFC 3339 time. |
QrRefresh
How an expired QR code is replaced.
| Field | Type | Description |
|---|---|---|
maxRefreshes | integer | How many times to replace an expired QR code automatically, from 0 to 3. The default is 3. |
mode | QrRefreshMode | Whether an expired QR code that nobody scanned is replaced automatically. The default is auto. |
QrRefreshMode
Whether an expired QR code is replaced automatically.
| Value | Description |
|---|---|
| ”auto” | Replace an expired, unscanned QR code with a new one, up to the refresh limit. |
| ”manual” | Do not replace it. An expired QR code ends the attempt as expired. |