> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bachs.io/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Money is always a decimal string at the currency's precision (for example "29.00"), paired with an ISO 4217 currency field. Never use minor units.
> Build against the sandbox first: base URL https://sandbox-api.bachs.io with sk_sandbox_ keys. Production is https://api.bachs.io with sk_live_ keys; going live is a key swap.
> Treat webhooks (for example collection.succeeded) as the source of truth for fulfilment, never client-side events or redirects.
> Subscriptions are created by completing a checkout for a recurring product. There is no direct create-subscription endpoint.
> IDs carry resource prefixes (cust_, prod_, sub_, chk_, inv_, ref_) and timestamps are ISO 8601 UTC.

# When a connection ends

> How a connection to your app ends, how to end one from your side, and what your app is told.

A connection ends in one of five ways. Each time, your webhook receives
[`app.deauthorized`](https://docs.bachs.io/guides/webhooks/events/app-deauthorized) first. Then the
access and refresh tokens and your webhook for that business stop. The business,
its money and its other integrations are not touched.

| How it ends | `reason` |
| - | - |
| The business clicks **Disconnect** in **Developer Portal → Connected apps**, approves your app again (the old connection is replaced), or the person who approved loses permission | `merchant` |
| Your server revokes it, reuses a code, or reuses an old refresh token | `app` |
| Nobody refreshed it for 90 days | `expired` |
| You delete the app | `deleted` |
| Bachs suspends the app | `suspended` |

## Handle app.deauthorized

When it arrives, mark the business as disconnected and delete its tokens and
its webhook signing secret. Do not try the old tokens again: they already stopped
working. To work with the business again, send it through a new connection.

The event comes on the webhook Bachs set up for that business, signed with that
connection's secret. Your app cannot subscribe to it or turn it off.

## End a connection from your side

Send the connection's refresh token or access token to the revoke endpoint, with
your client secret.

```bash cURL theme={"dark"}
curl -X POST https://sandbox-api.bachs.io/v1/connect/oauth/revoke \
  -u "app_9Kd2Mw7Qx1Lr5Tn8Vb3Hs6Pz:$BACHS_CLIENT_SECRET" \
  -d token=9w42ebfsXyghxLDgN0ZM0h6tYYyjrW0nXUTvVLnup2g
```

It answers `200` even when the token is unknown, already revoked or belongs to
another app, so you can call it safely when a user removes the integration on
your side. Your webhook still receives `app.deauthorized` with reason `app`.

## Keep a connection alive

Refresh at least once every 90 days. An app that refreshes when its access token
expires never reaches the limit. A connection that ends because nobody refreshed
needs a fresh approval from the business.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.