Back to Blog
Integration Guides

How to Integrate Twilio with Xero: Step-by-Step Guide

Add Twilio SMS to Xero to automate invoice reminders, payment receipts, and overdue notifications so your accounts team spends less time chasing.

DA
Danial A
Senior Twilio Consultant, Telphi Consulting
June 22, 2026
7 min read
Twilio
Integration
Payments
How to Integrate Twilio with Xero: Step-by-Step Guide

Xero and Twilio integrate through the Xero API and Twilio Messages API to automate SMS invoice reminders, payment receipt notifications, and overdue alerts, reducing manual accounts receivable effort and improving on-time payment rates for businesses that rely on Xero for their financial management. This integration uses Xero's OAuth 2.0 API with webhook subscriptions to detect invoice creation and payment events in real time, fetching contact phone numbers from Xero to dispatch timely SMS notifications via Twilio. Teams using Xero for invoicing benefit most from this integration when they handle high invoice volumes where manual follow-up does not scale.

What You Need Before You Start

Create a Xero application in the Xero Developer Portal under My Apps, select Web App as the app type, enter your middleware OAuth redirect URI, and copy the Client ID and Client Secret for use in the OAuth 2.0 authorization flow. Complete Xero OAuth 2.0 authorization by directing your Xero account admin to the Xero authorization URL with your Client ID, redirect URI, response_type set to code, and scope set to accounting.transactions accounting.contacts offline_access, then exchange the authorization code for an access token and refresh token by POSTing to https://identity.xero.com/connect/token with the code, redirect_uri, grant_type set to authorization_code, and Basic authentication using your Client ID and Secret. Register for Xero webhook events by creating a webhook subscription in the Xero Developer Portal under your app's Webhooks section, entering your middleware endpoint URL, selecting the Invoice events to subscribe to, and copying the Webhook Key Xero provides for payload signature verification. From Twilio, collect your Account SID, Auth Token, and an SMS-capable phone number, and confirm that your Xero Contact records include a Mobile phone number in the Phones array for the contacts you want to reach by SMS.

Step-by-Step Integration Guide

In your middleware webhook handler, verify the Xero webhook payload by computing HMAC-SHA256 of the raw request body using your Xero Webhook Key as the secret key, encoding the result as Base64, and comparing it against the x-xero-signature header value, returning HTTP 401 if they do not match. Parse the verified payload to extract the events array and for each event with resourceUrl pointing to an invoice, call GET https://api.xero.com/api.xro/2.0/Invoices/{invoiceId} with the Authorization header set to Bearer {accessToken} and the Xero-tenant-id header set to your Xero organization tenant ID retrieved from GET https://api.xero.com/connections. From the invoice response, extract the Contact.ContactID and fetch the full contact by calling GET https://api.xero.com/api.xro/2.0/Contacts/{contactId}, then read the Phones array and find the element where PhoneType equals MOBILE, extracting the PhoneNumber, PhoneAreaCode, and PhoneCountryCode fields to assemble the E.164 phone number. Dispatch the Twilio SMS by calling POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Messages.json with Basic auth, the To field set to the assembled E.164 phone, From set to your Twilio number, and Body set to a message containing the invoice number from InvoiceNumber, the amount due from AmountDue, and the due date from DueDate.

Common Issues and How to Fix Them

Xero access tokens expire after 30 minutes and require refresh using the stored refresh token via POST https://identity.xero.com/connect/token with grant_type=refresh_token, and failing to refresh the token causes all Xero API calls to return 401 well within a typical day's operation. Implement proactive token refresh by checking the token issue timestamp before every API call and refreshing when the token age exceeds 25 minutes rather than waiting for a 401 response, and store the new access token and refresh token together atomically in your token store to prevent race conditions in concurrent webhook processing. Xero webhook events use a polling-like delivery where Xero first sends an intent-to-send verification request with an empty events array to confirm your endpoint is reachable, and if your middleware returns anything other than HTTP 200 for this validation request, Xero marks your webhook as inactive. Handle the empty events array case explicitly by returning HTTP 200 immediately when the events array is empty, without attempting to process any invoice or contact data. The Xero Contact Mobile phone number is often absent because Xero does not require a mobile number during contact creation, and many contacts are imported from accounting files with only an office phone. Fall back to the PhoneType equals DEFAULT phone if MOBILE is not present, and log contacts with no usable phone number to a spreadsheet or database for your accounts team to update manually.

How to Get More from This Integration

Build a multi-stage invoice reminder sequence by running a scheduled daily job that queries Xero invoices for those due within 7 days and a separate query for invoices overdue by up to 7 days, dispatching different Twilio SMS templates for each stage and recording the last sent SMS date in a separate database table to avoid sending repeated reminders on consecutive days. Create a two-way SMS payment follow-up by configuring your Twilio inbound number's webhook to a handler that parses customer replies containing PAID and the invoice number, calls the Xero API to check the invoice status, and if still unpaid, replies with a Twilio SMS containing the Xero online payment link for the invoice fetched from the OnlineInvoiceUrl field on the invoice response object. Add a payment receipt SMS flow by subscribing to Xero Payment events via the webhook, fetching the associated invoice and contact, and dispatching a Twilio SMS confirming the paid amount and the invoice number the payment was applied to as soon as Xero records the payment, giving clients instant confirmation. Extend the integration to Xero Credit Notes by subscribing to the CreditNote event type in your Xero webhook, fetching the credit note details and the associated contact phone, and sending a Twilio SMS informing the contact of the credit amount and reference number so they are aware without waiting for the Xero email notification.

Conclusion

Xero and Twilio together automate the invoice reminder and payment confirmation cycle through SMS, helping your accounts team get paid faster with less manual effort. Get in touch with Telphi Consulting to build and deploy this integration for your Xero account.

Share this article:
0 views

Ready to Transform Your Business Communications?

Get a free consultation with our VoIP experts and discover how we can help you save costs, improve efficiency, and scale your business.

Comments (0)

Join the discussion and share your thoughts (AI-moderated for quality)

Protected by AI moderation

Be the first to comment

No comments yet. Share your thoughts below.