SpendGuard™ API Documentation

Operated by: Constant Control Limited

Effective Date: 26 March 2026

Reviewed: 26 March 2026  |  Next Review Due: April 2027

Contact: team@constantcontrol.co.nz

The SpendGuard API enables programmatic access to your organisation's contract spend data. API access is authenticated via service account API keys and enforces the same role-based access controls as the SpendGuard web application.

1. Authentication

All API requests require a valid API key passed as a Bearer token in the Authorization header:

curl -H "Authorization: Bearer sg_live_your_api_key_here" \
  https://www.spendguard.co.nz/api/v1/csos

Obtaining an API Key

  1. Navigate to Platform Admin → API Keys in SpendGuard
  2. Click + New Service Account
  3. Configure the name, role, scope, and expiry
  4. Copy the API key immediately — it is shown once and cannot be retrieved again

API Key Format

API keys follow the format sg_live_ followed by 64 hexadecimal characters. Example:

sg_live_a1b2c3d4e5f6...

2. Security Controls

ControlDetails
EncryptionAll requests must use HTTPS (TLS 1.2+)
Key ExpiryKeys expire after a configurable period (7, 14, 30, 60, or 90 days). Maximum 90 days.
IP AllowlistingOptional — restrict API access to specific IP addresses or CIDR ranges
Rate LimitingDefault 100 requests per minute per key. Configurable per service account.
Scoperead (GET only), read_write (all methods), or admin (all methods + admin endpoints)
RBACEach service account is assigned a role. The same row-level security policies that apply to human users apply to API requests.
Audit TrailEvery API action is logged with the service account name, IP address, endpoint, and timestamp

3. Base URL

https://www.spendguard.co.nz/api/v1

3.1 OpenAPI Specification

The full machine-readable API specification is available at:

Download OpenAPI Spec (JSON)

3.2 MCP (Model Context Protocol)

AI agents that support MCP can discover SpendGuard tools automatically:

GET /api/v1/mcp

Headers:
  Authorization: Bearer sg_live_your_key

Returns a manifest of available tools including get_csos, get_projects,
get_programmes, and get_vendors.

4. Endpoints

Health Check

GET /api/v1

Response:
{
  "name": "SpendGuard API",
  "version": "v1",
  "status": "healthy"
}

No authentication required. Use this to verify connectivity.

List CSOs

GET /api/v1/csos

Headers:
  Authorization: Bearer sg_live_your_key

Response:
{
  "data": [
    {
      "id": "uuid",
      "reference_number": "CSO-2026-0001",
      "title": "Cloud Migration Phase 1",
      "status": "active",
      "total_budget": 480000,
      "budget_spent": 99000,
      "start_date": "2026-01-01",
      "end_date": "2026-06-30",
      "created_at": "2026-03-05T03:24:05Z",
      "project_id": "uuid"
    }
  ],
  "meta": {
    "count": 1,
    "service_account": "Procurement Bot",
    "scope": "read"
  }
}

Returns all CSOs visible to the service account's role and organisation. Scope: read or higher.

5. Error Responses

StatusMeaningExample
401Invalid, expired, or missing API key{"error": "Invalid API key"}
403Insufficient scope or role for this endpoint{"error": "Insufficient scope"}
429Rate limit exceeded{"error": "Rate limit exceeded"}
500Internal server error{"error": "Failed to fetch CSOs"}

6. Rate Limits

API requests are rate-limited per service account using a sliding window of 1 minute. The default limit is 100 requests per minute. When the limit is exceeded, the API returns 429 Too Many Requests.

Enterprise organisations may request higher rate limits. Contact team@constantcontrol.co.nz.

7. Data Scoping

The API enforces the same data isolation as the web application:

  • Organisation isolation — Service accounts can only access data within their assigned organisation
  • Role-based access — A service account with the project_manager role sees only projects it manages and CSOs within those projects
  • Row-level security — Enforced at the database level, not application level

8. Upcoming Endpoints

The following endpoints are planned for future releases:

EndpointMethodDescriptionPhase
/api/v1/projectsGETList projectsPhase 2
/api/v1/programmesGETList programmesPhase 2
/api/v1/vendorsGETList vendorsPhase 2
/api/v1/transactionsGET, POSTList and record transactionsPhase 2
/api/v1/weekly-entriesGET, POSTList and submit weekly cost entriesPhase 2
/api/v1/webhooksPOSTSubscribe to outbound eventsPhase 3

9. Support

For API support, integration guidance, or to request additional endpoints:


Constant Control Limited — Licensed for business in New Zealand. Servicing a global market for our clients.