Skip to main content

API Reference

Complete reference for the Ampra REST API. All endpoints are served under https://api.ampra.solar/api/.


Base URL

EnvironmentBase URL
Productionhttps://api.ampra.solar/api
Local Developmenthttp://localhost:5001/api

Authentication

Ampra uses cookie-based session authentication. After a successful login, the server sets an HttpOnly, Secure, SameSite=Lax cookie with a 7-day sliding expiration window.

Session Lifecycle

POST /api/auth/login   →  Sets authentication cookie

(Authenticated requests carry cookie automatically)

POST /api/auth/logout → Clears authentication cookie

Endpoints marked with require a valid session cookie. Endpoints marked with may require specific roles.


Authorization Model

RoleLevelDescription
UserStandardDefault role — access to own resources
AdminElevatedUser management, system administration
OverseerSupremeFull system access, debug operations

Policies

PolicyRolesApplied To
OmniUser, Admin, OverseerData controllers (metrics, data)
Admin,OverseerAdmin, OverseerAdmin controller

Content Types

DirectionContent-Type
Request Bodyapplication/json
Response Bodyapplication/json
File Uploadmultipart/form-data
CSV Exporttext/csv
Excel Exportapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet

Error Handling

All errors follow a consistent response structure. The GlobalExceptionMiddleware maps exceptions to appropriate HTTP status codes.

Error Response Format

{
"message": "Human-readable error description"
}

Validation Error Format

{
"errors": {
"Email": ["The Email field is required."],
"Password": ["Password must be at least 8 characters."]
}
}

Status Code Reference

CodeMeaningWhen Returned
200OKSuccessful GET, PUT, POST operations
201CreatedResource creation (includes Location header)
204No ContentSuccessful DELETE operations
400Bad RequestValidation failure, invalid parameters
401UnauthorizedMissing or expired session
403ForbiddenInsufficient role permissions
404Not FoundResource does not exist or not owned
500Internal Server ErrorUnhandled server exception
503Service UnavailableExternal dependency down (weather API, ML service)

Rate Limiting & Constraints

ConstraintLimit
Email verification code resendRate-limited per account
Webhook payload size64 KB maximum
Image upload size5 MB maximum
Batch metrics request50 sources maximum
History query limit1,000 records maximum
CSV/Excel export range33 days maximum
Daily summary range400 days maximum
Aggregated data range90 days maximum
Pagination page size1–100 (clamped)

CORS Configuration

SettingValue
Allowed OriginsConfigured via CORS_ALLOWED_ORIGINS
Allowed MethodsAny
Allowed HeadersAny
CredentialsEnabled

Endpoint Index

ControllerRoute PrefixAuthEndpoints
Authentication/api/authMixed6
Administration/api/adminAdmin+4
Sun Sources/api/sunsourcesUser8
Power Groups/api/powergroupsUser5
Telemetry Data/api/sunsourcedataOmni11
Metrics/api/sunsourcemetricsOmni6
Predictions/api/predictionsUser5
ROI & Pricing/api/roiUser5
Weather/api/weatherUser2
Sharing/api/sharingMixed8
Export/api/exportUser2
Upload/api/uploadUser2
Settings/api/settingsUser2
Webhooks/api/webhookPublic1
MQTT Auth/api/internal/mqttInternal2