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

# Fulfill License Key Grant

> Manually fulfill a pending license-key grant by supplying the key value. Inserts the key, delivers it to the customer by email, and transitions the grant to delivered.

<Info>
  Use this endpoint only for grants created under a License Key entitlement with `fulfillment_mode: manual`. The grant must be in `pending` status with no key attached. See [Manual Fulfillment](/features/license-keys#manual-fulfillment) and the [Manual License Key Fulfillment Integration Guide](/developer-resources/manual-license-key-fulfillment) for the full flow.
</Info>


## OpenAPI

````yaml post /grants/{grant_id}/license-key
openapi: 3.1.0
info:
  title: public
  description: ''
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: 1.105.15
servers:
  - url: https://test.dodopayments.com/
    description: Test Mode Server Host
  - url: https://live.dodopayments.com/
    description: Live Mode Server Host
security: []
tags:
  - name: Products
  - name: Payments
  - name: Subscriptions
  - name: Addons
  - name: Customers
  - name: Refunds
  - name: Disputes
  - name: Events
  - name: License Keys
  - name: Entitlements
  - name: Licenses
  - name: Discounts
  - name: Meters
  - name: Credit Entitlements
  - name: Credit Entitlement Balances
  - name: Outgoing Webhooks
  - name: Checkout
  - name: Webhook Events
paths:
  /grants/{grant_id}/license-key:
    post:
      tags:
        - Entitlements
      summary: Fulfill a pending license-key grant by supplying the key.
      description: >-
        For entitlements whose license-key config uses `manual` fulfillment,
        grants

        are created in the `pending` state without a key. Call this endpoint to

        deliver the key: the grant moves to `delivered`, the customer is emailed
        the

        key, and the `license_key.created` and `entitlement_grant.delivered`
        webhook

        events are sent.
      operationId: fulfill_license_key_grant_handler
      parameters:
        - name: grant_id
          in: path
          description: Grant ID
          required: true
          schema:
            type: string
          example: entg_w0ZCJZgNXuNDdMVzvja6p
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FulfillLicenseKeyRequest'
        required: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntitlementGrantResponse'
        '400':
          description: Grant is not a license-key grant / empty key
        '404':
          description: Grant not found
        '409':
          description: Grant not awaiting fulfillment / duplicate key
        '422':
          description: Validation error
        '500':
          description: Something went wrong
      security:
        - API_KEY: []
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import DodoPayments from 'dodopayments';


            const client = new DodoPayments({
              bearerToken: process.env['DODO_PAYMENTS_API_KEY'], // This is the default and can be omitted
            });


            const entitlementGrant = await
            client.entitlements.grants.fulfillLicenseKey(
              'entg_w0ZCJZgNXuNDdMVzvja6p',
              { key: 'key' },
            );


            console.log(entitlementGrant.id);
        - lang: Python
          source: |-
            import os
            from dodopayments import DodoPayments

            client = DodoPayments(
                bearer_token=os.environ.get("DODO_PAYMENTS_API_KEY"),  # This is the default and can be omitted
            )
            entitlement_grant = client.entitlements.grants.fulfill_license_key(
                grant_id="entg_w0ZCJZgNXuNDdMVzvja6p",
                key="key",
            )
            print(entitlement_grant.id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/dodopayments/dodopayments-go\"\n\t\"github.com/dodopayments/dodopayments-go/option\"\n)\n\nfunc main() {\n\tclient := dodopayments.NewClient(\n\t\toption.WithBearerToken(\"My Bearer Token\"),\n\t)\n\tentitlementGrant, err := client.Entitlements.Grants.FulfillLicenseKey(\n\t\tcontext.TODO(),\n\t\t\"entg_w0ZCJZgNXuNDdMVzvja6p\",\n\t\tdodopayments.EntitlementGrantFulfillLicenseKeyParams{\n\t\t\tKey: dodopayments.F(\"key\"),\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", entitlementGrant.ID)\n}\n"
        - lang: Java
          source: >-
            package com.dodopayments.api.example;


            import com.dodopayments.api.client.DodoPaymentsClient;

            import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient;

            import
            com.dodopayments.api.models.entitlements.grants.EntitlementGrant;

            import
            com.dodopayments.api.models.entitlements.grants.GrantFulfillLicenseKeyParams;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    DodoPaymentsClient client = DodoPaymentsOkHttpClient.fromEnv();

                    GrantFulfillLicenseKeyParams params = GrantFulfillLicenseKeyParams.builder()
                        .grantId("entg_w0ZCJZgNXuNDdMVzvja6p")
                        .key("key")
                        .build();
                    EntitlementGrant entitlementGrant = client.entitlements().grants().fulfillLicenseKey(params);
                }
            }
        - lang: Kotlin
          source: >-
            package com.dodopayments.api.example


            import com.dodopayments.api.client.DodoPaymentsClient

            import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient

            import
            com.dodopayments.api.models.entitlements.grants.EntitlementGrant

            import
            com.dodopayments.api.models.entitlements.grants.GrantFulfillLicenseKeyParams


            fun main() {
                val client: DodoPaymentsClient = DodoPaymentsOkHttpClient.fromEnv()

                val params: GrantFulfillLicenseKeyParams = GrantFulfillLicenseKeyParams.builder()
                    .grantId("entg_w0ZCJZgNXuNDdMVzvja6p")
                    .key("key")
                    .build()
                val entitlementGrant: EntitlementGrant = client.entitlements().grants().fulfillLicenseKey(params)
            }
        - lang: Ruby
          source: >-
            require "dodopayments"


            dodo_payments = Dodopayments::Client.new(
              bearer_token: "My Bearer Token",
              environment: "test_mode" # defaults to "live_mode"
            )


            entitlement_grant =
            dodo_payments.entitlements.grants.fulfill_license_key("entg_w0ZCJZgNXuNDdMVzvja6p",
            key: "key")


            puts(entitlement_grant)
        - lang: PHP
          source: |-
            <?php

            require_once dirname(__DIR__) . '/vendor/autoload.php';

            use Dodopayments\Client;
            use Dodopayments\Core\Exceptions\APIException;

            $client = new Client(
              bearerToken: getenv('DODO_PAYMENTS_API_KEY') ?: 'My Bearer Token',
              environment: 'test_mode',
            );

            try {
              $entitlementGrant = $client->entitlements->grants->fulfillLicenseKey(
                'entg_w0ZCJZgNXuNDdMVzvja6p',
                key: 'key',
                activationsLimit: 0,
                expiresAt: new \DateTimeImmutable('2019-12-27T18:11:19.117Z'),
              );

              var_dump($entitlementGrant);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: C#
          source: >-
            using System;

            using DodoPayments.Client;

            using DodoPayments.Client.Models.Entitlements.Grants;


            DodoPaymentsClient client = new();


            GrantFulfillLicenseKeyParams parameters = new()

            {
                GrantID = "entg_w0ZCJZgNXuNDdMVzvja6p",
                Key = "key",
            };


            var entitlementGrant = await
            client.Entitlements.Grants.FulfillLicenseKey(parameters);


            Console.WriteLine(entitlementGrant);
        - lang: Rust
          source: |-
            use dodopayments::Client;

            #[tokio::main]
            async fn main() -> dodopayments::Result<()> {
                let client = Client::from_env()?;
                let grant_id = "grant_id";
                let result = client
                    .entitlements()
                    .grants()
                    .fulfill_license_key()
                    .grant_id(grant_id)
                    .body(dodopayments::models::EntitlementsGrantsFulfillLicenseKeyParams {
                            key: Some("key".to_string()),
                            ..Default::default()
                        })
                    .await?;
                println!("{result:?}");
                Ok(())
            }
components:
  schemas:
    FulfillLicenseKeyRequest:
      type: object
      description: Request body for manually fulfilling a pending license-key grant.
      required:
        - key
      properties:
        activations_limit:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            Per-key activation limit. Defaults to the entitlement's license-key
            configuration.
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            When the key expires. Defaults to the duration in the entitlement's
            license-key configuration.
        key:
          type: string
          description: The license key value to deliver to the customer.
    EntitlementGrantResponse:
      type: object
      description: |-
        Detailed view of a single entitlement grant: who it's for, its
        lifecycle state, and any integration-specific delivery payload.
      required:
        - id
        - business_id
        - entitlement_id
        - customer_id
        - status
        - metadata
        - integration_type
        - created_at
        - updated_at
        - brand_id
      properties:
        brand_id:
          type: string
          description: Brand id this grant belongs to.
        business_id:
          type: string
          description: Identifier of the business that owns the grant.
        created_at:
          type: string
          format: date-time
          description: Timestamp when the grant was created.
        customer_id:
          type: string
          description: Identifier of the customer the grant was issued to.
        delivered_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            Timestamp when the grant transitioned to `delivered`, when
            applicable.
        digital_product_delivery:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/DigitalProductDelivery'
              description: |-
                Digital-product-delivery payload, present when the entitlement
                integration is `digital_files`.
        entitlement_id:
          type: string
          description: Identifier of the entitlement this grant was issued from.
        error_code:
          type:
            - string
            - 'null'
          description: >-
            Machine-readable code reported when delivery failed, when
            applicable.
        error_message:
          type:
            - string
            - 'null'
          description: >-
            Human-readable message reported when delivery failed, when
            applicable.
        id:
          type: string
          description: Unique identifier of the grant.
        integration_type:
          $ref: '#/components/schemas/EntitlementIntegrationType'
          description: >-
            The integration type of the grant's entitlement (e.g.
            `license_key`).
        license_key:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/LicenseKeyGrant'
              description: >-
                License-key delivery payload, present when the entitlement
                integration

                is `license_key`.
        metadata:
          $ref: '#/components/schemas/Metadata'
          description: Arbitrary key-value metadata recorded on the grant.
        oauth_expires_at:
          type:
            - string
            - 'null'
          format: date-time
          description: Timestamp when `oauth_url` stops being valid, when applicable.
        oauth_url:
          type:
            - string
            - 'null'
          description: |-
            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.
        payment_id:
          type:
            - string
            - 'null'
          description: >-
            Identifier of the payment that triggered this grant, when
            applicable.
        revocation_reason:
          type:
            - string
            - 'null'
          description: Reason recorded when the grant was revoked, when applicable.
        revoked_at:
          type:
            - string
            - 'null'
          format: date-time
          description: Timestamp when the grant transitioned to `revoked`, when applicable.
        status:
          $ref: '#/components/schemas/EntitlementGrantStatus'
          description: Lifecycle status of the grant.
        subscription_id:
          type:
            - string
            - 'null'
          description: >-
            Identifier of the subscription that triggered this grant, when
            applicable.
        updated_at:
          type: string
          format: date-time
          description: Timestamp when the grant was last modified.
    DigitalProductDelivery:
      type: object
      title: Digital Product Delivery
      description: |-
        Digital-product-delivery payload, present on grants for `digital_files`
        entitlements. Each file carries a short-lived presigned download URL.
      required:
        - files
      properties:
        external_url:
          type:
            - string
            - 'null'
          description: |-
            Optional external URL, passed through from the entitlement
            configuration.
        files:
          type: array
          items:
            $ref: '#/components/schemas/DigitalProductDeliveryFile'
          description: One entry per attached file.
        instructions:
          type:
            - string
            - 'null'
          description: |-
            Optional human-readable delivery instructions, passed through from
            the entitlement configuration.
    EntitlementIntegrationType:
      type: string
      enum:
        - discord
        - telegram
        - github
        - figma
        - framer
        - notion
        - digital_files
        - license_key
    LicenseKeyGrant:
      type: object
      description: |-
        License-key delivery payload, present on grants for `license_key`
        entitlements. The grant's top-level `status` is the source of truth
        for the grant's lifecycle.
      required:
        - key
        - activations_used
      properties:
        activations_limit:
          type:
            - integer
            - 'null'
          format: int32
          description: Maximum activations allowed by the entitlement, when set.
        activations_used:
          type: integer
          format: int32
          description: Number of activations consumed so far.
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
          description: When the license key expires, when applicable.
        key:
          type: string
          description: Issued license key.
    Metadata:
      type: object
      additionalProperties:
        type: string
      propertyNames:
        type: string
    EntitlementGrantStatus:
      type: string
      enum:
        - Pending
        - Delivered
        - Failed
        - Revoked
    DigitalProductDeliveryFile:
      type: object
      title: Digital Product Delivery File
      description: One file in a digital-product delivery payload.
      required:
        - file_id
        - download_url
        - filename
        - expires_in
      properties:
        content_type:
          type:
            - string
            - 'null'
          description: Optional content-type declared at upload.
        download_url:
          type: string
          description: Short-lived presigned URL for downloading the file.
        expires_in:
          type: integer
          format: int64
          description: Seconds until `download_url` expires.
        file_id:
          type: string
          description: Identifier of the attached file.
        file_size:
          type:
            - integer
            - 'null'
          format: int64
          description: Optional size of the file in bytes.
        filename:
          type: string
          description: Original filename of the attached file.
  securitySchemes:
    API_KEY:
      type: http
      scheme: bearer

````