认证
每个 Merchant 在 LOMA 后台生成一对 API Key 与 API Secret(Secret 仅创建时展示一次,请妥善保存)。
每个请求都必须带以下请求头:
| Header | 必填 | 说明 |
|---|---|---|
X-Api-Key | ✅ | Merchant 的 API Key |
X-Api-Secret | ✅ | Merchant 的 API Secret |
Idempotency-Key | 发消息必填 | 幂等键;相同 key 的重复请求返回首次结果,不会重复发送 |
Content-Type | ✅ | application/json |
示例
curl -X POST https://loma-dev.acorners.com/api/v1/merchant/message/send \
-H "X-Api-Key: lk_xxxxxxxxxxxx" \
-H "X-Api-Secret: xxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Idempotency-Key: order-12345" \
-H "Content-Type: application/json" \
-d '{"customerExternalId":"C10086","text":"您的验证码是 395217"}'
鉴权失败
| 情况 | 返回 |
|---|---|
| Key/Secret 无效或停用 | HTTP 401,code = INVALID_API_KEY |
:::tip 幂等键(Idempotency-Key) 发送 OTP / 通知时强烈建议带上幂等键。网络重试导致的重复请求不会让客户收到两条消息。建议每笔业务用唯一的 key(如订单号),有效期 24 小时。 :::