QuickBooks Online (Apps step)
QuickBooks Online
Queries, reads, creates and updates QuickBooks Online accounting records: invoices, customers, items, bills, vendors and more.
Use it to connect the plant to accounting: list the open invoices for a collections report, look up a customer's balance, or create an invoice when an order ships.
Beta. This step has not yet been checked against a live QuickBooks Online account, so treat its first runs as a test, and tell us if an operation does not answer as described.
Find it in the workflow editor's palette under Apps. See Apps steps for what every Apps step has in common.
Set it up
- In the Intuit Developer portal (developer.intuit.com), create an app with the Accounting scope, add the Redirect URI DataMagik shows on the OAuth 2.0 credential to the app's redirect URIs, and copy its client id and secret (the Development keys for a sandbox company, the Production keys for your real books).
- Find your company ID: in QuickBooks, open Settings › Account and settings › Billing & subscription (or the sandbox company's details in the developer portal).
- Add quickbooks.api.intuit.com (or sandbox-quickbooks.api.intuit.com) to Allowed Domains in the workflow's Script settings.
Credential: An OAuth 2.0 credential for your Intuit Developer app, connected by a QuickBooks admin of the company.
Signing in with OAuth 2.0
| Grant type | Sign in with the provider (authorization code). Save the credential, then click Connect on it. |
| Sign-in (authorization) URL | https://appcenter.intuit.com/connect/oauth2 |
| Token URL | https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer |
| Scope | com.intuit.quickbooks.accounting |
Register the Redirect URI the credential form shows in the provider's app settings.
Create an app in the Intuit Developer portal with the Accounting scope and add the credential's Redirect URI to it. QuickBooks hands out a new refresh token every time the access token is refreshed; DataMagik stores the new one, so keep using the same credential rather than copying tokens elsewhere.
Hosts it calls: quickbooks.api.intuit.com, sandbox-quickbooks.api.intuit.com
Connection
| Field | Required | What to put |
|---|---|---|
| API host | Yes | quickbooks.api.intuit.com for your real books, or sandbox-quickbooks.api.intuit.com for a developer sandbox company. For example quickbooks.api.intuit.com. |
| Company ID | Yes | Your QuickBooks company ID (Intuit calls it the realm ID), a long number shown under Account and settings › Billing & subscription. For example 9130354988127436. |
Operations
| Operation | What it does |
|---|---|
| Query › Run | Runs a QuickBooks query (a SQL-like select on one entity) and returns its answer as one item. |
| Entity › Get | Reads one record by its Id. |
| Entity › Create | Creates a record. |
| Entity › Update | Changes a record. QuickBooks updates with a POST to the same address as Create; the record must carry its Id and current SyncToken. |
Query › Run
Runs a QuickBooks query (a SQL-like select on one entity) and returns its answer as one item.
Calls GET /query.
| Field | Required | What to put |
|---|---|---|
| Query | Yes | A QuickBooks query: select * or a list of fields from one entity, with an optional where, orderby, STARTPOSITION and MAXRESULTS (at most 1000 per query). Text and dates go in single quotes. For example select * from Invoice where Balance > '0' MAXRESULTS 100. |
What comes out: One item: the whole answer. The records are a list in {{ $json.QueryResponse.Invoice }} (named after the entity queried), with {{ $json.QueryResponse.startPosition }} and {{ $json.QueryResponse.maxResults }}; when nothing matches, QueryResponse has no list. Use a Split Out step on that list for one item per record.
Example: select * from Invoice where Balance > '0' and DueDate < '{{ $today }}' lists the overdue invoices for a collections email.
Entity › Get
Reads one record by its Id.
Calls GET /{entity}/{id}.
| Field | Required | What to put |
|---|---|---|
| Entity | Yes | The kind of QuickBooks record. One of: Invoice, Customer, Item, Bill, Vendor, Estimate, Payment, Purchase order, Sales receipt. |
| Id | Yes | The record's QuickBooks Id (not its document number): the Id field of a query result. For example 130. |
What comes out: One item with the record in a field named after the entity: {{ $json.Invoice }}, with {{ $json.Invoice.Id }}, {{ $json.Invoice.SyncToken }}, {{ $json.Invoice.DocNumber }} and {{ $json.Invoice.Balance }}.
Example: Read customer {{ $json.qb_customer_id }} for its {{ $json.Customer.Balance }} before releasing an order on credit hold.
Entity › Create
Creates a record.
Calls POST /{entity}.
| Field | Required | What to put |
|---|---|---|
| Entity | Yes | The kind of QuickBooks record. One of: Invoice, Customer, Item, Bill, Vendor, Estimate, Payment, Purchase order, Sales receipt. |
| Record | Yes | The record as a JSON object, in QuickBooks' field names; the API reference lists what each entity requires (an Invoice needs a CustomerRef and at least one Line). For example {"CustomerRef": {"value": "58"}, "Line": [{"Amount": 150.0, "DetailType": "SalesItemLineDetail", "SalesItemLineDetail": {"ItemRef": {"value": "7"}, "Qty": 10}}]}. |
What comes out: One item with the new record in a field named after the entity: {{ $json.Invoice.Id }}, {{ $json.Invoice.DocNumber }}, {{ $json.Invoice.TotalAmt }} and its other fields.
Example: When shipper {{ $json.shipper }} is confirmed, create an Invoice for the customer with one line per shipped part and save {{ $json.Invoice.DocNumber }} on the shipper.
Entity › Update
Changes a record. QuickBooks updates with a POST to the same address as Create; the record must carry its Id and current SyncToken.
Calls POST /{entity}.
| Field | Required | What to put |
|---|---|---|
| Entity | Yes | The kind of QuickBooks record. One of: Invoice, Customer, Item, Bill, Vendor, Estimate, Payment, Purchase order, Sales receipt. |
| Record | Yes | A JSON object with the record's Id and current SyncToken (from a Get) and the fields to change. Include "sparse": true to change only the fields you send; without it, QuickBooks replaces the whole record and clears every writable field you leave out. For example {"Id": "{{ $json.Invoice.Id }}", "SyncToken": "{{ $json.Invoice.SyncToken }}", "sparse": true, "CustomerMemo": {"value": "Shipped {{ $json.ship_date }}"}}. |
What comes out: One item with the record as it now is in a field named after the entity: {{ $json.Invoice.Id }}, {{ $json.Invoice.SyncToken }} (one higher than before) and its other fields.
Example: After Get reads invoice {{ $json.qb_invoice_id }}, update it with its Id, SyncToken, "sparse": true and a CustomerMemo naming the shipper.
Example
When a shipper is confirmed, QuickBooks › Create creates an Invoice for the customer's Id with one line per shipped part, then saves {{ $json.Invoice.DocNumber }} on the shipper.
Tips
- QuickBooks answers with the record inside a field named after the entity: {{ $json.Invoice }}, {{ $json.Customer }}. A query answers inside QueryResponse.
- References name another record by its Id: {"CustomerRef": {"value": "58"}}, {"ItemRef": {"value": "7"}}. Look the Ids up with a Query first.
- To change a record, Get it first: Update needs its Id and current SyncToken, and fails if someone changed it since.
- It calls QuickBooks on test runs too, so build against a sandbox company with API host sandbox-quickbooks.api.intuit.com.
Settings every Apps step has
- More query parameters: any query parameter the fields do not offer, sent as is.
- More body fields: a JSON object merged into the request body; nested objects merge, other values replace.
- Most requests per second: spaces the calls out for rate limits. A "too many requests" (429) answer is retried after the wait the API asks for.
- Most pages: for operations that follow pages, the most pages to fetch (10 unless you change it, up to 100). The run warns when it stops with more to get.
- Fail on a non-2xx response: on by default. Turn it off to handle errors yourself.
QuickBooks Online's own API documentation: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice