# Endpoint

> Seluruh endpoint API Publik beserta scope, filter, dan contoh permintaannya.

Source: https://docs.bakasir.com/id/docs/developers/endpoints

Semua path relatif terhadap `https://api.bakasir.com`. Kirim `Authorization: Bearer bak_kunci_anda` di setiap permintaan. Daftar menerima `limit`, `cursor`, dan `order`, lihat [Paginasi](https://docs.bakasir.com/id/docs/developers/conventions.md#paginasi).

## Informasi kunci

| Metode | Path | Scope |
| --- | --- | --- |
| GET | `/v1/me` | kunci apa pun |

```bash
curl https://api.bakasir.com/v1/me -H "Authorization: Bearer bak_kunci_anda"
```

Mengembalikan id, nama, prefiks, scope kunci, dan jumlah permintaan per menit yang diizinkan.

## Produk

| Metode | Path | Scope |
| --- | --- | --- |
| GET | `/v1/products` | `products` baca |
| GET | `/v1/products/{id}` | `products` baca |
| POST | `/v1/products` | `products` tulis |
| PATCH | `/v1/products/{id}` | `products` tulis |
| DELETE | `/v1/products/{id}` | `products` tulis |

Filter daftar: `category_id`, `type` (`standard`, `variant`, `digital`, `service`, `bundle`), `status` (`active` atau `inactive`), dan `search` (nama atau kode).

Buat produk. `name` dan `type` wajib. Harga dalam satuan terkecil mata uang:

```bash
curl https://api.bakasir.com/v1/products \
  -H "Authorization: Bearer bak_kunci_anda" \
  -H "Idempotency-Key: sku-1001" \
  -H "Content-Type: application/json" \
  -d '{"name": "Es Kopi Susu", "type": "standard", "code": "KOPI-001", "price": 22000, "cost": 9000}'
```

`PATCH` hanya mengubah kolom yang Anda kirim. Aturan harga sama dengan Portal. Produk yang punya stok atau riwayat penjualan tidak bisa dihapus, jadi atur `"status": false` untuk menyembunyikannya. Produk standar yang dibuat dengan `opening_stock` dimulai dengan stok itu di outlet pertama, atau di `store_id` jika Anda mengirimnya.

## Kategori

| Metode | Path | Scope |
| --- | --- | --- |
| GET | `/v1/categories` | `categories` baca |
| GET | `/v1/categories/{id}` | `categories` baca |
| POST | `/v1/categories` | `categories` tulis |
| DELETE | `/v1/categories/{id}` | `categories` tulis |

```bash
curl https://api.bakasir.com/v1/categories \
  -H "Authorization: Bearer bak_kunci_anda" \
  -H "Content-Type: application/json" \
  -d '{"name": "Minuman"}'
```

## Outlet dan stok

| Metode | Path | Scope |
| --- | --- | --- |
| GET | `/v1/stores` | `stock` baca |
| GET | `/v1/stock` | `stock` baca |
| POST | `/v1/stock/adjustments` | `stock` tulis |

`/v1/stock` mengembalikan satu baris per outlet, produk, dan varian dengan `qty` dan `avg_cost`. Filter dengan `store_id` dan `product_id`.

Penyesuaian menambah atau mengurangi stok dan langsung diposting, sama seperti penyesuaian stok yang dikirim di Portal. `type` adalah `addition` (bawaan) atau `subtraction`, dan `qty` selalu positif. Kosongkan `store_id` untuk memakai outlet pertama Anda.

```bash
curl https://api.bakasir.com/v1/stock/adjustments \
  -H "Authorization: Bearer bak_kunci_anda" \
  -H "Idempotency-Key: adj-2026-11-04-001" \
  -H "Content-Type: application/json" \
  -d '{
    "store_id": "01K9ZT6Q2X3M8N4V7B5C1D0STO",
    "reason": "correction",
    "note": "Hitung gudang",
    "items": [
      {"product_id": "01K9ZT6Q2X3M8N4V7B5C1D0EFG", "qty": 12, "type": "addition"},
      {"product_id": "01K9ZT6Q2X3M8N4V7B5C1D0HIJ", "qty": 2, "type": "subtraction"}
    ]
  }'
```

Maksimal 200 baris per permintaan. Outlet atau produk yang tidak dikenal mengembalikan `422`.

## Pelanggan

| Metode | Path | Scope |
| --- | --- | --- |
| GET | `/v1/customers` | `customers` baca |
| GET | `/v1/customers/{id}` | `customers` baca |
| POST | `/v1/customers` | `customers` tulis |
| PATCH | `/v1/customers/{id}` | `customers` tulis |
| DELETE | `/v1/customers/{id}` | `customers` tulis |

Filter daftar dengan `search` (nama, email, atau telepon). `name` wajib untuk membuat pelanggan. Poin loyalitas, tier, dan saldo awal tidak bisa diatur lewat API.

## Penjualan

| Metode | Path | Scope |
| --- | --- | --- |
| GET | `/v1/sales` | `sales` baca |
| GET | `/v1/sales/{id}` | `sales` baca |

Setiap penjualan menyertakan `items` dan `payments`. Filter: `status` (satu atau daftar dipisah koma seperti `completed,partially_refunded`), `customer_id`, `store_id`, serta `from` dan `to` pada waktu penjualan.

```bash
curl "https://api.bakasir.com/v1/sales?status=completed&from=2026-11-01&to=2026-11-05&limit=100" \
  -H "Authorization: Bearer bak_kunci_anda"
```

Penjualan di outlet Demo tidak pernah dikembalikan.

## Pesanan online

| Metode | Path | Scope |
| --- | --- | --- |
| GET | `/v1/orders` | `orders` baca |
| GET | `/v1/orders/{id}` | `orders` baca |

Pesanan yang masuk dari toko online Anda. Filter: `status` (`ordered`, `processing`, `delivering`, `completed`, `canceled`), `payment` (status pembayaran), `from`, dan `to`. Pesanan tunggal juga mengembalikan `lines`. Pakai `sale_id` untuk mencocokkan pesanan dengan `/v1/sales/{id}`.
