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

# GitHub Entitlement

> Grant customers collaborator access to a private GitHub repository at the permission level you choose, and revoke automatically on cancellation.

<Info>
  The GitHub entitlement adds a paying customer as a collaborator on a private repository. You choose the permission level (`pull`, `push`, `triage`, `maintain`, or `admin`) and Dodo Payments handles invitation, acceptance tracking, and removal on cancellation.
</Info>

## What gets delivered

* The customer is invited to your GitHub repository through an OAuth flow that links their GitHub account to the purchase.
* Once they accept, GitHub grants them collaborator access at the configured permission level.
* Cancellation, refund, or manual revoke removes the collaborator.

Common uses include source-available products, paid templates, course code repos, and gated client SDKs.

## Connect GitHub

<Steps>
  <Step title="Open Entitlements">
    In your Dodo Payments dashboard, go to **Entitlements** and click **+** to start a new entitlement.
  </Step>

  <Step title="Pick GitHub">
    Choose **GitHub Access** as the integration. If GitHub is not yet connected, you'll be prompted to **Connect GitHub**.

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

    Clicking through opens GitHub in a new tab. Sign in, then install the Dodo Payments GitHub App on the organization or user account that owns the repository. You can grant access to **all repositories** or only the ones you intend to gate.

    <Frame caption="GitHub Install & Authorize page — choose which repositories the app can manage.">
      <img src="https://mintcdn.com/dodopayments/do-W-dMDGVB_xzr_/images/entitlements/github/oauth-install.png?fit=max&auto=format&n=do-W-dMDGVB_xzr_&q=85&s=0788d3f6e9df8a087de824967f09c215" alt="GitHub Install and Authorize page with All repositories and Only select repositories options" style={{ maxHeight: '500px', width: 'auto' }} width="2000" height="1120" data-path="images/entitlements/github/oauth-install.png" />
    </Frame>

    When GitHub redirects back, you'll see a confirmation that the account is connected.

    <Frame caption="Account connected — return to the Dodo Payments dashboard to continue.">
      <img src="https://mintcdn.com/dodopayments/do-W-dMDGVB_xzr_/images/entitlements/github/connected.png?fit=max&auto=format&n=do-W-dMDGVB_xzr_&q=85&s=ee3c87c3b3917f473ff3d376dfdc6494" alt="GitHub Access connected successfully confirmation page" style={{ maxHeight: '500px', width: 'auto' }} width="2000" height="1137" data-path="images/entitlements/github/connected.png" />
    </Frame>
  </Step>

  <Step title="Pick a repository and permission">
    Back in the dashboard, choose the **repository** the entitlement should grant access to and pick the **permission** level. The repository picker only shows repositories the GitHub App has access to. Give the entitlement a **name** and click **Create Entitlement**.

    <Frame caption="Creating a GitHub entitlement. Pick the repository and the permission you want customers to receive.">
      <img src="https://mintcdn.com/dodopayments/do-W-dMDGVB_xzr_/images/entitlements/github/create.png?fit=max&auto=format&n=do-W-dMDGVB_xzr_&q=85&s=722e925ec5158a5d16c58213132ccb9d" alt="GitHub entitlement form with connected GitHub Access, repository selector, permission dropdown, and name field" style={{ maxHeight: '500px', width: 'auto' }} width="2000" height="1130" data-path="images/entitlements/github/create.png" />
    </Frame>
  </Step>

  <Step title="Save the entitlement">
    Save and attach the entitlement to any product. Customers who buy that product receive a GitHub invite on delivery.
  </Step>
</Steps>

## Permission levels

GitHub's standard repository permissions apply:

| Permission | Best for                                                                       |
| ---------- | ------------------------------------------------------------------------------ |
| `pull`     | Read-only access. Customers can clone, fetch, and view the repo.               |
| `triage`   | Read access plus the ability to manage issues and pull requests.               |
| `push`     | Read + write access. Customers can push branches and open pull requests.       |
| `maintain` | Push access plus management of repository settings (excluding sensitive ones). |
| `admin`    | Full control of the repository. Use with caution.                              |

<Warning>
  Grant the **least privilege** that fits your use case. Most paid-content scenarios only need `pull`.
</Warning>

## Customer flow

1. The customer completes checkout.
2. Dodo Payments creates a grant in `pending` status with an `oauth_url` for the customer to link their GitHub account.
3. The customer authorizes through the link in their email or customer portal.
4. Dodo Payments invites the customer's GitHub account to the repository at the configured permission. The grant moves to `delivered` once the invitation is created.
5. If the subscription is cancelled, refunded, or revoked, the customer is removed as a collaborator.

## Required configuration

| Field        | Required | Description                                                                                        |
| ------------ | -------- | -------------------------------------------------------------------------------------------------- |
| `target_id`  | Yes      | The repository to invite the customer to. The dashboard's repository picker fills this in for you. |
| `permission` | Yes      | One of `pull`, `push`, `triage`, `maintain`, `admin`.                                              |

## Create via API

<CodeGroup>
  ```typescript TypeScript theme={null} theme={null}
  const entitlement = await client.entitlements.create({
    name: 'Code Share Repository',
    integration_type: 'github',
    integration_config: {
      target_id: 'acme/private-sdk',
      permission: 'pull',
    },
  });
  ```

  ```python Python theme={null} theme={null}
  client.entitlements.create(
      name="Code Share Repository",
      integration_type="github",
      integration_config={
          "target_id": "acme/private-sdk",
          "permission": "pull",
      },
  )
  ```

  ```go Go theme={null} theme={null}
  client.Entitlements.New(ctx, dodopayments.EntitlementNewParams{
    Name:            dodopayments.F("Code Share Repository"),
    IntegrationType: dodopayments.F(dodopayments.EntitlementIntegrationTypeGithub),
    IntegrationConfig: dodopayments.F[dodopayments.IntegrationConfigUnionParam](
      dodopayments.IntegrationConfigGitHubConfigParam{
        TargetID:   dodopayments.F("acme/private-sdk"),
        Permission: dodopayments.F("pull"),
      },
    ),
  })
  ```
</CodeGroup>

## Webhooks

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

* `entitlement_grant.created` includes the `oauth_url` for GitHub authorization.
* `entitlement_grant.delivered` fires once the collaborator invitation is created.
* `entitlement_grant.failed` fires with `error_code: "github_permission_denied"` (or similar) if the GitHub App lost access to the repository.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Repository picker is empty">
    The Dodo Payments GitHub App must be installed on the org or user that owns the repository. Open **Entitlements → Integrations → GitHub** and reinstall the app, making sure to grant access to the relevant repositories.
  </Accordion>

  <Accordion title="Grant fails with permission_denied">
    The GitHub App's installation no longer has access to the repository, or the repository was renamed/transferred. Re-grant access to the app and the next regrant will succeed.
  </Accordion>

  <Accordion title="Customer hasn't accepted the invite">
    Customers must accept the GitHub invitation from their notifications page or by clicking the link in their email. Until they accept, they remain "invited" but cannot clone the repo. The grant is still `delivered` from Dodo Payments' perspective; the invitation is what we issue.
  </Accordion>
</AccordionGroup>
