# Payments API

> Send payments from your own server when your provider is not supported.

Use the Payments API for in-house billing or any provider Reveata does not connect to. Create a website API key in **Settings → Developer**; keys start with `dt_site_` and only work for their website.

```bash
curl -X POST https://reveata.com/api/v1/payments \
  -H "Authorization: Bearer $REVEATA_SITE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "transactionId": "order_1042",
    "amount": 49.00,
    "currency": "USD",
    "email": "ada@example.com",
    "visitorId": "the value of window.reveata.visitorId()"
  }'
```

## Fields

| Field                                 | Required            | Notes                                                                                |
| ------------------------------------- | ------------------- | ------------------------------------------------------------------------------------ |
| `transactionId`                       | yes                 | Your unique id. Sending the same id again does nothing, so retries are safe.         |
| `amount`                              | yes                 | Major units, e.g. `29.99`, excluding tax.                                            |
| `currency`                            | yes                 | Three-letter ISO code.                                                               |
| `type`                                | no                  | `new` (default), `renewal`, `refund` or `trial`. Trials have amount `0`.             |
| `email`, `customerId`, `customerName` | no                  | Help match the payment and group it by customer.                                     |
| `visitorId`, `sessionId`              | no                  | From `window.reveata.visitorId()` / `sessionId()` at checkout. The strongest match. |
| `userId`                              | no                  | The id you pass to `reveata('identify', …)`.                                        |
| `subscriptionId`                      | no                  | Renewals of the same subscription inherit the first payment’s attribution.           |
| `originalTransactionId`               | no                  | For refunds: the payment being refunded.                                             |
| `paidAt`                              | no                  | ISO 8601 date-time. Defaults to now.                                                 |
| `metadata`                            | no                  | Up to 20 string values for your own reference.                                       |
| `website`                             | with account tokens | Website id or domain. Website keys already imply their website.                      |

Unknown fields are rejected, so typos fail loudly instead of being ignored. See the [API reference](https://reveata.com/api-reference) for the full response format.
