---
title: "Generate billing documents by account ID"
method: POST
path: "/v1/accounts/{key}/billing-documents/generate"
tags: ["Billing Documents"]
---

# Generate billing documents by account ID

`POST /v1/accounts/{key}/billing-documents/generate`

Generates draft or posted billing documents for a specified account. You can also generate billing documents for specified subscriptions of a specified account. The billing documents contain invoices and credit memos. To generate credit memos, you must have the Invoice Settlement feature enabled.

**Note**: You cannot generate billing documents for cancelled or suspended subscriptions.

## Path parameters

- `key` string, required

## Headers

- `Idempotency-Key` string
- `Accept-Encoding` string
- `Content-Encoding` string
- `Zuora-Track-Id` string
- `Zuora-Entity-Ids` string
- `Zuora-Org-Ids` string
- `Zuora-Version` string

## Request body

- PostGenerateBillingDocumentType
  - `autoPost` true | false — Whether to automatically post the billing documents after the draft billing documents are generated. If an error occurs during posting billing documents, the draft billing documents are not generated too.
  - `autoRenew` true | false — Whether to automatically renew the subscriptions with **Auto Renew** set to **Yes**.
  - `chargeTypeToExclude` string[] — The types of the charges to be excluded from the generation of billing documents. The field values are case insensitive. Supported values include `onetime`, `recurring`, and `usage`.
  - `commitmentKeys` string[] — The IDs of the commitments to include in billing document generation.
  - `creditMemoReasonCode` string — A code identifying the reason for the credit memo transaction that is generated by the request. The value must be an existing reason code. If you do not pass the field or pass the field with empty value, Zuora uses the default reason code.
  - `effectiveDate` string, date, required — The date on which to generate the billing documents, in `yyyy-mm-dd` format.
  - `includeSubscriptions` boolean — Indicates whether to bill subscriptions in the bill run.
  - `includeOrderLineItems` boolean — Indicates whether to bill order line items in the bill run.
  - `subscriptionIds` string[] — The IDs of the subscriptions that you want to create the billing documents for. Each value must be the ID of the latest version of an active subscription.
  - `targetDate` string, date, required — The date used to determine which charges are to be billed, in `yyyy-mm-dd` format.

## Response `200`

OK

- GenerateBillingDocumentResponseType
  - `creditMemos` CreditMemoResponseType[] — Container for generated credit memos. **Note:** This container is only available if you have [Invoice Settlement](https://docs.zuora.com?resourceId=billing-invoice-settlement) enabled. The Invoice Settlement feature is generally available as of Zuora Billing Release 296 (March 2021). This feature includes Unapplied Payments, Credit and Debit Memo, and Invoice Item Settlement. If you want to enable Invoice Settlement, see [Invoice Settlement Enablement and Checklist Guide](https://docs.zuora.com?resourceId=billing-invoice-settlement-migration-checklist-and-guide) for more information.
    - `id` string — The ID of the generated credit memo.
  - `invoices` InvoiceResponseType[] — Container for generated invoics.
    - `id` string — The ID of the generated invoice.
  - `success` boolean — Returns `true` if the request was processed successfully.

## Other responses

- `500` — Internal Server Error
- `4XX` — Request Errors

---

[API](https://skmtc.dev/zuora/apis/api-reference.md) · [All operations](https://skmtc.dev/zuora/apis/api-reference/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/zuora/api-reference/revisions/d11e237f3e54/schema)
