# ShopAds API: missing endpoints and open decisions

Checked 2026-10-17 against [API_REFERENCE.md](API_REFERENCE.md); summary table
updated 2026-11-08. The website now
calls only the routes in that reference. For features without a route, the
client method fails immediately with "… belum tersedia di API ShopAds", without
sending a request. When you add a route, wire it in the matching file under
`app/Services/MyadsApi/Concerns/` (search for `unsupportedEndpoint`).

Suggested routes below are proposals that follow the reference's conventions
(Bearer auth, no wrapper, DigitalCore pass-through). Change them as needed.

## Summary

| # | Missing feature | What breaks today | Priority |
| --- | --- | --- | --- |
| 1 | Campaign detail / report | Connected to `GET /api/reports/campaigns/{channel}/{local_id}` (payload, synced status and counts, billing, short-link clicks, LBA estimate) | Done |
| 2 | Merchant campaign list with content | Delivery status and counts are now synced into the history; lists still have no message, sender, schedule or price | Medium |
| 3 | Token refresh | Users are logged out when the 60-minute JWT expires | High |
| 4 | Management: users, recipients, prices, summary | Connected (`/api/management/users`, `prices`, `summary`, `memberships`; recipients from `/api/balance/recipients`) | Done |
| 5 | LBA audience estimate | Connected: the report asks `POST /api/reports/campaigns/{channel}/{local_id}/estimate` once and then reads the stored value | Done |
| 6 | WABA template creation | Connected to `POST /api/waba/templates/add` | Done |
| 7 | Invoices and invoice email | Invoice pages/PDF fail; the invoice email choice is not sent | Medium |
| 8 | Membership status | Membership and quota come from `GET /api/auth/me`; only the old `/membership/status` call (`GET /api/membership/status`) is unsupported | Low |
| 9 | GoFood default link, event tracking | CTA link is empty; tracking is silently skipped | Low |
| 10 | RCS (all routes and uploads) | RCS pages show "belum dapat dimuat"; RCS is hidden in navigation | Low |
| 11 | DigitalCore `expiredBalance` | Dashboard no longer shows the balance expiry date | Low |
| 12 | Register | Not needed now: registration is admin-only and the form returns 403 | None |

## High priority

### 1. Campaign detail / report

Connected: detail pages look up the campaign's `local_id` and channel in
`GET /api/reports/campaigns`, then call `GET /api/reports/campaigns/{channel}/{local_id}`.
If that call fails, the page shows the history row.

The OpenAPI schema leaves the response unspecified, so the website reads it by
field name: `senderName`, `message`, `deliveries`, `controlNumbers`,
`contents.locations`, `recepientTotal`, `success`/`failed` counts, `bucketMain`,
`basePriceProduct` (camelCase or snake_case, at any depth). Confirm the response
carries the stored request payload and, if wanted, the DigitalCore
`report/view` counts (`report[].success`, `failed`, `read`, `delivered`).

### 2. Campaign list for merchants

`POST /api/campaigns/list` is admin-only, so merchant lists use the local
history. That history has no message, sender, schedule or price, and its status
is the submission status (`pending/created/rejected/unknown`), not the
DigitalCore delivery status (`WAITING`, `FINISH`, `REVISE`, …). Rows are also
limited to campaigns created through this API, so older campaigns do not appear.

- Option A: let merchants call `/api/campaigns/list`, filtered by account on the server.
- Option B: add delivery status, cost and the main payload fields to
  `/api/reports/campaigns` items.
- Decision: also needed for the management "Monitor Campaign" status filter,
  which now accepts only submission statuses.

### 3. Token refresh

Login returns a 60-minute JWT and no refresh token. When it expires, the next API
call returns 401 and the user is logged out, including in the middle of a
campaign form.

- Suggested: `POST /api/auth/refresh` with a refresh token returned by login, or
  a longer JWT lifetime.
- Decision: refresh token or longer expiry? The website's refresh handling still
  exists and can be reconnected.

### 4. Management (`/api/management/*`)

| Website screen | Former route | Proposed route |
| --- | --- | --- |
| Admin/reseller dashboard totals | `GET /api/management/summary` | `GET /api/management/summary` |
| User list / edit page | `GET /api/management/users` (search, role, partner_id, page) | same |
| Create / update user | `POST /api/management/users`, `PATCH /api/management/users/{id}` | same |
| Transfer recipients (reseller: own partner) | `GET /api/management/recipients` | same, or reuse the users list |
| Price list / update | `GET /api/management/prices`, `PATCH /api/management/prices/{id}` | same (writes the `/package_price` table) |

Transfers themselves are connected (`POST/GET /api/balance/transfers`), but the
transfer page cannot list recipients, so in practice nobody can send one.

- Transfer history items have no sender/receiver names and no total count. The
  table shows IDs and hides the total. Decision: add `sender_name`,
  `receiver_name` and `total`?

## Medium priority

### 5. LBA audience estimate (`lba-receive`)

The SMS/MMS LBA form estimates recipients from latitude, longitude and radius.
The website now always reports the estimate as unavailable. It never guesses a number.

- Suggested: `POST /api/lba/estimate` `{ latitude, longitude, radius }`, passing
  through DigitalCore with a numeric count field.

### 6. WABA template creation

Connected to `POST /api/waba/templates/add`. The form's "Kategori Template"
(`Single Banner`) is a layout choice, so `category` is sent as `MARKETING`, and
`bodyType` is `STATIC` because the form has no variables. Short-URL options on URL
buttons are not sent, because `TemplateButton` rejects unknown fields.

The API also accepts things the form doesn't offer yet. Decide whether to add them:

- `VIDEO` and `DOC` headers (the form offers none, text or image only).
- `VARIABLE` bodies (`bodyPathFile`, `bodyVariabel`, `bodyVariabelSampel`).
- `wabaButtonId`.

Two limits differ: the form allows a 550-character body (API: 1000) and a
60-character header text (API: 255).

### 7. Invoices and invoice email

- Invoice routes: `GET /api/invoices/{id}`, `GET /api/invoices/{id}/pdf`,
  `GET /api/invoices/campaign/{campaignId}`, `POST /api/invoices/generate`.
- The campaign forms still ask for an invoice email (`email_invoice`,
  `send_invoice`), but the campaign schemas reject unknown fields, so these are
  removed before sending. No invoice is sent.
- Decision: add optional invoice fields to the campaign schemas, add invoice
  routes, or remove the invoice options from the forms?

## Low priority

- **Membership status**: `GET /api/membership/status`. The dashboard falls back
  to its built-in defaults.
- **GoFood default link**: `GET /api/gw/gofood-link`, which prefilled the CTA link on LBA/targeted forms.
- **Event tracking**: `POST /api/reporting/event` `{ event_type }`. It never blocks the user.
- **RCS**: agents, campaign list, potential receivers, add/view for broadcast,
  targeted and LBA, plus template/MSISDN upload. `RcsCampaignApiTest` is skipped
  until these exist.
- **Balance expiry**: DigitalCore `expiredBalance`, formerly from `get-balance`.
  `GET /api/balance` has only local balances.

## Rule differences to decide

The API validates requests more strictly than the website forms do. The website
does not enforce these limits yet. The API's 422 message is shown to the user,
for example "Validasi API gagal: message: String should have at most 255 characters".

| Rule | API | Website today | Decision |
| --- | --- | --- | --- |
| MMS image | `mmsFile` required on every MMS route | Image is optional ("Gambar Iklan (opsional)") | Make the image required on the website, or optional in the API? |
| SMS/MMS LBA message | `message` and `contents.message` ≤ 255 | SMS 1600 (multi-part), MMS 1024 | Raise the API limit, or limit LBA forms to 255? |
| LBA content name | `contents.contentName` ≤ 50 | Auto-generated names are 30 characters; manual input allows 255 | Limit the form to 50? |
| Profile filters | `/api/profiles/list` accepts only `profile` | Forms send `province`, `kota`, `kecamatan` for cascading location lists | Add these filters to the API? (They are dropped today.) |
| Location type | `ALL`, `INDOOR`, `OUTDOOR` | Forms send `ALL`; validation updated to the API values. The RCS form still offers `HOME`/`MALL` | Confirm `INDOOR`/`OUTDOOR` are the intended values |
| Campaign-created check | HTTP 2xx, `code: 0` and non-null `data.campaignId` | Missing `campaignId` is now shown as uncertain (do not resend) | Confirm DigitalCore always returns `campaignId` on success |

## Deployment notes

- Set `MYADS_API_BASE_URL=http://100.110.107.13:3030` in `.env`.
- Existing sessions hold old API tokens. Users need to log in again after deploy.
- Cached MMS submissions from before this change keep their old `/api/gw/...`
  error text; the recovery checks still recognize it.
