revai-api / examples /new_endpoints.openapi.json
Shaankar39's picture
Add examples/: connector docs, OpenAPI for new endpoints, Hub listing copy, Stripe test script
387d030 verified
Raw
History Blame Contribute Delete
12.2 kB
{
"openapi": "3.1.0",
"info": {
"title": "RevAI API \u2014 new connector endpoints",
"version": "1.0.0"
},
"servers": [
{
"url": "https://shaankar39-revai-api.hf.space"
}
],
"paths": {
"/v1/predict/smart": {
"post": {
"tags": [
"Prediction"
],
"summary": "Predict Smart",
"description": "Universal connector \u2014 send rows with ANY column names. We auto-map them\nto RevAI's signals (and derive durations from dates), then score. The\nresponse includes a `field_mapping` report of what was matched/missed.",
"operationId": "predict_smart_v1_predict_smart_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SmartPredictInput"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PredictionResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
},
"security": [
{
"APIKeyHeader": []
}
]
}
},
"/v1/predict/csv": {
"post": {
"tags": [
"Prediction"
],
"summary": "Predict Csv",
"description": "Upload a CSV instead of hand-building JSON. One column per signal,\none row per customer/lead \u2014 we parse it and score every row.",
"operationId": "predict_csv_v1_predict_csv_post",
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/Body_predict_csv_v1_predict_csv_post"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PredictionResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
},
"security": [
{
"APIKeyHeader": []
}
]
}
},
"/v1/connect/stripe": {
"post": {
"tags": [
"connectors"
],
"summary": "Connect Stripe",
"description": "Paste a read-only Stripe key \u2192 we pull your recent customers, derive\nbilling-based churn signals (tenure, payment delays, subscription status,\ncontract type), and score them. The key is used in-memory and never stored.",
"operationId": "connect_stripe_v1_connect_stripe_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/StripeConnectInput"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PredictionResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
},
"security": [
{
"APIKeyHeader": []
}
]
}
}
},
"components": {
"schemas": {
"Body_predict_csv_v1_predict_csv_post": {
"properties": {
"file": {
"type": "string",
"contentMediaType": "application/octet-stream",
"title": "File",
"description": "CSV export of your customers/leads"
},
"model_type": {
"type": "string",
"title": "Model Type",
"description": "'churn' or 'lead'",
"default": "churn"
},
"model_id": {
"type": "string",
"title": "Model Id",
"description": "Optional trained model ID"
}
},
"type": "object",
"required": [
"file"
],
"title": "Body_predict_csv_v1_predict_csv_post"
},
"HTTPValidationError": {
"properties": {
"detail": {
"items": {
"$ref": "#/components/schemas/ValidationError"
},
"type": "array",
"title": "Detail"
}
},
"type": "object",
"title": "HTTPValidationError"
},
"PredictionResponse": {
"properties": {
"predictions": {
"items": {
"$ref": "#/components/schemas/SinglePrediction"
},
"type": "array",
"title": "Predictions"
},
"model_used": {
"type": "string",
"title": "Model Used"
},
"usage": {
"additionalProperties": true,
"type": "object",
"title": "Usage"
},
"benchmark": {
"anyOf": [
{
"additionalProperties": true,
"type": "object"
},
{
"type": "null"
}
],
"title": "Benchmark"
},
"field_mapping": {
"anyOf": [
{
"additionalProperties": true,
"type": "object"
},
{
"type": "null"
}
],
"title": "Field Mapping"
}
},
"type": "object",
"required": [
"predictions",
"model_used",
"usage"
],
"title": "PredictionResponse"
},
"RiskFactor": {
"properties": {
"rule": {
"type": "string",
"title": "Rule"
},
"points": {
"type": "integer",
"title": "Points"
},
"detail": {
"type": "string",
"title": "Detail"
}
},
"type": "object",
"required": [
"rule",
"points",
"detail"
],
"title": "RiskFactor"
},
"SinglePrediction": {
"properties": {
"index": {
"type": "integer",
"title": "Index"
},
"score": {
"type": "number",
"title": "Score"
},
"risk_level": {
"type": "string",
"title": "Risk Level"
},
"recommended_action": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Recommended Action"
},
"risk_factors": {
"items": {
"$ref": "#/components/schemas/RiskFactor"
},
"type": "array",
"title": "Risk Factors",
"default": []
},
"scoring_mode": {
"type": "string",
"title": "Scoring Mode"
},
"customer_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Customer Id"
},
"input_fields": {
"additionalProperties": true,
"type": "object",
"title": "Input Fields",
"default": {}
}
},
"type": "object",
"required": [
"index",
"score",
"risk_level",
"scoring_mode"
],
"title": "SinglePrediction"
},
"SmartPredictInput": {
"properties": {
"data": {
"items": {
"additionalProperties": true,
"type": "object"
},
"type": "array",
"maxItems": 1000,
"minItems": 1,
"title": "Data",
"description": "Your rows with WHATEVER column names you already have"
},
"mapping": {
"anyOf": [
{
"additionalProperties": {
"type": "string"
},
"type": "object"
},
{
"type": "null"
}
],
"title": "Mapping",
"description": "Optional {canonical_signal: your_column} overrides; auto-detected otherwise"
},
"model_type": {
"type": "string",
"title": "Model Type",
"description": "'churn' or 'lead'",
"default": "churn"
},
"model_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Model Id",
"description": "Optional trained model ID"
}
},
"type": "object",
"required": [
"data"
],
"title": "SmartPredictInput"
},
"StripeConnectInput": {
"properties": {
"stripe_key": {
"type": "string",
"title": "Stripe Key",
"description": "Your restricted, read-only Stripe key (rk_live_\u2026 or sk_\u2026)"
},
"limit": {
"type": "integer",
"maximum": 100.0,
"minimum": 1.0,
"title": "Limit",
"description": "How many recent customers to score",
"default": 100
},
"model_type": {
"type": "string",
"title": "Model Type",
"description": "'churn' or 'lead'",
"default": "churn"
},
"model_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Model Id",
"description": "Optional trained model ID"
}
},
"type": "object",
"required": [
"stripe_key"
],
"title": "StripeConnectInput"
},
"ValidationError": {
"properties": {
"loc": {
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
},
"type": "array",
"title": "Location"
},
"msg": {
"type": "string",
"title": "Message"
},
"type": {
"type": "string",
"title": "Error Type"
},
"input": {
"title": "Input"
},
"ctx": {
"type": "object",
"title": "Context"
}
},
"type": "object",
"required": [
"loc",
"msg",
"type"
],
"title": "ValidationError"
}
}
}
}