Orb Wrapper
Overview
Orb Wrapper
Orb is a billing infrastructure platform built for usage-based pricing models. It gives engineering, product, and finance teams the tools to automate billing, iterate on pricing, and connect metered usage to revenue, without lengthy implementations or custom pipelines.
The Orb Wrapper brings your Orb billing data into Postgres as queryable foreign tables. Query subscriptions, invoices, customers, usage events, and more with plain SQL and join them against your application data. The wrapper works with Supabase Vault for secure API key management and is built on WebAssembly (Wasm) for lightweight, sandboxed execution.
Preparation
Before you get started, make sure the wrappers extension is installed on your database:
_10create extension if not exists wrappers with schema extensions;
and then enable the Wasm foreign data wrapper:
_10create foreign data wrapper wasm_wrapper_10 handler wasm_fdw_handler_10 validator wasm_fdw_validator;
Secure your credentials (optional)
By default, Postgres stores FDW credentials inside pg_catalog.pg_foreign_server in plain text. Anyone with access to this table will be able to view these credentials. Wrappers is designed to work with Vault, which provides an additional level of security for storing credentials. We recommend using Vault to store your credentials.
_10select vault.create_secret(_10 '<Orb API key>',_10 'orb',_10 'Orb API key for Wrappers'_10);
Connecting to Orb
We need to provide Postgres with the credentials to access Orb, and any additional options. We can do this using the create server command:
With Vault:
_10create server orb_server_10 foreign data wrapper wasm_wrapper_10 options (_10 fdw_package_url 'https://github.com/supabase/wrappers/releases/download/wasm_orb_fdw_v0.2.0/orb_fdw.wasm',_10 fdw_package_name 'supabase:orb-fdw',_10 fdw_package_version '0.2.0',_10 fdw_package_checksum 'f9dd3bd2a1ce3d8d7c9e0a4dae8086d5f1118b6099e9513e4e93deb2eb8a2b6c',_10 api_url 'https://api.withorb.com/v1',_10 api_key_id '<key_ID>'_10 );
Without Vault:
_10create server orb_server_10 foreign data wrapper wasm_wrapper_10 options (_10 fdw_package_url 'https://github.com/supabase/wrappers/releases/download/wasm_orb_fdw_v0.2.0/orb_fdw.wasm',_10 fdw_package_name 'supabase:orb-fdw',_10 fdw_package_version '0.2.0',_10 fdw_package_checksum 'f9dd3bd2a1ce3d8d7c9e0a4dae8086d5f1118b6099e9513e4e93deb2eb8a2b6c',_10 api_url 'https://api.withorb.com/v1',_10 api_key '<Orb API key>'_10 );
Note: the fdw_package_* options are required and specify the Wasm package metadata. See the Available Versions table above for the full list.
Resources
Details
Third-party integrations and docs are managed by Supabase partners.