権利付与
権利付与が作成、配送、失敗、または取り消された時にウェブフックエンドポイントに送信されるペイロードです。
権利付与ウェブフックイベント
これらのイベントは、顧客の権利付与の状態が変化するたびに発生します。例えば、ライセンスキーが生成された時、Discordの役割が割り当てられた時、ダウンロードリンクが提供された時、またはアクセスが取り消された時です。これらのイベントを購読して、各顧客がアクセスできる内容とアプリケーションを同期させましょう。EntitlementGrantResponse ペイロードを共有しています。
イベントトリガー
entitlement_grant.created
grant の行が挿入されました。この時点以降、ステータスが変わっても grant には常に固定のid があります。この event を使用して、fulfillment が進行中であることを記録してください。
auto-fulfilled license keys と feature flags の場合、行は status: "Delivered" と delivered_at が入力された状態で直接挿入されます。そのため、単一の created event の後、grant が後で revoked されない限り、以降の 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ベースのintegration(Discord、GitHub、Notion)では、顧客がconsentを完了するためにアクセスする必要がある
oauth_urlを使用します。Dodo Paymentsはgrantの作成時にこれを作成しようとするため、entitlement_grant.createdに含まれている場合があります。nullの場合は、顧客がCustomer Portalからaccept flowを開始した時点で入力されます。顧客が承認するまで、grantはPendingのままです。 - Platform-direct integration(Telegram、Framer、Digital Files)は、platform callの実行中のみ短時間
Pendingに置かれ、その後Deliveredに移行します。
pending から delivered へ移行しました。顧客は権利で示されるアクセスを現在持っています。このイベントを使用して、独自のシステム内で依存機能を解除するために使用します。例えば、ワークスペースのプロビジョニングやカスタムウェルカムメールの送信、「fulfilled」フラグの設定などです。
grant が Delivered に移行しました。通常は Pending からの移行です。customer は entitlement に記載された access を利用できるようになりました。この event を使用して、独自の system で依存する feature のロックを解除してください。たとえば、workspace の provision、custom welcome email の送信、または「fulfilled」flag の設定などに利用できます。
payload の delivered_at field には、delivery が完了した時刻が記録されます。delivered は、既存の grant の status が Delivered に変わるたびに発生します。Pending からの移行、失敗した OAuth grant が後から成功した場合、または revoked された grant が復元された場合が該当します。auto-fulfilled license key のように、作成時に Delivered となる grant では、created のみが発生します。
配信が試行され、再試行不可能なエラーで失敗しました。フィールド 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)
License Key Delivered (entitlement_grant.delivered)
License Key Pending Manual Fulfillment (entitlement_grant.created)
customer が、License Key entitlement に fulfillment_mode: manual を使用する product を購入したときに発生します。grant は Pending で、license_key object はまだありません — merchant が key を提供する必要があります。
Digital Files Delivered (entitlement_grant.delivered)
Discord Role Created and Pending (entitlement_grant.created)
Grant Revoked on Subscription Cancellation (entitlement_grant.revoked)
Delivery Failed (entitlement_grant.failed)
統合のヒント
- grantが
Deliveredに達したら、依存する機能をアンロックします。payment.succeededeventは、支払いが完了したことを示しますが、顧客がまだGitHub repoやDiscord roleを取得したことまでは示しません。entitlement_grant.deliveredを処理し、entitlement_grant.createdをstatus: "Delivered"とともに処理してください。作成時にdeliveryされるgrantでは、deliveredeventが発生しないためです。 revocation_reasonをretention flowにマッピングします。subscription_on_holdrevokeは通常、顧客のカード決済に失敗し、次回のrenewalでアクセスが再付与されることを意味します。manualまたはsubscription_cancelledrevokeは意図的なものです。顧客へのメッセージでは、これらを区別して扱ってください。- grantの
idではなく、webhook-idheaderで重複を検出します。 grantはcreatedを1回だけ発行しますが、deliveredとrevokedはそれぞれ複数回発生する可能性があります。revokeされたgrantは復元後に再度revokeされることがあるためです。failedも常に最終状態とは限りません。OAuth grantが失敗してもdeliveryされる場合があります。Webhook systemからの再deliveryによって、同じeventが繰り返されることもあります。webhook-idで重複をスキップし、自身のgrant recordではgrantidをキーにしてください。 integration_typeを読み取り、grant typeを認識します。 payloadにはintegration_typeが直接含まれます(例:license_key、digital_files、discord)。license_keyおよびdigital_product_deliveryのnested objectは、それぞれのgrantがdeliveryされると入力されます。手動でfulfillするlicense-key grantは、fulfillするまでintegration_type: "license_key"およびnulllicense_keyを伴うPendingのままです。- OAuthベースのgrantでは、
oauth_urlを顧客に提示します。 Discord、GitHub、またはNotionのsubscriber flowにおけるentitlement_grant.createdeventには、oauth_urlとoauth_expires_atが含まれる場合があります。nullの場合は、後続のeventを待つか、顧客をCustomer Portalに案内してください。deliveryを解除するため、URLを顧客にメールで送信するか、アプリに表示します。
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.