API Reference
Complete reference for every REST endpoint exposed by the GreenMetric AI platform.
https://api.greenmetric.aiTable of Contents
Authentication
Prefix: /v1/auth
Most endpoints are public. /v1/auth/me and /v1/auth/logout require a valid access token.
/v1/auth/signup// Request body
{
"email": "user@example.com",
"password": "securePassword123",
"name": "Jane Doe"
}
// Response (200)
{
"success": true,
"data": {
"user": { "id": "usr_...", "email": "user@example.com", "name": "Jane Doe" },
"accessToken": "eyJhbGci...",
"refreshToken": "eyJhbGci..."
}
}/v1/auth/login// Request body
{
"email": "user@example.com",
"password": "securePassword123"
}
// Response (200)
{
"success": true,
"data": {
"user": { "id": "usr_...", "email": "user@example.com" },
"accessToken": "eyJhbGci...",
"refreshToken": "eyJhbGci..."
}
}/v1/auth/refresh/v1/auth/logout/v1/auth/verify-email/v1/auth/forgot-password/v1/auth/reset-password/v1/auth/meAnalysis
Prefix: /v1/analysis
All endpoints require a valid API key (x-api-key header) or access token.
/v1/analysis/text// Request body
{
"text": "Used iPhone 14 Pro Max, excellent condition, 256GB", // 10–5,000 chars
"destinationCountry": "US" // optional, ISO 3166-1 alpha-2, defaults to "US"
}
// Supported countries: US, CN, IN, JP, KR, DE, GB, FR, IT, ES,
// SE, PT, VN, BD, TW, MX, TH, ID, TR, KH
// Response (202 Accepted)
{
"success": true,
"data": {
"id": "analysis_abc123",
"status": "pending",
"type": "text",
"createdAt": "2025-01-15T10:30:00Z"
}
}/v1/analysis/url// Request body
{
"url": "https://www.amazon.com/dp/B0CHX3QBCH", // must be an Amazon URL
"destinationCountry": "DE" // optional, defaults to "US"
}
// Response (202 Accepted)
{
"success": true,
"data": {
"id": "analysis_def456",
"status": "pending",
"type": "url",
"createdAt": "2025-01-15T10:31:00Z"
}
}/v1/analysis/:id// Response (200) — when status is "completed"
{
"success": true,
"data": {
"id": "analysis_abc123",
"status": "completed",
"product": {
"name": "iPhone 14 Pro Max",
"category": "Smartphones",
"condition": "Excellent",
"materials": ["Aluminum", "Glass", "Lithium-ion"],
"originCountry": "CN"
},
"scores": {
"overallScore": 87,
"rating": "A+",
"euGreenIndexScore": 82,
"durabilityRating": 8,
"repairabilityScore": 6,
"reusabilityScore": 9
},
"environmentalImpact": {
"co2SavedKg": 68.0,
"waterSavedLiters": 11050,
"energySavedKwh": 245,
"rawMaterialsSavedKg": 0.18,
"packagingWasteAvoidedKg": 0.35
},
"purchaseRecommendation": {
"bestChoice": true,
"reasoning": "High reuse value with minimal environmental cost",
"estimatedSavings": "$580"
},
"recommendations": { ... },
"comparison": { ... },
"euGreenIndex": { ... }
}
}/v1/analysis/:id/v1/analysis// Query parameters
// page — Page number (default: 1)
// limit — Items per page (default: 20, max: 100)
// status — Filter: "pending" | "processing" | "completed" | "failed"
// sort — Sort field (default: "createdAt")
// order — "asc" | "desc" (default: "desc")
// Response (200)
{
"success": true,
"data": [ ... ],
"pagination": {
"page": 1,
"limit": 20,
"total": 142,
"totalPages": 8
}
}Organizations
Prefix: /v1/organizations
All endpoints require a valid access token. Some actions are restricted by member role.
/v1/organizations/v1/organizations/:orgId/v1/organizations/:orgId/v1/organizations/:orgId/v1/organizations/:orgId/members/v1/organizations/:orgId/members/v1/organizations/:orgId/members/:memberId/v1/organizations/:orgId/members/:memberIdAPI Keys
Prefix: /v1/organizations/:orgId/api-keys
All endpoints require a valid access token with admin or owner role.
/v1/organizations/:orgId/api-keys// Request body
{
"name": "Production Backend",
"permissions": ["analysis:write", "analysis:read"],
"restrictions": {
"allowedIps": ["203.0.113.0/24"], // optional IP allowlist
"allowedOrigins": ["https://myapp.com"] // optional CORS origins
},
"expiresIn": "90d" // optional: "30d", "90d", "365d", or null (never)
}
// Response (201) — key is shown only once
{
"success": true,
"data": {
"id": "key_...",
"name": "Production Backend",
"key": "gm_live_xxxxxxxxxxxxxxxxxxxx",
"prefix": "gm_live_",
"createdAt": "2025-01-15T10:00:00Z"
}
}/v1/organizations/:orgId/api-keys/v1/organizations/:orgId/api-keys/:keyId/v1/organizations/:orgId/api-keys/:keyId/v1/organizations/:orgId/api-keys/:keyIdWebhooks
Prefix: /v1/organizations/:orgId/webhooks
All endpoints require a valid access token with admin or owner role.
/v1/organizations/:orgId/webhooks// Request body
{
"url": "https://myapp.com/webhooks/greenmetric",
"events": [
"analysis.completed",
"analysis.failed",
"quota.warning",
"quota.exceeded"
],
"secret": "whsec_..." // optional, auto-generated if omitted
}
// Webhook payload example (analysis.completed)
{
"event": "analysis.completed",
"timestamp": "2025-01-15T10:35:00Z",
"data": {
"analysisId": "analysis_abc123",
"status": "completed",
"scores": { "overallScore": 87, "rating": "A+" }
}
}/v1/organizations/:orgId/webhooks/v1/organizations/:orgId/webhooks/:webhookId/v1/organizations/:orgId/webhooks/:webhookId/v1/organizations/:orgId/webhooks/:webhookId/v1/organizations/:orgId/webhooks/:webhookId/deliveriesBilling
Prefix: /v1/billing
All endpoints require a valid access token. Organization-scoped via the token.
/v1/billing/checkout/v1/billing/portal/v1/billing/subscription// Response (200)
{
"success": true,
"data": {
"plan": "pro",
"status": "active",
"currentPeriodEnd": "2025-02-15T00:00:00Z",
"cancelAtPeriodEnd": false,
"limits": {
"monthlyApiCalls": 50000,
"membersPerOrg": 25
}
}
}/v1/billing/invoices/v1/billing/usage// Response (200)
{
"success": true,
"data": {
"apiCallsThisPeriod": 1234,
"limit": 50000,
"periodStart": "2025-01-15T00:00:00Z",
"periodEnd": "2025-02-15T00:00:00Z"
}
}Analytics
Prefix: /v1/analytics
All endpoints require a valid access token with admin or owner role.
/v1/analytics/usage/v1/analytics/latency/v1/analytics/errors/v1/analytics/api-keysReports
Prefix: /v1/reports
All endpoints require a valid access token.
/v1/reports/personal/v1/reports/personal/summaryHealth
Prefix: /v1/health
No authentication required.
/v1/health// Response (200)
{
"status": "ok",
"timestamp": "2025-01-15T10:00:00Z",
"uptime": 86400,
"version": "0.1.0"
}