Developer

API & MCP

Connect your applications and AI tools to CirStack carbon inventory data. REST and MCP share authentication, permissions and validated operations.

Release status: implementation complete for the operations documented here; deployment and authenticated staging validation are pending. Use the service URL provided by your CirStack administrator after activation. Examples use placeholders.

Get started

  1. After service activation, sign in to CirStack and open Settings → API & MCP keys.
  2. Name your key. Start with read-only access; enable Allow writes only when your integration needs edits and your account permits them.
  3. Copy the full key immediately: it is shown only once. Store it in your server environment or secret manager.
  4. Copy the REST and MCP URLs displayed with your key. Both use Authorization: Bearer cs_live_… over HTTPS.

Revoke unused or exposed keys in the same settings panel. Key permissions remain subject to your current team and organization access.

REST API

Set CIRSTACK_API_ORIGIN to the service origin (without /v1) and CIRSTACK_API_KEY to your personal key. Confirm your permissions first:

curl "$CIRSTACK_API_ORIGIN/v1/me" \
  -H "Authorization: Bearer $CIRSTACK_API_KEY"

curl "$CIRSTACK_API_ORIGIN/v1/reports?offset=0&limit=50" \
  -H "Authorization: Bearer $CIRSTACK_API_KEY"
HTTPEndpointOperation
GET/v1/meIdentity, permissions and capabilities
GET/v1/organizationsAccessible organizations
GET/v1/reports?offset=0&limit=50Paginated reports
GET/v1/reports/{reportId}Report details
GET/v1/reports/{reportId}/itemsInventory items (offset / limit)
GET/v1/reports/{reportId}/items/{itemId}Saved item data and calculations
GET/v1/reports/{reportId}/items/{itemId}/factorsTrusted factors (query / offset; C3/C4 also require year / frequency / index)
POST/v1/reportsCreate from an existing accessible report; Idempotency-Key required
POST/v1/reports/{reportId}/changes/{kind}Prepare electricity, fuel, refrigerant or inventory changes
POST/v1/reports/{reportId}/imports/{kind}/xlsxPrepare a mapped XLSX import for the same four kinds
GET/v1/changes/{changeId}Inspect preview and status
POST/v1/changes/{changeId}/applyApply a reviewed change
POST/v1/changes/{changeId}/undoUndo when later edits do not conflict

The activated service publishes its machine-readable contract at /openapi/v1.json. Consult it for complete request and response schemas.

MCP

Connect a client that supports HTTP MCP with a configured bearer token to the provided /mcp URL. Use the same key as REST. This release uses API keys; OAuth-only connectors are not supported.

URL: https://YOUR_API_HOST/mcp
Authorization: Bearer YOUR_CIRSTACK_API_KEY

Discover the tools through your client. Available operations cover identity, organizations, reports, report creation from an existing report, inventory items, factor search, change preparation, preview, apply and undo.

Example request to your assistant: “List my reports, inspect the electricity item in the selected report, and prepare an import preview. Show me the preview before applying any changes.” Supply a stable requestId for retryable preparation calls. Upload XLSX files through REST rather than embedding workbook data as base64 in MCP messages.

Review, apply and undo

Preparing a change validates inputs and returns a preview receipt valid for 24 hours. The report is updated only after apply. Keep the same Idempotency-Key (8–128 characters) when retrying the same preparation; use a new key for a different request.

curl -X POST "$CIRSTACK_API_ORIGIN/v1/reports/REPORT_ID/imports/electricity/xlsx" \
  -H "Authorization: Bearer $CIRSTACK_API_KEY" \
  -H "Idempotency-Key: electricity-import-001" \
  -F "file=@electricity.xlsx" \
  -F "moduleId=MODULE_ID" \
  -F 'mapping={"sheet":"Electricity","headerRow":1,"frequency":"annual","columns":{"annualUsage":"Annual kWh","emissionFactor":"Factor"}}'

# Replace CHANGE_ID with receipt.id after reviewing the preview.
curl -X POST "$CIRSTACK_API_ORIGIN/v1/changes/CHANGE_ID/apply" \
  -H "Authorization: Bearer $CIRSTACK_API_KEY"

Replace REPORT_ID and MODULE_ID with IDs returned by report and item discovery. Supply an XLSX sheet with the mapped headers and values matching the destination configuration. Imports use multipart file, moduleId and JSON mapping fields; fuel, refrigerant and inventory have their own schemas. Formula cells in mapped columns are rejected: export calculated values first. Check receipt and coverage counts before applying.

Each prepared item change applies atomically; a whole workbook is not one transaction. If data, factors or permissions changed, inspect the conflict and prepare a fresh preview. Undo succeeds only when later edits have not changed the affected item.

Permissions, coverage and errors

  • data.read permits authorized reads. Writes require data.write and your current account edit permissions. A key never expands team access.
  • Supported preparation covers electricity, ISO 14064 C1_1 fuel, C1_2 refrigerants, C1_3/C1_4 wastewater, C1_5 fugitive sources, C1_6 land use, C3_1 transport and C4_1/C4_2 activity factors, subject to saved item configuration. Inspect /v1/me capabilities and destination data before writing.
  • REST and MCP operations do not call CirStack AI Assist or consume its AI credits. Your external AI client may have its own charges. Paid ecoinvent lookup is excluded from automated factor search.
  • For authentication errors, check the key, expiry and revocation. For permission errors, check scopes and team access. For validation errors, correct units, periods, mappings and trusted factor IDs. For conflicts, fetch current data and prepare again. Respect rate-limit responses and retry later.
Contact the integration team