Skip to main content

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

FieldTypeRequiredDescription
decision_idstringYesDecision identifier this outcome relates to
customer_idstringYesCustomer identifier (must match authenticated user)
outcomestringYesDescription 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

ParameterTypeRequiredDefaultDescription
outcome_idstringNo-Specific outcome ID to retrieve
decision_idstringNo-Filter by decision ID
limitintegerNo100Maximum 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

FieldTypeDescription
outcome_idstringUnique outcome identifier
decision_idstringRelated decision identifier
customer_idstringCustomer who owns the outcome
outcomestringOutcome description
created_atstringISO 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, and customer_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