Create a new transaction
Endpoint
Section titled “Endpoint”POST /v1/transactions
Authentication
Section titled “Authentication”Requires Bearer token authentication.
Request Body
Section titled “Request Body”{ "requestFacts": { "source": "langchain-llm", "version": "v1", "sdk": { "name": "@sapiom/sdk", "version": "1.0.0" }, "request": { "modelClass": "ChatOpenAI", "modelId": "gpt-4-turbo", "estimatedInputTokens": 1247 } }, "serviceName": "openai", "actionName": "completion", "resourceName": "gpt-4", "qualifiers": { "model": "gpt-4", "tokens": 1000 }, "paymentData": null, "metadata": null, "traceId": "123e4567-e89b-12d3-a456-426614174000", "traceExternalId": "checkout-session-abc123", "agentId": "string", "agentName": "marketing-agent-99", "costs": [ { "fiatAmount": "0.05", "fiatAssetSymbol": "USD", "isEstimate": true, "costDetails": { "provider": "anthropic", "model": "claude-3-5-sonnet-20241022", "inputTokens": 1000 } } ]}cURL Example
Section titled “cURL Example”curl -X POST "https://api.sapiom.ai/v1/transactions" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "requestFacts": { "source": "langchain-llm", "version": "v1", "sdk": { "name": "@sapiom/sdk", "version": "1.0.0" }, "request": { "modelClass": "ChatOpenAI", "modelId": "gpt-4-turbo", "estimatedInputTokens": 1247 } }, "serviceName": "openai", "actionName": "completion", "resourceName": "gpt-4", "qualifiers": { "model": "gpt-4", "tokens": 1000 }, "paymentData": null, "metadata": null, "traceId": "123e4567-e89b-12d3-a456-426614174000", "traceExternalId": "checkout-session-abc123", "agentId": "string", "agentName": "marketing-agent-99", "costs": [ { "fiatAmount": "0.05", "fiatAssetSymbol": "USD", "isEstimate": true, "costDetails": { "provider": "anthropic", "model": "claude-3-5-sonnet-20241022", "inputTokens": 1000 } } ]}'Response
Section titled “Response”{ "id": "123e4567-e89b-12d3-a456-426614174000", "tenantId": "123e4567-e89b-12d3-a456-426614174000", "serviceName": "openai", "actionName": "completion", "resourceName": "gpt-4", "serviceId": "123e4567-e89b-12d3-a456-426614174000", "status": "authorized", "requiresPayment": true, "qualifiers": { "model": "gpt-4", "tokens": 1000 }, "metadata": null, "createdAt": "2024-01-01T00:00:00.000Z", "updatedAt": "2024-01-01T00:00:00.000Z", "authorizedAt": "2024-01-01T00:00:00.000Z", "completedAt": "2024-01-01T00:00:00.000Z", "outcome": "success", "currentPaymentTransactionId": "123e4567-e89b-12d3-a456-426614174000", "payment": null, "trace": null, "agentId": "123e4567-e89b-12d3-a456-426614174000", "agent": null, "costs": [ { "id": "123e4567-e89b-12d3-a456-426614174000", "transactionId": "123e4567-e89b-12d3-a456-426614174000", "tenantId": "123e4567-e89b-12d3-a456-426614174000", "paymentTransactionId": "123e4567-e89b-12d3-a456-426614174000", "fiatAmount": "0.25", "fiatAssetId": "123e4567-e89b-12d3-a456-426614174000", "isEstimate": false, "isActive": true, "supersedesCostId": "123e4567-e89b-12d3-a456-426614174000", "supersededAt": "2024-01-15T10:30:00Z", "costDetails": { "provider": "anthropic", "model": "claude-3-5-sonnet-20241022", "inputTokens": 1000, "outputTokens": 5000 }, "createdAt": "2024-01-15T10:00:00Z", "updatedAt": "2024-01-15T10:30:00Z" } ]}Error Responses
Section titled “Error Responses”| Status | Code | Description |
|---|---|---|
| 400 | - | Invalid request data |
| 401 | - | Unauthorized - invalid or missing API key |
See API Introduction for error handling details.