Esta página ainda está em inglês. A tradução para português está em andamento.
Bling ERP Integration
Bling is a Brazilian cloud ERP for managing products, sales orders, contacts (customers/suppliers), fiscal invoices (NF-e), and stock. The @flux agent uses Bling alongside Omie, Stripe, and Asaas to get a complete financial and operational picture for Brazilian businesses. Theint-bling skill talks to Bling API v3 via OAuth2 with automatic token refresh — you authenticate once with make bling-auth and the skill keeps the session alive forever.
Setup
1. Create a Bling App
- Log in at developer.bling.com.br
- Go to Meus Apps and create a new application
- Set the redirect URI to exactly:
- Copy the Client ID and Client Secret
2. Configure .env
BLING_ACCESS_TOKEN and BLING_REFRESH_TOKEN empty — the next step fills them in.
3. Run the OAuth Login
- Starts a local callback server on
http://localhost:8787/callback - Opens your browser at Bling’s authorization page
- You log in and approve the app
- Bling redirects back to the local server with an authorization code
- The helper exchanges the code for
access_token+refresh_token - Both tokens are persisted to
.env
.env contains:
4. Test the Connection
Run any read operation through the Python client:401, the client will automatically refresh the token and retry once.
How Automatic Refresh Works
The Python client (.claude/skills/int-bling/scripts/bling_client.py) is the single entry point for all API calls. On any HTTP 401:
- It exchanges
BLING_REFRESH_TOKENfor a newaccess_token+refresh_tokenathttps://www.bling.com.br/Api/v3/oauth/tokenusing HTTP Basic auth with Client ID and Client Secret. - Both new tokens are persisted back to
.envand toos.environ. - The original request is retried once with the fresh access token.
Important: Bling rotates the refresh token on every refresh, so always use the provided client. Never call the API directly withcurlunless you are debugging — otherwise the next refresh will use a stale refresh token and the session will break. If that happens, runmake bling-authagain to start over.
Calling the Client
Available Operations
Theint-bling skill documents 10 operations covering the core of an ERP workflow:
All list endpoints support pagination via
page and limit (default 100). Dates use the YYYY-MM-DD format.
Advanced Endpoints (Reference Only)
The following are not wrapped by the skill yet — use the reference implementation inworkspace/projects/mcp-dev-brasil/packages/erp/bling/ and the official API v3 docs as guides:
- Product categories and variations
- Purchase orders and production management
- Warehouse/depósito CRUD
- Stock movement history and audit trails
- NF-e cancellations and complementary invoices
- Webhooks
bling_client.py and document the new operation in .claude/skills/int-bling/SKILL.md.
Skills That Use Bling
Troubleshooting
make bling-auth says “missing BLING_CLIENT_ID / BLING_CLIENT_SECRET”
Fill both values in .env first, then run again.
Browser does not open automatically
Copy the URL the CLI prints and paste it manually. The local callback server will still catch the redirect.Redirect URI mismatch
Bling will show an error page if the app’s redirect URI is not exactlyhttp://localhost:8787/callback. Fix it in the app settings at developer.bling.com.br.
401 errors keep coming back
Your refresh token is probably stale because some other process bypassedbling_client.py. Run make bling-auth again to get a fresh pair of tokens.
State mismatch error
The CLI refused the callback because of a CSRF check failure (very rare — usually means the browser returned an old callback). Re-runmake bling-auth.