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
| Plan | Requests/minute |
|---|---|
| Free | 60 |
| Growth | 300 |
| Scale | 1000 |
| Enterprise | Custom |
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:
| Parameter | Type | Description |
|---|---|---|
start_date | string | Start date (ISO 8601) |
end_date | string | End date (ISO 8601) |
entity_type | string | Filter by entity type |
entity_id | string | Filter by entity ID |
model | string | Filter by model |
limit | integer | Max results (default 100, max 1000) |
offset | integer | Pagination 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:
| Parameter | Type | Description |
|---|---|---|
type | string | Filter by entity type |
limit | integer | Max results |
offset | integer | Pagination 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
| Code | HTTP Status | Description |
|---|---|---|
invalid_request | 400 | Invalid request parameters |
unauthorized | 401 | Invalid or missing API key |
forbidden | 403 | Insufficient permissions |
not_found | 404 | Resource not found |
rate_limited | 429 | Rate limit exceeded |
internal_error | 500 | Server 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
| Event | Description |
|---|---|
anomaly.detected | Anomaly detected for an entity |
limit.reached | Usage limit reached |
export.completed | Data export ready |
SDKs
Official SDKs that wrap this API:
- Python SDK
- JavaScript SDK (coming soon)
- Go SDK (coming soon)
Next Steps
- Analytics API - Aggregated cost queries
- Python SDK - SDK documentation
- Configuration - SDK configuration