Skip to main content

権利付与ウェブフックイベント

これらのイベントは、顧客の権利付与の状態が変化するたびに発生します。例えば、ライセンスキーが生成された時、Discordの役割が割り当てられた時、ダウンロードリンクが提供された時、またはアクセスが取り消された時です。これらのイベントを購読して、各顧客がアクセスできる内容とアプリケーションを同期させましょう。 すべての4つのイベントは、以下のスキーマに記載されている同じ EntitlementGrantResponse ペイロードを共有しています。

イベントトリガー

entitlement_grant.created

付与行が挿入されました。この時点から、たとえそのステータスが変わっても、付与には安定した id があります。このイベントを使って、履行が進行中であることを記録します。 ライセンスキーの場合、行は直接 status: "delivered"delivered_at が入力された状態で挿入され、単一の created イベントの後に、付与が後に取り消されない限り、さらなる状態変化はありません。 その他すべての統合の場合、行は status: "pending" で到着します。配信が完了すると、delivered または failed イベントが続きます:
  • OAuthベースの統合(Discord、GitHub、Notion)は、顧客が同意を完了するために訪れる必要がある oauth_url を含みます。顧客が承認するまで、付与は pending のままです。
  • プラットフォーム直接統合(Telegram、Framer、デジタルファイル)は、プラットフォーム呼び出しが実行される間にのみ pending にあり、その後 delivered に移動します。

entitlement_grant.delivered

付与が pending から delivered へ移行しました。顧客は権利で示されるアクセスを現在持っています。このイベントを使用して、独自のシステム内で依存機能を解除するために使用します。例えば、ワークスペースのプロビジョニングやカスタムウェルカムメールの送信、「fulfilled」フラグの設定などです。 ペイロードの delivered_at フィールドは、配信が完了した時刻を記録します。作成時に delivered で到着した付与については、createddelivered イベントが連続して届きます。

entitlement_grant.failed

配信が試行され、再試行不可能なエラーで失敗しました。フィールド error_codeerror_message が失敗の原因を説明します。一般的な原因には、OAuthトークンの取り消し、プラットフォーム権限の拒否、またはターゲットの欠落(例:削除されたDiscordギルド)があります。
entitlement_grant.failed を実行可能として扱います。顧客は支払いをしましたが、アクセスを得られていません。あなたのサポートチームに失敗を告知するか、基盤の問題が解決された後に再付与を起動します。

entitlement_grant.revoked

プラットフォームレベルでアクセスが取り消されました:Discord役割が削除され、GitHub協力者が削除され、ライセンスキーが無効化され、ファイルダウンロードURLが発行されなくなりました。revocation_reason フィールドはトリガーを記録します。

ペイロードバリアント

data フィールドは常に EntitlementGrantResponse オブジェクトです。2つの統合タイプが追加のネストオブジェクトを含みます:
  • license_key は、権利統合タイプが license_key である場合に含まれます。それは生成されたキー、有効期限、およびアクティベーション使用を含みます。
  • digital_product_delivery は、統合タイプが digital_files である場合に含まれます。それは事前署名付きダウンロードURL、オプションの instructions、およびオプションの external_url を含んでいます。
その他の全ての統合タイプ(Discord、GitHub、Telegram、Framer、Notion)について、どちらのフィールドも null です;関連構成は、付与自体ではなく、権利に記録されています。

サンプルペイロード

ライセンスキー配送(entitlement_grant.delivered

デジタルファイル配送(entitlement_grant.delivered

Discord役割が作成され保留中(entitlement_grant.created

サブスクリプションキャンセルで付与が取り消されました(entitlement_grant.revoked

配送失敗(entitlement_grant.failed


統合のヒント

  • 依存機能を解除する前に entitlement_grant.delivered を待ちます。 payment.succeeded イベントはお金がクリアされたことを伝えますが、顧客がGitHubリポジトリやDiscord役割をまだ持っていないことを伝えません。delivered イベントは、履行の真実の情報源です。
  • revocation_reason を保持フローにマッピングします。 subscription_on_hold の取り消しは通常、顧客のカードが失敗し、次の更新が再付与することを意味します。manual または subscription_cancelled の取り消しは意図的です。顧客メッセージングで異なる扱いをしてください。
  • 付与 id を冪等性キーとして使用します。 単一の付与は最大で1つの created イベント、最大で1つのターミナルイベント(delivered または failed)、最大で1つの revoked イベントを発します。ウェブフックシステムからの再配信はイベントを繰り返することがあります;付与の idtype で重複を排除してください。
  • license_keydigital_product_delivery を検査して統合タイプを認識します。 付与ペイロード自体は統合タイプを保持しませんが、ライセンスキーおよびデジタルファイルの権利に対してこれらのネストされたオブジェクトのどちらか1つが含まれています。
  • OAuthベースの付与の場合、oauth_url を顧客に表示します。 Discord、GitHub、またはNotionのサブスクリバーフローのentitlement_grant.created イベントには、oauth_urloauth_expires_at が含まれます。お客様にメールしたり、アプリ内に表示して配信を解除してください。

統合のヒント

  • 依存機能のロックを解除する前に、entitlement_grant.delivered を待ちます。 payment.succeeded イベントはお金の清算が完了したことを知らせますが、顧客が GitHub レポジトリまたは Discord ロールをまだ持っているとは限りません。delivered イベントが実行の事実情報源です。
  • revocation_reason をリテンションフローにマップします。 subscription_on_hold の取消は通常、顧客のカードが失敗し、次の更新でアクセスが再付与されることを意味します。manual または subscription_cancelled 取消は意図的です。それぞれに異なるカスタマーメッセージを扱います。
  • あなたの冪等性キーとして grant id を使用します。 単一の付与は、最大で1つの created イベントと、1つのターミナルイベント(delivered または failed)、および1つの revoked イベントを発行します。Webhook システムからの再配信はイベントを繰り返すことがあります。付与 idtype でデータを重複排除します。
  • grant タイプを認識するために integration_type を読みます。 ペイロードは integration_type を直接運びます(例: license_keydigital_filesdiscord)。license_keydigital_product_delivery のネストされたオブジェクトは、それぞれの付与が配信されると一度だけ初期化されます。手動実行のライセンスキー付与は pendingintegration_type: "license_key" として保持され、null license_key されます。
  • OAuthベースの付与については、顧客に対して oauth_url を表示します。 Discord、GitHub、または Notion のサブスクリバーフローの entitlement_grant.created イベントには、oauth_url および oauth_expires_at が含まれています。顧客に電子メールで送信するか、アプリに表示して配信を解除します。

Detailed view of a single entitlement grant: who it's for, its lifecycle state, and any integration-specific delivery payload.

brand_id
string
必須

Brand id this grant belongs to.

business_id
string
必須

Identifier of the business that owns the grant.

created_at
string<date-time>
必須

Timestamp when the grant was created.

customer_id
string
必須

Identifier of the customer the grant was issued to.

entitlement_id
string
必須

Identifier of the entitlement this grant was issued from.

id
string
必須

Unique identifier of the grant.

integration_type
enum<string>
必須

The integration type of the grant's entitlement (e.g. license_key).

利用可能なオプション:
discord,
telegram,
github,
figma,
framer,
notion,
digital_files,
license_key,
feature_flag
metadata
Metadata · object
必須

Arbitrary key-value metadata recorded on the grant.

status
enum<string>
必須

Lifecycle status of the grant.

利用可能なオプション:
Pending,
Delivered,
Failed,
Revoked
updated_at
string<date-time>
必須

Timestamp when the grant was last modified.

delivered_at
string<date-time> | null

Timestamp when the grant transitioned to delivered, when applicable.

digital_product_delivery
null | Digital Product Delivery · object

Digital-product-delivery payload, present when the entitlement integration is digital_files.

error_code
string | null

Machine-readable code reported when delivery failed, when applicable.

error_message
string | null

Human-readable message reported when delivery failed, when applicable.

feature
null | object

Typed feature payload, present only when the entitlement integration is feature_flag; null for every other integration type.

license_key
null | object

License-key delivery payload, present when the entitlement integration is license_key.

oauth_expires_at
string<date-time> | null

Timestamp when oauth_url stops being valid, when applicable.

oauth_url
string | null

Customer-facing OAuth URL for OAuth-style integrations. Populated during the customer-portal accept flow; null until the customer completes that step, and on grants for non-OAuth integrations.

payment_id
string | null

Identifier of the payment that triggered this grant, when applicable.

revocation_reason
string | null

Reason recorded when the grant was revoked, when applicable.

revoked_at
string<date-time> | null

Timestamp when the grant transitioned to revoked, when applicable.

subscription_id
string | null

Identifier of the subscription that triggered this grant, when applicable.

最終更新日 2026年6月26日