> ## Documentation Index
> Fetch the complete documentation index at: https://docs-test.rye.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Create on-demand top-up invoice

> Request an on-demand top-up invoice..
Requires drawdown billing to be enabled. Only one unpaid top-up invoice
is allowed at a time.



## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/checkout-intents/openapi.documented.yml post /api/v1/billing/drawdown/topup
openapi: 3.0.0
info:
  title: Universal Checkout API
  version: 1.0.5
  description: >-
    Turn any product URL into a completed checkout. Instantly retrieve price,
    tax, and shipping for any product, and let users buy without ever leaving
    your native AI experience.


    View the [Rye API docs](https://docs.rye.com).
  termsOfService: https://rye.com/terms-of-service
  license:
    name: UNLICENSED
  contact:
    name: Rye
    email: dev@rye.com
    url: https://docs.rye.com
servers:
  - url: https://staging.api.rye.com
security: []
paths:
  /api/v1/billing/drawdown/topup:
    post:
      tags:
        - Billing
      summary: Create on-demand top-up invoice
      description: |-
        Request an on-demand top-up invoice..
        Requires drawdown billing to be enabled. Only one unpaid top-up invoice
        is allowed at a time.
      operationId: CreateTopUpInvoice
      parameters: []
      requestBody:
        description: Top-up parameters
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTopUpParams'
              description: ''
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '400':
          description: ''
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                required:
                  - message
                type: object
        '401':
          description: Authentication Failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthenticationError'
        '409':
          description: ''
          content:
            application/json:
              schema:
                properties:
                  invoice:
                    anyOf:
                      - $ref: '#/components/schemas/Invoice'
                      - $ref: '#/components/schemas/DuplicateInvoice'
                    nullable: true
                  message:
                    type: string
                required:
                  - invoice
                  - message
                type: object
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidateError'
        '503':
          description: ''
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                required:
                  - message
                type: object
      security:
        - bearerAuth:
            - billing:write
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import CheckoutIntents from 'checkout-intents';


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


            const response = await client.billing.createTopupInvoice({
            amountSubunits: 500000 });


            console.log(response.id);
        - lang: Python
          source: |-
            import os
            from checkout_intents import CheckoutIntents

            client = CheckoutIntents(
                api_key=os.environ.get("CHECKOUT_INTENTS_API_KEY"),  # This is the default and can be omitted
            )
            response = client.billing.create_topup_invoice(
                amount_subunits=500000,
            )
            print(response.id)
        - lang: Java
          source: |-
            package com.rye.example;

            import com.rye.client.CheckoutIntentsClient;
            import com.rye.client.okhttp.CheckoutIntentsOkHttpClient;
            import com.rye.models.billing.BillingCreateTopupInvoiceParams;
            import com.rye.models.billing.BillingCreateTopupInvoiceResponse;

            public final class Main {
                private Main() {}

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

                    BillingCreateTopupInvoiceParams params = BillingCreateTopupInvoiceParams.builder()
                        .amountSubunits(500000)
                        .build();
                    BillingCreateTopupInvoiceResponse response = client.billing().createTopupInvoice(params);
                }
            }
        - lang: cURL
          source: |-
            curl https://staging.api.rye.com/api/v1/billing/drawdown/topup \
                -H 'Content-Type: application/json' \
                -H "Authorization: Bearer $CHECKOUT_INTENTS_API_KEY" \
                -d '{
                      "amountSubunits": 500000,
                      "chargeAutomatically": false
                    }'
components:
  schemas:
    CreateTopUpParams:
      properties:
        chargeAutomatically:
          type: boolean
          description: |-
            Override whether to automatically charge the invoice.
            Defaults to the developer's drawdown config value if not specified.
          example: false
        amountSubunits:
          type: integer
          format: int32
          description: Amount in smallest currency unit (e.g. cents).
          example: 500000
          minimum: 1
      required:
        - amountSubunits
      type: object
    Invoice:
      properties:
        bankTransferDetails:
          $ref: '#/components/schemas/BankTransferDetails'
        url:
          type: string
          nullable: true
          example: https://invoice.stripe.com/i/acct_xxx/test_xxx
        amount:
          $ref: '#/components/schemas/Money'
        status:
          $ref: '#/components/schemas/InvoiceStatus'
        id:
          type: string
          example: in_abc123
      required:
        - bankTransferDetails
        - url
        - amount
        - status
        - id
      type: object
    AuthenticationError:
      properties:
        name:
          type: string
        message:
          type: string
        stack:
          type: string
      required:
        - name
        - message
      type: object
      additionalProperties: false
    DuplicateInvoice:
      allOf:
        - $ref: '#/components/schemas/Omit_Invoice.amount-or-bankTransferDetails_'
        - properties:
            bankTransferDetails:
              allOf:
                - $ref: '#/components/schemas/BankTransferDetails'
              nullable: true
            amount:
              allOf:
                - $ref: '#/components/schemas/Money'
              nullable: true
          required:
            - bankTransferDetails
            - amount
          type: object
      description: >-
        Degraded invoice returned when full details are unavailable (e.g. Stripe
        fetch failed)
    ValidateError:
      properties:
        name:
          type: string
        message:
          type: string
        stack:
          type: string
        status:
          type: number
          format: double
        fields:
          $ref: '#/components/schemas/FieldErrors'
      required:
        - name
        - message
        - status
        - fields
      type: object
      additionalProperties: false
    BankTransferDetails:
      description: Vendor-agnostic bank transfer details for push-based payment
      properties:
        routingNumber:
          type: string
        accountNumber:
          type: string
        bankName:
          type: string
        accountHolderName:
          type: string
      required:
        - routingNumber
        - accountNumber
        - bankName
        - accountHolderName
      type: object
      additionalProperties: false
    Money:
      properties:
        currencyCode:
          type: string
          example: USD
        amountSubunits:
          type: integer
          format: int32
          example: 1500
      required:
        - currencyCode
        - amountSubunits
      type: object
    InvoiceStatus:
      type: string
      enum:
        - draft
        - open
        - paid
        - uncollectible
        - void
        - unknown
    Omit_Invoice.amount-or-bankTransferDetails_:
      $ref: >-
        #/components/schemas/Pick_Invoice.Exclude_keyofInvoice.amount-or-bankTransferDetails__
      description: Construct a type with the properties of T except for those in type K.
    FieldErrors:
      properties: {}
      type: object
      additionalProperties:
        properties:
          value: {}
          message:
            type: string
        required:
          - message
        type: object
    Pick_Invoice.Exclude_keyofInvoice.amount-or-bankTransferDetails__:
      properties:
        id:
          type: string
          example: in_abc123
        status:
          $ref: '#/components/schemas/InvoiceStatus'
        url:
          type: string
          example: https://invoice.stripe.com/i/acct_xxx/test_xxx
      required:
        - id
        - status
        - url
      type: object
      description: From T, pick a set of properties whose keys are in the union K
  securitySchemes:
    bearerAuth:
      type: apiKey
      in: header
      name: Authorization
      description: Rye API key

````