---
title: Credits
icon: doughnut
description: Set up, configure, and run the Reloop credits microservice locally.
---
> For the complete documentation index, see [llms-docs.txt](/llms-docs.txt) or the site index [llms.txt](/llms.txt). Full docs corpus: [llms-full-docs.txt](/llms-full-docs.txt). Prefer markdown URLs (append `.md`) for agent consumption. Product skill: [skill.md](/skill.md).


Subscription tiers, credit balances, usage tracking, and Stripe billing integration.

<Tip>
Run [`bun setup`](/docs/setup) once from the monorepo root. Env files come from `bun setup` / `bun env:setup`.
</Tip>


## Overview

| Property | Value |
| :--- | :--- |
| **Directory** | `apps/backend/credits` |
| **Port** | `8023` |
| **Local URL** | [https://local.reloop.sh/api/credits](https://local.reloop.sh/api/credits) |
| **Swagger UI** | [https://local.reloop.sh/api/credits/openapi](https://local.reloop.sh/api/credits/openapi) |
| **Stack** | ElysiaJS · PostgreSQL · NATS |


## Quick start

```bash
bun be:credits:dev
```

Or `bun backend:dev` / `bun dev`.


## Environment

`apps/backend/credits/.env` — from `bun setup` / `bun env:setup`.

```bash
PORT=8023
NODE_ENV=development
INITIAL_CREDITS=100
NATS_URL=nats://localhost:4222
```

| Variable | Required | Default |
| :--- | :--- | :--- |
| `PORT` | **YES** | `8023` |
| `INITIAL_CREDITS` | **YES** | `100` |
| `NATS_URL` | **YES** | `nats://localhost:4222` |


## Commands

| Command | Description |
| :--- | :--- |
| `bun be:credits:dev` | Start dev server with hot reloading |
| `bun run --filter=be-credits build` | Compile production bundle |
| `bun run --filter=be-credits start` | Run compiled production build |
| `bun run --filter=be-credits check-types` | TypeScript type-check |


## Architecture

| Layer | Detail |
| :--- | :--- |
| **Credits** | Tracks balances and blocks sends when credits reach zero |
| **Stripe** | Manages subscriptions, invoices, and billing webhooks |
| **Events** | Publishes `billing.quota-warning` and related NATS subjects |
| **Schema** | `plan`, `subscription`, `credit_ledger` in `packages/db/src/schema/billing.ts` |


## Next

<CardGroup cols={2}>
  <Card icon="rocket" title="Setup" href="/setup">
    One-command local bootstrap
  </Card>
  <Card icon="globe" title="Port reference" href="/setup/port">
    Gateway routes and ports
  </Card>
  <Card icon="mail-single" title="Mail" href="/setup/backend/mail">
    Sends that consume credits
  </Card>
  <Card icon="mail" title="Email" href="/setup/backend/email">
    Platform billing notifications
  </Card>
</CardGroup>
