Read SKU.io data in Supabase
If you're building your own app on Supabase, you can read your SKU.io stock, products, costs, and sales orders there as SQL tables. Your app uses the numbers SKU.io already keeps, instead of working them out again. The connection is read-only: nothing your app does in Supabase changes SKU.io.
The setup scripts are in the open-source SKU.io for Postgres repository. You run them in your own Supabase project.
Before you begin
- You need a Supabase project, and permission to run SQL in it.
- You need to be comfortable running SQL. If you'd rather not, see Get your SKU.io data into a spreadsheet or BI tool.
- The token acts as you, so your SKU.io role has to allow you to see products, sales orders, and reports.
- Each Supabase project reads one SKU.io account.
What you get
| Table | What's in it | Refreshes |
|---|---|---|
| sku.stock | Available, allocated, on hold, on hand, in transit, backorder, and inbound, per product per warehouse | Every 5 minutes |
| sku.products | Products with brand, supplier, costs, price, and stock totals | Every hour |
| sku.costs | Unit cost, average cost, supplier price, and stock value per product | With products |
| sku.sales_orders | Sales orders from the last 90 days, without their lines | Every 15 minutes |
Your queries read the copy in your own database. Only a refresh calls SKU.io. If a refresh can't read everything, it keeps the previous copy and records why.
Steps
1. Create a read-only token
In SKU.io, create a personal access token with these three scopes and no others:
products:readorders:readreports:read
Leave the IP allowlist empty unless your Supabase project has a fixed outbound address. Copy the token.
2. Store the token in Supabase Vault
In Supabase, open the SQL Editor, paste your token into this line, and run it. Don't save the query.
select vault.create_secret('<your token>', 'sku_api_token');
3. Run the install script
- Open
sql/01_install.sqland copy it into the SQL Editor. - Replace
YOUR-SUBDOMAINwith the part before.sku.ioin your SKU.io address. Forhttps://acme.sku.io, that'sacme. - Run the whole script.
It loads the tables and finishes with a list of each table, how many rows it has, and whether the load worked.
4. Schedule the refreshes
Run sql/02_schedule.sql
the same way. To see how fresh each table is at any time, run:
select * from sku.refresh_status;
5. Query your data
select sku, warehouse_name, available, inbound
from sku.stock
where available < 10
order by available;
Get changes as they happen
To store shipments and stock changes when SKU.io sends them, use the webhook function in the repository. Stock changes are sent in 30-second batches. It checks each delivery's signature and stores it once.
- Follow Webhooks in the repository to add the function to your project.
- In SKU.io, subscribe to webhooks for Stock Level Changed and Shipment Sent, with your function's address as the Target URL.
- Click Send test delivery on each one.
Decide who can see the tables
Only your server code can read the tables at first. Anything you show to signed-in users has to be a view you create on purpose. The repository has an example. Think about costs before you share them: everyone who can read a view sees every row in it.
Webhook deliveries are stored as SKU.io sends them, which for shipments includes the customer's name and email.
If a refresh fails
Run the status query from step 4 and read the error column.
| The error says | What to do |
|---|---|
| HTTP 401 | The token is wrong, expired, or revoked. Create a new one and replace it in Vault. |
| HTTP 403 | The token is missing a scope, or its IP allowlist blocks Supabase. See Fix a 403 from your API token. |
| read … of … rows | Records were removed while the refresh was reading. The next refresh tries again. |
Next steps
- Subscribe to webhooks: the events you can receive, and how deliveries are signed.
- Manage personal access tokens: see what the token has read, or revoke it.
- Connect n8n or Make: move data without writing code.