Generate On-Demand Invoice Document (POST)

Generate an invoice document for a record, and update any junction object record.

Resource 

1/revenue/billing/document/actions/generate

Resource Example 

1https://{yourInstance}.salesforce.com/services/data/v68.0/revenue/billing/document/actions/generate

Available Version 

66.0

HTTP Methods 

POST

Request Body for POST 

JSON Example

1{
2  "recordId": "3ttasd98776266777",
3  "shouldForceRegenerate": true,
4  "documentTemplateId": "0694x000000XyzABC",
5  "documentTitle": "DOC-00000012",
6  "tokenData": "{\"InvoiceLines\":{\"StartDate\":\"02/21/2025\",\"IsUsageBasedInvoiceLine\":false,\"UnitPrice\":\"$7.99\",\"ProductName\":\"Mouse\",\"UsageProductId\":\"01tSG00000BHFPSYA5\",\"Subtotal\":\"$7.99\",\"Quantity\":\"1\",\"Tax\":\"$0.00\",\"Id\":\"5TVSG000000DU3V4AW\",\"CurrencyIsoCode\":\"USD\",\"EndDate\":\"02/21/2025\"},\"NetCreditsApplied\":\"$0.00\",\"CompanyEmail\":\"rsamantaray@salesforce.com\",\"CompanyState\":\"CA\",\"DocumentNumber\":\"DOC-000000001\",\"SubTotal\":\"$7.99\",\"CompanyStreet\":\"1 Market St\",\"CompanyName\":\"260.1\",\"TotalAmnt\":\"$7.99\",\"TotalTax\":\"$0.00\",\"InvoiceDueDate\":\"10/08/2025\",\"CompanyPostalCode\":\"94105\",\"InvoiceDate\":\"09/08/2025\",\"CompanyCity\":\"San Francisco\",\"CompanyCountry\":\"US\",\"AccountName\":\"Sonia BAT Account\"}"
7}

Properties

NameTypeDescriptionRequired or OptionalAvailable Version
documentTemplateIdStringDocument template ID to use for PDF generation. The document template must be active with UsageType as INVOICE. If you don’t specify this value, the system auto-resolves by using the default template.Optional66.0
documentTitleStringCustom title for the generated document. If you don’t specify a value, the value is auto-generated.Optional66.0
recordIdStringRecord ID of the object the document is generated for. You can specify invoice ID only.Required66.0
shouldForceRegenerateBooleanIndicates whether to regenerate the document (true) or not (false). If set to true, this API generates a document, replacing any existing ones. If set to false, this API skips the generation of document if invoice already has an associated document. The default value is false.Optional66.0
tokenDataStringToken data to generate the document.Optional66.0

Response Body for POST 

On-Demand Document Generation Response