> ## Documentation Index
> Fetch the complete documentation index at: https://dodopayments-mintlify-external-integration-datafast-autosen.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Update License Key

> This endpoint allows you to update a license key by its ID.



## OpenAPI

````yaml patch /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.61.5
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: Licenses
  - name: Discounts
  - name: Meters
  - name: Outgoing Webhooks
  - name: Checkout
  - name: Webhook Events
paths:
  /license_keys/{id}:
    patch:
      tags:
        - License Keys
      operationId: update_license_key
      parameters:
        - name: id
          in: path
          description: License key ID
          required: true
          schema:
            type: string
          example: lic_123
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PatchLicenseKeyRequest'
        required: true
      responses:
        '200':
          description: License key updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LicenseKeyResponse'
        '400':
          description: Cannot set expiry for subscription-based license
        '404':
          description: License key not found
        '422':
          description: New activation limit is less than current instances count
        '500':
          description: Something went wrong :(
      security:
        - API_KEY: []
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import DodoPayments from 'dodopayments';

            const client = new DodoPayments({
              bearerToken: 'My Bearer Token',
            });

            const licenseKey = await client.licenseKeys.update('lic_123');

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

            client = DodoPayments(
                bearer_token="My Bearer Token",
            )
            license_key = client.license_keys.update(
                id="lic_123",
            )
            print(license_key.id)
        - lang: Go
          source: |
            package main

            import (
              "context"
              "fmt"

              "github.com/dodopayments/dodopayments-go"
              "github.com/dodopayments/dodopayments-go/option"
            )

            func main() {
              client := dodopayments.NewClient(
                option.WithBearerToken("My Bearer Token"),
              )
              licenseKey, err := client.LicenseKeys.Update(
                context.TODO(),
                "lic_123",
                dodopayments.LicenseKeyUpdateParams{

                },
              )
              if err != nil {
                panic(err.Error())
              }
              fmt.Printf("%+v\n", licenseKey.ID)
            }
        - 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.LicenseKeyUpdateParams;


            public final class Main {
                private Main() {}

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

                    LicenseKey licenseKey = client.licenseKeys().update("lic_123");
                }
            }
        - 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.LicenseKeyUpdateParams


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

                val licenseKey: LicenseKey = client.licenseKeys().update("lic_123")
            }
        - 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.update("lic_123")

            puts(license_key)
components:
  schemas:
    PatchLicenseKeyRequest:
      type: object
      properties:
        activations_limit:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            The updated activation limit for the license key.

            Use `null` to remove the limit, or omit this field to leave it
            unchanged.
        disabled:
          type:
            - boolean
            - 'null'
          description: >-
            Indicates whether the license key should be disabled.

            A value of `true` disables the key, while `false` enables it. Omit
            this field to leave it unchanged.
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            The updated expiration timestamp for the license key in UTC.

            Use `null` to remove the expiration date, or omit this field to
            leave it unchanged.
    LicenseKeyResponse:
      type: object
      required:
        - id
        - business_id
        - key
        - status
        - customer_id
        - product_id
        - payment_id
        - instances_count
        - created_at
      properties:
        activations_limit:
          type:
            - integer
            - 'null'
          format: int32
          description: The maximum number of activations allowed for this license key.
          example: 5
        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:00Z'
        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:59Z'
        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
          description: >-
            The unique identifier of the payment associated with the license
            key.
        product_id:
          type: string
          description: >-
            The unique identifier of the product associated with the license
            key.
        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.
    LicenseKeyStatus:
      type: string
      enum:
        - active
        - expired
        - disabled
  securitySchemes:
    API_KEY:
      type: http
      scheme: bearer

````