Docs / API Reference
🏠 Home

API Reference

Every REST endpoint the CargoPRO backend serves at /api β€” the same API the customer and driver apps are built on.

Overview

ConventionValue
Base URLhttps://your-domain.com/api (paths below are relative to it)
AuthenticationLaravel Sanctum personal access tokens, sent as Authorization: Bearer <token>
Content typeapplication/json (also send Accept: application/json)
Response envelope{ "success": bool, "message": string, "data": ... }
Validation errorsHTTP 422 with { "success": false, "message": ..., "errors": {...} }
UnauthenticatedHTTP 401 with { "message": "Unauthenticated." }
PaginationList endpoints accept page / per_page (the apps request 20 per page, max 100)
MethodEndpointPurpose
GET/healthHealth check (status, timestamp, version)
GET/versionAPI, Laravel and PHP version info
GET/avatar/{filename}Serve a user avatar image (public)
Where the apps point The customer app sets ApiConstants.baseUrl in cargoproapp/lib/constants/api_constants.dart; the driver app sets ApiConfig.baseUrl in cargoprodriver/lib/core/api_config.dart (overridable with --dart-define=CARGOPRO_API_BASE=...). Both must end in /api.

Authentication flow

Protected routes sit behind the auth:sanctum middleware. POST /auth/login issues a Sanctum personal access token (token_type: "Bearer"); the login, register and password endpoints are rate-limited by the throttle:login middleware. When a token is missing, expired or revoked the API returns 401 Unauthenticated. β€” the apps then clear the stored token and return to the login screen.

sequenceDiagram
    autonumber
    participant A as Mobile app
    participant S as CargoPRO API
    A->>S: POST /api/auth/login (username or email + password)
    S-->>A: 200 success, data.token (Bearer)
    A->>S: GET /api/packages/customer with Authorization Bearer token
    S-->>A: 200 success with data rows
    Note over A,S: Token expired, revoked or missing
    A->>S: GET /api/notifications with Authorization Bearer token
    S-->>A: 401 Unauthenticated.
    A->>A: Discard stored token and show login screen
      

Example requests

# 1) Login - username OR email, plus password (min 6 chars)
curl -X POST https://your-domain.com/api/auth/login \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{"username": "demo@devtrixx.com", "password": "secret123"}'

# Response (trimmed)
{
  "success": true,
  "message": "Login successful",
  "data": {
    "token": "1|9abcdefghijKLMNopqrsTUVwxyZ",
    "token_type": "Bearer"
  }
}

# 2) Any authenticated call - send the token as a Bearer header
curl https://your-domain.com/api/packages/customer \
  -H "Accept: application/json" \
  -H "Authorization: Bearer 1|9abcdefghijKLMNopqrsTUVwxyZ"

{
  "success": true,
  "message": "Packages retrieved successfully",
  "data": [ ... ]
}
401 vs 403 401 means the token is bad or missing (re-login). 403 means the account is fine but inactive, or the role lacks the permission: / role: middleware the route demands β€” check the account in the admin panel.

Authentication & profile

MethodEndpointPurpose
POST/auth/loginLogin with username or email; returns the Sanctum Bearer token (throttled)
POST/auth/registerRegister an account (driver accounts are created inactive for approval)
POST/auth/forgot-passwordRequest a password reset link
POST/auth/reset-passwordReset the password with the emailed token
POST/auth/verify-emailVerify the email address
MethodEndpointPurpose
POST/auth/logoutRevoke the current token
GET/auth/userCurrent account with roles and permission names
GET/auth/profileCurrent profile (driver app also gets delivery statistics)
PUT/auth/profileUpdate the profile (name, phone, etc.)
POST/auth/profile/avatarUpload or replace the avatar (multipart)
DELETE/auth/accountDelete the signed-in account (requires password)
POST/auth/refreshRefresh the current token
POST/auth/change-passwordChange the account password
POST/auth/resend-verificationResend the email verification message
GET/auth/permissionsFlat list of the account's permission names
GET/auth/rolesRoles of the signed-in account
MethodEndpointPurpose
GET/users/profileProfile of the signed-in customer
PUT/users/profileUpdate the customer profile
POST/users/profile/avatarUpdate the profile picture (multipart)
GET/users/profile/addressesList saved addresses
POST/users/profile/addressesCreate an address
PUT/users/profile/addresses/{id}Update an address
DELETE/users/profile/addresses/{id}Delete an address
GET/users/profile/order-historyPast orders of the signed-in customer
GET/users/profile/countriesCountries for address forms
GET/users/profile/countries/{id}/statesStates of a country
GET/users/profile/states/{id}/citiesCities of a state

Packages

MethodEndpointPurpose
GET/packages/customerList the signed-in customer's packages
POST/packages/customerCreate a package for the signed-in customer
GET/packages/customer/{id}Package detail
GET/packages/customer/{id}/lifecyclePackage lifecycle / status history
GET/packages/customer/{id}/invoiceFetch the package invoice
POST/packages/customer/{id}/invoiceUpload a customer invoice for the package
POST/packages/customer/{id}/self-pickupBook warehouse self-pickup for the package
GET/packages/customer/warehousesWarehouse options for the package form
GET/packages/customer/statusesPackage status options
GET/packages/customer/sendersSearch sender customers (staff)
GET/packages/customer/sender-addressesSaved sender addresses for the form
POST/packages/customer/{id}/assign-warehouseAssign the package to a warehouse (staff)
POST/packages/customer/bulk-actionBulk status action (staff)
POST/packages/customer/bulk-warehouseBulk warehouse move (staff)
POST/packages/customer/{id}/payment-verifyVerify package payment (staff, permission-gated)
PUT/packages/customer/{id}Update a package (staff)
DELETE/packages/customer/{id}Delete a package (staff)
MethodEndpointPurpose
GET/packages/lockerList the customer's virtual-locker packages
POST/packages/lockerCreate a locker package
GET/packages/locker/{id}Locker package detail
PUT/packages/locker/{id}Update a locker package
DELETE/packages/locker/{id}Delete a locker package
GET/packages/locker/warehousesWarehouse options for locker packages
POST/packages/locker/{id}/assign-warehouseAssign a locker package to a warehouse (staff)
MethodEndpointPurpose
GET/packages/track/{tracking_number}Public tracking lookup (no auth; also used by the driver app for unknown labels)
POST/packages/upload-invoiceUpload a package invoice file
GET/packages/statusesPackage status catalogue (pending, processing, in transit, ...)

Shipments

MethodEndpointPurpose
GET/shipmentsList shipments β€” customers and drivers only see their own rows; drivers also get stats
POST/shipmentsCreate a shipment (permission courier.create)
GET/shipments/{id}Shipment detail: line items, charges, tracking, sender and recipient
PUT/shipments/{id}Update a shipment (staff)
DELETE/shipments/{id}Delete a shipment (staff)
POST/shipments/{id}/completeMark a shipment completed (staff)
POST/shipments/{id}/cancelCancel a shipment (staff)
GET/shipments/{id}/invoiceFetch the shipment invoice
POST/shipments/{id}/invoiceUpload a customer invoice for the shipment
POST/shipments/{id}/self-pickupBook warehouse self-pickup for the shipment
GET/shipments/{id}/labelFetch the shipping label
POST/shipments/{id}/deliverClose a delivery with proof β€” signature, photos, collected amount (driver app)
POST/shipments/{id}/exceptionReport a failed delivery attempt with reason and photos (driver app)
POST/shipments/{id}/assign-driverAssign a driver (staff)
POST/shipments/{id}/update-statusUpdate the shipment status (staff)
MethodEndpointPurpose
GET/tracking/typesTracking event types
GET/tracking/{id}/historyTracking events for an order (used by both apps)
POST/tracking/{id}/updateAdd a tracking update (staff)
GET/courier/recipientsSearch recipients for shipment creation
POST/courier/recipientsCreate a recipient
GET/courier/recipient-addressesSaved recipient addresses
POST/courier/recipient-addressesCreate a recipient address

Pickups

MethodEndpointPurpose
GET/pickupsList pickup jobs β€” drivers only see their own
POST/pickupsSchedule a pickup
GET/pickups/{id}Pickup detail
PUT/pickups/{id}Update a pickup
DELETE/pickups/{id}Cancel / delete a pickup
GET/pickups/driversDriver options for the pickup form (staff)
POST/pickups/{id}/assign-driverAssign a driver to the pickup (staff)
Driver tip Pickups are closed out through POST /shipments/{id}/deliver β€” the same endpoint as shipments; the backend checks the pickups.deliver permission when the row is a pickup.

Pre-alerts

MethodEndpointPurpose
GET/pre-alertsList pre-alerts
POST/pre-alertsCreate a pre-alert
GET/pre-alerts/recentMost recent pre-alerts
GET/pre-alerts/couriersCourier options for the pre-alert form
GET/pre-alerts/{id}Pre-alert detail
PUT/pre-alerts/{id}Update a pre-alert
DELETE/pre-alerts/{id}Delete a pre-alert
GET/pre-alerts/{id}/invoiceFetch the pre-alert invoice file
POST/pre-alerts/{id}/invoiceUpload the pre-alert invoice (multipart)

Notifications

MethodEndpointPurpose
GET/notificationsList notifications for the signed-in account
GET/notifications/recentMost recent notifications
GET/notifications/unread-countUnread notification count (badge)
GET/notifications/statsNotification statistics
POST/notifications/{id}/readMark one notification as read
POST/notifications/mark-all-readMark every notification as read
DELETE/notifications/{id}Delete a notification
POST/notifications/device-tokenRegister this device's FCM push token (alias of POST /device-tokens)
POST/notifications/device-token/removeRemove this device's push token at sign-out (alias of DELETE /device-tokens)

Device tokens (push)

MethodEndpointPurpose
GET/device-tokensList the account's registered devices
POST/device-tokensRegister an FCM token for the signed-in account
DELETE/device-tokensDelete the account's device tokens
POST/device-tokens/syncSync a batch of device tokens
POST/device-tokens/last-usedUpdate a token's last-used timestamp
POST/device-tokens/{id}/deactivateDeactivate one device token

Transactions & invoices

MethodEndpointPurpose
GET/transactionsList transactions (staff, permission transactions.view)
GET/transactions/summaryTransaction totals summary (staff)
GET/transactions/{id}Transaction detail (staff)
POST/transactions/{id}/refundRefund a transaction (permission payments.process)
GET/invoicesList invoices β€” customers only see their own
GET/invoices/{id}Invoice detail
POST/invoices/{id}/sendEmail an invoice to the customer
GET/invoices/{id}/pdfDownload the invoice PDF

Payments

MethodEndpointPurpose
POST/payments/stripeProcess a Stripe payment (permission payments.process)
POST/payments/paypalProcess a PayPal payment
POST/payments/paystackProcess a Paystack payment
GET/payments/gateways/activeActive payment gateways for checkout
GET/payments/methodsList payment methods
GET/payments/methods/activeActive payment methods
GET/payments/methods/by-type/{type}Payment methods filtered by type
GET/payments/modesList payment modes
GET/payments/modes/activeActive payment modes
Gateway management is separate The CRUD routes under /payments/gateways (except /active) expose secret keys and are locked to staff with the tools.payment-gateways.manage permission.

Catalog & location data

MethodEndpointPurpose
GET/catalog/categoriesPackage categories
GET/catalog/delivery-timesDelivery time options
GET/catalog/packagingPackaging options
GET/catalog/incotermsIncoterm options
GET/catalog/stylesShipment status catalogue (id, label, colour)
GET/catalog/agenciesAgencies
GET/catalog/couriersCouriers
GET/catalog/service-optionsShipping service options
GET/catalog/payment-methodsPayment methods for checkout
GET/catalog/officesOffices
GET/catalog/statusesShipment statuses
GET/catalog/driversDriver options
Mirrored dropdown data The same dropdown lists are also served under /courier/statuses, /courier/drivers, /courier/agencies, /courier/offices, /courier/warehouses, /courier/packaging, /courier/categories, /courier/couriers, /courier/shipping-modes and /courier/delivery-times β€” the driver app uses /courier/statuses. Country / state / city cascades for address forms live under /users/profile/countries (see Authentication & profile).

Dashboard, files & driver documents

MethodEndpointPurpose
GET/dashboard/statsDashboard statistics (company revenue hidden from customers)
GET/dashboard/recent-activitiesRecent activity feed
GET/dashboard/charts/revenueRevenue chart data
GET/dashboard/charts/packagesPackage chart data
GET/dashboard/charts/shipmentsShipment chart data
POST/files/uploadUpload a generic file
GET/files/{id}File metadata
GET/files/{id}/downloadDownload a file
DELETE/files/{id}Delete a file
GET/driver/documentsThe signed-in driver's requested documents
POST/driver/documents/{docId}Upload or replace one requested document (multipart)
Staff-only groups (not shown above) routes/api.php also defines permission-gated management APIs used by the admin panel itself: /users/customers, /users/drivers, /users/management, /lockers provisioning, /consolidations, /templates, /newsletter, /reports, /analytics, /google and everything under /admin/* (settings, locations, offices, catalog, shipping lines/tariffs, backups). They follow the same envelope and auth rules.