Products API CRUD

通过核心API管理产品 https://api.licensechain.app/v1 使用相同的字段,您可以在 Dashboard (卖家产品),包括政策 URL、第三方支付合作伙伴选项和(在支持的层级上)交付设置。

发送 Authorization: Bearer … 使用用户 JWT 或应用程序 API 密钥。多种语言的复制粘贴示例: API示例(多语言).

端点

  • GET /v1/products — 列出您的产品(下面的分页和过滤器)
  • POST /v1/products — 创建(必需: name, price;可选字段如示例中所示)
  • GET /v1/products/{id} — 读一
  • PUT /v1/products/{id} — 完全替换提供的密钥(与 PATCH 相同的验证)
  • PATCH /v1/products/{id} — 部分更新;省略的键保持不变
  • DELETE /v1/products/{id} — 当没有许可证或订阅引用该产品时删除

列出查询参数

GET /v1/products?limit=20&offset=0&active=true&search=pro&sortBy=createdAt&sortDir=desc

limit(默认 20,最大 100)、offset、可选 active (true/false)、search(产品名称中不区分大小写的子字符串)、sortBy (createdAt | name | price), sortDir (asc | desc)。

创建产品(示例正文)

如果您的帐户不在 Enterprise 上,则仅限 Enterprise 的字段(hideEmailautoRedirectlicenseEmailssendLicenseToCustomer)会返回 403。定期计费需要stripePriceIdRecurring。禁用 cryptoPaymentsEnabled 需要 Business 或 Enterprise。 API 存储库中的OpenAPI 列出了每个字段和约束。

{
  "name": "Pro Monthly",
  "description": "Recurring access to premium feature set",
  "price": 49.99,
  "currency": "USD",
  "active": true,
  "successUrl": "https://merchant.example.com/pay/success",
  "cancelUrl": "https://merchant.example.com/pay/cancel",
  "helpUrl": "https://merchant.example.com/help",
  "supportUrl": "https://merchant.example.com/support",
  "termsUrl": "https://merchant.example.com/terms",
  "privacyUrl": "https://merchant.example.com/privacy",
  "refundUrl": "https://merchant.example.com/refund",
  "productType": "subscription",
  "billingType": "recurring",
  "interval": "month",
  "stripePriceIdRecurring": "price_1AbCdEfGhIjKlMn",
  "stripeTaxEnabled": true,
  "stripeIdentityRequired": false,
  "cryptoPaymentsEnabled": true,
  "hideEmail": false,
  "autoRedirect": false
}

更新产品

使用 PATCH 进行部分更新,或使用 PUT 进行要更改的字段。重定向 URL 必须为 httphttps 并且最多 2000 个字符。

PATCH /v1/products/{id}
{
  "name": "Pro Monthly Updated",
  "price": 59.99,
  "active": true,
  "stripeTaxEnabled": true
}

删除产品

DELETE /v1/products/{id}

当许可证或客户订阅仍链接到产品时,返回 409

响应形状

callbackSecret 是针对新产品发布的,并且在启用隐藏电子邮件流程时可能会轮换;将其视为 Webhook 签名的秘密(请参阅付款 Webhook 指南)。在某些内部或遗留行中,userId可能是null;客户应该容忍丢失的所有者 ID。

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "userId": "user_123",
  "name": "Pro Monthly",
  "description": "Recurring access to premium feature set",
  "price": 49.99,
  "currency": "USD",
  "active": true,
  "successUrl": "https://merchant.example.com/pay/success",
  "cancelUrl": "https://merchant.example.com/pay/cancel",
  "helpUrl": "https://merchant.example.com/help",
  "supportUrl": "https://merchant.example.com/support",
  "termsUrl": "https://merchant.example.com/terms",
  "privacyUrl": "https://merchant.example.com/privacy",
  "refundUrl": "https://merchant.example.com/refund",
  "productType": "subscription",
  "billingType": "recurring",
  "interval": "month",
  "stripePriceIdRecurring": "price_1AbCdEfGhIjKlMn",
  "stripeTaxEnabled": true,
  "stripeIdentityRequired": false,
  "cryptoPaymentsEnabled": true,
  "hideEmail": false,
  "autoRedirect": false,
  "licenseEmails": [
    "licenses-a@merchant.example.com",
    "licenses-b@merchant.example.com"
  ],
  "sendLicenseToCustomer": true,
  "callbackSecret": "base64url_or_base64_secret_from_product_record",
  "createdAt": "2026-05-11T07:00:00.000Z",
  "updatedAt": "2026-05-11T07:00:00.000Z"
}