> ## 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.

# Notion Entitlement

> Copy a Notion template into the customer's Notion workspace when they purchase, after they authorize Dodo Payments with Notion.

<Info>
  The Notion entitlement copies a template you prepared into the paying customer's Notion workspace. The customer authorizes Dodo Payments with Notion and picks the workspace to receive the template, and Dodo Payments creates the copy.
</Info>

## What Gets Delivered

* The customer connects their Notion workspace from the Customer Portal. The payment confirmation email marks the entitlement **Action Required** and links to the portal.
* After they authorize, Dodo Payments copies the configured template into a page the customer shared during authorization, in the workspace they chose.
* When the grant is revoked, the copy stays in the customer's workspace. Dodo Payments marks the grant `Revoked` for record-keeping and doesn't delete the copy.

Common uses include paid Notion templates, productivity systems, and OS or CRM templates.

## Connect Notion

<Steps>
  <Step title="Open Entitlements">
    In the Dodo Payments dashboard, go to **Entitlements** and click **+**.
  </Step>

  <Step title="Pick Notion">
    Choose **Notion Template** as the integration. If Notion isn't connected yet, click **Connect Notion**.

    <Frame caption="Connect Notion prompt before the OAuth handoff.">
      <img src="https://mintcdn.com/dodopayments/do-W-dMDGVB_xzr_/images/entitlements/notion/connect-prompt.png?fit=max&auto=format&n=do-W-dMDGVB_xzr_&q=85&s=90f1f2a60c96918a8da19665a24fcaca" alt="New entitlement panel prompting the merchant to connect Notion" style={{ maxHeight: '500px', width: 'auto' }} width="2000" height="1133" data-path="images/entitlements/notion/connect-prompt.png" />
    </Frame>

    Notion opens in a new tab. Sign in to the workspace that owns your source templates and review the permissions Dodo Payments requests. Then pick the pages (templates) the integration can read and copy.

    <Frame caption="Notion OAuth: review the permissions Dodo Payments requests.">
      <img src="https://mintcdn.com/dodopayments/do-W-dMDGVB_xzr_/images/entitlements/notion/oauth-permissions.png?fit=max&auto=format&n=do-W-dMDGVB_xzr_&q=85&s=957e39812ac19bbf81cceb50f023a14a" alt="Notion OAuth permissions screen for Dodo Payments" style={{ maxHeight: '420px', width: 'auto' }} width="2000" height="1121" data-path="images/entitlements/notion/oauth-permissions.png" />
    </Frame>

    <Frame caption="Notion OAuth: pick the template pages to share.">
      <img src="https://mintcdn.com/dodopayments/do-W-dMDGVB_xzr_/images/entitlements/notion/oauth-select-pages.png?fit=max&auto=format&n=do-W-dMDGVB_xzr_&q=85&s=1f8bd414d5900f9d246d96f15877aba1" alt="Notion page picker selecting which templates Dodo Payments can access" style={{ maxHeight: '420px', width: 'auto' }} width="2000" height="1138" data-path="images/entitlements/notion/oauth-select-pages.png" />
    </Frame>

    When Notion redirects back, a confirmation page shows that the workspace is connected.

    <Frame caption="Workspace connected. Return to the Dodo Payments dashboard to continue.">
      <img src="https://mintcdn.com/dodopayments/do-W-dMDGVB_xzr_/images/entitlements/notion/connected.png?fit=max&auto=format&n=do-W-dMDGVB_xzr_&q=85&s=5e526d2cc12c27f526b2a6e469157bd8" alt="Notion Template connected successfully confirmation page" style={{ maxHeight: '500px', width: 'auto' }} width="2000" height="1143" data-path="images/entitlements/notion/connected.png" />
    </Frame>
  </Step>

  <Step title="Pick a Template">
    Back in the dashboard, select the template to copy under **Template**. Only pages you shared in the previous step appear here. Enter a **Name** for the entitlement and click **Create Entitlement**.

    <Frame>
      <img src="https://mintcdn.com/dodopayments/do-W-dMDGVB_xzr_/images/entitlements/notion/create.png?fit=max&auto=format&n=do-W-dMDGVB_xzr_&q=85&s=82a51c79ed0c6937abf866c187673ab7" alt="Notion entitlement form with connected workspace, template picker, and name field" style={{ maxHeight: '500px', width: 'auto' }} width="2000" height="1135" data-path="images/entitlements/notion/create.png" />
    </Frame>
  </Step>

  <Step title="Attach It to a Product">
    Attach the entitlement to any product. See [Attach Entitlements to Products](/features/entitlements/introduction#attach-entitlements-to-products).
  </Step>
</Steps>

## Customer Flow

1. The customer completes checkout.
2. Dodo Payments creates a grant in `Pending` status. Dodo Payments tries to create a Notion authorization URL right away and stores it in `oauth_url`. If that fails, `oauth_url` stays `null` until the customer starts the accept flow.
3. In the Customer Portal, the customer clicks **Connect** on the entitlement, authorizes with Notion, picks the workspace to receive the template, and shares at least one page with Dodo Payments.
4. Dodo Payments copies the template into a shared page in that workspace. The grant moves to `Delivered`.
5. On revocation, the grant is marked `Revoked`, and the copy remains in the customer's workspace.

<Note>
  Revocation doesn't delete the copy. The copy lives in the customer's workspace, and the Dodo Payments revoke flow only marks the grant `Revoked`.
</Note>

## Required Configuration

| Field | Required | Description |
| - | - | - |
| `notion_template_id` | Yes | The ID (a UUID) of the template to copy. The dashboard's template picker fills this in. |

## Create via API

<CodeGroup>
  ```typescript TypeScript expandable theme={null}
  import DodoPayments from 'dodopayments';

  const client = new DodoPayments({
    bearerToken: process.env['DODO_PAYMENTS_API_KEY'],
    environment: 'test_mode',
  });

  const entitlement = await client.entitlements.create({
    name: 'Study Notes',
    integration_type: 'notion',
    integration_config: {
      notion_template_id: '3f2b8c1e-7d4a-4e9b-a6c5-1d2e3f4a5b6c',
    },
  });
  ```

  ```python Python expandable theme={null}
  import os
  from dodopayments import DodoPayments

  client = DodoPayments(
      bearer_token=os.environ.get("DODO_PAYMENTS_API_KEY"),
      environment="test_mode",
  )

  entitlement = client.entitlements.create(
      name="Study Notes",
      integration_type="notion",
      integration_config={"notion_template_id": "3f2b8c1e-7d4a-4e9b-a6c5-1d2e3f4a5b6c"},
  )
  ```

  ```go Go expandable theme={null}
  // client is a *dodopayments.Client, for example from
  // dodopayments.NewClient(option.WithEnvironmentTestMode()); ctx is a context.Context.
  client.Entitlements.New(ctx, dodopayments.EntitlementNewParams{
    Name:            dodopayments.F("Study Notes"),
    IntegrationType: dodopayments.F(dodopayments.EntitlementIntegrationTypeNotion),
    IntegrationConfig: dodopayments.F[dodopayments.IntegrationConfigUnionParam](
      dodopayments.IntegrationConfigNotionConfigParam{
        NotionTemplateID: dodopayments.F("3f2b8c1e-7d4a-4e9b-a6c5-1d2e3f4a5b6c"),
      },
    ),
  })
  ```
</CodeGroup>

## Webhooks

The [`entitlement_grant.*` webhook events](/developer-resources/webhooks/intents/entitlement-grant) cover the Notion flow:

* `entitlement_grant.created` fires with `status: "Pending"`. `oauth_url` may already hold the Notion authorization URL. If it is `null`, it is populated once the customer starts the accept flow from the Customer Portal.
* `entitlement_grant.delivered` fires once the template is copied.
* `entitlement_grant.revoked` fires on cancellation. The customer's copy is left untouched.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Customer didn't get the template">
    The grant stays `Pending` until the customer completes the Notion authorization. Ask the customer to open the Customer Portal and click **Connect**. Each authorization link expires 30 minutes after it's generated, and the Customer Portal generates a new one when the customer returns. During authorization, the customer must share at least one page, because Dodo Payments creates the copy inside a shared page.
  </Accordion>

  <Accordion title="Template picker is empty">
    In the entitlement form, click **Disconnect** on the Notion card, then click **Connect Notion** and reconnect with the workspace that owns the source templates. Share the template pages during authorization.
  </Accordion>

  <Accordion title="Customer wants the template removed after refund">
    Dodo Payments doesn't delete the copy when it revokes the grant. The customer must delete the copy from their own workspace.
  </Accordion>
</AccordionGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.