> ## 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.

# Create an app

> Make an app in sandbox, set it up, get its client secret and test a connection.

You need a verified business on Bachs that is not a connected account, and
permission to manage settings. You can make up to 20 apps.

Build in sandbox first. Sandbox and live apps are separate, with separate ids
and secrets.

**1. Create the app**

In the sandbox dashboard, open **Developer Portal → Apps** and click
**Create app**. Give it a name of 3 to 40 characters. It cannot contain
"Bachs".

The app opens with its `client_id` and its first **client secret**
(`appsk_test_…` in sandbox). The secret is shown once. Copy it to your server's
secret store now.

**2. Fill in the details**

On **Details**, add what a business sees when it connects:

* An icon: a square PNG or SVG of 512 KB or less.
* A description of up to 300 characters.
* Your website, privacy policy and terms links.
* A support email.

**3. Set up OAuth**

On **OAuth**, add:

* **Callback addresses**: up to 10, matched exactly, including path, port and
  trailing slash. Sandbox also accepts loopback addresses such as
  `http://localhost:3000/callback`. Live needs HTTPS.
* **Permissions**: only what your app needs. Each one needs a reason of 10 to
  200 characters, written for the business: "So you can refund customers from
  your helpdesk". See [Permissions for apps](https://docs.bachs.io/apps/reference/permissions.md).
* **Install URL**: the page on your site that starts a connection. The Bachs
  app directory and **Test install** send people there.

**4. Add a webhook**

On **Webhooks**, add a public HTTPS URL and the exact event names it should
receive. Each event needs its read permission: `collection.succeeded` needs
`payments:read`. When a business connects, Bachs sets up a signed webhook for
that business with these events.

**5. Test a connection**

Click **Test install**. It opens your install URL, so you run a full connection
against one of your own sandbox businesses, with your server holding the
`state` and verifier. Follow [Connect a business](https://docs.bachs.io/apps/connect-a-business.md).

**6. Copy it to live**

Click **Copy to live**. It makes the live app with the same settings and a new
live secret (`appsk_live_…`). Loopback callback addresses are dropped, and the
dialog lists them. Upload the icon again on the live app. After that, edit the
two apps separately.

A live app starts private. To let other businesses install it, see
[Who can install it](https://docs.bachs.io/apps/distribution.md) and [Publish your app](https://docs.bachs.io/apps/publish.md).

## Rotate a client secret

An app can have two active secrets at once, so you can rotate without downtime.

1. On **Credentials**, click **Make a secret** and copy it.
2. Switch your server to the new secret.
3. Revoke the old one.

A revoked secret stops working at once.

## Delete an app

Delete it from the menu on the app page. Every business connected to it is
disconnected, and your webhook receives `app.deauthorized` with reason
`deleted` for each one first.


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