Developers

Developer API

A versioned REST API to read and create projects, list .sri files, and get notified the moment a contract is signed. It requires an active paid software plan with Developer API enabled for its tier. Base, Launch and Core have token allowances, but those balances do not override the feature gate. Trial-Core does not grant API access. Mint a key from your dashboard's Account → Developer API tab — this page is the endpoint reference.

Authentication

Every request carries your key as a bearer token. Keys are scoped to your own account — you'll only ever see or modify your own projects.

curl https://sriwatt.io/api/v1/projects \
  -H "Authorization: Bearer swpk_..."

A missing or invalid key returns 401 with { "error": "unauthorized" }.

Rate limits

Reads have a 60 requests/minute ceiling and writes (POST/PATCH) a 20 requests/minute ceiling, in endpoint-specific buckets keyed by network address. Reduced limits may apply when the shared limiter is unavailable. A refusal returns 429 with { "error": "rate_limit_exceeded" }. Metered endpoints also require a sufficient token balance; see the token reference.

Versioning

Everything lives under /api/v1/. A breaking response-shape change ships as a sibling /api/v2/ rather than mutating this contract — no field is ever removed or repurposed under an existing integration.

Projects

GET/api/v1/projects

Lists customer records, newest first. Each record’s id identifies the customer; projectId identifies the exact site/project.

Query params: limit (default 50, max 200), cursor (an ISO createdAt to page before), and optional projectId to select the exact project.

{
  "ok": true,
  "projects": [
    {
      "id": "customer-id", "projectId": "project-id",
      "firstName": "...", "lastName": "...", "email": "...",
      "projectType": "on-grid", "projectSizeKw": 250,
      "contractStatus": "pending", "quoteStatus": "not_generated",
      "location": "...", "createdAt": "...", "updatedAt": "..."
    }
  ],
  "nextCursor": "2026-07-01T00:00:00.000Z"
}
GET/api/v1/projects/:id

Fetches an owned customer record, including phone and exact project facts. Use ?projectId=… when the customer has multiple projects; an ambiguous selection returns inputAuthority: "review-required" and empty project facts. A missing or unowned customer returns 404.

The response includes expectedProject, the reviewed project capture needed for a subsequent provisional-input edit. Governing design facts come from the saved design.

POST/api/v1/projects

Creates a new software-only project and attempts the customer invitation. Check invited in the response; a failed invitation does not undo the project, and can be resent from the dashboard.

For safe retries, send a UUID in Idempotency-Key and reuse that key with the identical JSON body. A recovered creation returns the original project without repeating the creation or its project-credit debit.

Scoped down from the dashboard's New Project wizard: one project per new customer email (an existing email returns 409 — add a second site from the dashboard instead), and software-only (a subscriptionTier other than "software" returns 422 — device-based projects need inventory assignment the dashboard still owns).

curl -X POST https://sriwatt.io/api/v1/projects \
  -H "Authorization: Bearer swpk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "firstName": "Asha", "lastName": "Rao", "email": "asha@example.com",
    "projectType": "on-grid", "projectSizeKw": 25,
    "lat": 23.03, "lon": 72.58
  }'

# 201
{ "ok": true, "invited": true, "project": { "id": "...", ... } }

Required: firstName, a valid email (no + aliases), projectType (on-grid / off-grid / hybrid), a positive projectSizeKw. Optional: lastName, phone, location, lat/lon, entityType (individual/company), businessType (when entityType is company).

PATCH/api/v1/projects/:id

Updates an owned customer’s phone, or the exact project’s provisional inputs. A phone-only edit can use:

{
  "phone": "+91..."
}

To change projectType, projectSizeKw or quoteStatus, also send the exact projectId and the complete, unchanged expectedProject from the GET response you reviewed. A concurrent change or governing design returns 409; review the design in the dashboard. Location, latitude and longitude edits are refused here and must use the dashboard’s reviewed project-site flow.

Deliberately not writable here: email (it's the customer's login identity — changing it would orphan their invite) and contractStatus (marking a contract "signed" without a real signature would fabricate one — that stays a dashboard/customer action). 404 if the id doesn't exist or isn't yours.

.sri files

GET/api/v1/sri-files

Lists your empirical module-performance files (summary metadata — status, module identity, measurement period).

Query params: limit (default 50, max 200).

{
  "ok": true,
  "sriFiles": [
    {
      "id": "...", "module_brand": "...", "module_model": "...",
      "module_power_class_w": 580, "status": "validated",
      "period_start": "...", "period_end": "...",
      "generation_date": "...", "created_at": "..."
    }
  ]
}

Webhooks

Register a URL from the dashboard's Developer API tab to receive a signed POST the moment one of these fires: project.created, contract.signed, quote.generated, sri_file.generated. Leave the event list empty on a subscription to receive all of them.

POST <your URL>
Content-Type: application/json
X-SriWatt-Event: project.created
X-SriWatt-Signature: sha256=<hmac-sha256 of the raw body, hex>

{"type":"project.created","createdAt":"...","data":{"projectId":"...","email":"...","projectType":"on-grid","projectSizeKw":25}}

Verify the signature with your subscription's secret (shown once at creation, and always visible in the dashboard afterward — unlike an API key, this secret authenticates calls from SriWatt, so it stays retrievable). Delivery is best-effort with an 8-second timeout and no retry queue in this first version.

Errors

Inspect the HTTP status and JSON error or message. A typical validation response is:

{ "error": "invalid_request", "message": "projectSizeKw must be a positive number." }

Common codes: unauthorized (401), invalid_request (400), conflict (409), not_found (404), rate_limit_exceeded (429), internal_error (500), requires_core (403, paid access or capability missing), entitlement_unavailable (503), and insufficient_tokens (402).

Manage keys and webhook subscriptions from your dashboard's Account → Developer API tab.