API Integration Guide

bexio API: The Complete 2026 Guide for Swiss Freelancers

Connect Switzerland's most popular business software with virtually any tool you use. OAuth 2.0 setup, code examples, and a simpler invoice API alternative compared.

API Integration Illustration

Stop the Manual Data Entry.
Automate Everything.

You're spending hours on manual data entry between your tools. Your invoicing app doesn't talk to your CRM. Your e-commerce store requires copy-pasting orders into accounting software. The bexio API solves this—connecting 40,000+ Swiss businesses with virtually any other tool.

5+ Hours Weekly

Lost to manual data entry
🔗

Disconnected Tools

Apps that don't talk to each other
📋

Copy-Paste Chaos

Orders manually entered into accounting

What Is the bexio API?

An API (Application Programming Interface) lets different software systems exchange data automatically. The bexio API is a RESTful interface that exposes bexio's core features—contacts, invoices, accounting, inventory—to external applications.

In practical terms: Instead of manually creating an invoice in bexio after completing a project, your project management tool can trigger automatic invoice creation. Instead of copying customer details from your webshop, orders flow directly into bexio.

The API uses HTTPS and JSON format, making it compatible with any programming language. bexio currently offers API version 3.0.0.

What You Can Automate

FunctionAPI Capability
ContactsCreate, update, list clients and suppliers
InvoicesGenerate, send, track payment status
OrdersCreate from external systems, update status
ProductsSync inventory, update stock levels
AccountingFetch accounts, record transactions
ProjectsCreate, assign, track time

2025 Authentication Migration

If you have existing bexio API integrations, read this first.

bexio decommissioned idp.bexio.com on 31 March 2025. All applications must use the new identity provider:

Old: https://idp.bexio.com
New: https://auth.bexio.com/realms/bexio

For most applications, migration requires only updating the authorization and token endpoint URLs. If you haven't migrated yet, your integration is no longer working.

Migration checklist:

  1. Update authorization URL in your app configuration
  2. Update token endpoint URL
  3. Test the complete OAuth flow
  4. Monitor bexio's status page at bexio-status.com for announcements
  1. Shopify → bexio: New order creates invoice automatically
  2. Toggl → bexio: Logged time entries sync to project
  3. HubSpot → bexio: New CRM contact creates bexio contact
  4. Gmail → bexio: Email attachment creates expense entry
Developer Setup

Getting Started with the bexio API

Everything you need to know for your first integration

Prerequisites

  1. bexio Account: Any paid plan (Starter CHF 45/month, Pro CHF 75/month, Pro+ CHF 125/month). API access is included.
  2. Developer Portal Access: Visit the bexio Developer Portal and log in with your bexio credentials.

Creating API Credentials

  1. Navigate to "My Apps" in the developer portal
  2. Click "Create New App"
  3. Set a Redirect URL (required for OAuth flow)
  4. Save your Client ID and Client Secret immediately—you won't see the secret again

Authentication Deep Dive

bexio uses OAuth 2.0, the industry standard for API authorization. Understanding the dual authorization system is crucial.

Two Levels of Authorization

Level 1: Application Scopes When users connect your app, they grant specific permissions (scopes). Request only what you need—users see these permissions in the consent screen.

Available scope categories:

  • contact_show, contact_edit — Contact management
  • kb_invoice_show, kb_invoice_edit — Invoice access
  • accounting_show — Read accounting data
  • article_show, article_edit — Product management

Level 2: User Rights API requests execute with the permissions of the user who authorized the connection. If that user lacks permission to delete invoices in bexio, your API can't delete invoices either.

OAuth 2.0 Flow

1. Your app redirects user to:
   https://auth.bexio.com/realms/bexio/protocol/openid-connect/auth
   ?client_id=YOUR_CLIENT_ID
   &redirect_uri=YOUR_REDIRECT_URL
   &response_type=code
   &scope=contact_show kb_invoice_edit

2. User logs in and approves permissions

3. bexio redirects to your URL with authorization code

4. Exchange code for tokens at:
   https://auth.bexio.com/realms/bexio/protocol/openid-connect/token

5. Use access token for API requests

Token management:

  • Access tokens are short-lived (typically 1 hour)
  • Refresh tokens get new access tokens without user interaction
  • Store refresh tokens securely and implement automatic token refresh
Code Examples

bexio API in Python & JavaScript

Ready-to-use code snippets for the most common use cases

Python

import requests

BASE_URL = "https://api.bexio.com/2.0"
ACCESS_TOKEN = "your_access_token"

headers = {
    "Authorization": f"Bearer {ACCESS_TOKEN}",
    "Accept": "application/json"
}

# Fetch all contacts
response = requests.get(f"{BASE_URL}/contact", headers=headers)
contacts = response.json()

for contact in contacts:
    print(f"{contact['id']}: {contact['name_1']}")

# Create new invoice
invoice_data = {
    "contact_id": 1,
    "title": "Project Work - January 2026",
    "positions": [
        {
            "type": "KbPositionCustom",
            "text": "Consulting Services",
            "unit_price": "150.00",
            "amount": "10"
        }
    ]
}

response = requests.post(
    f"{BASE_URL}/kb_invoice",
    headers=headers,
    json=invoice_data
)
print(response.json())

JavaScript (Node.js)

const axios = require('axios');

const BASE_URL = 'https://api.bexio.com/2.0';
const ACCESS_TOKEN = process.env.BEXIO_TOKEN;

const api = axios.create({
  baseURL: BASE_URL,
  headers: {
    'Authorization': `Bearer ${ACCESS_TOKEN}`,
    'Accept': 'application/json'
  }
});

// Fetch contacts
async function getContacts() {
  const response = await api.get('/contact');
  return response.data;
}

// Create contact
async function createContact(contactData) {
  const response = await api.post('/contact', {
    contact_type_id: 1, // 1 = Company, 2 = Person
    name_1: contactData.company,
    name_2: contactData.name,
    mail: contactData.email,
    country_id: 1 // Switzerland
  });
  return response.data;
}

getContacts().then(contacts => console.log(contacts));

Note: Community libraries exist for PHP and Python, but they cover only a subset of API methods. For complete functionality, direct HTTP calls may be needed.

bexio API Limitations
& Workarounds

Being transparent about what the API can't do saves you hours of frustration. bexio's API has limitations—but knowing them upfront helps you plan better.

🔔

No Native Webhooks

Use polling or Zapier as workarounds
🚦

Undocumented Rate Limits

Implement backoff and caching
🧪

No Sandbox Environment

Test with real data carefully

Workarounds for No Webhooks

  • Polling: Check for changes periodically (every 5-15 minutes)
  • Zapier: Uses polling but handles the infrastructure
  • Third-party webhook services: Some integration platforms offer pseudo-webhook functionality

Handling Rate Limits

Based on community experience:

  • Implement exponential backoff on 429 errors
  • Cache responses where possible
  • Batch requests when the API supports it
  • Avoid unnecessary polling frequency

Limited Client Libraries

Official SDKs don't exist. Community libraries are incomplete. For production applications, expect to write custom code.

Simpler Alternative

Just Need to Generate Swiss Invoices via API?

The bexio API is powerful but complex—OAuth 2.0, scopes, token management, no sandbox. If all you need is to generate Swiss QR invoices programmatically, the Magic Heidi Invoice API is a dramatically simpler option. One POST request. One API key. A PDF invoice with Swiss QR code in return.

Magic Heidi Invoice List

Magic Heidi Invoice API

The Magic Heidi Swiss Invoice QR Code API is an open, single-endpoint API for generating professional Swiss invoices with QR payment slips. No OAuth, no token refresh, no scopes—just an API key and a POST request.

How It Works

  1. Send a POST request with your invoice data (sender, customer, line items)
  2. Receive a PDF download URL valid for 24 hours
  3. That's it—no OAuth flow, no developer portal registration

Python Example

import requests

response = requests.post(
    "https://europe-west6-magic-heidi.cloudfunctions.net/create_invoice_abstract_v1d",
    headers={"key": "your_api_key"},
    json={
        "user_details": {
            "name": "Muster GmbH",
            "address": "Bahnhofstrasse 1",
            "zip": "8001",
            "city": "Zurich",
            "iban": "CH93 0076 2011 6238 5295 7"
        },
        "customer_details": {
            "name": "Acme AG",
            "address": "Bundesplatz 3",
            "zip": "3011",
            "city": "Bern"
        },
        "invoice_items": [
            {
                "description": "Web Development",
                "quantity": 10,
                "unit_price": 150
            },
            {
                "description": "Design Review",
                "quantity": 3,
                "unit_price": 120
            }
        ],
        "language": "en",
        "currency": "CHF",
        "vat_enabled": true,
        "vat_percentage": 8.1,
        "vat_number": "CHE-123.456.789 MWST"
    }
)

data = response.json()
print(f"Download your invoice: {data['url']}")

JavaScript (Node.js) Example

const axios = require('axios');

const response = await axios.post(
  'https://europe-west6-magic-heidi.cloudfunctions.net/create_invoice_abstract_v1d',
  {
    user_details: {
      name: 'Muster GmbH',
      address: 'Bahnhofstrasse 1',
      zip: '8001',
      city: 'Zurich',
      iban: 'CH93 0076 2011 6238 5295 7'
    },
    customer_details: {
      name: 'Acme AG',
      address: 'Bundesplatz 3',
      zip: '3011',
      city: 'Bern'
    },
    invoice_items: [
      { description: 'Web Development', quantity: 10, unit_price: 150 },
      { description: 'Design Review', quantity: 3, unit_price: 120 }
    ],
    language: 'en',
    currency: 'CHF'
  },
  { headers: { key: 'your_api_key' } }
);

console.log(`Download your invoice: ${response.data.url}`);

Key Features

  • Swiss QR invoices compliant with Swiss payment standards
  • Multi-language: English, German, French, Italian
  • CHF and EUR currency support
  • VAT handling with configurable rates and VAT number
  • Custom logos via URL
  • QR-only mode for generating just the payment slip
  • Free testing without an API key
  • Open documentation on GitHub
Comparison

bexio API vs. Magic Heidi Invoice API

Choose the right tool for your use case

FeatureMagic Heidi APIbexio API
Use CaseInvoice generationFull business suite
Authentication Simple API keyOAuth 2.0 flow
SetupAPI key onlyDeveloper portal + OAuth app
Swiss QR Invoices Built-in Manual setup
Sandbox / Free Testing Yes No
Contacts & CRM No Yes
Accounting No Yes
Minimum CostFree to testCHF 45/month
FAQ

Frequently Asked Questions

Is the bexio API free?

Yes, API access is included with all paid bexio plans (starting CHF 45/month).

What programming languages work with these APIs?

Any language that can make HTTP requests—Python, JavaScript, PHP, C#, Ruby, Go, etc. Both the bexio API and Magic Heidi API use standard REST/JSON.

Can I use the bexio API without coding?

Yes. Zapier and Make.com offer no-code automation with bexio.

Does bexio support webhooks?

Not natively. Use polling or Zapier as workarounds.

What's the difference between bexio API and Magic Heidi API?

bexio API gives you access to a full business suite (contacts, accounting, invoices, inventory). Magic Heidi's API is focused on one thing: generating Swiss QR invoices with a single API call. If you just need programmatic invoice generation, Magic Heidi is much simpler.

Can I test the Magic Heidi API for free?

Yes. You can send requests without an API key for testing. Production use requires an API key—contact hello@magicheidi.ch.

Is there a bexio test/sandbox environment?

No. You must test with real data carefully.

Need Simpler Swiss Invoicing?

Magic Heidi handles QR invoices, expenses, and VAT—available on every platform. Use the app or generate invoices via API.