Skip to content

API Reference

This section contains the API documentation for integrating with AnyBiz.

AnyBiz provides a RESTful API built with oRPC (OpenAPI-compatible RPC). The API supports:

  • Authentication - Organization API keys for integrations, Better Auth sessions for the apps
  • Organization Context - All API calls operate within an organization context
  • Type-Safe Contracts - Full TypeScript support with Valibot validation
  • Login/Logout
  • Registration
  • Session management
  • Organization management
  • Member management
  • Subscription management
  • Point of Sale (POS)
  • Invoices (list, get, create, finalize, send to eFaktura)
  • Business Partners
  • Settings (organization, eFaktura, fiscalization)
  • Events SDK (/api/events/sdk/*) for external map embedding and checkout flow — see the TicketMap SDK integration guide
  • Internal: POST /api/internal/sef-subscribe (cron; requires X-Cron-Secret or Authorization: Bearer with SEF_CRON_SECRET)

To use the AnyBiz API:

  1. Get a credential - Create an API key under Settings → API keys, or sign in for a session
  2. Organization context - An API key is bound to its organization; a session sets an active organization
  3. Make API Calls - Use the documented endpoints

A worked example of issuing an invoice from your own backend is in External integrations.

The full OpenAPI specification can be generated from the oRPC contracts. Run pnpm docs:generate-api from the repository to regenerate it.

https://api.anybiz.com/api

For local development:

http://localhost:3000/api

Every API request needs one of two credentials.

For server-to-server access, an organization owner creates a key under Settings → API keys in the app. The key is shown once; only its hash is stored. Send it with every request, either as a bearer token or in the X-API-Key header:

Terminal window
curl -X GET "https://api.anybiz.com/api/organization/current" \
-H "Authorization: Bearer ak_your_key"
Terminal window
curl -X GET "https://api.anybiz.com/api/organization/current" \
-H "X-API-Key: ak_your_key"

A key acts as the owner who created it, inside the organization it was created for: requests get full owner access, and the key stops working as soon as that owner leaves the organization, when it is revoked, or when its expiry passes. Only owners can create or revoke keys, keys cannot manage keys, and they do not work on the /api/auth/* endpoints.

The web and desktop apps sign in through /api/auth/* and send the session cookie, or the set-auth-token response header as Authorization: Bearer <token>. A session can switch its active organization; an API key is bound to one.

API calls are subject to rate limiting. Please ensure your integration handles rate limit responses appropriately.

All API errors follow a consistent format:

{
"error": {
"code": "ERROR_CODE",
"message": "Human-readable error message"
}
}

Common error codes:

  • UNAUTHORIZED - Authentication required
  • FORBIDDEN - Insufficient permissions
  • NOT_FOUND - Resource not found
  • VALIDATION_ERROR - Invalid request data