How to download invoice PDFs from MYOB

Edited

The Apideck Accounting unified API doesn't expose invoice PDF download as a unified operation, but you can retrieve them via the Proxy API. This guide shows how to do this for MYOB.

The flow is: use the unified GET /accounting/invoices endpoint to find the invoice, then use the company file URI plus the invoice's downstream ID and layout type in a Proxy API call to download the PDF.

MYOB is unique among accounting connectors because the downstream URL isn't a fixed host - it depends on the company file the user has connected. You'll need to do a one-time discovery call to find the correct base URL.

Prerequisites

  • An active Apideck Vault connection for MYOB (service-id: myob)

  • The Apideck consumer-id, app-id, and api-key

  • The connection in Vault must have a company file selected. If you have multiple files, pick the one you want to query in the connection settings.

  • An invoice in MYOB with a layout of Item, Service, Professional, or TimeBilling (Miscellaneous-layout invoices cannot render as PDF)

Step 1: Get the company file URI

Before you can call any other MYOB endpoint via the Proxy, you need the company file's base URL. Send a GET to https://api.myob.com/accountright/:

curl --location 'https://unify.apideck.com/proxy' \
  --header 'Authorization: Bearer {APIDECK_API_KEY}' \
  --header 'x-apideck-app-id: {APP_ID}' \
  --header 'x-apideck-consumer-id: {CONSUMER_ID}' \
  --header 'x-apideck-service-id: myob' \
  --header 'x-apideck-downstream-url: https://api.myob.com/accountright/' \
  --header 'Accept: application/json'

Each company file has a Uri field that looks like https://arl2.api.myob.com/accountright/{companyFileGUID}. Copy it. The arN portion (e.g. ar3, arl2) is the regional shard for that specific file - always read it from the discovery response.

You'll typically only need to do this once per connection and cache the URI.

Step 2: Find the invoice

Use the unified Accounting API to list invoices:

curl --location 'https://unify.apideck.com/accounting/invoices' \
  --header 'Authorization: Bearer {APIDECK_API_KEY}' \
  --header 'x-apideck-app-id: {APP_ID}' \
  --header 'x-apideck-consumer-id: {CONSUMER_ID}' \
  --header 'x-apideck-service-id: myob'

For each invoice, you'll need two fields from the response:

  • downstream_id - the actual MYOB invoice UID (a GUID). This goes in the proxy URL. Don't use the unified id - that's a base64-encoded composite for internal use.

  • type - tells you which layout URL segment to use:

    • type: "product"/Sale/Invoice/Item/

    • type: "service"/Sale/Invoice/Service/

    • type: "professional"/Sale/Invoice/Professional/

    • type: "time_billing"/Sale/Invoice/TimeBilling/

Note: If the unified call returns an empty array, your Vault connection most likely doesn't have a company file selected. Open the connection in the Vault dashboard and pick one.

Step 3: Download the PDF via Proxy

Use the company file URI from step 1, the downstream_id from step 2, and the matching layout segment:

curl --location 'https://unify.apideck.com/proxy' \
  --header 'Authorization: Bearer {APIDECK_API_KEY}' \
  --header 'x-apideck-app-id: {APP_ID}' \
  --header 'x-apideck-consumer-id: {CONSUMER_ID}' \
  --header 'x-apideck-service-id: myob' \
  --header 'x-apideck-downstream-url: https://arl2.api.myob.com/accountright/{COMPANY_FILE_GUID}/Sale/Invoice/Item/{DOWNSTREAM_ID}/?format=pdf' \
  --header 'Accept: application/pdf' \
  --output myob-invoice.pdf

The response is the raw PDF binary. The Apideck Proxy detects the binary response and base64-encodes it internally; API Gateway decodes it back to bytes before delivery, so your client receives a normal PDF file you can write straight to disk.

Gotchas

The ?format=pdf query parameter is required. Unlike Xero or Sage where the Accept: application/pdf header alone triggers PDF mode, MYOB needs the query string. Setting only the Accept header without the query parameter returns JSON.

Layout segment must match the invoice's type. If you call /Sale/Invoice/Service/{uid} with the UID of a product-layout (Item) invoice, MYOB returns a 404. Always read the type field from the unified response and pick the matching segment.

Use downstream_id, not id. The unified id is a base64-encoded internal identifier (it combines the UID and type). The actual MYOB UID is in downstream_id — that's what the connector's native endpoint expects.

Miscellaneous invoices can't be rendered as PDF. This is a MYOB API limitation — the /Sale/Invoice/Miscellaneous/{uid}/?format=pdf endpoint doesn't exist. If your application needs to handle this case, fall back to fetching the invoice JSON.

Empty unified response means no company file selected. If GET /accounting/invoices?service_id=myob returns an empty array, the connection in Vault doesn't have a company file resolved. This is most common when the user has multiple company files. Resolve it in the connection settings before retrying.

Related articles

Was this article helpful?

Sorry about that! Care to tell us more?

Thanks for the feedback!

There was an issue submitting your feedback
Please check your connection and try again.