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

# Kích hoạt Giấy phép

> Điểm cuối này cho phép bạn kích hoạt một giấy phép cho người dùng.

<Info>
  **Không yêu cầu khóa API**: Đây là một endpoint công khai không yêu cầu xác thực. Bạn có thể gọi nó trực tiếp từ các ứng dụng khách, phần mềm máy tính để bàn, hoặc CLI để kích hoạt khóa giấy phép mà không cần tiết lộ thông tin xác thực API của mình.
</Info>


## OpenAPI

````yaml post /licenses/activate
openapi: 3.1.0
info:
  title: public
  description: ''
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: 1.106.2
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
  - name: Payment Connector Webhooks
paths:
  /licenses/activate:
    post:
      tags:
        - Licenses
      operationId: activate_license_key
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActivateLicenseKeyRequest'
        required: true
      responses:
        '201':
          description: License key instance created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActivateLicenseKeyResponse'
        '403':
          description: License key cannot be activated (inactive)
        '404':
          description: License key not found
        '422':
          description: License key activation limit reached
        '500':
          description: Something went wrong :(
      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 response = await client.licenses.activate({ license_key:
            'license_key', name: 'name' });


            console.log(response.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
            )
            response = client.licenses.activate(
                license_key="license_key",
                name="name",
            )
            print(response.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\tresponse, err := client.Licenses.Activate(context.TODO(), dodopayments.LicenseActivateParams{\n\t\tLicenseKey: dodopayments.F(\"license_key\"),\n\t\tName:       dodopayments.F(\"name\"),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.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.licenses.LicenseActivateParams;
            import com.dodopayments.api.models.licenses.LicenseActivateResponse;

            public final class Main {
                private Main() {}

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

                    LicenseActivateParams params = LicenseActivateParams.builder()
                        .licenseKey("license_key")
                        .name("name")
                        .build();
                    LicenseActivateResponse response = client.licenses().activate(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.licenses.LicenseActivateParams
            import com.dodopayments.api.models.licenses.LicenseActivateResponse

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

                val params: LicenseActivateParams = LicenseActivateParams.builder()
                    .licenseKey("license_key")
                    .name("name")
                    .build()
                val response: LicenseActivateResponse = client.licenses().activate(params)
            }
        - lang: Ruby
          source: >-
            require "dodopayments"


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


            response = dodo_payments.licenses.activate(license_key:
            "license_key", name: "name")


            puts(response)
        - 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 {
              $response = $client->licenses->activate(
                licenseKey: 'license_key', name: 'name'
              );

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

            DodoPaymentsClient client = new();

            LicenseActivateParams parameters = new()
            {
                LicenseKey = "license_key",
                Name = "name",
            };

            var response = await client.Licenses.Activate(parameters);

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

            #[tokio::main]
            async fn main() -> dodopayments::Result<()> {
                let client = Client::from_env()?;
                let result = client
                    .licenses()
                    .activate()
                    .body(dodopayments::models::LicensesActivateParams {
                            license_key: Some("license_key".to_string()),
                            name: Some("name".to_string()),
                            ..Default::default()
                        })
                    .await?;
                println!("{result:?}");
                Ok(())
            }
components:
  schemas:
    ActivateLicenseKeyRequest:
      type: object
      required:
        - name
        - license_key
      properties:
        license_key:
          type: string
        name:
          type: string
    ActivateLicenseKeyResponse:
      type: object
      required:
        - id
        - business_id
        - name
        - license_key_id
        - created_at
        - product
        - customer
      properties:
        business_id:
          type: string
          description: Business ID
        created_at:
          type: string
          format: date-time
          description: Creation timestamp
          example: '2024-01-01T00:00:00.000Z'
        customer:
          $ref: '#/components/schemas/CustomerLimitedDetailsResponse'
          description: Limited customer details associated with the license key.
        id:
          type: string
          description: License key instance ID
          example: lki_123
        license_key_id:
          type: string
          description: Associated license key ID
          example: lic_123
        name:
          type: string
          description: Instance name
          example: Production Server 1
        product:
          $ref: '#/components/schemas/ActivateLicenseKeyProductInfo'
          description: >-
            Related product info. Present if the license key is tied to a
            product.
    CustomerLimitedDetailsResponse:
      type: object
      required:
        - customer_id
        - name
        - email
      properties:
        customer_id:
          type: string
          description: Unique identifier for the customer
        email:
          type: string
          description: Email address of the customer
        metadata:
          $ref: '#/components/schemas/Metadata'
          description: Additional metadata associated with the customer
        name:
          type: string
          description: Full name of the customer
        phone_number:
          type:
            - string
            - 'null'
          description: Phone number of the customer
    ActivateLicenseKeyProductInfo:
      type: object
      required:
        - product_id
      properties:
        name:
          type:
            - string
            - 'null'
          description: Name of the product, if set by the merchant.
        product_id:
          type: string
          description: Unique identifier for the product.
    Metadata:
      type: object
      title: Metadata
      description: >-
        Arbitrary key-value metadata. Values can be string, integer, number, or
        boolean.
      additionalProperties:
        oneOf:
          - type: string
            title: String
          - type: integer
            title: Integer
            format: int64
          - type: number
            title: Number
            format: double
          - type: boolean
            title: Boolean
        title: Metadata Value
        description: Metadata value can be a string, integer, number, or boolean

````