REST API

The InfraPrism REST API allows programmatic access to your cost data, configuration, and account management.

Base URL

https://api.infraprism.com/v1

Authentication

All API requests require an API key in the Authorization header:

curl https://api.infraprism.com/v1/me \
  -H "Authorization: Bearer ip-your-api-key"

Rate Limits

PlanRequests/minute
Free60
Growth300
Scale1000
EnterpriseCustom

Rate limit headers are included in all responses:

X-RateLimit-Limit: 300
X-RateLimit-Remaining: 299
X-RateLimit-Reset: 1704067260

Endpoints

Account

Get Current Account

GET /v1/me

Response:

{
  "id": "acc_123",
  "email": "[email protected]",
  "name": "John Doe",
  "company": "Acme Corp",
  "plan": "growth",
  "created_at": "2024-01-01T00:00:00Z"
}

Events

List Events

GET /v1/events

Query Parameters:

ParameterTypeDescription
start_datestringStart date (ISO 8601)
end_datestringEnd date (ISO 8601)
entity_typestringFilter by entity type
entity_idstringFilter by entity ID
modelstringFilter by model
limitintegerMax results (default 100, max 1000)
offsetintegerPagination offset

Response:

{
  "data": [
    {
      "id": "evt_123",
      "timestamp": "2025-01-15T10:30:00Z",
      "model": "gpt-4o",
      "provider": "openai",
      "input_tokens": 150,
      "output_tokens": 500,
      "cost_usd": 0.0065,
      "latency_ms": 1200,
      "entity_type": "customer",
      "entity_id": "acme-corp",
      "tags": {"feature": "chatbot"},
      "success": true
    }
  ],
  "pagination": {
    "total": 1523,
    "limit": 100,
    "offset": 0,
    "has_more": true
  }
}

Get Event

GET /v1/events/{event_id}

Response:

{
  "id": "evt_123",
  "timestamp": "2025-01-15T10:30:00Z",
  "model": "gpt-4o",
  ...
}

Entities

List Entities

GET /v1/entities

Query Parameters:

ParameterTypeDescription
typestringFilter by entity type
limitintegerMax results
offsetintegerPagination offset

Response:

{
  "data": [
    {
      "entity_type": "customer",
      "entity_id": "acme-corp",
      "first_seen": "2024-06-01T00:00:00Z",
      "last_seen": "2025-01-15T10:30:00Z",
      "total_cost": 523.45,
      "total_events": 15234
    }
  ]
}

Get Entity

GET /v1/entities/{entity_type}/{entity_id}

Response:

{
  "entity_type": "customer",
  "entity_id": "acme-corp",
  "first_seen": "2024-06-01T00:00:00Z",
  "last_seen": "2025-01-15T10:30:00Z",
  "total_cost": 523.45,
  "total_events": 15234,
  "cost_by_model": {
    "gpt-4o": 412.30,
    "gpt-4o-mini": 111.15
  }
}

API Keys

List API Keys

GET /v1/api-keys

Response:

{
  "data": [
    {
      "id": "key_123",
      "name": "Production",
      "prefix": "ip-abc",
      "created_at": "2024-01-01T00:00:00Z",
      "last_used_at": "2025-01-15T10:30:00Z"
    }
  ]
}

Create API Key

POST /v1/api-keys

Request:

{
  "name": "Staging Environment"
}

Response:

{
  "id": "key_456",
  "name": "Staging Environment",
  "key": "ip-full-key-shown-once",
  "prefix": "ip-xyz",
  "created_at": "2025-01-15T10:30:00Z"
}

Note: The full API key is only shown once at creation.

Delete API Key

DELETE /v1/api-keys/{key_id}

Response:

{
  "deleted": true
}

Exports

Create Export

POST /v1/exports

Request:

{
  "start_date": "2025-01-01",
  "end_date": "2025-01-31",
  "format": "csv",
  "entity_type": "customer"
}

Response:

{
  "id": "exp_123",
  "status": "processing",
  "format": "csv",
  "created_at": "2025-01-15T10:30:00Z"
}

Get Export

GET /v1/exports/{export_id}

Response:

{
  "id": "exp_123",
  "status": "completed",
  "format": "csv",
  "download_url": "https://...",
  "expires_at": "2025-01-16T10:30:00Z",
  "created_at": "2025-01-15T10:30:00Z"
}

Error Responses

All errors follow this format:

{
  "error": {
    "code": "invalid_request",
    "message": "The 'start_date' parameter is required",
    "param": "start_date"
  }
}

Error Codes

CodeHTTP StatusDescription
invalid_request400Invalid request parameters
unauthorized401Invalid or missing API key
forbidden403Insufficient permissions
not_found404Resource not found
rate_limited429Rate limit exceeded
internal_error500Server error

Pagination

List endpoints support pagination:

curl "https://api.infraprism.com/v1/events?limit=100&offset=100" \
  -H "Authorization: Bearer ip-..."

Response includes pagination info:

{
  "data": [...],
  "pagination": {
    "total": 5000,
    "limit": 100,
    "offset": 100,
    "has_more": true
  }
}

Webhooks

Configure webhooks to receive real-time notifications.

Create Webhook

POST /v1/webhooks

Request:

{
  "url": "https://your-app.com/webhook",
  "events": ["anomaly.detected", "limit.reached"]
}

Webhook Events

EventDescription
anomaly.detectedAnomaly detected for an entity
limit.reachedUsage limit reached
export.completedData export ready

SDKs

Official SDKs that wrap this API:

  • Python SDK
  • JavaScript SDK (coming soon)
  • Go SDK (coming soon)

Next Steps