# Deplete funds

Depletes prepaid balance funds.

A fund is depleted only when it exists, is not deleted, has a balance greater than zero, 
and its source type is a prepayment fund: charge-based unit funds, upfront currency funds. 
Other funds in the request (for example in-arrears currency or non-prepayment sources) are not depleted; 
each appears in the response with status set to failed.

Supply exactly one of fundIds or depleteOptions.

fundIds depletes each listed fund in full using the default accounting date.

depleteOptions selects funds through each entry's fundId and lets each entry specify
its own accounting date and partial amount or quantity. When depleteOptions is non-empty, 
it alone determines which funds are depleted; fundIds is ignored.

A single request cannot mix currency funds with unit or incentive funds.
Such a request is rejected in full.

If one fund fails, the remaining funds are still processed and the affected fund is
returned with status set to failed. This applies to per-fund rejection before any depletion runs 
(unknown id, deleted, zero balance, non-prepayment, invalid partial amount or quantity, or invalid 
caller-supplied depleteDate).

If the request fails request-level validation (shape, batch limits, mixed depletable groups, 
blank or duplicate fundId in depleteOptions, both depleteAmount and depleteQuantity on one entry, 
or unrecognized body fields), no funds are depleted.

Endpoint: POST /v1/prepaid-balance-funds/deplete
Version: 2026-10-01
Security: bearerAuth

## Header parameters:

  - `Idempotency-Key` (string)
    Specify a unique idempotency key if you want to perform an idempotent POST or PATCH request. Do not use this header in other request types. 

With this header specified, the Zuora server can identify subsequent retries of the same request using this value, which prevents the same operation from being performed multiple times by accident.

  - `Accept-Encoding` (string)
    Include the Accept-Encoding: gzip header to compress responses as a gzipped file. It can significantly reduce the bandwidth required for a response. 

If specified, Zuora automatically compresses responses that contain over 1000 bytes of data, and the response contains a Content-Encoding header with the compression algorithm so that your client can decompress it.

  - `Content-Encoding` (string)
    Include the Content-Encoding: gzip header to compress a request. With this header specified, you should upload a gzipped file for the request payload instead of sending the JSON payload.

  - `Authorization` (string)
    The value is in the Bearer {token} format where {token} is a valid OAuth token generated by calling Create an OAuth token.

  - `Zuora-Entity-Ids` (string)
    An entity ID. If you have Zuora Multi-entity enabled and the OAuth token is valid for more than one entity, you must use this header to specify which entity to perform the operation in. If the OAuth token is only valid for a single entity, or you do not have Zuora Multi-entity enabled, you should not set this header.

  - `Zuora-Org-Ids` (string)
    Comma separated IDs. If you have Zuora Multi-Org enabled, 
you can use this header to specify which orgs to perform the operation in. If you do not have Zuora Multi-Org enabled, you should not set this header.

The IDs must be a sub-set of the user's accessible orgs. If you specify an org that the user does not have access to, the operation fails. This header is important in Multi-Org (MO) setups because it defines the organization context under which the API should operate—mainly used for read access or data visibility filtering. If the header is not set, the operation is performed in scope of the user's accessible orgs.

  - `Zuora-Track-Id` (string)
    A custom identifier for tracing the API call. If you set a value for this header, Zuora returns the same value in the response headers. This header enables you to associate your system process identifiers with Zuora API calls, to assist with troubleshooting in the event of an issue.

The value of this field must use the US-ASCII character set and must not include any of the following characters: colon (:), semicolon (;), double quote ("), and quote (').

  - `Zuora-Version` (string)
    The minor API version.

For a list of available minor versions, see API upgrades.

## Request fields (application/json):

  - `fundIds` (array)
    IDs of the funds to deplete in full.
Mutually exclusive with depleteOptions.
Each fund is recorded with the default accounting date of endDate minus one day.
Duplicate ids in this array are not rejected by request validation.

  - `depleteOptions` (array)
    Per-fund deplete instructions.
Mutually exclusive with fundIds.
When supplied, this array alone determines which funds are depleted.
A fundId must not appear more than once.
    Example: [{"fundId":"4028818c8d0c9db5018d0cbbdecd72c1","depleteDate":"2022-06-15","depleteAmount":302}]

  - `depleteOptions.fundId` (string, required)
    The ID of the fund to deplete.

  - `depleteOptions.depleteDate` (string)
    Accounting date recorded on the deplete transaction and the daily consumption record.
Must be on or after the later of startDate and the fund's most recent drawdown
or deplete date, and on or before endDate minus one day.
Defaults to endDate minus one day.

  - `depleteOptions.depleteAmount` (number)
    Amount to deplete from a currency fund.
Must be greater than zero and must not exceed the fund's balance.
Mutually exclusive with depleteQuantity.
Not applicable to quantity-based funds.
When both depleteAmount and depleteQuantity are omitted,
the fund is depleted in full.

  - `depleteOptions.depleteQuantity` (number)
    Quantity to deplete from a quantity-based fund.
Must be greater than zero and must not exceed the fund's balance.
Mutually exclusive with depleteAmount.
Not applicable to amount-based funds (for example upfront currency).

## Response 200 fields (application/json):

  - `processId` (string)
    The ID of the process that handles the operation.

  - `reasons` (array)
    The container of the error code and message. 
This field is available only if the success field is false.

  - `reasons.code` (string)
    The error code of the response.

  - `reasons.message` (string)
    Detailed information about the error response.

  - `requestId` (string)
    Unique identifier of the request.

  - `success` (boolean)
    Indicates whether the request was structurally valid and processing completed.
A value of true can include per-fund failures.
A value of false indicates the entire request was rejected (validation, permission, 
or depletion transaction failure), with details in reasons.

  - `fundIds` (array)
    One entry per fund in the request, covering both depleted funds and funds that were 
rejected on their own. Absent when the request was rejected as a whole.

  - `fundIds.fundId` (string)
    The unique ID of the fund.

  - `fundIds.status` (string)
    The status of the fund depletion: 
success if the fund was depleted, and failed if this fund alone was rejected.
    Enum: "success", "failed"

  - `fundIds.message` (string)
    Localized description of the outcome for this fund.

  - `fundIds.depleteDate` (string)
    Accounting date on which the depletion was recorded.
Present only when status is success; omitted for failed funds.

## Response 500 fields (application/json):

  - `reasons` (array)
    Example: [{"code":"ObjectNotFound","message":"Notification definition with id 6e569e1e05f040eda51a927b140c0ac1 does not exist"}]

  - `reasons.code` (string)
    The error code of response.

  - `reasons.message` (string)
    The detail information of the error response

## Response 4XX fields (application/json):

  - `processId` (string)
    The ID of the process that handles the operation.

  - `reasons` (array)
    The container of the error code and message. This field is available only if the success field is false.

  - `reasons.code` (string)
    The error code of response.

  - `reasons.message` (string)
    The detail information of the error response

  - `requestId` (string)
    Unique identifier of the request.

  - `success` (boolean)
    Indicates whether the call succeeded.


