> For the complete documentation index, see [llms.txt](https://docs.biti.so/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.biti.so/javascript-sdk-1.md).

# javascript sdk

Use the SDK in your page inside the Biti mini browser, and in a normal browser.

```html
<script src="https://cdn.biti.so/v1/biti-sdk.min.js" data-biti-origin="https://m.biti.so"></script>
```

## Methods

| Method                                 | In the Biti app                                         | In a normal browser                          |
| -------------------------------------- | ------------------------------------------------------- | -------------------------------------------- |
| `biti.getContext()`                    | `{ app_id, platform, version }`                         | `{ platform: "web" }`                        |
| `biti.login({ scopes })`               | Consent and wallet picker, returns `{ code }`           | Rejects with `not_in_biti_app`. Use Connect. |
| `biti.requestPayment({ order_id })`    | Pay sheet and PIN, returns `{ status, transaction_id }` | Redirects to `/pay/<order_id>`               |
| `biti.requestApproval({ mandate_id })` | Auto-pay sheet and PIN, returns `{ status }`            | Redirects to `/pay/mandate/<id>`             |
| `biti.requestHold({ hold_id })`        | Hold sheet and PIN, returns `{ status }`                | Redirects to `/pay/hold/<id>`                |
| `biti.share({ title, path })`          | Share sheet                                             | none                                         |
| `biti.close()`                         | Closes the page                                         | `history.back()`                             |

## Example

```javascript
const { order_id } = await fetch("/api/create-biti-order", { method: "POST" }).then((r) => r.json());
const result = await biti.requestPayment({ order_id });
if (result.status === "paid") {
  // Confirm on your server with get-order-status before you ship.
}
```

{% hint style="warning" %}
The page result is not proof of payment. Confirm on your server with `get-order-status` or a signed webhook.
{% endhint %}

## Pin an exact version

Use `https://cdn.biti.so/v1.0.0/biti-sdk.min.js` with `integrity="<sha384 from biti-sdk.min.js.sha384>"` and `crossorigin="anonymous"`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.biti.so/javascript-sdk-1.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
