# Shopads API reference

Base URL: **http://100.110.107.13:3030**

Live [Swagger UI](http://100.110.107.13:3030/docs), [ReDoc](http://100.110.107.13:3030/redoc), and [OpenAPI JSON](http://100.110.107.13:3030/openapi.json).

Updated 2026-10-17 (Asia/Makassar). Routes and request schemas were read from the live OpenAPI endpoint; `/health` returned `{"status":"ok"}`. The [saved OpenAPI snapshot](openapi.json) records that schema. Local response examples below are derived from the implementation, with fictional data. Protected routes and DigitalCore payloads were not exercised. The live schema currently leaves successful response schemas unspecified.

## Request and response conventions

- All application routes except login and health require `Authorization: Bearer <access_token>`.
- POST bodies use `Content-Type: application/json`, except upload, which uses `multipart/form-data`. Send `{}` for default-only lookup requests; an absent body is invalid.
- GET routes take no body. Query parameters are listed per route.
- Unknown JSON fields are rejected. Field names are case-sensitive; preserve the provider spelling `recepientTotal` and `recepientMax`.
- Local responses have the shapes shown below; there is no common `success`/`message`/`data` wrapper.
- DigitalCore responses preserve upstream HTTP status and parsed JSON. A business failure can have HTTP 200 and nonzero `code`; check both.
- Local money values are decimal strings. Local timestamps are ISO 8601 strings, with application-written times stored in UTC without an offset. Existing database timestamps retain their stored values.

## Route index

| Method | Path | Access | Request | Response |
| --- | --- | --- | --- | --- |
| POST | [/api/auth/login](#post-apiauthlogin) | Public | JSON | Local JSON |
| GET | [/api/auth/me](#get-apiauthme) | Bearer | None | Local JSON |
| POST | [/api/auth/change-password](#post-apiauthchange-password) | Bearer | JSON | Empty (204) |
| POST | [/api/management/users/{user_id}/reset-password](#post-apimanagementusersuser_idreset-password) | Admin/client admin | JSON | Empty (204) |
| GET, PUT, DELETE | [/api/management/memberships/{user_id}](#apimanagementmembershipsuser_id) | Main admin | JSON (PUT) | Local JSON / Empty (204) |
| POST | [/api/membership/join](#post-apimembershipjoin) | Merchant | None | Local JSON |
| GET, PUT, DELETE | [/api/management/packages/accounts/{user_id}](#apimanagementpackagesaccountsuser_id) | Main admin | JSON (PUT) | Local JSON |
| GET | [/api/management/users/{user_id}/package-purchases](#apimanagementpackagesaccountsuser_id) | Main admin | None | Local JSON |
| GET | [/api/packages](#get-apipackages) | Merchant | None | Local JSON |
| POST | [/api/packages/{package_id}/buy](#post-apipackagespackage_idbuy) | Merchant | None | Local JSON |
| GET | [/api/packages/orders/{order_id}](#paket-qris-orders) | Merchant (own) / main admin | None | Local JSON |
| POST | [/api/packages/orders/{order_id}/complete, /cancel](#paket-qris-orders) | Merchant (own) / main admin | None | Local JSON |
| POST | [/api/short-links](#post-apishort-links) | Admin/merchant | JSON | Local JSON (201) |
| GET | [/api/short-links/{code}/open](#get-apishort-linkscodeopen) | Public | Query parameters | Local JSON |
| POST | [/api/balance/transfers](#post-apibalancetransfers) | Admin/reseller | JSON | Local JSON |
| GET | [/api/balance/transfers](#get-apibalancetransfers) | Bearer | Query parameters | Local JSON |
| GET | [/health](#get-health) | Public | None | Local JSON |
| POST | [/api/sms/broadcast/add](#post-apismsbroadcastadd) | Bearer | JSON | DigitalCore JSON (pass-through) |
| POST | [/api/sms/targeted/add](#post-apismstargetedadd) | Bearer | JSON | DigitalCore JSON (pass-through) |
| POST | [/api/sms/lba/add](#post-apismslbaadd) | Bearer | JSON | DigitalCore JSON (pass-through) |
| POST | [/api/mms/broadcast/add](#post-apimmsbroadcastadd) | Bearer | JSON | DigitalCore JSON (pass-through) |
| POST | [/api/mms/targeted/add](#post-apimmstargetedadd) | Bearer | JSON | DigitalCore JSON (pass-through) |
| POST | [/api/mms/lba/add](#post-apimmslbaadd) | Bearer | JSON | DigitalCore JSON (pass-through) |
| POST | [/api/{sms,mms}/{broadcast,targeted,lba}/add_main](#post-apismsmmsbroadcasttargetedlbaadd_main) | Bearer | JSON | DigitalCore JSON (pass-through) |
| POST | [/api/waba/broadcast/add](#post-apiwababroadcastadd) | Bearer | JSON | DigitalCore JSON (pass-through) |
| POST | [/api/waba/targeted/add](#post-apiwabatargetedadd) | Bearer | JSON | DigitalCore JSON (pass-through) |
| POST | [/api/waba/lba/add](#post-apiwabalbaadd) | Bearer | JSON | DigitalCore JSON (pass-through) |
| POST | [/api/campaigns/list](#post-apicampaignslist) | Admin | JSON | DigitalCore JSON (pass-through) |
| GET | [/api/reports/campaigns](#get-apireportscampaigns) | Bearer | Query parameters | Local JSON |
| GET | [/api/balance](#get-apibalance) | Bearer | None | Local JSON |
| GET | [/api/admin/digitalcore/balance](#get-apiadmindigitalcorebalance) | Admin | None | DigitalCore JSON (pass-through) |
| POST | [/api/profiles/list](#post-apiprofileslist) | Bearer | JSON | DigitalCore JSON (pass-through) |
| GET | [/package_price](#get-package_price) | Bearer | None | Local JSON |
| POST | [/api/pricebook](#post-apipricebook) | Bearer | JSON | DigitalCore JSON (pass-through) |
| POST | [/api/waba/templates/list](#post-apiwabatemplateslist) | Bearer | JSON | DigitalCore JSON (pass-through) |
| GET | [/api/waba/display-names](#get-apiwabadisplay-names) | Bearer | None | DigitalCore JSON (pass-through) |
| POST | [/api/content/upload](#post-apicontentupload) | Bearer | Multipart | DigitalCore JSON (pass-through) |

## Endpoint details

### POST /api/auth/login

URL: `http://100.110.107.13:3030/api/auth/login`

Matches `users.merchant_id` and verifies the stored password hash. `_token` is optional and unused. The JWT lifetime defaults to 60 minutes; `expires_in` is seconds. There is no refresh-token endpoint.

Request content type: `application/json`. Full field definitions: [LoginRequest](#loginrequest).

Example request:
```json
{
  "_token": "",
  "merchant_id": "example_merchant",
  "password": "<password>"
}
```

Success: HTTP **200**, `application/json`. Example:

```json
{
  "access_token": "<JWT>",
  "token_type": "bearer",
  "expires_in": 3600,
  "user": {
    "id": "user-example-id",
    "email": "merchant@example.com",
    "name": "Example Merchant",
    "merchant_id": "example_merchant",
    "partner_id": "example_partner",
    "role": "merchant",
    "client_type": "non-member",
    "main_balance": "100.00",
    "refund_balance": "0.00"
  }
}
```

Errors: see [error responses](#error-responses).

### GET /api/auth/me

URL: `http://100.110.107.13:3030/api/auth/me`

Returns the current database account without its password. Balances are decimal strings; nullable account fields may be null. `membership` is the merchant's own membership with its quota (`active`, `expires_at`, `used`, `remaining`; same shape as [GET /api/management/memberships/{user_id}](#apimanagementmembershipsuser_id)), or `null` when it has none and for every other role.

Request body: none.

Success: HTTP **200**, `application/json`. Example:

```json
{
  "id": "user-example-id",
  "email": "merchant@example.com",
  "name": "Example Merchant",
  "merchant_id": "example_merchant",
  "partner_id": "example_partner",
  "role": "merchant",
  "client_type": "non-member",
  "main_balance": "100.00",
  "refund_balance": "0.00",
  "membership": null
}
```

Errors: see [error responses](#error-responses).

### POST /api/auth/change-password

URL: `http://100.110.107.13:3030/api/auth/change-password`

Any signed-in account (admin, admin_client, reseller, merchant) changes its own password.

Request content type: `application/json`. Fields (extra fields are rejected):

- `current_password` (string, required): the account's current password.
- `new_password` (string, required, 8–72 characters): must differ from `current_password`.

```json
{"current_password": "old-password", "new_password": "new-password-123"}
```

Success: HTTP **204**, no body. Existing access tokens stay valid until they expire.

Errors: **422** `Current password is incorrect` (deliberately not 401, so the portal does not treat it as an expired login), **422** when the new password is the same, too short or too long, **401** without a valid bearer token.

### POST /api/management/users/{user_id}/reset-password

URL: `http://100.110.107.13:3030/api/management/users/{user_id}/reset-password`

A manager sets a new password for another account. The main admin may reset any account; an admin_client only its own resellers and merchants (the same scope as editing users). Resellers and merchants receive 403.

Request content type: `application/json`:

- `password` (string, required, 8–72 characters).

```json
{"password": "new-password-123"}
```

Success: HTTP **204**, no body.

Errors: **403** for resellers and merchants, **404** for a missing account or one outside the caller's scope, **422** for an invalid password or when `user_id` is the caller (use change-password instead).

### /api/management/memberships/{user_id}

URL: `http://100.110.107.13:3030/api/management/memberships/{user_id}`

A merchant's membership offer: a price and a recipient quota per service for 30 days, one row per account in the `memberships` table. Only the main admin may use these routes; everyone else receives 403. Only merchant accounts can have one. Saving it charges nothing and does not make the merchant a member: the merchant joins it with [POST /api/membership/join](#post-apimembershipjoin) and pays `price` by QRIS; completing that order starts the 30 days. `started_at` and `expires_at` are `null` until then. DELETE refunds nothing.

While the membership is active, every campaign the merchant creates (portal or direct API call) whose recipients fit in the remaining quota of its service (`<channel>_<kind>_limit`) uses that quota instead of `main_balance`; it is still sent to DigitalCore unchanged. Quota counts recipients, not SMS parts. When the quota left is smaller than the campaign's recipients, the whole campaign is charged to `main_balance` as usual. A campaign DigitalCore rejects, at submission or later in review, gets its quota back ([outcomes](#campaign-outcomes-refunds-and-resends)). Each quota-paid campaign is a `membership_usage` row. After `expires_at` campaigns are charged to balance and the account's `client_type` becomes `non-member`.

- **GET**: the membership. **404** when the account has none.
- **PUT**: create or update the offer. Every field is required and must be a whole number from 0 to 2147483647 (`price` in whole rupiah). A limit may be `null`: unlimited quota for that service (every campaign uses the membership; usage is still recorded and `remaining` is `null`). `0` means the service has no quota. A running period and its used quota are kept.
- **DELETE**: remove the membership and set `client_type` back to `non-member`. Success: HTTP **204**, no body.

```json
{"price": 150000,
 "sms_broadcast_limit": 10, "sms_targeted_limit": 10, "sms_lba_limit": 5,
 "mms_broadcast_limit": 10, "mms_targeted_limit": 10, "mms_lba_limit": 5,
 "waba_broadcast_limit": 10, "waba_targeted_limit": 10, "waba_lba_limit": 5}
```

GET and PUT respond with those fields plus `id`, `user_id`, `started_at`, `expires_at` (UTC), `active`, `used` and `remaining` (recipients per service, e.g. `{"sms_targeted": 20}`), `created_at` and `updated_at`. For the main admin, `GET /api/management/users` also returns each user's `membership` (that object, or `null`).

Errors: **403** for every role except the main admin, **404** for a missing account (or a missing membership on GET/DELETE), **422** for a non-merchant account or invalid values.

### POST /api/reports/campaigns/{channel}/{local_id}/estimate

Estimasi Penerima Potensial of an LBA campaign the user can see (`channel`: sms, mms or waba). The first call asks DigitalCore `campaign/lba/receive` for the campaign's own `contents.locations` (latitude, longitude, radius, locationType), stores the answer in `campaign_estimates` and returns `{population, min_population, max_population, created_at}`; later calls return the stored row without contacting DigitalCore. `GET /api/reports/campaigns/{channel}/{local_id}` includes it as `estimate` (`null` until asked). Errors: **404** campaign not found or not visible, **422** not an LBA campaign or no saved location, **502** DigitalCore gave no estimate (nothing is stored, so the next call asks again).

### POST /api/short-links

Makes a tracked short link for a URL that goes in a campaign message ("Tambah Link Singkat"). Body: `{"target_url": "https://...", "code": "PromoAkhirTahun"}`: `target_url` http or https, at most 2000 characters; `code` optional, 4-64 letters, digits, `-` or `_`, case-sensitive (without it a random 6-character code is made). Responds 201 with `code`, `target_url`, `click_count`, `last_clicked_at`, `created_at`. Errors: **403** for resellers and client admins, **409** `Kode link singkat sudah dipakai. Pilih kode lain.` when `code` is taken, **422** for an invalid URL or code. Tables: `short_links` and `short_link_campaigns`. The API does not know the short-link domain: the portal shows a link as its `SHORT_LINK_BASE_URL` (default `APP_URL`) + `/` + code, e.g. `https://s.example.com/AxGweT`, and refuses that domain as a target.

When a campaign is sent, the sender's own short links are attached to it: for SMS/MMS those in its `message` (or LBA `contents.message`); for WABA those in the body and URL-button `actionUrlTarget` of the sender's template whose `digitalcore_template_id` is the campaign's `wabaUserTemplateId` (the WA template builder offers "Buat Link Singkat" on URL buttons). Campaign reports (`GET /api/reports/campaigns` items and `GET /api/reports/campaigns/{channel}/{local_id}`) then include `short_links` (list, each with `click_count`) and `link_clicks` (sum, `null` without links). Clicks are counted per link: campaigns sharing one link share its count.

### GET /api/short-links/{code}/open

Public. Used by the portal's `/{code}` redirect on its short-link domain: responds `{"target_url": "..."}` and adds one click, or **404** for an unknown code. `count=false` returns the URL without counting (link previews and bots).

### POST /api/membership/join

URL: `http://100.110.107.13:3030/api/membership/join`

The merchant joins the membership offer the main admin made (no request body) and pays its `price` by QRIS: the response is a pending [QRIS order](#paket-qris-orders) with `kind` `membership`, `name` `Membership CTSA`, `duration_days` 30 and the offer's limits as `items` (`recipients` `null` = unlimited). If a pending membership order exists, that one is returned again. Completing the order starts the 30-day period with the quota unused and sets `client_type` to `member`; `main_balance` is not used. After the period ends the merchant can join the same offer again.

Errors: **403** for every role except merchant, **404** `Belum ada penawaran membership` without an offer, **409** `Membership masih aktif` while a period runs.

### /api/management/packages/accounts/{user_id}

Paket bundles (`packages` and `package_items` tables), main admin only (everyone else receives 403). A paket has a `name`, a `price` (whole rupiah), `duration_days` (1-3650 days valid after purchase, or `null` for never) and `quotas`: the recipients it gives for each service it includes, e.g. `{"sms_lba": 1000, "sms_targeted": 1000}`. An account may have several pakets. `user_id` `default` holds the defaults offered to every merchant; a merchant id holds that merchant's own pakets, which it is offered instead of the defaults once it has any (other roles get **422**, unknown ids **404**).

- `GET` returns `{"user_id", "source", "items": [...], "defaults": [...]}`: `items` are the account's own pakets (the defaults for `default`), `defaults` the default pakets, and `source` what the merchant is offered (`own`, `default` or `none`). A paket is `{id, name, price, duration_days, quotas, items: [{service, label, recipients}], source}`.
- `PUT` body `{"packages": [{"id"?, "name"?, "price", "duration_days", "quotas"}]}` replaces the account's paket list: a paket with the `id` of one of the account's pakets changes it, one without `id` is added, and the account's pakets left out are removed (purchases keep what was bought). An empty `name` becomes `Paket <services>`. Each quota is >= 1 and a paket needs at least one. An empty list gives a merchant the defaults again. Responds like GET; **422** for invalid values or an `id` that is not the account's.
- `DELETE` removes the merchant's own pakets (it gets the defaults again) and responds like GET; **422** for `default`.
- `GET /api/management/users/{user_id}/package-purchases` lists a merchant's purchases (`{"items": [...]}`, shape as in [GET /api/packages](#get-apipackages)).

Purchases already made are never changed by these routes.

### GET /api/packages

The merchant's pakets and its purchases (403 for other roles): `{"pakets": [...], "active": {"<service>": quota}, "orders": [...], "purchases": [...]}`. A paket (shape as in Kelola Paket) also has `active` (the running purchase of this paket or `null`), `order` (its pending QRIS order or `null`) and `blocked` (why it cannot be bought now, e.g. `Kuota SMS LBA dari Paket Hemat masih aktif (sisa 900 penerima)`, or `null`). `active` maps each service with a running quota to `{purchase_id, package_id, name, service, recipients, used, remaining, expires_at}`; a service has at most one. `orders` are the pending orders. A purchase is `{id, package_id, name, price, purchased_at, expires_at, items: [{service, label, recipients, used, remaining, active}], recipients, used, remaining, expired, active}` (copied when bought, times in UTC). [GET /api/auth/me](#get-apiauthme) also returns `active` as `packages` (`null` for other roles).

How campaigns use it: an active membership whose quota covers the whole campaign pays first; otherwise the active paket quota of the service. With `QUOTA_ONLY=true` (the default) there is no balance payment: the paket must cover the whole campaign too, else the campaign is refused with **409** `Kuota <service> tidak cukup: iklan ini untuk N penerima (sisa kuota paket M penerima). Berlangganan paket untuk menambah kuota.` and nothing is used. With `QUOTA_ONLY=false` the paket pays for as many recipients as it has left and the rest is charged to `main_balance` at the normal price (a split payment). A paket counts recipients, not SMS parts. A campaign DigitalCore rejects gets its paket recipients (and any balance) back. The campaign report's `billing` shows `paid_with` `package` (the paket paid everything) or `main_balance` with `package_name` and `package_recipients` set on a split.

### POST /api/packages/{package_id}/buy

The merchant orders one of its pakets (the `id` from GET /api/packages; no body) and pays it by QRIS: the response is a pending order (see below). If a pending order for the paket exists, that one is returned again. `main_balance` is not charged.

Errors: **403** for every role except merchant, **404** `Paket tidak ditemukan` for a paket the merchant is not offered, **409** `Kuota ... masih aktif (sisa N penerima)` while one of the paket's services still has an active quota (one at a time per service).

### Paket QRIS orders

`package_orders` table: the QRIS orders of pakets (`kind` `paket`) and of membership offers (`kind` `membership`, see [POST /api/membership/join](#post-apimembershipjoin)). An order is `{id, kind, package_id, name, price, duration_days, items: [{service, label, recipients}], recipients, status, qris_content, created_at, expires_at, paid_at, cancelled_at, purchase_id}`; `recipients` is the total of the items (`null` when a membership limit is unlimited) and `status` is `pending`, `paid`, `cancelled` or `expired` (a pending order expires 15 minutes after it was made). The name, price, days and quotas are copied when the order is made. [GET /api/packages](#get-apipackages) returns the pending orders as `orders` and on each paket as `order`.

**The QRIS is a DUMMY for now**: `qris_content` is `DUMMY-QRIS/CTSA/<order id>/<price>`, which no bank app can pay, and `complete` / `cancel` stand in for the payment provider's callback. Only the order's merchant and the main admin can use these routes (others get **404**).

- `GET /api/packages/orders/{order_id}`: Cek Status.
- `POST /api/packages/orders/{order_id}/complete`: marks it `paid` and creates the purchase (the paket becomes active; `purchase_id` is set), or for a membership order starts the membership. Repeating it returns the paid order. **409** `Pesanan sudah dibatalkan` / `Pesanan sudah kedaluwarsa`, `Kuota ... masih aktif` when a service of the paket got an active quota meanwhile, or `Membership masih aktif`.
- `POST /api/packages/orders/{order_id}/cancel`: marks a pending order `cancelled` (nothing is bought). Repeating it, or cancelling an expired order, returns it unchanged; **409** `Pesanan sudah dibayar` for a paid order.

### POST /api/balance/transfers

URL: `http://100.110.107.13:3030/api/balance/transfers`

POST is restricted to admins/resellers; merchants cannot initiate transfers. Resellers can send only to merchants with the same nonempty partner_id. The sender comes from authentication. The same idempotency key and details replay the original transfer; changed details return 409. GET returns the caller's incoming/outgoing transfers; admins see all. History is ordered by created_at descending, then id. Money fields are decimal strings. No total count is included in history.

Request content type: `application/json`. Full field definitions: [TransferRequest](#transferrequest).

Example request:
```json
{
  "recipient_id": "recipient-example-id",
  "amount": "25.50",
  "idempotency_key": "transfer-example-001"
}
```

Success: HTTP **200**, `application/json`. Example:

```json
{
  "id": 1,
  "transfer_id": "00000000-0000-4000-8000-000000000001",
  "sender_id": "sender-example-id",
  "receiver_id": "recipient-example-id",
  "transferred_balance": "25.50",
  "idempotency_key": "transfer-example-001",
  "sender_balance_before": "100.00",
  "sender_balance_after": "74.50",
  "receiver_balance_before": "100.00",
  "receiver_balance_after": "125.50",
  "transaction_type": "transfer",
  "created_at": "2026-10-17T10:00:00",
  "updated_at": "2026-10-17T10:00:00"
}
```

Errors: see [error responses](#error-responses).

### GET /api/balance/transfers

URL: `http://100.110.107.13:3030/api/balance/transfers`

POST is restricted to admins/resellers; merchants cannot initiate transfers. Resellers can send only to merchants with the same nonempty partner_id. The sender comes from authentication. The same idempotency key and details replay the original transfer; changed details return 409. GET returns the caller's incoming/outgoing transfers; admins see all. History is ordered by created_at descending, then id. Money fields are decimal strings. No total count is included in history.

Request body: none.

| Query parameter | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `limit` | integer | No | min: `1`; max: `500`; default: `50` |
| `offset` | integer | No | min: `0`; default: `0` |

Success: HTTP **200**, `application/json`. Example:

```json
{
  "items": [
    {
      "id": 1,
      "transfer_id": "00000000-0000-4000-8000-000000000001",
      "sender_id": "sender-example-id",
      "receiver_id": "recipient-example-id",
      "transferred_balance": "25.50",
      "idempotency_key": "transfer-example-001",
      "sender_balance_before": "100.00",
      "sender_balance_after": "74.50",
      "receiver_balance_before": "100.00",
      "receiver_balance_after": "125.50",
      "transaction_type": "transfer",
      "created_at": "2026-10-17T10:00:00",
      "updated_at": "2026-10-17T10:00:00"
    }
  ],
  "limit": 50,
  "offset": 0
}
```

Errors: see [error responses](#error-responses).

### GET /health

URL: `http://100.110.107.13:3030/health`

Public liveness endpoint. Does not contact DigitalCore; a successful response does not prove that the database or upstream provider is healthy.

Request body: none.

Success: HTTP **200**, `application/json`. Example:

```json
{
  "status": "ok"
}
```

Errors: see [error responses](#error-responses).

### POST /api/{sms,mms}/{broadcast,targeted,lba}/add_main

URLs: `http://100.110.107.13:3030/api/sms/broadcast/add_main`, `/api/sms/targeted/add_main`, `/api/sms/lba/add_main`, `/api/mms/broadcast/add_main`, `/api/mms/targeted/add_main`, `/api/mms/lba/add_main`

The same as the matching `/add` route (same body, validation, local record, charge, refund and DigitalCore path `campaign/{kind}/add`), except the gateway sends `useBonusBalance: "0"` to DigitalCore instead of `"1"`, so DigitalCore does not use the bonus balance. A `useBonusBalance` in the request body is ignored. WABA has no `add_main` route (404).

### POST /api/sms/broadcast/add

URL: `http://100.110.107.13:3030/api/sms/broadcast/add`

Creates a SMS broadcast campaign for the authenticated user. See [campaign validation](#campaign-validation) for additional rules beyond the field tables.

Request content type: `application/json`. Full field definitions: [Broadcast](#broadcast).

Example request (replace placeholder files, sender names, template IDs, recipients, and dates):

```json
{
  "campaignName": "Test",
  "deliveries": [
    {
      "deliveryDate": "20261101",
      "deliveryTime": "0800"
    }
  ],
  "senderName": "MyAds",
  "message": "Test message",
  "msisdnFile": "encrypted-path",
  "msisdnFileName": "numbers.csv"
}
```

Response: upstream HTTP status and JSON from DigitalCore `campaign/broadcast/add`, returned unchanged. All upstream calls use POST.

Illustrative success shape consumed by this implementation (not a live response):
```json
{
  "code": 0,
  "data": {
    "campaignId": 2171
  }
}
```

Other provider fields are preserved. The response carries `X-Local-Campaign-Id: <local UUID>` after the local record is created. A successful created state requires HTTP 2xx, `code: 0`, and a non-null `data.campaignId`.

Errors: see [error responses](#error-responses).

### POST /api/sms/targeted/add

URL: `http://100.110.107.13:3030/api/sms/targeted/add`

Creates a SMS targeted campaign for the authenticated user. See [campaign validation](#campaign-validation) for additional rules beyond the field tables.

Request content type: `application/json`. Full field definitions: [Targeted](#targeted).

Example request (replace placeholder files, sender names, template IDs, recipients, and dates):

```json
{
  "campaignName": "Test",
  "deliveries": [
    {
      "deliveryDate": "20261101",
      "deliveryTime": "0800"
    }
  ],
  "senderName": "MyAds",
  "message": "Test message",
  "recepientTotal": 10
}
```

Response: upstream HTTP status and JSON from DigitalCore `campaign/targeted/add`, returned unchanged. All upstream calls use POST.

Illustrative success shape consumed by this implementation (not a live response):
```json
{
  "code": 0,
  "data": {
    "campaignId": 2171
  }
}
```

Other provider fields are preserved. The response carries `X-Local-Campaign-Id: <local UUID>` after the local record is created. A successful created state requires HTTP 2xx, `code: 0`, and a non-null `data.campaignId`.

Errors: see [error responses](#error-responses).

### POST /api/sms/lba/add

URL: `http://100.110.107.13:3030/api/sms/lba/add`

Creates a SMS lba campaign for the authenticated user. See [campaign validation](#campaign-validation) for additional rules beyond the field tables.

Request content type: `application/json`. Full field definitions: [Lba](#lba).

Example request (replace placeholder files, sender names, template IDs, recipients, and dates):

```json
{
  "campaignName": "Test",
  "deliveries": [
    {
      "deliveryStartDate": "20261101",
      "deliveryStartTime": "0800",
      "deliveryEndDate": "20261102",
      "deliveryEndTime": "0900"
    }
  ],
  "senderName": "MyAds",
  "message": "Test message",
  "recepientTotal": 10,
  "contents": {
    "locations": {
      "address": "Jakarta",
      "latitude": -6.2,
      "longitude": 106.8,
      "locationNameMap": "Jakarta",
      "locationNameUser": "Office",
      "radius": 500,
      "locationType": "ALL"
    },
    "contentName": "Test",
    "message": "Hello"
  },
  "controlNumbers": [
    "628123456789"
  ]
}
```

Response: upstream HTTP status and JSON from DigitalCore `campaign/lba/add`, returned unchanged. All upstream calls use POST.

Illustrative success shape consumed by this implementation (not a live response):
```json
{
  "code": 0,
  "data": {
    "campaignId": 2171
  }
}
```

Other provider fields are preserved. The response carries `X-Local-Campaign-Id: <local UUID>` after the local record is created. A successful created state requires HTTP 2xx, `code: 0`, and a non-null `data.campaignId`.

Errors: see [error responses](#error-responses).

### POST /api/mms/broadcast/add

URL: `http://100.110.107.13:3030/api/mms/broadcast/add`

Creates a MMS broadcast campaign for the authenticated user. See [campaign validation](#campaign-validation) for additional rules beyond the field tables.

Request content type: `application/json`. Full field definitions: [Broadcast](#broadcast).

Example request (replace placeholder files, sender names, template IDs, recipients, and dates):

```json
{
  "campaignName": "Test",
  "deliveries": [
    {
      "deliveryDate": "20261101",
      "deliveryTime": "0800"
    }
  ],
  "senderName": "MyAds",
  "message": "Test message",
  "msisdnFile": "encrypted-path",
  "msisdnFileName": "numbers.csv",
  "mmsFile": "encrypted-media",
  "mmsSubject": "Subject"
}
```

Response: upstream HTTP status and JSON from DigitalCore `campaign/broadcast/add`, returned unchanged. All upstream calls use POST.

Illustrative success shape consumed by this implementation (not a live response):
```json
{
  "code": 0,
  "data": {
    "campaignId": 2171
  }
}
```

Other provider fields are preserved. The response carries `X-Local-Campaign-Id: <local UUID>` after the local record is created. A successful created state requires HTTP 2xx, `code: 0`, and a non-null `data.campaignId`.

Errors: see [error responses](#error-responses).

### POST /api/mms/targeted/add

URL: `http://100.110.107.13:3030/api/mms/targeted/add`

Creates a MMS targeted campaign for the authenticated user. See [campaign validation](#campaign-validation) for additional rules beyond the field tables.

Request content type: `application/json`. Full field definitions: [Targeted](#targeted).

Example request (replace placeholder files, sender names, template IDs, recipients, and dates):

```json
{
  "campaignName": "Test",
  "deliveries": [
    {
      "deliveryDate": "20261101",
      "deliveryTime": "0800"
    }
  ],
  "senderName": "MyAds",
  "message": "Test message",
  "recepientTotal": 10,
  "mmsFile": "encrypted-media",
  "mmsSubject": "Subject"
}
```

Response: upstream HTTP status and JSON from DigitalCore `campaign/targeted/add`, returned unchanged. All upstream calls use POST.

Illustrative success shape consumed by this implementation (not a live response):
```json
{
  "code": 0,
  "data": {
    "campaignId": 2171
  }
}
```

Other provider fields are preserved. The response carries `X-Local-Campaign-Id: <local UUID>` after the local record is created. A successful created state requires HTTP 2xx, `code: 0`, and a non-null `data.campaignId`.

Errors: see [error responses](#error-responses).

### POST /api/mms/lba/add

URL: `http://100.110.107.13:3030/api/mms/lba/add`

Creates a MMS lba campaign for the authenticated user. See [campaign validation](#campaign-validation) for additional rules beyond the field tables.

Request content type: `application/json`. Full field definitions: [Lba](#lba).

Example request (replace placeholder files, sender names, template IDs, recipients, and dates):

```json
{
  "campaignName": "Test",
  "deliveries": [
    {
      "deliveryStartDate": "20261101",
      "deliveryStartTime": "0800",
      "deliveryEndDate": "20261102",
      "deliveryEndTime": "0900"
    }
  ],
  "senderName": "MyAds",
  "message": "Test message",
  "recepientTotal": 10,
  "contents": {
    "locations": {
      "address": "Jakarta",
      "latitude": -6.2,
      "longitude": 106.8,
      "locationNameMap": "Jakarta",
      "locationNameUser": "Office",
      "radius": 500,
      "locationType": "ALL"
    },
    "contentName": "Test",
    "message": "Hello",
    "mmsFile": "encrypted-media",
    "mmsSubject": "Subject"
  },
  "controlNumbers": [
    "628123456789"
  ]
}
```

Response: upstream HTTP status and JSON from DigitalCore `campaign/lba/add`, returned unchanged. All upstream calls use POST.

Illustrative success shape consumed by this implementation (not a live response):
```json
{
  "code": 0,
  "data": {
    "campaignId": 2171
  }
}
```

Other provider fields are preserved. The response carries `X-Local-Campaign-Id: <local UUID>` after the local record is created. A successful created state requires HTTP 2xx, `code: 0`, and a non-null `data.campaignId`.

Errors: see [error responses](#error-responses).

### POST /api/waba/broadcast/add

URL: `http://100.110.107.13:3030/api/waba/broadcast/add`

Creates a WABA broadcast campaign for the authenticated user. See [campaign validation](#campaign-validation) for additional rules beyond the field tables.

Request content type: `application/json`. Full field definitions: [WabaBroadcast](#wababroadcast).

Example request (replace placeholder files, sender names, template IDs, recipients, and dates):

```json
{
  "campaignName": "Test",
  "deliveries": [
    {
      "deliveryDate": "20261101",
      "deliveryTime": "0800"
    }
  ],
  "wabaUserTemplateId": 484,
  "msisdnFile": "encrypted-path",
  "msisdnFileName": "numbers.csv"
}
```

Response: upstream HTTP status and JSON from DigitalCore `campaign/waba/broadcast/add`, returned unchanged. All upstream calls use POST.

Illustrative success shape consumed by this implementation (not a live response):
```json
{
  "code": 0,
  "data": {
    "campaignId": 2171
  }
}
```

Other provider fields are preserved. The response carries `X-Local-Campaign-Id: <local UUID>` after the local record is created. A successful created state requires HTTP 2xx, `code: 0`, and a non-null `data.campaignId`.

Errors: see [error responses](#error-responses).

### POST /api/waba/targeted/add

URL: `http://100.110.107.13:3030/api/waba/targeted/add`

Creates a WABA targeted campaign for the authenticated user. See [campaign validation](#campaign-validation) for additional rules beyond the field tables.

Request content type: `application/json`. Full field definitions: [WabaTargeted](#wabatargeted).

Example request (replace placeholder files, sender names, template IDs, recipients, and dates):

```json
{
  "campaignName": "Test",
  "deliveries": [
    {
      "deliveryDate": "20261101",
      "deliveryTime": "0800"
    }
  ],
  "wabaUserTemplateId": 484,
  "recepientTotal": 10
}
```

Response: upstream HTTP status and JSON from DigitalCore `campaign/waba/targeted/add`, returned unchanged. All upstream calls use POST.

Illustrative success shape consumed by this implementation (not a live response):
```json
{
  "code": 0,
  "data": {
    "campaignId": 2171
  }
}
```

Other provider fields are preserved. The response carries `X-Local-Campaign-Id: <local UUID>` after the local record is created. A successful created state requires HTTP 2xx, `code: 0`, and a non-null `data.campaignId`.

Errors: see [error responses](#error-responses).

### POST /api/waba/lba/add

URL: `http://100.110.107.13:3030/api/waba/lba/add`

Creates a WABA lba campaign for the authenticated user. See [campaign validation](#campaign-validation) for additional rules beyond the field tables.

Request content type: `application/json`. Full field definitions: [WabaLba](#wabalba).

Example request (replace placeholder files, sender names, template IDs, recipients, and dates):

```json
{
  "campaignName": "Test",
  "deliveries": {
    "deliveryStartDate": "20261101",
    "deliveryStartTime": "0800",
    "deliveryEndDate": "20261102",
    "deliveryEndTime": "0900"
  },
  "wabaUserTemplateId": 484,
  "recepientTotal": 10,
  "contents": {
    "locations": {
      "address": "Jakarta",
      "latitude": -6.2,
      "longitude": 106.8,
      "locationNameMap": "Jakarta",
      "locationNameUser": "Office",
      "radius": 500,
      "locationType": "ALL"
    }
  },
  "controlNumbers": [
    "628123456789"
  ]
}
```

Response: upstream HTTP status and JSON from DigitalCore `campaign/waba/lba/add`, returned unchanged. All upstream calls use POST.

Illustrative success shape consumed by this implementation (not a live response):
```json
{
  "code": 0,
  "data": {
    "campaignId": 2171
  }
}
```

Other provider fields are preserved. The response carries `X-Local-Campaign-Id: <local UUID>` after the local record is created. A successful created state requires HTTP 2xx, `code: 0`, and a non-null `data.campaignId`.

Errors: see [error responses](#error-responses).

### POST /api/campaigns/list

URL: `http://100.110.107.13:3030/api/campaigns/list`

Admin only. Lists DigitalCore campaigns, not the local report. `{}` is a valid body and applies defaults. `keywordByRequestList` accepts objects without a locally defined inner schema; provider rules still apply.

Request content type: `application/json`. Full field definitions: [CampaignList](#campaignlist).

Example request:
```json
{
  "keyword": "",
  "keywordByRequestList": [],
  "pageNo": 1,
  "rowPerPage": 10,
  "sortBy": "created_date",
  "sortType": "desc"
}
```

Response: upstream HTTP status and JSON from DigitalCore `campaign/list`, returned unchanged. All upstream calls use POST.

This gateway does not define a fixed response field schema for this provider endpoint. It may return a provider envelope such as `code` and `data`, but the exact data fields, types, and error body must be read from the provider response. They are not fabricated in this reference.

Errors: see [error responses](#error-responses).

### GET /api/reports/campaigns

URL: `http://100.110.107.13:3030/api/reports/campaigns`

Local history only. Merchants see their own rows; resellers see their own and merchants with matching partner_id; admins see all. Returns total before pagination, ordered by created_at descending, local_id, then channel. campaign_id, ownership fields, total_recipient and upstream_http_status can be null. Request/response payloads are excluded.

Request body: none.

| Query parameter | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `channel` | string or null | No | allowed: `"sms"`, `"mms"`, `"waba"` |
| `environment` | string or null | No | allowed: `"preprod"`, `"prod"` |
| `submission_status` | string or null | No | allowed: `"pending"`, `"created"`, `"rejected"`, `"not_sent"`, `"unknown"` ([outcomes](#campaign-outcomes-refunds-and-resends)) |
| `campaign_type` | string or null | No | allowed: `"broadcast"`, `"targeted"`, `"lba"` |
| `limit` | integer | No | min: `1`; max: `500`; default: `50` |
| `offset` | integer | No | min: `0`; default: `0` |

Success: HTTP **200**, `application/json`. Example:

```json
{
  "total": 1,
  "limit": 50,
  "offset": 0,
  "items": [
    {
      "channel": "sms",
      "local_id": "00000000-0000-4000-8000-000000000002",
      "user_id": "user-example-id",
      "merchant_id": "example_merchant",
      "partner_id": "example_partner",
      "environment": "preprod",
      "campaign_id": "2171",
      "campaign_name": "Example campaign",
      "campaign_type": "broadcast",
      "total_recipient": null,
      "submission_status": "created",
      "upstream_http_status": 200,
      "created_at": "2026-10-17T10:00:00",
      "updated_at": "2026-10-17T10:00:01"
    }
  ]
}
```

Errors: see [error responses](#error-responses).

### GET /api/balance

URL: `http://100.110.107.13:3030/api/balance`

Returns the logged-in account's local balances as decimal strings. Does not query DigitalCore.

Request body: none.

Success: HTTP **200**, `application/json`. Example:

```json
{
  "main_balance": "100.00",
  "refund_balance": "0.00"
}
```

Errors: see [error responses](#error-responses).

### GET /api/admin/digitalcore/balance

URL: `http://100.110.107.13:3030/api/admin/digitalcore/balance`

Admin only. Returns the shared DigitalCore account balance, not the logged-in user's local balance.

Request body: none.

Response: upstream HTTP status and JSON from DigitalCore `user/get-balance`, returned unchanged. All upstream calls use POST.

This gateway does not define a fixed response field schema for this provider endpoint. It may return a provider envelope such as `code` and `data`, but the exact data fields, types, and error body must be read from the provider response. They are not fabricated in this reference.

Errors: see [error responses](#error-responses).

### POST /api/profiles/list

URL: `http://100.110.107.13:3030/api/profiles/list`

`{}` is valid and uses profile ALL. The local API accepts any string for profile; provider-supported values come from DigitalCore.

Request content type: `application/json`. Full field definitions: [ProfileRequest](#profilerequest).

Example request:
```json
{
  "profile": "ALL"
}
```

Response: upstream HTTP status and JSON from DigitalCore `campaign/profile-dropdown-list`, returned unchanged. All upstream calls use POST.

This gateway does not define a fixed response field schema for this provider endpoint. It may return a provider envelope such as `code` and `data`, but the exact data fields, types, and error body must be read from the provider response. They are not fabricated in this reference.

Errors: see [error responses](#error-responses).

### GET /package_price

URL: `http://100.110.107.13:3030/package_price`

Returns the current user's rows. Only if that entire list is empty, returns rows for `user_id = 1`. No per-service merging. Empty result: `{"items":[]}`. All six table columns are returned; nullable price/timestamp fields may be null. No user-ID parameter is supported.

Request body: none.

Success: HTTP **200**, `application/json`. Example:

```json
{
  "items": [
    {
      "id": 1,
      "layanan_name": "sms_broadcast",
      "price": "305.00",
      "user_id": "1",
      "created_at": "2026-10-15T20:37:12",
      "updated_at": "2026-10-15T20:37:12"
    }
  ]
}
```

Errors: see [error responses](#error-responses).

### POST /api/pricebook

URL: `http://100.110.107.13:3030/api/pricebook`

`{}` is valid and uses campaignType ALL. Returns the shared DigitalCore pricebook, separate from the local /package_price endpoint.

Request content type: `application/json`. Full field definitions: [PriceRequest](#pricerequest).

Example request:
```json
{
  "campaignType": "ALL"
}
```

Response: upstream HTTP status and JSON from DigitalCore `campaign/price-view`, returned unchanged. All upstream calls use POST.

This gateway does not define a fixed response field schema for this provider endpoint. It may return a provider envelope such as `code` and `data`, but the exact data fields, types, and error body must be read from the provider response. They are not fabricated in this reference.

Errors: see [error responses](#error-responses).

### POST /api/waba/templates/list

URL: `http://100.110.107.13:3030/api/waba/templates/list`

`{}` is valid; templateId defaults to null. Requires a local Bearer token even though the upstream call uses signed headers without an upstream bearer token.

Request content type: `application/json`. Full field definitions: [TemplateRequest](#templaterequest).

Example request:
```json
{
  "templateId": 484
}
```

Response: upstream HTTP status and JSON from DigitalCore `waba/template/list`, returned unchanged. All upstream calls use POST.

This gateway does not define a fixed response field schema for this provider endpoint. It may return a provider envelope such as `code` and `data`, but the exact data fields, types, and error body must be read from the provider response. They are not fabricated in this reference.

Errors: see [error responses](#error-responses).

### GET /api/waba/display-names

URL: `http://100.110.107.13:3030/api/waba/display-names`

Returns shared DigitalCore WABA display-name data. No body or query parameters.

Request body: none.

Response: upstream HTTP status and JSON from DigitalCore `waba/display-name/list`, returned unchanged. All upstream calls use POST.

This gateway does not define a fixed response field schema for this provider endpoint. It may return a provider envelope such as `code` and `data`, but the exact data fields, types, and error body must be read from the provider response. They are not fabricated in this reference.

Errors: see [error responses](#error-responses).

### POST /api/content/upload

URL: `http://100.110.107.13:3030/api/content/upload`

Multipart upload, not JSON. FILE allows .csv/.txt; MULTIMEDIA allows .jpg/.jpeg/.png/.mp4. File must be nonempty and strictly less than 40 MiB. CSV recipient files start with msisdn. Use provider data.pathFile as msisdnFile or mmsFile, and data.nameFile as msisdnFileName.

Request content type: `multipart/form-data`. Full field definitions: [Body_upload_api_content_upload_post](#body_upload_api_content_upload_post).

Required form fields: `file` (binary file), `type` (`FILE` or `MULTIMEDIA`).

```bash
curl -X POST "http://100.110.107.13:3030/api/content/upload" \
  -H "Authorization: Bearer <access_token>" \
  -F "type=FILE" \
  -F "file=@numbers.csv"
```

Response: upstream HTTP status and JSON from DigitalCore `content/upload`, returned unchanged. All upstream calls use POST.

This gateway does not define a fixed response field schema for this provider endpoint. It may return a provider envelope such as `code` and `data`, but the exact data fields, types, and error body must be read from the provider response. They are not fabricated in this reference.

Errors: see [error responses](#error-responses).

## Campaign validation

- SMS/MMS: `channel` can be omitted; it is inferred from the route. If supplied, it must match SMS or MMS for that route.
- All MMS routes require a nonempty `mmsFile`. For broadcast/targeted it is at the top level; for LBA it belongs inside `contents`. MMS targeted also requires nonempty `mmsSubject`.
- SMS/MMS LBA requires nonempty `contents.contentName`, `contents.message`, and `contents.locations.locationNameUser`, plus at least one `controlNumbers` item. The top-level message is also required.
- SMS/MMS broadcast/targeted and WABA broadcast/targeted use a nonempty `deliveries` array of Delivery objects. SMS/MMS LBA uses a nonempty array of Window objects. WABA LBA uses one Window object, not an array.
- Delivery dates use YYYYMMDD and times use HHMM; they must parse as valid dates/times. A window end must be later than its start. Choose a valid future schedule for the provider; local validation does not enforce a future date or convert schedule timezones.
- `contents.locations` is one Location object, not a list.
- WABA uses `wabaUserTemplateId`; top-level SMS fields such as senderName, message, channel, and useBonusBalance are not accepted.
- Profile fields in Targeted/WabaTargeted are top-level. LBA profile fields belong in contents. Both `profileLifestyleSegment` and `profileLifeStyleSegment` exist in Content and their casing is significant.
- No local campaign cost is deducted by these creation endpoints.

## Request field schemas

Required means the field must be present. Optional fields may be omitted; `or null` means explicit JSON null is also accepted by the base schema. Route-level rules above can impose stricter requirements. Defaults shown are applied by the request model, although campaign forwarding omits fields not explicitly supplied.

### Body_upload_api_content_upload_post

| Field | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `file` | string | Yes | - |
| `type` | string | Yes | allowed: `"FILE"`, `"MULTIMEDIA"` |

### Broadcast

| Field | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `campaignName` | string | Yes | min length: `1`; max length: `100` |
| `controlNumbers` | array of string or null | No | each item: pattern: `^\d{1,20}$` |
| `usePackage` | integer or null | No | allowed: `0`, `1` |
| `channel` | string or null | No | allowed: `"SMS"`, `"MMS"` |
| `senderName` | string | Yes | min length: `1`; max length: `50` |
| `message` | string | Yes | min length: `1` |
| `useBonusBalance` | integer, string or null | No | allowed: `0`, `1`, `"0"`, `"1"`; ignored, the gateway sends `"1"` to DigitalCore (`"0"` on the [`add_main`](#post-apismsmmsbroadcasttargetedlbaadd_main) routes) |
| `msisdnFile` | string | Yes | min length: `1` |
| `msisdnFileName` | string | Yes | min length: `1` |
| `mmsFile` | string or null | No | - |
| `mmsSubject` | string or null | No | - |
| `deliveries` | array of [Delivery](#delivery) | Yes | min items: `1` |

### CampaignList

| Field | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `campaignId` | integer or null | No | - |
| `keyword` | string | No | default: `""` |
| `keywordByRequestList` | array of object | No | - |
| `pageNo` | integer | No | min: `1.0`; default: `1` |
| `rowPerPage` | integer | No | min: `1.0`; default: `10` |
| `offset` | integer or null | No | min: `0.0` |
| `sortBy` | string | No | default: `"created_date"` |
| `sortType` | string | No | allowed: `"asc"`, `"desc"`; default: `"desc"` |

### Content

| Field | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `profileGender` | string or null | No | - |
| `profileAge` | string or null | No | - |
| `profileMobileDataSubs` | string or null | No | allowed: `"A"`, `"Y"`, `"N"`, `""` |
| `profileArpu` | string or null | No | - |
| `profileOs` | string or null | No | - |
| `profileMaritalStatus` | string or null | No | - |
| `profileLifestyleSegment` | string or null | No | - |
| `profileReligion` | string or null | No | - |
| `profileCardType` | string or null | No | - |
| `profileHometown` | string or null | No | - |
| `profileWork` | string or null | No | - |
| `locations` | [Location](#location) | Yes | - |
| `contentName` | string or null | No | max length: `50` |
| `message` | string or null | No | max length: `255` |
| `mmsFile` | string or null | No | - |
| `mmsSubject` | string or null | No | max length: `100` |
| `recepientMax` | integer or null | No | max: `999999.0`; greater than: `0.0` |
| `profileArpuMin` | integer or null | No | min: `0.0` |
| `profileArpuMax` | integer or null | No | min: `0.0` |
| `profileLifeStyleSegment` | string or null | No | - |

### Delivery

| Field | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `deliveryDate` | string | Yes | pattern: `^\d{8}$` |
| `deliveryTime` | string | Yes | pattern: `^\d{4}$` |

### Lba

| Field | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `campaignName` | string | Yes | min length: `1`; max length: `100` |
| `controlNumbers` | array of string | Yes | min items: `1`; each item: pattern: `^\d{1,20}$` |
| `usePackage` | integer or null | No | allowed: `0`, `1` |
| `channel` | string or null | No | allowed: `"SMS"`, `"MMS"` |
| `senderName` | string | Yes | min length: `1`; max length: `50` |
| `message` | string | Yes | min length: `1`; max length: `255` |
| `useBonusBalance` | integer, string or null | No | allowed: `0`, `1`, `"0"`, `"1"`; ignored, the gateway sends `"1"` to DigitalCore (`"0"` on the [`add_main`](#post-apismsmmsbroadcasttargetedlbaadd_main) routes) |
| `recepientTotal` | integer | Yes | max: `999999.0`; greater than: `0.0` |
| `deliveries` | array of [Window](#window) | Yes | min items: `1` |
| `contents` | [Content](#content) | Yes | - |

### Location

| Field | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `address` | string | Yes | min length: `1`; max length: `255` |
| `latitude` | number | Yes | min: `-90.0`; max: `90.0` |
| `longitude` | number | Yes | min: `-180.0`; max: `180.0` |
| `locationNameMap` | string | Yes | min length: `1`; max length: `255` |
| `locationNameUser` | string or null | No | max length: `255` |
| `radius` | integer | Yes | max: `99999.0`; greater than: `0.0` |
| `locationType` | string | Yes | allowed: `"ALL"`, `"INDOOR"`, `"OUTDOOR"` |
| `recepientMax` | integer or null | No | max: `999999.0`; greater than: `0.0` |

### LoginRequest

| Field | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `_token` | string or null | No | - |
| `merchant_id` | string | Yes | min length: `1`; max length: `128`; pattern: `\S` |
| `password` | string | Yes | min length: `1`; max length: `1024` |

### PriceRequest

| Field | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `campaignType` | string | No | allowed: `"ALL"`, `"BROADCAST"`, `"TARGETED"`, `"LBA"`, `"WABA"`; default: `"ALL"` |

### ProfileRequest

| Field | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `profile` | string | No | default: `"ALL"` |

### Targeted

| Field | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `profileGender` | string or null | No | - |
| `profileAge` | string or null | No | - |
| `profileMobileDataSubs` | string or null | No | allowed: `"A"`, `"Y"`, `"N"`, `""` |
| `profileArpu` | string or null | No | - |
| `profileOs` | string or null | No | - |
| `profileMaritalStatus` | string or null | No | - |
| `profileLifestyleSegment` | string or null | No | - |
| `profileReligion` | string or null | No | - |
| `profileCardType` | string or null | No | - |
| `profileHometown` | string or null | No | - |
| `profileWork` | string or null | No | - |
| `campaignName` | string | Yes | min length: `1`; max length: `100` |
| `controlNumbers` | array of string or null | No | each item: pattern: `^\d{1,20}$` |
| `usePackage` | integer or null | No | allowed: `0`, `1` |
| `channel` | string or null | No | allowed: `"SMS"`, `"MMS"` |
| `senderName` | string | Yes | min length: `1`; max length: `25` |
| `message` | string | Yes | min length: `1` |
| `useBonusBalance` | integer, string or null | No | allowed: `0`, `1`, `"0"`, `"1"`; ignored, the gateway sends `"1"` to DigitalCore (`"0"` on the [`add_main`](#post-apismsmmsbroadcasttargetedlbaadd_main) routes) |
| `mmsFile` | string or null | No | - |
| `mmsSubject` | string or null | No | max length: `100` |
| `recepientTotal` | integer | Yes | max: `99999.0`; greater than: `0.0` |
| `deliveries` | array of [Delivery](#delivery) | Yes | min items: `1` |

### TemplateRequest

| Field | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `templateId` | integer or null | No | - |

### TransferRequest

| Field | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `recipient_id` | string | Yes | min length: `1`; max length: `36` |
| `amount` | number or string | Yes | greater than: `0.0` |
| `idempotency_key` | string | Yes | min length: `8`; max length: `128`; pattern: `^[A-Za-z0-9_-]+$` |

### WabaBroadcast

| Field | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `campaignName` | string | Yes | min length: `1`; max length: `255` |
| `controlNumbers` | array of string or null | No | each item: pattern: `^\d{1,20}$` |
| `usePackage` | integer or null | No | allowed: `0`, `1` |
| `wabaUserTemplateId` | integer | Yes | greater than: `0.0` |
| `msisdnFile` | string | Yes | min length: `1` |
| `msisdnFileName` | string | Yes | min length: `1`; max length: `255` |
| `deliveries` | array of [Delivery](#delivery) | Yes | min items: `1` |

### WabaLba

| Field | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `campaignName` | string | Yes | min length: `1`; max length: `255` |
| `controlNumbers` | array of string or null | No | each item: pattern: `^\d{1,20}$` |
| `usePackage` | integer or null | No | allowed: `0`, `1` |
| `wabaUserTemplateId` | integer | Yes | greater than: `0.0` |
| `recepientTotal` | integer | Yes | greater than: `0.0` |
| `deliveries` | [Window](#window) | Yes | - |
| `contents` | [Content](#content) | Yes | - |

### WabaTargeted

| Field | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `profileGender` | string or null | No | - |
| `profileAge` | string or null | No | - |
| `profileMobileDataSubs` | string or null | No | allowed: `"A"`, `"Y"`, `"N"`, `""` |
| `profileArpu` | string or null | No | - |
| `profileOs` | string or null | No | - |
| `profileMaritalStatus` | string or null | No | - |
| `profileLifestyleSegment` | string or null | No | - |
| `profileReligion` | string or null | No | - |
| `profileCardType` | string or null | No | - |
| `profileHometown` | string or null | No | - |
| `profileWork` | string or null | No | - |
| `campaignName` | string | Yes | min length: `1`; max length: `255` |
| `controlNumbers` | array of string or null | No | each item: pattern: `^\d{1,20}$` |
| `usePackage` | integer or null | No | allowed: `0`, `1` |
| `wabaUserTemplateId` | integer | Yes | greater than: `0.0` |
| `recepientTotal` | integer | Yes | greater than: `0.0` |
| `deliveries` | array of [Delivery](#delivery) | Yes | min items: `1` |

### Window

| Field | Type | Required | Constraints/default |
| --- | --- | --- | --- |
| `deliveryStartDate` | string | Yes | pattern: `^\d{8}$` |
| `deliveryStartTime` | string | Yes | pattern: `^\d{4}$` |
| `deliveryEndDate` | string | Yes | pattern: `^\d{8}$` |
| `deliveryEndTime` | string | Yes | pattern: `^\d{4}$` |

For TransferRequest, amount must be positive with at most 15 total digits and two decimal places. Send it as a decimal string (for example `"25.50"`) to avoid client floating-point rounding.

## Error responses

Local HTTP errors typically use:
```json
{
  "detail": "Invalid merchant ID or password"
}
```

Validation errors use an array; extra fields such as input or ctx may also appear:
```json
{
  "detail": [
    {
      "type": "missing",
      "loc": [
        "body",
        "merchant_id"
      ],
      "msg": "Field required"
    }
  ]
}
```

| Status | Meaning/examples |
| --- | --- |
| 401 | Missing Bearer token; invalid/expired JWT; deleted account; wrong merchant ID/password |
| 403 | Unsupported account role; admin-only endpoint; merchant transfer attempt; recipient outside reseller group |
| 404 | Unknown route or missing transfer account |
| 405 | Wrong HTTP method |
| 409 | Idempotency details conflict; insufficient funds; recipient balance overflow |
| 413 | Upload is 40 MiB or larger |
| 422 | Missing/invalid body or query fields; wrong channel; missing MMS/LBA fields; empty/unsupported upload; transfer to self |
| 500 | Unhandled server error; default response may be plain text Internal Server Error |
| 502 | DigitalCore unreachable, invalid authentication response, unexpected redirect, non-JSON response, or refused by DigitalCore's gateway (non-JSON 4xx) |
| 503 | Missing/short JWT_SECRET, missing DigitalCore credentials, database unavailable, or campaign persistence failure |
| 504 | DigitalCore timeout (campaign outcome may be unknown) or connection timeout (not sent) |

A campaign failure before the local INSERT returns 503 and no upstream request is made. If the provider responds but the final local UPDATE fails, 503 uses an object-valued detail:
```json
{
  "detail": {
    "message": "DigitalCore responded but the local result could not be saved. Do not resubmit; reconcile this pending record.",
    "local_id": "<local UUID>",
    "upstream_http_status": 200,
    "upstream_response": {
      "code": 0,
      "data": {
        "campaignId": 2171
      }
    }
  }
}
```

Once a local campaign exists, upstream HTTPException responses and persistence failures carry `X-Local-Campaign-Id`. Do not retry campaign creation from the client: a `not_sent` campaign is resent by the API itself, and after a timeout or other uncertain result the campaign may exist upstream; inspect the local record and the upstream campaign first. Provider business errors and HTTP errors otherwise keep the provider JSON rather than being wrapped in detail.

### Campaign outcomes, refunds and resends

Every campaign route records the campaign and its payment first, then calls DigitalCore once. The
outcome is stored as `submission_status` (`GET /api/reports/campaigns`):

| `submission_status` | When | Payment | Report `campaign_status` before a sync |
| --- | --- | --- | --- |
| `created` | DigitalCore answered with a `campaignId` | Kept | `WAITING` |
| `rejected` | DigitalCore refused it (4xx or a nonzero `code`), or its gateway refused it with a non-JSON 4xx such as the firewall's 432 (HTTP **502** `DigitalCore refused the request (HTTP 432, non-JSON response)`) | Refunded at once | `REJECT` |
| `not_sent` | DigitalCore certainly did not receive it: credentials missing (**503**), `auth/get-token` failed (**502**) or no connection (**502**/**504**). `detail` ends with `The campaign is saved and will be resent automatically before its delivery time; do not submit it again.` | Kept; resent by the API's `resend_campaigns` job until the first delivery time, then `rejected` and refunded | `NOT_SENT` |
| `unknown` | No usable answer after the request may have reached DigitalCore: timeout (**504**), broken connection, 5xx, or success without a `campaignId` | Kept; never resent or refunded automatically | `UNKNOWN` |
| `pending` | Still being sent, or the answer could not be saved (**503** below) | Kept | `PENDING` |

The API's `refund_campaigns` job also refunds campaigns DigitalCore rejects later in review
(`campaign_status` `REJECT` after a sync) and rejected ones whose refund failed. A refund returns
the `main_balance` payment (`transaction_type` `campaign refund`) or the membership quota, at most
once per campaign. Failed numbers of a sent campaign are not refunded.


## Documentation routes

| Method | Path | Request | Response |
| --- | --- | --- | --- |
| GET / HEAD | `/docs` | None; public | 200 HTML Swagger UI |
| GET / HEAD | `/redoc` | None; public | 200 HTML ReDoc |
| GET / HEAD | `/openapi.json` | None; public | 200 OpenAPI JSON |
| GET / HEAD | `/docs/oauth2-redirect` | Browser callback; public | 200 HTML Swagger OAuth callback helper |

These are framework documentation routes and are not listed as application operations in OpenAPI. `/` has no route and returns 404. There are no register, refresh-token, logout, or API-log-list routes in this implementation.

## Laravel usage

```php
use Illuminate\Support\Facades\Http;

$baseUrl = "http://100.110.107.13:3030";
$login = Http::acceptJson()->post($baseUrl . "/api/auth/login", [
    "_token" => "",
    "merchant_id" => $merchantId,
    "password" => $password,
]);
$login->throw();
$token = $login->json("access_token");

$prices = Http::acceptJson()->withToken($token)
    ->get($baseUrl . "/package_price");
$prices->throw();
$items = $prices->json("items");
```

For logging, SQL, configuration, and deployment behavior, see the [API and database guide](API_AND_DATABASE.md). Request logging redacts secrets only in the stored log; the actual login response still contains the access token.
