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

# Dapatkan Kunci Lisensi

> Ambil detail dari kunci lisensi tertentu berdasarkan ID-nya.

<Warning>
  **API yang Dihentikan**: Kunci lisensi sekarang dikelola melalui sistem [Entitlements](/features/entitlements/introduction). Gunakan [List Grants](/api-reference/entitlements/list-grants) (filter dengan `integration_type=license_key`) untuk mengambil grant kunci dan detail `license_key`-nya. Endpoint ini akan dihapus pada rilis mendatang.
</Warning>


## OpenAPI

````yaml get /license_keys/{id}
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.11
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:
  /license_keys/{id}:
    get:
      tags:
        - License Keys
      operationId: get_license_key_handler
      parameters:
        - name: id
          in: path
          description: License key ID
          required: true
          schema:
            type: string
          example: lic_7namTC0VcgrnzrF3GTSwB
      responses:
        '200':
          description: License key found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LicenseKeyResponse'
        '404':
          description: License key not found
        '500':
          description: Something went wrong :(
      deprecated: true
      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 licenseKey = await
            client.licenseKeys.retrieve('lic_7namTC0VcgrnzrF3GTSwB');


            console.log(licenseKey.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
            )
            license_key = client.license_keys.retrieve(
                "lic_7namTC0VcgrnzrF3GTSwB",
            )
            print(license_key.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\tlicenseKey, err := client.LicenseKeys.Get(context.TODO(), \"lic_7namTC0VcgrnzrF3GTSwB\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", licenseKey.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.licensekeys.LicenseKey;

            import
            com.dodopayments.api.models.licensekeys.LicenseKeyRetrieveParams;


            public final class Main {
                private Main() {}

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

                    LicenseKey licenseKey = client.licenseKeys().retrieve("lic_7namTC0VcgrnzrF3GTSwB");
                }
            }
        - 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.licensekeys.LicenseKey

            import
            com.dodopayments.api.models.licensekeys.LicenseKeyRetrieveParams


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

                val licenseKey: LicenseKey = client.licenseKeys().retrieve("lic_7namTC0VcgrnzrF3GTSwB")
            }
        - lang: Ruby
          source: >-
            require "dodopayments"


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


            license_key =
            dodo_payments.license_keys.retrieve("lic_7namTC0VcgrnzrF3GTSwB")


            puts(license_key)
        - 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 {
              $licenseKey = $client->licenseKeys->retrieve('lic_7namTC0VcgrnzrF3GTSwB');

              var_dump($licenseKey);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: C#
          source: |-
            using System;
            using DodoPayments.Client;
            using DodoPayments.Client.Models.LicenseKeys;

            DodoPaymentsClient client = new();

            LicenseKeyRetrieveParams parameters = new()
            {
                ID = "lic_7namTC0VcgrnzrF3GTSwB"
            };

            var licenseKey = await client.LicenseKeys.Retrieve(parameters);

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

            #[tokio::main]
            async fn main() -> dodopayments::Result<()> {
                let client = Client::from_env()?;
                let id = "id";
                let result = client
                    .license_keys()
                    .retrieve()
                    .id(id)
                    .await?;
                println!("{result:?}");
                Ok(())
            }
components:
  schemas:
    LicenseKeyResponse:
      type: object
      required:
        - id
        - business_id
        - key
        - status
        - customer_id
        - product_id
        - instances_count
        - created_at
        - source
        - brand_id
      properties:
        activations_limit:
          type:
            - integer
            - 'null'
          format: int32
          description: The maximum number of activations allowed for this license key.
          example: 5
        brand_id:
          type: string
          description: Brand id this license key belongs to
        business_id:
          type: string
          description: >-
            The unique identifier of the business associated with the license
            key.
        created_at:
          type: string
          format: date-time
          description: The timestamp indicating when the license key was created, in UTC.
          example: '2024-01-01T00:00:00.000Z'
        customer_id:
          type: string
          description: >-
            The unique identifier of the customer associated with the license
            key.
          example: cus_123
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
          description: The timestamp indicating when the license key expires, in UTC.
          example: '2024-12-31T23:59:59.000Z'
        id:
          type: string
          description: The unique identifier of the license key.
          example: lic_123
        instances_count:
          type: integer
          format: int32
          description: The current number of instances activated for this license key.
        key:
          type: string
          description: The license key string.
        payment_id:
          type:
            - string
            - 'null'
          description: >-
            The unique identifier of the payment associated with the license
            key, if any.
        product_id:
          type: string
          description: >-
            The unique identifier of the product associated with the license
            key.
        source:
          $ref: '#/components/schemas/LicenseKeySource'
          description: >-
            The source of the license key - 'auto' for keys generated by
            payment/subscription flows, 'import' for merchant-imported keys.
        status:
          $ref: '#/components/schemas/LicenseKeyStatus'
          description: >-
            The current status of the license key (e.g., active, inactive,
            expired).
        subscription_id:
          type:
            - string
            - 'null'
          description: >-
            The unique identifier of the subscription associated with the
            license key, if any.
    LicenseKeySource:
      type: string
      enum:
        - auto
        - import
        - manual
    LicenseKeyStatus:
      type: string
      enum:
        - active
        - expired
        - disabled
  securitySchemes:
    API_KEY:
      type: http
      scheme: bearer

````