# Getting started

Regoria is a merchant of record: your buyers pay Regoria, Regoria collects US sales tax, holds a rolling reserve and pays you out monthly. The API gives your server what it needs around that: a catalog, hosted checkout sessions, orders to fulfil, customers and their saved cards, subscriptions, refunds, your balance and payouts, and webhooks that tell you when something happened.

## What you need

- A merchant account on Regoria with access to the dashboard.
- An **API key**. In the dashboard open **Developers → API keys** and create a key in **test** mode with the scopes you need (start with `v1.products.write`, `v1.checkout_sessions.write`, `v1.orders.read`, `v1.webhook_endpoints.manage`). The key is shown once: copy it into your server's secret store.
- A server that can make HTTPS calls and receive them. The API never talks to a browser directly.

## Two environments

| | Live | Sandbox |
|---|---|---|
| Base URL | `https://api.staging.regoria.com` | `https://api.sandbox.staging.regoria.com` |
| Keys | `mor_live_…` | `mor_test_…` |
| Money | real cards, real payouts | test cards, nothing moves |

A test key is refused on the live base URL and a live key on the sandbox. Everything in these guides runs on the sandbox until you say otherwise. See [Test mode and the sandbox](http://docs.staging.regoria.com/guides/test-mode).

## Conventions in one minute

- JSON in, JSON out. Every amount is an **integer in cents** (`2900` is $29.00); the currency is `USD`.
- The key goes in the `Authorization` header as a bearer token. See [Authentication and API keys](http://docs.staging.regoria.com/guides/authentication).
- Ids are prefixed: `prd_` product, `prc_` price, `pln_` plan, `cks_` checkout session, `ord_` order, `chg_` charge, `rfd_` refund, `sub_` subscription, `pm_` saved card, `cus_` customer, `dsp_` dispute, `whk_` webhook endpoint, `key_` API key.
- Lists are plain JSON arrays with the paging in headers (`X-Total-Count`, `Link`). See [Pagination, sorting and filtering](http://docs.staging.regoria.com/guides/pagination).
- Errors are `{"errors": [{"key": "…", "message": "…"}]}` with stable keys. See [Errors](http://docs.staging.regoria.com/guides/errors).
- A `POST` that creates money state takes an `Idempotency-Key` header. See [Idempotency](http://docs.staging.regoria.com/guides/idempotency).

## 1. Your first call

```bash
curl https://api.sandbox.staging.regoria.com/v1/merchants/me \
  -H "Authorization: Bearer $API_KEY"
```

You get your merchant profile back: `id` (`mer_…`), `display_name`, `status`, `support_email`, `timezone`. If you get `401`, the key is wrong or on the wrong base URL; `403 insufficient_scope` means the key lacks `v1.merchants.read`.

## 2. A product with a price

```bash
curl -X POST https://api.sandbox.staging.regoria.com/v1/products \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Starter pack", "type": "one_off", "amount_cents": 2900}'
```

The answer is the product with its `active_price` (`prc_…`). A product is `one_off` (bought once) or `plan` (billed on a schedule; add a plan with `POST /v1/plans`). A new price for the same product is `POST /v1/prices`; the old one stays on the orders that used it.

## 3. A hosted checkout

```bash
curl -X POST https://api.sandbox.staging.regoria.com/v1/checkout-sessions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "lines": [{"price_id": "prc_…", "quantity": 1}],
    "customer_ref": "cus_A1B2",
    "reference": "INV-1001",
    "success_url": "https://shop.example.com/thanks",
    "cancel_url": "https://shop.example.com/cart"
  }'
```

Send the buyer to the session's `url`. Regoria shows the hosted page, quotes the sales tax for the buyer's address, takes the card and captures. The buyer lands on your `success_url`; your server learns about the sale from the **`order.paid` webhook**, never from the redirect alone. Sessions expire after 30 minutes. The whole flow, with the webhook handler, is in [Hosted checkout end to end](http://docs.staging.regoria.com/guides/hosted-checkout).

## 4. A webhook endpoint

```bash
curl -X POST https://api.sandbox.staging.regoria.com/v1/webhook-endpoints \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://shop.example.com/webhooks", "events": ["order.paid", "refund.issued"]}'
```

The answer carries the signing `secret` once. Store it; every delivery is signed with it. [Webhooks](http://docs.staging.regoria.com/guides/webhooks) has the verification code and the retry schedule.

## Where next

- The [API reference](http://docs.staging.regoria.com/reference) lists every operation with its scope, examples and code samples; the same document is [`openapi.json`](http://docs.staging.regoria.com/openapi.json).
- [Subscriptions](http://docs.staging.regoria.com/guides/subscriptions), [Refunds and disputes](http://docs.staging.regoria.com/guides/refunds-and-disputes), [Balance and payouts](http://docs.staging.regoria.com/guides/balance-and-payouts).
- Integrating with a coding agent: [Build with AI](http://docs.staging.regoria.com/guides/build-with-ai).
- Questions: [support@staging.regoria.com](mailto:support@staging.regoria.com).
