Back to blog
AccountingGuides & Tutorials

How to get your Xero API Key?

Get your Xero API keys in under 10 minutes with this step-by-step guide covering OAuth setup, client secrets, scopes, and common authentication mistakes developers make.

Saurabh RaiSaurabh Rai

Saurabh Rai

4 min read
How to get your Xero API Key?

What's Xero?

Xero is cloud accounting software for small to medium businesses who think QuickBooks is ugly and want something that actually works. It handles invoicing, bank reconciliation, expense tracking, and payroll. All the standard accounting stuff, but with a UI that doesn't make you want to quit. You're here because you need to connect Xero to your app, sync data, or automate workflows. Here's how to get API access in under 10 minutes.

Prerequisites

  • Xero account (any plan, even a trial works)
  • Know if you're building for just yourself or multiple organizations
  • Developer account (free, takes 30 seconds to create)

Step 1: Create a Xero Developer Account

Go to https://developer.xero.com and sign up. Use the same email address as your Xero account to avoid confusion later.

Step 2: Create Your App

Hit MyApps → New app

Fill this out:

Pick your integration type:

  • Web app: For multi-tenant apps serving multiple Xero orgs
  • Desktop or mobile app: For PKCE flow without client secrets
  • Custom connection: For internal tools accessing only YOUR organization

Save it. You get a Client ID immediately.

Step 3: Get Your Client Secret

Click your app name, then Configuration.

Generate a client secret. Copy it now. Xero shows it once, then it's gone forever.

Step 4: Set Up Scopes

Still in Configuration, select the scopes you need:

  • accounting.transactions: Read/write invoices, bills, payments
  • accounting.contacts: Customer and supplier data
  • accounting.settings: Company info and preferences
  • offline_access: Refresh tokens that don't expire in 30 minutes

Don't be greedy. Pick only what you need or users will bail at the consent screen.

Step 5: Connect Your Organization

For testing with your own org:

  1. Click Authorize in your app dashboard
  2. Select your organization
  3. Approve the permissions
  4. You're redirected to your callback URL with an authorization code

Step 6: Exchange Code for Tokens

POST the authorization code to Xero's token endpoint. You get:

  • Access token (expires in 30 minutes)
  • Refresh token (expires in 60 days if unused)
  • ID token (contains user and tenant info)

Store the tenant ID from the connections endpoint—you need it for every API call.

Common Screwups to Avoid

  1. Wrong Redirect URI: Must match EXACTLY what's in your app config. Trailing slashes matter. http vs https matters.

  2. Expired Tokens: Access tokens die in 30 minutes. Implement refresh token rotation or your integration breaks during lunch.

  3. Missing Tenant ID: Every API call needs the tenant ID in headers. No tenant ID = 401 errors.

  4. Rate Limits:

    • Minute limit: 60 calls
    • Daily limit: 5000 calls
    • Hit these = 429 errors for up to 60 seconds
  5. Sandbox vs Production: Xero has a Demo Company for testing. Use it. Don't test on real books like an amateur.

App Types: Which One?

  • Custom Connection: You're building internal tools for YOUR company only
  • Public App: You're building for multiple Xero organizations
  • Partner App: You want to be listed in Xero's app marketplace (requires approval)

Pick one. Stop overthinking it. If you want a detailed guide on the partner app, please check out our guide here.

Testing Your Connection

  1. Use the Demo Company (create one in your Xero account)
  2. Make a simple GET request to /api.xro/2.0/organisation
  3. If you get JSON back with your company details, you're connected
  4. If you get 401, check your tenant ID and token

Security Requirements That Actually Matter

  • Store tokens encrypted, not in plain text
  • Use PKCE for mobile/desktop apps (no client secret needed)
  • Rotate refresh tokens before they expire
  • Never commit credentials to git (use environment variables)

That's it. You now have Xero API access. Stop reading documentation and start pulling data.

And if you want to know more about Xero authentication, integration, and bank feeds, check out the guides below:

Managing Xero API connectivity with Apideck's Vault

If you want to integrate with Xero and other accounting systems, managing API connections can be challenging. You can use Apideck to connect to accounting applications. Apideck's Vault allows for:

  • Secure credential storage with automatic token refresh - No need to build token management infrastructure or handle OAuth flows manually.
  • Pre-built authentication UI - Embedded Vault components handle credential input and OAuth authorization without custom UI development.
  • Centralized connection monitoring - Track connection states, validate credentials, and manage multiple accounting platforms from a single dashboard.

And here's how you can easily connect and manage permissions for your API Access. Go to the platform, select Xero, and add the required credentials that you obtained.

Screenshot 2025-11-17 at 18.49.33@2x

Save and then click on test-vault. Click Authorize, then authenticate via Xero.

Screenshot 2025-11-17 at 18.50.13@2x

This will then authenticate and you can start using Xero via Apideck.

Ready to get started?

Scale your integration strategy and deliver the integrations your customers need in record time.

Ready to get started?
Talk to an expert

Trusted by fast-moving product & engineering teams

JobNimbus
Blue Zinc
Drata
Octa
Nmbrs
Apideck Blog

Insights, guides, and updates from Apideck

Discover company news, API insights, and expert blog posts. Explore practical integration guides and tech articles to make the most of Apideck's platform.

Top Embedded iPaaS Solutions in 2025
Unified APIGuides & Tutorials

Top Embedded iPaaS Solutions in 2025

This article breaks down the top embedded iPaaS platforms in 2025 and compares how they handle developer experience, extensibility, scalability, and real-world deployment. It explains when embedded iPaaS makes more sense than unified APIs, what technical advantages it brings, and helps SaaS teams choose the right platform based on their product’s integration needs.

Kateryna Poryvay

Kateryna Poryvay

12 min read
How to get your QuickBooks API Key
AccountingGuides & Tutorials

How to get your QuickBooks API Key

Skip Intuit's 500-page docs and get your QuickBooks API keys in 7 steps - with every gotcha that'll waste your week spelled out.

Saurabh Rai

Saurabh Rai

5 min read