Back to server

API documentation

MyTree API endpoints

Use these endpoints from the mobile app, admin panel, or vendor tools. JSON endpoints return a consistent success/error envelope with a trace ID.

System

GET
/api/health

Checks API and database connectivity.

Public
GET
/api/info

Returns API name, version, environment, and base URL.

Public

Public

GET
/api/stats/home

Returns public home page planting statistics.

Public
GET
/api/map/trees

Returns planted tree locations for the map.

Public

Auth

POST
/api/auth/request-otp

Requests an OTP for phone or identifier login.

Public
POST
/api/auth/verify-otp

Verifies OTP and returns auth tokens.

Public
POST
/api/auth/refresh

Refreshes an access token.

Authenticated
POST
/api/auth/logout

Revokes the current refresh token.

Authenticated

Donations

POST
/api/donations/payments/initiate

Initiates an SSLCommerz hosted checkout for a donation.

Public
GET
/api/donations/payments/status

Returns the current status of a donation payment.

Public
GET
/api/donations/payments/callback

Public browser callback endpoint for SSLCommerz payment redirects.

Public
POST
/api/donations/payments/ipn

Public SSLCommerz IPN endpoint for server-to-server payment updates.

Public

Profile

GET
/api/me

Returns the current user profile.

Authenticated
PATCH
/api/me

Updates the current user profile.

Authenticated
GET
/api/me/role

Returns the current user role.

Authenticated

Plantings

POST
/api/plantings

Creates a planting record from a QR plant.

Authenticated
GET
/api/plantings/[id]

Returns a planting by ID.

Authenticated
GET
/api/plantings/map

Returns planting map markers with optional lat/lng/radius filter.

Public
GET
/api/plantings/my

Returns paginated list of the current user's plantings.

Authenticated

QR

GET
/api/qr/[recordId]

Returns public QR record data.

Public
GET
/api/qr/[recordId]/details

Returns detailed QR record information.

Public
GET
/api/qr/[recordId]/png

Returns QR code PNG image.

Public

Certificates

GET
/api/certificates/[id]

Returns certificate details.

Public
GET
/api/certificates/[id]/history

Returns certificate activity history.

Public
GET
/api/certificates/verify/[hash]

Verifies a certificate by public hash.

Public
GET
/api/certificates/me

Returns certificates owned by the current user.

Authenticated
POST
/api/certificates/mint

Mints a certificate for an approved planting.

Authenticated

Sync

POST
/api/sync/pull

Pulls server changes for offline sync.

Authenticated
POST
/api/sync/push

Pushes client changes for offline sync.

Authenticated
GET
/api/sync/status

Returns sync status for the current user.

Authenticated

Vendor

GET
/api/vendor/qr/my

Lists QR records created by the current vendor.

Vendor
POST
/api/vendor/qr/single

Creates a single QR record.

Vendor
POST
/api/vendor/qr/batch

Creates a batch QR record.

Vendor
DELETE
/api/vendor/qr/[recordId]

Deletes or deactivates a vendor QR record.

Vendor

Admin

GET
/api/admin/users/[userId]

Returns a user for admin review.

Admin
PATCH
/api/admin/users/[userId]/role

Updates a user role.

Admin
GET
/api/admin/verifications/flagged

Lists flagged planting verifications.

Admin
POST
/api/admin/verifications/[id]/approve

Approves a flagged planting verification.

Admin
POST
/api/admin/verifications/[id]/reject

Rejects a flagged planting verification.

Admin
POST
/api/admin/verifications/[id]/ai-review

Runs Gemini AI review for a planting and stores AI verification output.

Admin

Admin Carbon

GET
/api/admin/carbon/stats

Returns aggregate carbon statistics.

Admin
GET
/api/admin/carbon/stats/district

Returns carbon statistics by district.

Admin
GET
/api/admin/carbon/stats/time

Returns carbon statistics by time period.

Admin
GET
/api/admin/carbon/trends/monthly

Returns monthly carbon trends.

Admin
GET
/api/admin/carbon/leaderboard/districts

Returns district carbon leaderboard.

Admin