権利付与
権利付与が作成、配送、失敗、または取り消された時にウェブフックエンドポイントに送信されるペイロードです。
Documentation Index
Fetch the complete documentation index at: https://docs.dodopayments.com/llms.txt
Use this file to discover all available pages before exploring further.
権利付与ウェブフックイベント
これらのイベントは、顧客の権利付与の状態が変化するたびに発生します。例えば、ライセンスキーが生成された時、Discordの役割が割り当てられた時、ダウンロードリンクが提供された時、またはアクセスが取り消された時です。これらのイベントを購読して、各顧客がアクセスできる内容とアプリケーションを同期させましょう。| イベント | 説明 |
|---|---|
entitlement_grant.created | 新しい付与行が作成されました。ステータスはライセンスキーの場合は即座に delivered であり、その他の統合では pending です。 |
entitlement_grant.delivered | 付与が配信状態に移行しました。顧客は現在、権利を付与されたプラットフォーム、ファイル、またはライセンスキーへのアクセスを持っています。 |
entitlement_grant.failed | 配信が失敗し、再試行されていません。error_code と error_message を確認してください。 |
entitlement_grant.revoked | アクセスが取り消されました。理由を理解するために revocation_reason を確認してください。 |
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 で到着した付与については、created と delivered イベントが連続して届きます。
entitlement_grant.failed
配信が試行され、再試行不可能なエラーで失敗しました。フィールドerror_code と error_message が失敗の原因を説明します。一般的な原因には、OAuthトークンの取り消し、プラットフォーム権限の拒否、またはターゲットの欠落(例:削除されたDiscordギルド)があります。
entitlement_grant.revoked
プラットフォームレベルでアクセスが取り消されました:Discord役割が削除され、GitHub協力者が削除され、ライセンスキーが無効化され、ファイルダウンロードURLが発行されなくなりました。revocation_reason フィールドはトリガーを記録します。
revocation_reason | トリガー |
|---|---|
subscription_cancelled | 顧客のサブスクリプションがキャンセルされました(subscription.cancelled イベント)。 |
subscription_on_hold | サブスクリプションが失敗した更新のために保留中です(subscription.on_hold)。回復可能:成功した再試行は再付与を生む。 |
subscription_expired | サブスクリプションがその期間の終わりに達しました(subscription.expired)。 |
plan_changed | プランが変更されました。古い付与は新しいものが発行される前に取り消されます(subscription.plan_changed)。 |
refund | 元の一回払いの返金が処理されました(refund.succeeded)。 |
manual | 商人がAPIまたはダッシュボード経由で付与を取り消しました。手動の取り消しはサブスクリプション更新時に自動再付与されません。 |
license_key_disabled | ライセンスキーの後ろのライセンスキー付与が無効化されました。キーが再び有効になれば付与は自動的に再アクティブ化されます。 |
platform_external | 統合のプラットフォーム側が同期から外れました(例えば、Discord役割が手動で削除された、GitHubアプリはリポジトリアクセスを失った、または再調整パスは欠落したターゲットを検出した)。基礎的なプラットフォーム問題が解決されるまで、サブスクリプション更新時には自動再付与されません。 |
ペイロードバリアント
data フィールドは常に EntitlementGrantResponse オブジェクトです。2つの統合タイプが追加のネストオブジェクトを含みます:
license_keyは、権利統合タイプがlicense_keyである場合に含まれます。それは生成されたキー、有効期限、およびアクティベーション使用を含みます。digital_product_deliveryは、統合タイプがdigital_filesである場合に含まれます。それは事前署名付きダウンロードURL、オプションのinstructions、およびオプションのexternal_urlを含んでいます。
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イベントを発します。ウェブフックシステムからの再配信はイベントを繰り返することがあります;付与のidとtypeで重複を排除してください。 license_keyとdigital_product_deliveryを検査して統合タイプを認識します。 付与ペイロード自体は統合タイプを保持しませんが、ライセンスキーおよびデジタルファイルの権利に対してこれらのネストされたオブジェクトのどちらか1つが含まれています。- 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.
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.
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.
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.