L LAB

Admin API

The package mounts a management API under /internal/admin/v1/, behind the boilerplate admin stack when it’s present (or a Sanctum-authenticated stack on a plain Laravel app — see Configuration). No routes need to be added by hand.

Endpoints

All paths are prefixed with /internal/admin/v1.

MethodEndpointNameDescription
GET/couponsadmin.coupons.indexList coupons (type, is_active, search, per_page)
POST/couponsadmin.coupons.storeCreate a coupon
POST/coupons/bulkadmin.coupons.bulkBulk-generate codes
GET/coupons/{coupon}admin.coupons.showCoupon detail + redemptions_count
PATCH/coupons/{coupon}admin.coupons.updateUpdate name, is_active, restrictions
DELETE/coupons/{coupon}admin.coupons.destroySoft-delete (see force rule below)
PATCH/coupons/{coupon}/activateadmin.coupons.activateSet is_active = true
PATCH/coupons/{coupon}/deactivateadmin.coupons.deactivateSet is_active = false
GET/coupons/{coupon}/redemptionsadmin.coupons.redemptionsRedemptions for one coupon
GET/coupon-redemptionsadmin.coupon-redemptions.indexGlobal redemption list

Responses use the standard API envelope; paginated lists return the { data, meta, links } shape.

Create a coupon

curl -X POST https://your-app/internal/admin/v1/coupons \
  -H 'Accept: application/json' -H 'Authorization: Bearer <admin-token>' \
  -H 'Content-Type: application/json' \
  -d '{
    "code": "LAUNCH20",
    "name": "Launch promotion — 20% off",
    "type": "percent_off",
    "value": { "percent": 20 },
    "restrictions": { "max_uses": 500, "per_user": 1, "expires_at": "2026-12-31T23:59:59Z" }
  }'

code is optional — omit it to auto-generate. Returns 201 with the coupon resource.

Bulk generation

curl -X POST https://your-app/internal/admin/v1/coupons/bulk \
  -H 'Authorization: Bearer <admin-token>' -H 'Content-Type: application/json' \
  -d '{ "quantity": 50, "prefix": "LAUNCH", "type": "free_months", "value": { "months": 1 } }'

Returns 201 with an array of the created code strings (not full resources, to keep the payload small).

Immutability & deletion rules

  • type and value are immutable after creation. PATCH only accepts name, is_active and restrictions — this preserves the integrity of the redemption snapshot.
  • Deletion is soft. Deleting a coupon that has redemptions requires ?force=true; without it the endpoint returns 422. Redemption history is always preserved.

Audit events

When the host provides the boilerplate’s audit_log() helper, admin mutations are recorded:

EventTrigger
admin.coupon.createdSingle coupon created
admin.coupon.bulk_createdBulk generation completed (quantity in metadata)
admin.coupon.updatedCoupon fields updated
admin.coupon.deletedCoupon soft-deleted
admin.coupon.activated / admin.coupon.deactivatedis_active toggled

On a standalone app without the helper, these calls are silently skipped.