Scope requirements
Scope requirements
Create invoices
The invoice creation process can be broken up into the following steps:- Create an invoice: create a draft invoice and set the currency.
- Configure the invoice: add associations to CRM records, such as a contact and line items to the invoice, properties, and configure payment settings.
- Move the invoice status to open: move the invoice status from
drafttoopen. - Share the invoice: share the invoice with the buyer.
POST request to /crm/v3/objects/invoices.
In the post body, include a properties object to store basic invoice information.
- The only property required for creating a draft invoice is
hs_currency, which accepts a string value of a currency code (e.g.,USD). - You can modify a drafted invoice’s properties any time by updating the invoice.
- The invoice will inherit other property values when you later associate a contact with it, such as contact and company details, which will be required before you can set the invoice to the Open state. Learn more about updating properties and adding associations.
Depending on your preferred workflow, you can instead create a draft invoice with associations through one POST request, rather than making two separate requests.
id, which you’ll use to continue configuring the invoice. You can update invoice properties at any time by making a PATCH request to /crm/v3/objects/invoices/{invoiceId}.
Invoice configuration
To move the invoice to theopen status so that it can be shared and paid, you’ll need to set a few required properties and associate it with other CRM records, such as line items and a contact. If you’ve set up HubSpot payments or Stripe payment processing, you can also configure the invoice’s payment settings.
Update invoice properties
To update an invoice’s properties, make aPATCH request to /crm/v3/objects/invoices/{invoiceId}. In the request body, include a properties object with fields for the properties you want to update.
Add associations
To associate other CRM records with the invoice, make aPUT request to /crm/v4/objects/invoices/{fromObjectId}/associations/default/{toObjectType}/{toObjectId}.
The table below show which CRM record associations are required to move the invoice to the Open state, and which are optional. View a full list of the objects can be associated with invoices.
To make each association, you’ll first need to retrieve the ID of each object you want to associate. To retrieve each ID, you’ll make a
GET request to the relevant object endpoint, which follows the same pattern across each CRM object.
200 response with details for each fetched object type. You’ll use the value in the id field to set associations in the next step.
Make an invoice non-billable
A non-billable invoice won’t render, meaning an invoice document won’t be created, and other invoice functionalities, such as validation, email, and notifications, will not be included. This could be useful if you want to track invoice data in HubSpot, but manage or bill the invoices outside of HubSpot. To make an invoice non-billable, create an invoice, making aPOST request to /crm/v3/objects/invoices and include the hs_invoice_billable property.
Configure payment settings
If your account is set up to collect digital payments using HubSpot payments or Stripe payment processing, and the currency of the invoice is set to a currency that is valid for transacting, the invoice will automatically be configured to collect payments. In addition, other properties will automatically be set based on the account payment settings. The properties below can be amended if required. This is not an exhaustive list. To get a list of all available properties, make aGET request to /crm/v3/objects/invoices.
Add taxes to an invoice
You can add taxes to an invoice in two different ways depending on your use case:- Add taxes to individual line items by setting the
hs_tax_rate_group_idproperty when you create an invoice. You’ll first need to set up tax rates in your account before associating them with line items. You’ll need to authorize thetax_rates.readscope for your app to fetch tax rates and thecrm.objects.line_items.writescope to update or create a line item. - Use the tax object to add taxes to the entire invoice, applying taxes to the total amount of the invoice.
Add taxes to line items
To associate a tax rate with a line item of an invoice, first make aGET request to /tax-rates/v1/tax-rates to fetch all tax rates. The resulting response will resemble the following:
id of one of your tax rates as the hs_tax_rate_group_id when creating or updating a line item. Learn more about setting up tax rates in the line items API guide.
Add taxes to the entire invoice order
Rather than apply an existing tax rate to individual line items, you can instead apply a tax to the entire invoice order. An invoice-level tax has a 1:1 relationship with the invoice, meaning the tax must be unique to the invoice. However, an invoice can include multiple taxes. To add taxes to an entire invoice order:Move the invoice to the Open status
An invoice can be set to one of four statuses, as set by thehs_invoice_status property:
When creating an invoice, you may want to set its status to
draft until it’s ready to be sent to the buyer. Once all of the required properties and associations are added to the invoice, you can update its status to open, meaning the invoice can be shared and is payable.
To move the invoice to the open status, make a PATCH request to /crm/v3/objects/invoices and set the hs_invoice_status property to open.
Retrieve invoices
Depending on the information you need, there are a few ways to retrieve invoices:- To retrieve all invoices, make a
GETrequest tocrm/v3/objects/invoices. - To retrieve a specific invoice, make a
GETrequest to the above URL and specify an invoice ID. For example:crm/v3/objects/invoices/44446244097. - To retrieve invoices that meet a specific set of criteria, you can make a
POSTrequest to the search endpoint and include filters in the request body. See an example of using the search endpoint below.
GET request to crm/v3/properties/invoices. Learn more about using the properties API.
Search for invoices by properties
You can use the search endpoint to retrieve invoices that meet a specific set of filter criteria. This will be aPOST request that includes your filter criteria in the request body.
For example, to search for all open invoices, you would make a POST request to crm/v3/objects/invoices/search with the following request body:
filters array specifies the search criteria, while the properties array specifies which properties to return.
Retrieve associations
To retrieve association information for an invoice,make aGET request to the following URL:
crm/v3/objects/invoice/{`hs_object_id}`/associations/{associatedObjectName}
Associated objects can include contacts, companies, deals, line items, discounts, fees, and taxes.
For example, to retrieve an invoice and the line items associated with it, make a GET request to:
crm/v3/objects/invoice/{invoiceId}/associations/line_items
This will return the IDs of the currently associated line items, along with meta information about the association type.
POST request to the following URL with the request body below:
crm/v3/objects/line_items/batch/read
Delete invoices
You can delete invoices with ahs_invoice_status of draft and open (if enabled in your account settings).
- To delete one invoice by ID, make a
DELETErequest to/crm/v3/objects/invoices/{invoiceId}. - To delete a batch of invoices by ID, make a
POSTrequest to/crm/v3/objects/invoices/batch/archivewith the invoice IDs specified in the request body:
Reference
Common properties
Below is a list of properties commonly used. This is not an exhaustive list. To get a list of all available properties, make aGET request to /crm/v3/objects/invoices.
Create a draft with associations (single request)
The following request body will create a new draft invoice with an association to a contact.POST /crm/v3/objects/invoices/batch/create