Skip to main content

Generate an invoice using SOAP API


Generate an invoice using SOAP API

This article walks you through the process of generating an invoice with the SOAP API. This process uses the generate() call and the Invoice object. Generating a new invoice with the SOAP API is similar to the process of creating an ad hoc invoice in the Zuora UI. This article gives you some examples on how to generate a new invoice and how to regenerate a PDF version of the invoice. 

How to Use this Walkthrough

This walkthrough uses a fictitious company as a case study. Substitute your own values when you use these steps and examples.

Start all of your processes by creating your SOAP envelope, and put your code inside. Don't forget to pass your session ID and URL with your SOAP calls.

This walkthrough assumes that you are using the latest version of the WSDL. If you are using an older version of the WSDL, some of the fields, calls, and objects are not available. For example, if your WSDL version is older than version 40.0, then you cannot regenerate an invoice PDF.

Generate a new invoice

Lucia from Widget Wiki needs to generate an invoice for a specific customer whose account number is 8a8ae4b122561fc00122562fbc3d0002. The invoice needs to include all charges through July 31, 2016. She wants to look at the invoice before posting it, so the invoice needs to be in Draft status upon generation. 

Lucia sets the following fields and values:

  • AccountId: 8a8ae4b122561fc00122562fbc3d0002
  • IncludesOneTime: true
  • IncludesRecurring: true
  • IncludesUsage: true
  • InvoiceDate: 2016-08-01
  • TargetDate: 2016-07-31

If Lucia wants to post it now, she can use an update() call.

Example Request

  <ns1:zObjects xsi:type="ns2:Invoice">

The response returns an invoice to Lucia in Draft status and indicates Success: true.

Regenerate a PDF Version of the invoice

Lucia made some changes that affect an invoice she generated. She can use the update() call with the RegenerateInvoicePDF field to regenerate a PDF version of this invoice. The value for this field can be set to true or false. Note that when you set the RegenerateInvoicePDF field to true, you cannot update any other fields in the same update() call. Otherwise, you will receive the following INVALID_VALUE error:

When field RegenerateInvoicePDF is set to true to regenerate the invoice PDF file, changes on other fields of the invoice are not allowed.

Lucia sets the following fields and values:

  • Id: 8a8ae4b122561fc00122562fbc3d0002
  • RegenerateInvoicePDF: true  

 Example Request

<ns1:update xmlns:ns1="">
    <ns1:zObjects xsi:type="ns2:Invoice" xmlns:ns2=""

The response returns a new invoice PDF to Lucia in Draft status and indicates Success: true.