Outcomes API
Outcome Management
Create and retrieve outcome records for decision evaluation and analytics.
Create Outcome
Log a new outcome for a decision to track results and performance.
Endpoint
POST /api/outcomes/upload
Authentication
Required: JWT Bearer token
Request Body
{
"decision_id": "64a1b2c3d4e5f6789012345",
"customer_id": "customer_123",
"outcome": "success - customer purchased recommended product"
}
Request Fields
| Field | Type | Required | Description |
|---|---|---|---|
| decision_id | string | Yes | Decision identifier this outcome relates to |
| customer_id | string | Yes | Customer identifier (must match authenticated user) |
| outcome | string | Yes | Description of the outcome/result |
Response
{
"outcome_id": "64a1b2c3d4e5f6789012346"
}
Error Responses
400 Bad Request
{
"detail": "Customer ID does not match"
}
400 Bad Request
{
"detail": "Database connection failed"
}
Get Outcomes
Retrieve outcome records by various filters.
Endpoint
GET /api/outcomes/get
Authentication
Required: JWT Bearer token
Query Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| outcome_id | string | No | - | Specific outcome ID to retrieve |
| decision_id | string | No | - | Filter by decision ID |
| limit | integer | No | 100 | Maximum number of outcomes to return |
Response
[
{
"outcome_id": "64a1b2c3d4e5f6789012346",
"decision_id": "64a1b2c3d4e5f6789012345",
"customer_id": "customer_123",
"outcome": "success - customer purchased recommended product",
"created_at": "2023-07-01T14:30:00.000Z"
}
]
Response Fields
| Field | Type | Description |
|---|---|---|
| outcome_id | string | Unique outcome identifier |
| decision_id | string | Related decision identifier |
| customer_id | string | Customer who owns the outcome |
| outcome | string | Outcome description |
| created_at | string | ISO timestamp of creation |
Error Responses
404 Not Found
{
"detail": "Outcome not found"
}
500 Internal Server Error
{
"detail": "Database connection error"
}
Example Usage
Create Outcome
curl -X POST "http://localhost:5049/api/outcomes/upload" \
-H "Authorization: Bearer <jwt-token>" \
-H "Content-Type: application/json" \
-d '{
"decision_id": "64a1b2c3d4e5f6789012345",
"customer_id": "customer_123",
"outcome": "success - customer satisfied with recommendation"
}'
Get All Outcomes
curl -X GET "http://localhost:5049/api/outcomes/get" \
-H "Authorization: Bearer <jwt-token>"
Get Specific Outcome
curl -X GET "http://localhost:5049/api/outcomes/get?outcome_id=64a1b2c3d4e5f6789012346" \
-H "Authorization: Bearer <jwt-token>"
Get Outcomes by Decision
curl -X GET "http://localhost:5049/api/outcomes/get?decision_id=64a1b2c3d4e5f6789012345" \
-H "Authorization: Bearer <jwt-token>"
Data Storage
Outcomes are stored in MongoDB with the following structure:
- Collection:
outcomes - Indexing: Automatic indexing on
outcome_id,decision_id, andcustomer_id - Metadata: Each outcome includes creation timestamp and service information
Security Notes
- Outcomes can only be created for the authenticated customer's ID
- All outcome operations are logged for audit purposes
- MongoDB connection uses secure connection strings from environment variables
Outcome Categories
Common outcome patterns:
- Success: Positive results (purchase, satisfaction, goal achieved)
- Partial Success: Mixed results (some goals met)
- Failure: Negative results (no purchase, dissatisfaction)
- Neutral: No clear positive or negative outcome