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

# Update Credit Entitlement

> Updates an existing credit entitlement with partial data



## OpenAPI

````yaml patch /credit-entitlements/{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.102.0
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:
  /credit-entitlements/{id}:
    patch:
      tags:
        - Credit Entitlements
      summary: Updates an existing credit entitlement with partial data.
      description: >-
        Allows partial updates to a credit entitlement's configuration. Only the
        fields

        provided in the request body will be updated; all other fields remain
        unchanged.

        This endpoint supports nullable fields using the double option pattern.


        # Authentication

        Requires an API key with `Editor` role.


        # Path Parameters

        - `id` - The unique identifier of the credit entitlement to update
        (format: `cde_...`)


        # Request Body (all fields optional)

        - `name` - Human-readable name of the credit entitlement (1-255
        characters)

        - `description` - Optional description (max 1000 characters)

        - `unit` - Unit of measurement for the credit (1-50 characters)


        Note: `precision` cannot be modified after creation as it would
        invalidate existing grants.

        - `expires_after_days` - Number of days after which credits expire (use
        `null` to remove expiration)

        - `rollover_enabled` - Whether unused credits can rollover to the next
        period

        - `rollover_percentage` - Percentage of unused credits that rollover
        (0-100, nullable)

        - `rollover_timeframe_count` - Count of timeframe periods for rollover
        limit (nullable)

        - `rollover_timeframe_interval` - Interval type (day, week, month, year,
        nullable)

        - `max_rollover_count` - Maximum number of times credits can be rolled
        over (nullable)

        - `overage_enabled` - Whether overage charges apply when credits run out

        - `overage_limit` - Maximum overage units allowed (nullable)

        - `currency` - Currency for pricing (nullable)

        - `price_per_unit` - Price per credit unit (decimal, nullable)


        # Responses

        - `200 OK` - Credit entitlement updated successfully

        - `404 Not Found` - Credit entitlement does not exist or does not belong
        to the authenticated business

        - `422 Unprocessable Entity` - Invalid request parameters or validation
        failure

        - `500 Internal Server Error` - Database or server error


        # Business Logic

        - Only non-deleted credit entitlements can be updated

        - Fields set to `null` explicitly will clear the database value (using
        double option pattern)

        - The `updated_at` timestamp is automatically updated on successful
        modification

        - Changes take effect immediately but do not retroactively affect
        existing credit grants

        - The merged state is validated: currency required with price, rollover
        timeframe fields together, price required for overage
      operationId: patch_credit_entitlement
      parameters:
        - name: id
          in: path
          description: Credit Entitlement ID
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PatchCreditEntitlementRequest'
        required: true
      responses:
        '200':
          description: Credit entitlement updated successfully
        '404':
          description: Credit entitlement not found
        '422':
          description: Invalid Request Object or Parameters
        '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
            });

            await client.creditEntitlements.update('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
            )
            client.credit_entitlements.update(
                id="id",
            )
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\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\terr := client.CreditEntitlements.Update(\n\t\tcontext.TODO(),\n\t\t\"id\",\n\t\tdodopayments.CreditEntitlementUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\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.creditentitlements.CreditEntitlementUpdateParams;


            public final class Main {
                private Main() {}

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

                    client.creditEntitlements().update("id");
                }
            }
        - 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.creditentitlements.CreditEntitlementUpdateParams


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

                client.creditEntitlements().update("id")
            }
        - lang: Ruby
          source: |-
            require "dodopayments"

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

            result = dodo_payments.credit_entitlements.update("id")

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

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

            use Dodopayments\Client;
            use Dodopayments\Core\Exceptions\APIException;
            use Dodopayments\CreditEntitlements\CbbOverageBehavior;
            use Dodopayments\Misc\Currency;
            use Dodopayments\Subscriptions\TimeInterval;

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

            try {
              $result = $client->creditEntitlements->update(
                'id',
                currency: Currency::AED,
                description: 'description',
                expiresAfterDays: 0,
                maxRolloverCount: 0,
                name: 'name',
                overageBehavior: CbbOverageBehavior::FORGIVE_AT_RESET,
                overageEnabled: true,
                overageLimit: 0,
                pricePerUnit: 'price_per_unit',
                rolloverEnabled: true,
                rolloverPercentage: 0,
                rolloverTimeframeCount: 0,
                rolloverTimeframeInterval: TimeInterval::DAY,
                unit: 'unit',
              );

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

            DodoPaymentsClient client = new();

            CreditEntitlementUpdateParams parameters = new() { ID = "id" };

            await client.CreditEntitlements.Update(parameters);
components:
  schemas:
    PatchCreditEntitlementRequest:
      type: object
      properties:
        currency:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Currency'
              description: Currency for pricing
        description:
          type:
            - string
            - 'null'
          description: Optional description of the credit entitlement
        expires_after_days:
          type:
            - integer
            - 'null'
          format: int32
          description: Number of days after which credits expire
        max_rollover_count:
          type:
            - integer
            - 'null'
          format: int32
          description: Maximum number of times credits can be rolled over
        name:
          type:
            - string
            - 'null'
          description: Name of the credit entitlement
        overage_behavior:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/CbbOverageBehavior'
              description: Controls how overage is handled at billing cycle end.
        overage_enabled:
          type:
            - boolean
            - 'null'
          description: Whether overage charges are enabled when credits run out
        overage_limit:
          type:
            - integer
            - 'null'
          format: int64
          description: Maximum overage units allowed
        price_per_unit:
          type:
            - string
            - 'null'
          description: Price per credit unit
        rollover_enabled:
          type:
            - boolean
            - 'null'
          description: Whether rollover is enabled for unused credits
        rollover_percentage:
          type:
            - integer
            - 'null'
          format: int32
          description: Percentage of unused credits that can rollover (0-100)
        rollover_timeframe_count:
          type:
            - integer
            - 'null'
          format: int32
          description: Count of timeframe periods for rollover limit
        rollover_timeframe_interval:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TimeInterval'
              description: Interval type for rollover timeframe
        unit:
          type:
            - string
            - 'null'
          description: >-
            Unit of measurement for the credit (e.g., "API Calls", "Tokens",
            "Credits")
    Currency:
      type: string
      enum:
        - AED
        - ALL
        - AMD
        - ANG
        - AOA
        - ARS
        - AUD
        - AWG
        - AZN
        - BAM
        - BBD
        - BDT
        - BGN
        - BHD
        - BIF
        - BMD
        - BND
        - BOB
        - BRL
        - BSD
        - BWP
        - BYN
        - BZD
        - CAD
        - CHF
        - CLP
        - CNY
        - COP
        - CRC
        - CUP
        - CVE
        - CZK
        - DJF
        - DKK
        - DOP
        - DZD
        - EGP
        - ETB
        - EUR
        - FJD
        - FKP
        - GBP
        - GEL
        - GHS
        - GIP
        - GMD
        - GNF
        - GTQ
        - GYD
        - HKD
        - HNL
        - HRK
        - HTG
        - HUF
        - IDR
        - ILS
        - INR
        - IQD
        - JMD
        - JOD
        - JPY
        - KES
        - KGS
        - KHR
        - KMF
        - KRW
        - KWD
        - KYD
        - KZT
        - LAK
        - LBP
        - LKR
        - LRD
        - LSL
        - LYD
        - MAD
        - MDL
        - MGA
        - MKD
        - MMK
        - MNT
        - MOP
        - MRU
        - MUR
        - MVR
        - MWK
        - MXN
        - MYR
        - MZN
        - NAD
        - NGN
        - NIO
        - NOK
        - NPR
        - NZD
        - OMR
        - PAB
        - PEN
        - PGK
        - PHP
        - PKR
        - PLN
        - PYG
        - QAR
        - RON
        - RSD
        - RUB
        - RWF
        - SAR
        - SBD
        - SCR
        - SEK
        - SGD
        - SHP
        - SLE
        - SLL
        - SOS
        - SRD
        - SSP
        - STN
        - SVC
        - SZL
        - THB
        - TND
        - TOP
        - TRY
        - TTD
        - TWD
        - TZS
        - UAH
        - UGX
        - USD
        - UYU
        - UZS
        - VES
        - VND
        - VUV
        - WST
        - XAF
        - XCD
        - XOF
        - XPF
        - YER
        - ZAR
        - ZMW
    CbbOverageBehavior:
      type: string
      description: >-
        Controls how overage is handled at the end of a billing cycle.


        | Preset                  | Charge at billing | Credits reduce overage |
        Preserve overage at reset |

        |-------------------------|:-----------------:|:---------------------:|:-------------------------:|

        | `forgive_at_reset`      | No                | No                    |
        No                        |

        | `invoice_at_billing`    | Yes               | No                    |
        No                        |

        | `carry_deficit`         | No                | No                    |
        Yes                       |

        | `carry_deficit_auto_repay` | No             | Yes                   |
        Yes                       |
      enum:
        - forgive_at_reset
        - invoice_at_billing
        - carry_deficit
        - carry_deficit_auto_repay
    TimeInterval:
      type: string
      enum:
        - Day
        - Week
        - Month
        - Year
  securitySchemes:
    API_KEY:
      type: http
      scheme: bearer

````