EngageLab Web Push API Skill
This skill enables interaction with the EngageLab Web Push REST API (MTPush Web). The service supports push notifications and in-app messages to web platforms only, with support for EngageLab channel and system channels (Chrome, Firefox, Safari, Edge, Opera).
It covers these areas:
- 1. Create Push — Send notification or message to single/multiple web devices (broadcast, tag, alias, registrationid)
- Batch Single Push — Batch push by registrationid or alias (up to 500 per request)
- Group Push — Push to all apps in a group
- Scheduled Tasks — Create, get, update, delete scheduled web push tasks (single, periodical, intelligent)
- Tag & Alias — Query/set/delete device tags and aliases; query tag count
- Delete User — Delete a user (registration_id) and all associated data
- Statistics — Message lifecycle stats (targets, sent, delivered, impressions, clicks by channel)
- Callback — Webhook setup and signature verification
Resources
scripts/
- -
webpush_client.py — Python client class (EngageLabWebPush) wrapping create push, batch push (regid/alias), device get/set/delete, tag count, scheduled tasks CRUD, and message details. Handles Basic auth and typed error handling.
references/
- -
error-codes.md — Web Push API error codes and descriptions http-status-code.md — HTTP status code specificationcallback-api.md — Callback address, validation, security (X-CALLBACK-ID, HMAC-SHA256)
Source API docs: doc/webpush/REST API/ (REST API Overview, Create Push API, Batch Single Push API, Group Push API, Scheduled Tasks API, Tag Alias API, Delete User API, Statistics API, Callback API, HTTP Status Code).
Authentication
All EngageLab Web Push API calls use HTTP Basic Authentication.
- - Base URL (choose by data center):
- Singapore:
https://webpushapi-sgp.engagelab.com
- Hong Kong:
https://webpushapi-hk.engagelab.com
- - Header: INLINECODE8
- Content-Type: INLINECODE9
Obtain AppKey and Master Secret from Console → Application Settings → Application Info.
Group Push uses different auth: username = group- + GroupKey, password = Group Master Secret (from Group management).
Example (curl):
CODEBLOCK0
If the user hasn't provided credentials, ask for AppKey and Master Secret before generating API calls.
Request Rate Limits
- - Standard: 500 requests per second per AppKey.
- Batch Single Push shares the same QPS quota as the Push API (1 target = 1 QPS).
Quick Reference — Main Endpoints
| Operation | Method | Path |
|---|
| Create push | INLINECODE13 | INLINECODE14 |
| Batch push by registration_id |
POST |
/v4/batch/push/regid |
| Batch push by alias |
POST |
/v4/batch/push/alias |
| Group push |
POST |
/v4/grouppush |
| Create scheduled task |
POST |
/v4/schedules |
| Get scheduled task |
GET |
/v4/schedules/{schedule_id} |
| Update scheduled task |
PUT |
/v4/schedules/{schedule_id} |
| Delete scheduled task |
DELETE |
/v4/schedules/{schedule_id} |
| Tag count |
GET |
/v4/tags_count |
| Get device (tags/alias) |
GET |
/v4/devices/{registration_id} |
| Set device tags/alias |
POST |
/v4/devices/{registration_id} |
| Delete device (user) |
DELETE |
/v4/devices/{registration_id} |
| Message statistics |
GET |
/v4/messages/details (message_ids) |
Create Push (POST /v4/push)
Push a notification or message to web devices. Platform is web only.
Request structure (summary)
| Field | Type | Required | Description |
|---|
| INLINECODE40 | string | No | Sender, e.g. INLINECODE41 |
| INLINECODE42 |
string or object | Yes | Target:
"all" (broadcast, devices active within 30 days), or object with
tag,
tag_and,
tag_not,
alias,
registration_id |
|
body | object | Yes | See below |
|
request_id | string | No | Client-defined request ID returned in response |
|
custom_args | object | No | Returned on callback |
body
| Field | Type | Required | Description |
|---|
| INLINECODE52 | string | Yes | Must be INLINECODE53 |
| INLINECODE54 |
object | Optional* | Notification content (web: alert, title, url, icon, image, extras) |
|
message | object | Optional* | In-app/custom message (msg
content, title, contenttype, extras) |
|
options | object | No | time
tolive, override
msgid, big
pushduration, web
buttons, multilanguage, third
partychannel (w3push.distribution), plan_id, cid |
*One of notification or message must exist; they cannot coexist.
notification.web
| Field | Type | Required | Description |
|---|
| INLINECODE57 | string | Yes | Message content |
| INLINECODE58 |
string | Yes | Click jump URL |
|
title | string | No | Message title |
|
icon | string | No | Notification icon (recommended 192×192px; ≤1MB; JPG/PNG/GIF; Chrome, Firefox) |
|
image | string | No | Big image (recommended 360×180px; ≤1MB; Chrome, Edge) |
|
extras | object | No | Custom key-value for business |
options (highlights)
- - timetolive: Offline retention in seconds (default 86400, max 15 days); 0 = online only.
- overridemsgid: Override a previous message (effective 1 day).
- bigpushduration: Throttled push over n minutes (max 1440); max 20 throttled pushes at once.
- webbuttons: Array of up to 2 buttons (id, text, icon, url); Chrome 48+.
- multilanguage: Per-language content/title (e.g. en, zh-Hans).
- thirdpartychannel.w3push.distribution:
first_ospush | mtpush | secondary_push | ospush for system channel priority. - plan_id, cid: Push plan ID and duplicate-prevention ID (max 64 chars, unique per AppKey).
Push target to examples
- - Broadcast: INLINECODE68
- Tags (OR): INLINECODE69
- Tags (AND): INLINECODE70
- Tag NOT: INLINECODE71
- Alias:
"to": { "alias": ["user1","user2"] } (up to 1000) - Registration IDs:
"to": { "registration_id": ["id1","id2"] } (up to 1000)
Response (success)
CODEBLOCK1
Notification body length limit: 2048 bytes (doc); total message limit 4000 bytes. See doc/webpush/REST API/Create Push API.md. Error codes: references/error-codes.md.
Batch Single Push
- - By registration_id: INLINECODE76
- By alias: INLINECODE77
Request body: { "requests": [ { "target": "reg_id_or_alias", "platform": "web", "notification": { "web": { "alert", "title", "url", ... } }, "message": {...}, "options": {...}, "custom_args": {...} } ] }. Max 500 items per request; target must be unique. See doc/webpush/REST API/Batch Single Push API.md.
Group Push
INLINECODE81 — Same body structure as Create Push (platform web, notification.web). Auth: Basic with group-{GroupKey} and Group Master Secret. overridemsgid and Schedule API not supported for group push.
Scheduled Tasks
- - Create:
POST /v4/schedules — Body: name, enabled, trigger (single / periodical / intelligent), push (same as Create Push body with platform web). - Get:
GET /v4/schedules/{schedule_id}. - Update:
PUT /v4/schedules/{schedule_id}. - Delete:
DELETE /v4/schedules/{schedule_id}.
Trigger types: single (time, zonetype), periodical (start, end, time, timeunit, point, zonetype), intelligent (backuptime: "now" or "yyyy-MM-dd HH:mm:ss"). Max 1000 valid scheduled tasks. See doc/webpush/REST API/Scheduled Tasks API.md.
Tag & Alias
- - Tag count:
GET /v4/tags_count?tags=tag1&tags=tag2&platform=web (up to 1000 tags; platform for Web Push is typically web — confirm in doc). - Get device:
GET /v4/devices/{registration_id} — Returns tags, alias. - Set device:
POST /v4/devices/{registration_id} — Body: { "tags": { "add": ["t1"], "remove": ["t2"] }, "alias": "alias1" }.
Limits: 100,000 tags per app; 40 bytes per tag; 100 tags per device; 100,000 devices per tag; one alias per device (40 bytes); 100,000 aliases per app. See doc/webpush/REST API/Tag Alias API.md.
Delete User
INLINECODE103 — Asynchronously deletes user and all related data. Cannot be restored. Batch deletion not supported.
Statistics
- - Message details:
GET /v4/messages/details?message_ids=id1,id2 (up to 100 messageids). Returns targets, sent, delivered, impressions, clicks, and sub-stats by channel (subweb: engageLab_web, chrome, safari, firefox, edge, opera). Data retained up to one month. See doc/webpush/REST API/Statistics API.md.
Callback
Configure callback URL (via Engagelab support). Validation: server sends POST with echostr in body; respond with body = echostr value. Security: use X-CALLBACK-ID header; signature = HMAC-SHA256(secret, timestamp+nonce+username). Respond with 200/204 within 3 seconds for success. See references/callback-api.md and doc/webpush/REST API/Callback API.md.
Generating Code
When the user asks to send web push or use other Web Push APIs, generate working code. Default to curl unless the user specifies a language. Supported: curl, Python (requests), Node.js (fetch/axios), Java (HttpClient), Go (net/http). Always include the Authorization header and error handling. Use placeholders YOUR_APP_KEY and YOUR_MASTER_SECRET if credentials are not provided.
Python Example — Create Web Push
CODEBLOCK2
技能名称: engagelab-webpush
详细描述:
EngageLab Web Push API 技能
该技能支持与 EngageLab Web Push REST API(MTPush Web)进行交互。该服务仅支持向 Web 平台发送推送通知和应用内消息,支持 EngageLab 通道和系统通道(Chrome、Firefox、Safari、Edge、Opera)。
涵盖以下领域:
- 1. 创建推送 — 向单个或多个 Web 设备发送通知或消息(广播、标签、别名、registrationid)
- 批量单推 — 按 registrationid 或别名进行批量推送(每次请求最多 500 条)
- 群组推送 — 向群组中的所有应用推送
- 定时任务 — 创建、获取、更新、删除 Web 推送定时任务(单次、周期性、智能)
- 标签与别名 — 查询/设置/删除设备标签和别名;查询标签数量
- 删除用户 — 删除用户(registration_id)及其所有关联数据
- 统计 — 消息生命周期统计(目标数、发送数、送达数、展示数、按渠道点击数)
- 回调 — Webhook 设置与签名验证
资源
scripts/
- - webpush_client.py — Python 客户端类(EngageLabWebPush),封装了创建推送、批量推送(regid/别名)、设备获取/设置/删除、标签数量、定时任务 CRUD 以及消息详情。处理基本认证和类型化错误处理。
references/
- - error-codes.md — Web Push API 错误码及描述
- http-status-code.md — HTTP 状态码规范
- callback-api.md — 回调地址、验证、安全性(X-CALLBACK-ID、HMAC-SHA256)
源 API 文档:doc/webpush/REST API/(REST API 概述、创建推送 API、批量单推 API、群组推送 API、定时任务 API、标签别名 API、删除用户 API、统计 API、回调 API、HTTP 状态码)。
认证
所有 EngageLab Web Push API 调用均使用 HTTP 基本认证。
- 新加坡:https://webpushapi-sgp.engagelab.com
- 香港:https://webpushapi-hk.engagelab.com
- - 请求头:Authorization: Basic base64(appKey:masterSecret)
- 内容类型:application/json
从控制台 → 应用设置 → 应用信息中获取 AppKey 和 Master Secret。
群组推送使用不同的认证:username = group- + GroupKey,password = 群组主密钥(来自群组管理)。
示例(curl):
bash
curl -X POST https://webpushapi-sgp.engagelab.com/v4/push \
-H Content-Type: application/json \
-u YOURAPPKEY:YOURMASTERSECRET \
-d { from: push, to: all, body: { platform: web, notification: { web: { alert: Hello!, title: Web Push, url: https://example.com } } } }
如果用户未提供凭证,请在生成 API 调用前询问 AppKey 和 Master Secret。
请求速率限制
- - 标准:每个 AppKey 每秒 500 次请求。
- 批量单推与推送 API 共享相同的 QPS 配额(1 个目标 = 1 QPS)。
快速参考 — 主要端点
| 操作 | 方法 | 路径 |
|-----------|--------|------|
| 创建推送 | POST | /v4/push |
| 按 registration_id 批量推送 | POST | /v4/batch/push/regid |
| 按别名批量推送 | POST | /v4/batch/push/alias |
| 群组推送 | POST | /v4/grouppush |
| 创建定时任务 | POST | /v4/schedules |
| 获取定时任务 | GET | /v4/schedules/{schedule_id} |
| 更新定时任务 | PUT | /v4/schedules/{schedule_id} |
| 删除定时任务 | DELETE | /v4/schedules/{schedule_id} |
| 标签数量 | GET | /v4/tags_count |
| 获取设备(标签/别名) | GET | /v4/devices/{registration_id} |
| 设置设备标签/别名 | POST | /v4/devices/{registration_id} |
| 删除设备(用户) | DELETE | /v4/devices/{registration_id} |
| 消息统计 | GET | /v4/messages/details(message_ids) |
创建推送(POST /v4/push)
向 Web 设备推送通知或消息。平台仅限 web。
请求结构(概要)
| 字段 | 类型 | 必填 | 描述 |
|-------|------|----------|-------------|
| from | 字符串 | 否 | 发送者,例如 push |
| to | 字符串或对象 | 是 | 目标:all(广播,30 天内活跃的设备),或包含 tag、tagand、tagnot、alias、registration_id 的对象 |
| body | 对象 | 是 | 见下文 |
| request_id | 字符串 | 否 | 客户端定义的请求 ID,在响应中返回 |
| custom_args | 对象 | 否 | 回调时返回 |
body
| 字段 | 类型 | 必填 | 描述 |
|-------|------|----------|-------------|
| platform | 字符串 | 是 | 必须为 web |
| notification | 对象 | 可选* | 通知内容(web:alert、title、url、icon、image、extras) |
| message | 对象 | 可选* | 应用内/自定义消息(msgcontent、title、contenttype、extras) |
| options | 对象 | 否 | timetolive、overridemsgid、bigpushduration、webbuttons、multilanguage、thirdpartychannel(w3push.distribution)、plan_id、cid |
*notification 和 message 必须存在其一,不能同时存在。
notification.web
| 字段 | 类型 | 必填 | 描述 |
|-------|------|----------|-------------|
| alert | 字符串 | 是 | 消息内容 |
| url | 字符串 | 是 | 点击跳转 URL |
| title | 字符串 | 否 | 消息标题 |
| icon | 字符串 | 否 | 通知图标(建议 192×192px;≤1MB;JPG/PNG/GIF;Chrome、Firefox) |
| image | 字符串 | 否 | 大图(建议 360×180px;≤1MB;Chrome、Edge) |
| extras | 对象 | 否 | 自定义键值对,用于业务 |
options(要点)
- - timetolive:离线保留时间(秒,默认 86400,最长 15 天);0 表示仅在线。
- overridemsgid:覆盖之前的消息(有效期为 1 天)。
- bigpushduration:在 n 分钟内限速推送(最长 1440 分钟);一次最多 20 个限速推送。
- webbuttons:最多 2 个按钮的数组(id、text、icon、url);Chrome 48+。
- multilanguage:按语言的内容/标题(例如 en、zh-Hans)。
- thirdpartychannel.w3push.distribution:firstospush | mtpush | secondarypush | ospush,用于系统通道优先级。
- plan_id、cid:推送计划 ID 和去重 ID(最长 64 字符,每个 AppKey 唯一)。
推送目标 to 示例
- - 广播:to: all
- 标签(OR):to: { tag: [tag1,tag2] }
- 标签(AND):to: { tag_and: [tag3,tag4] }