Back to Strategies API Documentation

Update Purchase Endpoint

PUT .../api/v0/user/<user>/purchase/<purchase_id>/update

This endpoint updates an existing customer purchase by storing the strategy outputs.

Authentication

This endpoint requires authentication using a Bearer token:

Authorization: Bearer <your_customer_token>

Parameters

URL Parameters

Parameter Type Required Description
user String Yes User identifier
purchase_id UUID Yes Purchase identifier

Request Body Parameters

Parameter Type Required Description
status String Yes Status of the purchase. Can be "failed", "pending" or "completed".
error String Yes Error message if the purchase failed. Should contain the error message if "status": "failed".
outputs Object Yes Strategy outputs to store in the purchase.

Request Format

The request must be sent as application/json:

PUT /api/v0/user/<user>/purchase/<purchase_id>/update Authorization: Bearer <your_token> Content-Type: application/json { "status": "completed", // Can be also "failed" "error": "", // Should contain the error message if "status": "failed" "outputs": [ { "idmodel": 1, "value": { "MD": [ { "datetime": "YYYY-MM-DD HH:MM", "purchase_percentage": 1.0, "sale_percentage": 0.0 }, ... ], "MID1": [ ... ], "MID2": [ ... ], "MID3": [ ... ] } }, { "idmodel": 2, "value": { "MD": [...], "MID1": [...], ... } } ... ] }

Response Format

Success Response (200 OK)

{ "id": "00000000-0000-0000-0000-000000000000", "status": "pending", "error": "", "outputs": [ { "idmodel": 1, "value": { ... }}, { "idmodel": 2, "value": { ... }}, ... ], "updated_at": "2025-01-15T14:30:00Z", "message": "CustomerPurchase ... updated successfully" }

Error Responses

Authentication Error (401 Unauthorized)

{ "detail": "Authentication credentials were not provided." }

Not Found (404)

{ "error": "Purchase not found." }

Validation Error (400 Bad Request)

{ "error": "Missing required field \"outputs\"." }

Example Usage

curl -X PUT \ "https://{{ server_host }}/api/v0/user/example_user/purchase/00000000-0000-0000-0000-000000000000/update" \ -H "Authorization: Bearer your_token_here" \ -H "Content-Type: application/json" \ -d '{ "outputs": { "result": "ok", "detail": { "score": 0.95 } } }'