生命周期
订单流程
三次调用,加一个签名 Webhook,礼品卡、eSIM 和话费充值都一样。
查找商品
GET /products
在同一个目录中搜索礼品卡、eSIM 和话费充值,或按 ID 刷新您在售的商品。
提交订单
POST /orders
一次调用完成定价和下单,绝不超过您设定的价格上限。用同一个幂等键重放请求,返回的仍是同一笔订单。
接收 Webhook
order.fulfilled
交付完成的那一刻,带签名的事件就会通知您。无需轮询。
显示兑换码
POST /orders/{id}/fulfillment
兑换码和 PIN 码通过独立且经审计的端点获取。响应从不缓存,每次查看都有记录。
快速入门
任意编程语言,纯 HTTPS
REST 加 JSON,用 X-Api-Key 请求头认证,无需安装 SDK。首单只需三次调用:查找、下单、查看兑换码。
- 基础 URL
- https://myapi.xegora.com/api/v1
- 身份验证
- X-Api-Key
- 格式
- application/json
- 速率限制
- 每个工作区每分钟 120 次请求
create-order.ts
const BASE = "https://myapi.xegora.com/api/v1";const response = await fetch(`${BASE}/orders`, { method: "POST", headers: { "X-Api-Key": process.env.XEGORA_API_KEY!, "Content-Type": "application/json", "Idempotency-Key": "order-10231", }, body: JSON.stringify({ clientReference: "po-10231", item: { productId, variantId, quantity: 1, currency: "USD" }, maximumTotal: 60.0, // the price your buyer saw }),});const order = await response.json();// 409 price_above_maximum carries quotedTotal — show the new price insteadconsole.log(order.status); // "reserved" — wait for "fulfilled", then reveal工作区
目录
报价与订单
POST/api/v1/orders
使用预付钱包下单:发送要定价的商品,一次调用即可完成定价和下单(可附带 maximumTotal),或者发送 quoteId。必须提供 Idempotency-Key 请求头——重试将返回同一订单。权限范围:orders.create。
响应示例202 Accepted
{
"id": "0198e000-1111-7abc-9def-222233334444",
"publicReference": "ord_0198e00011117abc9def222233334444",
"clientReference": "po-10231",
"status": "reserved",
"total": 58.50,
"currency": "USD",
"lines": [
{ "productId": "0198d72d-99d6-75a6-9f12-971050ba7a5f", "variantId": "0198d72d-a15b-7cbf-…",
"productName": "Everyday Digital Gift Card", "variantLabel": "50", "quantity": 1,
"unitPrice": 58.50, "lineTotal": 58.50, "currency": "USD", "faceValue": 50, "faceCurrency": "EUR" }
],
"createdAtUtc": "2026-09-05T12:01:02Z",
"updatedAtUtc": "2026-09-05T12:01:02Z"
}钱包与充值
提现
为生产环境而生
您真正想要的“无聊”基础设施
幂等下单
下单和查看兑换码的请求都支持 Idempotency-Key 请求头。同一请求发送三次,也只会生成一笔订单。
- POST/api/v1/orders · Idempotency-Key: order-10231ord_0198e000…
- POST/api/v1/orders · Idempotency-Key: order-10231ord_0198e000…
- POST/api/v1/orders · Idempotency-Key: order-10231ord_0198e000…
统一目录
礼品卡、eSIM 套餐和话费充值共用一套数据结构、一个价格源和一条下单流程。
签名 Webhook
每条事件都用 HMAC-SHA256 签名,并保证至少送达一次。请按事件 ID 去重。
- X-Xegora-Signature
- HMAC-SHA256
- X-Xegora-Event-Id
- 0198e000-…
- order.processing
- order.under_review
- order.fulfilled
- order.failed
- order.refunded
- wallet.credited
最小权限密钥
每个密钥只授予必需的权限范围,并可设置 IP 白名单和有效期。吊销密钥立即生效。
xeg_live_Q3m9TzK1pWbx · allowedCidrCount: 1
- products.read
- quotes.create
- orders.create
- orders.read
- wallet.read
- orders.reveal
- wallet.deposit-address.write
专为选品打造的目录
可按类别、国家/地区或关键词筛选。每件商品都附带兑换步骤,并以您的销售币种定价。
- query=coffee
- countryCode=FR
- publicCategory=gaming
- amountType=custom
- sort
- limit=50
预充值钱包
订单会从您的预付余额中预留资金,交付时正式扣款。订单失败则释放预留。
- availableBalance
- 1240.50 USD
- reservedBalance
- 58.50 USD
- 1. 以您的销售币种计的批发价格:报价总额就是钱包实际扣除的金额
- 2. 无隐藏的按次调用费用;每个工作区统一限速为每分钟 120 次请求
- 3. 您的工作区方案(开通费用及条款)在商户入驻时约定
- 4. 提取未使用的资金时,确认前会显示手续费、实收金额和到账日期

