権利付与
権利付与が作成、配送、失敗、または取り消された時にウェブフックエンドポイントに送信されるペイロードです。
権利付与ウェブフックイベント
これらのイベントは、顧客の権利付与の状態が変化するたびに発生します。例えば、ライセンスキーが生成された時、Discordの役割が割り当てられた時、ダウンロードリンクが提供された時、またはアクセスが取り消された時です。これらのイベントを購読して、各顧客がアクセスできる内容とアプリケーションを同期させましょう。EntitlementGrantResponse ペイロードを共有しています。
イベントトリガー
entitlement_grant.created
付与行が挿入されました。この時点から、たとえそのステータスが変わっても、付与には安定したid があります。このイベントを使って、履行が進行中であることを記録します。
auto-fulfilled license keys の場合、行は status: "Delivered" と delivered_at が設定された状態で直接挿入されるため、単一の created event の後、grant が後から revoke されない限り、それ以上の state change は発生しません。
manually-fulfilled license keys(fulfillment_mode: manual を持つ entitlements)の場合、行は status: "Pending" とともに作成され、license_key object はありません — まだ key が存在しないためです。この event は、key が fulfillment 待ちであることを示します。POST /grants/{grant_id}/license-key で key を提供すると、entitlement_grant.delivered が発生します。Manual Fulfillment を参照してください。
その他すべての integration の場合、行は status: "Pending" とともに作成されます。delivery が完了すると、delivered または failed event が続いて発生します。
- OAuth-based integrations(Discord、GitHub、Notion)には、customer が consent を完了するためにアクセスする必要がある
oauth_urlが含まれます。customer が authorize するまで、grant はPendingのままです。 - Platform-direct integrations(Telegram、Framer、Digital Files)は、platform call の実行中だけ短時間
Pendingに留まり、その後Deliveredに移行します。
pending から delivered へ移行しました。顧客は権利で示されるアクセスを現在持っています。このイベントを使用して、独自のシステム内で依存機能を解除するために使用します。例えば、ワークスペースのプロビジョニングやカスタムウェルカムメールの送信、「fulfilled」フラグの設定などです。
grant が Pending から Delivered に遷移しました。customer は entitlement に記載された access を利用できるようになりました。この event を使用して、自社 system の dependent features を有効化してください。たとえば、workspace の provision、custom welcome email の送信、または「fulfilled」flag の設定などに利用できます。
payload の delivered_at field には、delivery が完了した時刻が記録されます。作成時に Delivered となった grant については、created event と delivered event を連続して受け取ります。
配信が試行され、再試行不可能なエラーで失敗しました。フィールド error_code と error_message が失敗の原因を説明します。一般的な原因には、OAuthトークンの取り消し、プラットフォーム権限の拒否、またはターゲットの欠落(例:削除されたDiscordギルド)があります。
entitlement_grant.revoked
プラットフォームレベルでアクセスが取り消されました:Discord役割が削除され、GitHub協力者が削除され、ライセンスキーが無効化され、ファイルダウンロードURLが発行されなくなりました。revocation_reason フィールドはトリガーを記録します。
ペイロードバリアント
data フィールドは常に EntitlementGrantResponse オブジェクトです。2つの統合タイプが追加のネストオブジェクトを含みます:
data field は常に EntitlementGrantResponse object です。payload には integration_type field(例: license_key、digital_files、discord)が含まれるため、grant type を直接識別できます。3 種類の integration では、さらに nested object も付加されます。
license_keyは、integration_typeがlicense_keyであり、かつ key が発行済みの場合に含まれます。生成された key、expiry、activation usage が含まれます。まだPendingの manually-fulfilled grant では、grant を fulfill するまでこの object はnullです。digital_product_deliveryは、integration_typeがdigital_filesの場合に含まれます。presigned download URL、optional なinstructions、optional なexternal_urlが含まれます。featureは、integration_typeがfeature_flagの場合に含まれます。grant によって付与された capability のfeature_typeとfeature_idが含まれます。
null です。該当する configuration は grant ではなく entitlement 自体に記録されます。
サンプルペイロード
ライセンスキー配送(entitlement_grant.delivered)
fulfillment_mode: manual を使用する product を購入したときに発生します。grant は Pending で、license_key object はまだありません — merchant が key を提供する必要があります。
サブスクリプションキャンセルで付与が取り消されました(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イベントを発します。ウェブフックシステムからの再配信はイベントを繰り返することがあります;付与のidとtypeで重複を排除してください。 license_keyとdigital_product_deliveryを検査して統合タイプを認識します。 付与ペイロード自体は統合タイプを保持しませんが、ライセンスキーおよびデジタルファイルの権利に対してこれらのネストされたオブジェクトのどちらか1つが含まれています。- OAuthベースの付与の場合、
oauth_urlを顧客に表示します。 Discord、GitHub、またはNotionのサブスクリバーフローのentitlement_grant.createdイベントには、oauth_urlとoauth_expires_atが含まれます。お客様にメールしたり、アプリ内に表示して配信を解除してください。
統合のヒント
- dependent features を有効化する前に
entitlement_grant.deliveredを待機してください。payment.succeededevent は支払いが確定したことを示しますが、customer がまだ GitHub repo や Discord role を利用できることを示すものではありません。fulfillment の source of truth はdeliveredevent です。 revocation_reasonを retention flow に対応付けてください。subscription_on_holdrevoke は通常、customer の card が失敗し、次回 renewal で access が再付与されることを意味します。manualまたはsubscription_cancelledrevoke は意図的なものです。customer messaging では両者を区別して扱ってください。- grant の
idを idempotency key として使用してください。 1 つの grant から発生するcreatedevent は最大 1 件、terminal event(deliveredまたはfailed)は最大 1 件、revokedevent も最大 1 件です。webhook system からの再 delivery により event が重複する可能性があるため、grant のidとtypeの組み合わせで重複排除してください。 integration_typeを読み取り、grant type を識別してください。 payload にはintegration_typeが直接含まれます(例:license_key、digital_files、discord)。license_keyとdigital_product_deliveryの nested object は、それぞれの grant が delivered されると設定されます。manually-fulfilled license-key grant は、fulfill するまでintegration_type: "license_key"とnullのlicense_keyを伴ったPendingのままです。- OAuth-based grant では、
oauth_urlを customer に提示してください。 Discord、GitHub、Notion の subscriber flow におけるentitlement_grant.createdevent には、oauth_urlとoauth_expires_atが含まれます。customer に email で送信するか、app に表示して delivery を進められるようにしてください。
Detailed view of a single entitlement grant: who it's for, its lifecycle state, and any integration-specific delivery payload.
Brand id this grant belongs to.
Identifier of the business that owns the grant.
Timestamp when the grant was created.
Identifier of the customer the grant was issued to.
Identifier of the entitlement this grant was issued from.
Unique identifier of the grant.
The integration type of the grant's entitlement (e.g. license_key).
discord, telegram, github, figma, framer, notion, digital_files, license_key, feature_flag Arbitrary key-value metadata recorded on the grant.
Lifecycle status of the grant.
Pending, Delivered, Failed, Revoked Timestamp when the grant was last modified.
Timestamp when the grant transitioned to delivered, when applicable.
Digital-product-delivery payload, present when the entitlement
integration is digital_files.
Machine-readable code reported when delivery failed, when applicable.
Human-readable message reported when delivery failed, when applicable.
Typed feature payload, present only when the entitlement integration is
feature_flag; null for every other integration type.
License-key delivery payload, present when the entitlement integration
is license_key.
Timestamp when oauth_url stops being valid, when applicable.
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.
Identifier of the payment that triggered this grant, when applicable.
Reason recorded when the grant was revoked, when applicable.
Timestamp when the grant transitioned to revoked, when applicable.
Identifier of the subscription that triggered this grant, when applicable.