> For the complete documentation index, see [llms.txt](https://docs.loomgate.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.loomgate.io/en/api-reference.md).

# API reference

Base URL, authentication, format, pagination, idempotency and rate limits.

## Base URL

```
https://api.loomgate.io
```

All integration API routes live under `/partner/v1`, for example `POST https://api.loomgate.io/partner/v1/payment_intents`.

| Route group                       | Authentication                                                  | Called from                        |
| --------------------------------- | --------------------------------------------------------------- | ---------------------------------- |
| `/partner/v1/*` (except `client`) | `Authorization: Bearer sk_live_…`                               | Your server                        |
| `/partner/v1/client/*`            | `Authorization: Bearer pk_live_…` + `client_secret` in the body | The browser, through `loomgate.js` |

See [API keys and authentication](/en/getting-started/api-keys.md).

## Format

* Requests with a body send JSON with `Content-Type: application/json`. Responses are always JSON.
* Field names are `snake_case`. Times are unix seconds. Amounts are integers in the smallest unit.
* Every object has an `object` field that gives its type (`payment_intent`, `refund`, `list`…).
* Ignore response fields you don't use, so your code doesn't break when the API adds new fields. Unknown fields in a **request** are rejected (`validation_error`).
* `metadata`: up to 50 keys (each key up to 40 characters); values are strings of up to 500 characters. Metadata is only stored at Loomgate and is not sent to anyone else.

## Pagination

List routes return the newest items first:

```json
{ "object": "list", "data": [ … ], "has_more": true }
```

| Parameter        | Meaning                                    |
| ---------------- | ------------------------------------------ |
| `limit`          | 1–100, default 20                          |
| `starting_after` | `id` of the last item on the previous page |

Repeat with `starting_after` set to the last `id` until `has_more` is `false`.

## Idempotency

`POST /partner/v1/payment_intents` and `POST /partner/v1/refunds` accept an `Idempotency-Key` header (1–255 characters) so that you can retry safely:

* Same key, same body → returns the result of the first request and creates nothing new (for a payment: same `id` and `client_secret`).
* Same key, different body → `409 idempotency_key_reused`.
* Keys belong to your account, are shared between the two routes and never expire: use different prefixes (`order-…`, `refund-…`).
* A request that ends in an error stores nothing; sending the same key again runs it again.

## Rate limits

| Scope                                   | Limit                                                                |
| --------------------------------------- | -------------------------------------------------------------------- |
| Server routes (secret key)              | 1200 requests/minute per account, counted separately for each route  |
| Failed authentication on server routes  | 300/minute per IP address                                            |
| Browser routes (`/partner/v1/client/*`) | 60 requests/minute per IP address, counted separately for each route |
| Payment attempts                        | See [Payments and statuses](/en/concepts/payments.md)                |

Going over a limit returns `429 rate_limited` with a `Retry-After` header (seconds). Wait exactly that many seconds, then retry.

## ID prefixes

| Prefix   | Object           |
| -------- | ---------------- |
| `lg_pi_` | Payment intent   |
| `lg_cs_` | Client secret    |
| `lg_re_` | Refund           |
| `adj_`   | Adjustment       |
| `evt_`   | Webhook event    |
| `we_`    | Webhook endpoint |

## Reference pages

| Page                                                              | Routes                                           |
| ----------------------------------------------------------------- | ------------------------------------------------ |
| [Payment intents](/en/api-reference/payment-intents.md)           | Create, retrieve, list, update, confirm, release |
| [Refunds](/en/api-reference/refunds.md)                           | Refund, retrieve, list                           |
| [Fee quotes](/en/api-reference/fee-quotes.md)                     | Quote fees in advance                            |
| [Balance](/en/api-reference/balance.md)                           | Balance                                          |
| [Webhook signing keys](/en/api-reference/webhook-signing-keys.md) | Public keys that verify webhooks                 |
| [Client API](/en/api-reference/client.md)                         | Browser routes used by `loomgate.js`             |
| [Errors](/en/api-reference/errors.md)                             | Error format and the list of codes               |


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.loomgate.io/en/api-reference.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
