cURL Examples¶
All examples use the POST /api/v1/public/decide endpoint.
Basic Request¶
curl -X POST https://api.cloman.app/api/v1/public/decide \
-H "X-API-Key: $CLOMAN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"context": "Should we approve this refund?"
}'
With Action Type and Data¶
curl -X POST https://api.cloman.app/api/v1/public/decide \
-H "X-API-Key: $CLOMAN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"context": "Should we approve this refund request?",
"action_type": "approval",
"data": {
"amount": 49.99,
"reason": "defective product",
"customer_tier": "premium"
}
}'
Extracting Fields with jq¶
Get just the decision¶
curl -s -X POST https://api.cloman.app/api/v1/public/decide \
-H "X-API-Key: $CLOMAN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"context": "Should we approve?"}' | jq -r '.decision'
Get decision + confidence¶
curl -s -X POST https://api.cloman.app/api/v1/public/decide \
-H "X-API-Key: $CLOMAN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"context": "Should we approve?"}' | jq '{decision, confidence, confidence_level}'
Pretty-print the full response¶
curl -s -X POST https://api.cloman.app/api/v1/public/decide \
-H "X-API-Key: $CLOMAN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"context": "Should we approve?"}' | jq .
Error Handling in Shell Scripts¶
#!/bin/bash
set -e
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
https://api.cloman.app/api/v1/public/decide \
-H "X-API-Key: $CLOMAN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"context": "Should we approve?"}')
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
BODY=$(echo "$RESPONSE" | sed '$d')
if [ "$HTTP_CODE" -ne 200 ]; then
ERROR_CODE=$(echo "$BODY" | jq -r '.error.code')
ERROR_MSG=$(echo "$BODY" | jq -r '.error.message')
echo "Error [$ERROR_CODE]: $ERROR_MSG" >&2
exit 1
fi
DECISION=$(echo "$BODY" | jq -r '.decision')
echo "Decision: $DECISION"
Using Environment Variables¶
Set your API key as an environment variable:
Then reference it with $CLOMAN_API_KEY in all requests.
Self-Hosted Instance¶
Replace the base URL: