All API endpoints are located under /api and share common bootstrap logic from:
api/_bootstrap.php
Common response format:
- Success:
{"success": true, "...": "..."} - Error:
{"success": false, "message": "..."}
- Loads
includes/config.phpandincludes/functions.php - Calls
ensureRewardClaimSchema()(runtime schema prep; should be migrated away) - Provides helpers:
apiJsonResponse,apiSuccessResponse,apiErrorResponseapiRequireMethodapiGetRequestedUserIdapiGetAuthenticatedUserapiResolveAuthorizedUserIdapiRequireRewardIssuer
- API calls rely on current session context (user/admin cookies).
apiGetAuthenticatedUser():- accepts admin session (
admin_id) as privileged actor - accepts logged-in user session via app auth helpers
- accepts admin session (
apiResolveAuthorizedUserId()prevents normal users from reading/updating other users' reward data.
- Query:
user_id(optional for current user) - Response: available balance + cached profile balance
- Body:
user_id,amount,source, optionalaction_type,reference_id - Access: admin/reward issuer only
- Effect: inserts
reward_ledgerentry
- Query:
user_idoptional - Returns consolidated reward dashboard payload:
- balances
- claim eligibility
- open/recent claims
- recent ledger entries
- mini task/task stats and security signals
- Query:
user_idoptional - Returns active task list for authorized user
- Body:
task_id, optionalproof, optionaluser_id - Completes task or submits for review depending on task config
- Query:
user_idoptional - Returns TaskHub mission state for authorized user
- Body:
task_key, optional payload fields (wallet_address,proof,x_handle,telegram_handle,answers_json, optionaluser_id) - Returns task result, updated state, and balance
- Body: optional
user_id - Locks available rewards and creates claim snapshot
- Query:
snapshot_id(required) - Returns snapshot details (scoped to actor unless admin)
- Most endpoint exceptions map to
422. - Special cases:
generate_claim.phpmay return409for already-prepared state.claim_status.phpmay return404when snapshot not found.- method mismatch returns
405viaapiRequireMethod.
RexLink is the wallet-linking and approval companion for CoinRex. These endpoints are the session, pairing, and approval foundation only: no private keys, seed phrases, custody, real signing, or on-chain broadcasts are implemented.
- Returns enabled RexLink networks.
- Current defaults:
polygon-amoytestnetplasma-testnetstub/testnet placeholder
- Returns enabled RexLink networks plus token catalog, logo metadata, placeholder balances, and price metadata.
- POL price is fetched server-side and cached briefly; the mobile app does not call third-party price APIs directly.
- REX testnet price is returned as
$0.00withprice_status: testnet_unpriced. - Plasma/XPL pricing is fetched from CoinGecko when available; otherwise it falls back to
unavailable. - Mobile wallet balances are read client-side from Polygon Amoy RPC for native POL and ERC-20 REX; Plasma balances remain placeholder until RPC details are finalized.
- Access: logged-in CoinRex user session.
- Body: optional
duration_minutesfrom 5 to 60. - Creates a short-lived manual/QR pairing code.
- Response includes
display_codeandqr_payload.
- Access: valid pending pairing code.
- Body:
code, optionaldevice_name. - Completes pairing and returns a one-time visible
session_token. - Server stores only
session_token_hash.
- Access: logged-in CoinRex user session or
Bearer <session_token>. - Returns active session count and recent RexLink sessions for the user.
- Access: logged-in CoinRex user session or
Bearer <session_token>. - Body: optional
session_id, optionalreason. - Revokes an active signer session owned by the user.
- Access: logged-in CoinRex user session.
- Body:
network_slug, optionalrequest_type,title,summary,amount,fee_estimate,payload,expires_minutes. - Creates a pending approval request for the paired RexLink queue.
- Access: logged-in CoinRex user session or
Bearer <session_token>. - Query: optional
status(pending,approved,rejected,expired,cancelled,all). - Lists approval requests scoped to the user.
- Access: active
Bearer <session_token>RexLink session. - Body:
request_id,decision(approvedorrejected), optionalnote. - Updates a pending approval request. This records approval state only; it does not sign or broadcast transactions.
- Uses prepared statements through shared helpers.
- Authorization checks are present for user scope and issuer scope.
- CSRF enforcement is not consistently explicit on all session-authenticated POST endpoints.