REST API for the SOFE FinOps Engine
Multi-tenant evaluation platform with catalog, history, and alerts.
Quick Start · Endpoints · Usage · Ecosystem
Wraps the SOFE Python engine in a FastAPI application, enabling HTTP-based evaluations.
pip install sofe sofe-server
sofe-server
# → http://localhost:8080
Quick Start
# Install
pip install sofe sofe-server
# Start server
sofe-server
# Evaluate your AWS account
curl -X POST http://localhost:8080/evaluate \
-H "Content-Type: application/json" \
-d '{"profile": "default"}'
Or use the Go CLI:
sofe serve # starts sofe-server in background
sofe evaluate # calls localhost:8080/evaluate
Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /health |
Health check |
| POST | /evaluate |
Evaluate AWS account against policies |
| POST | /validate |
Validate an Architecture Graph (BYaML v0.4 JSON) |
| GET | /policies |
List all loaded policies |
| GET | /collectors |
List available collectors |
| GET | /metrics |
List metrics per collector |
| POST | /connect/test |
Test STS AssumeRole connection |
| POST | /billing/query |
Cost Explorer query through the customer role |
| POST | /billing/organization |
Organization accounts and OU paths |
| POST | /billing/dimensions |
Cost Explorer dimensions/tags |
| POST | /billing/resources |
Resource-level costs (last 14 days) |
Usage
Evaluate a different AWS account (cross-account role)
Pass the role to assume and its ExternalId. The server calls sts:AssumeRole and runs
every collector with those temporary credentials, so the account behind the role is
the one that gets evaluated:
curl -X POST http://localhost:8080/evaluate \
-H "Content-Type: application/json" \
-d '{
"role_arn": "arn:aws:iam::123456789012:role/sofe-read-only",
"external_id": "your-external-id"
}'
| Field | Notes |
|---|---|
role_arn |
IAM role ARN to assume. Takes precedence over profile. |
external_id |
Required with role_arn (2-1224 chars: letters, digits, +=,.@:/-). |
The response says what was actually read: account_id, evaluated_via
(assumed_role | profile | default_credentials) and evaluated_role_arn.
| Status | Meaning |
|---|---|
400 |
Missing/invalid role_arn or external_id, or a role is required (see below). No AWS call is made. |
403 |
STS denied the assume: the role does not exist in that account or its trust policy ExternalId does not match. |
502 |
STS failed for another reason. |
501 |
The installed sofe engine is too old for role-based evaluation (upgrade sofe). |
The ExternalId is never echoed in responses or logs.
Hosted deployments: require a role
By default, a request without role_arn evaluates the account of the server's own
credentials (or profile) — the right behavior for self-hosted use. A hosted server
that evaluates other people's accounts must never do that. Set:
SOFE_REQUIRE_ROLE=true
and any /evaluate request that does not name a role is rejected with 400 before any
AWS API is called.
Billing (S116)
All /billing/* endpoints require role_arn + external_id; the server assumes
the customer's sofe-read-only role with RoleSessionName=sofe-billing and never
uses its own Cost Explorer permissions. Amounts are returned as USD decimal
strings and every result includes cost_status (ok, partial, access_denied,
not_enabled, no_data, error). The frozen contract is in
sofe-platform/docs/billing-contract-v1.schema.json.
curl -X POST http://localhost:8080/billing/query \
-H "x-sofe-internal-secret: $SOFE_INTERNAL_SECRET" \
-H "Content-Type: application/json" \
-d '{
"role_arn": "arn:aws:iam::111111111111:role/sofe-read-only",
"external_id": "external-id-from-sofe",
"from": "2026-10-01",
"to": "2026-11-01",
"granularity": "monthly",
"metric": "unblended",
"group_by": [{"Type": "DIMENSION", "Key": "SERVICE"}]
}'
List policies
curl http://localhost:8080/policies
Docker
docker run -p 8080:8080 -v ~/.aws:/root/.aws:ro \
ghcr.io/breakingthecloud/sofe-community:latest
Architecture
sofe-server (this repo)
│
│ imports
▼
sofe/ (engine — pip install sofe)
│
│ boto3
▼
Your AWS Account (read-only)
sofe-server is a thin wrapper — all policy evaluation logic lives in the sofe engine.
Requirements
- Python 3.11+
sofe>= 0.2.0 (engine)- AWS credentials (profile or role)
Development
git clone https://github.com/breakingthecloud/sofe-server.git
cd sofe-server
uv venv && source .venv/bin/activate
uv pip install -e ".[dev]" -e ../sofe/
uvicorn sofe_server.app:app --reload --port 8080
# Tests (no AWS needed: STS and the engine are faked)
pytest
Ecosystem
| Project | Description |
|---|---|
| sofe | Python engine (collectors + policies) |
| sofe-cli | Go CLI (19 commands, TUI) |
| sofe-action | GitHub Action for CI/CD |
| platform.sofe.dev | SaaS dashboard (free tier) |
| sofe.dev/docs | Documentation (26 pages) |
License
Apache 2.0 — see LICENSE.
Metadata
Release files for sofe-server 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sofe_server-0.5.0.tar.gz | 28.5 kB | Without provenance | Details for sofe_server-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sofe_server-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for sofe_server-0.5.0-py3-none-any.whl |
Total release size: 48.0 kB
Release files / sofe_server-0.5.0.tar.gz
| Download URL | sofe_server-0.5.0.tar.gz |
|---|---|
| Size | 28.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
431ec59cb9d964e41ff6650f4bc203d6779f6160fbefecfbc3b71f8075d0d943
|
|
BLAKE2b-256 checksum How to use checksums |
c35e69732bcd34934fe6adabfeb160c38b5518247692e09f54f2700302e268b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.17
|
Release files / sofe_server-0.5.0-py3-none-any.whl
| Download URL | sofe_server-0.5.0-py3-none-any.whl |
|---|---|
| Size | 19.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6570b3697252e1e5b222e2af18a01d7a9698c25c7a5999d8ae1575a1507fdb53
|
|
BLAKE2b-256 checksum How to use checksums |
c7e154e268d64e93a8dd88ddfccbe702588265508e5d6be1d19788cc0e01b635
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.17
|
Security for sofe-server 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.