Built in Agents
List Sonzai built-in backend agents
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Response Body
application/json
application/problem+json
curl -X GET "https://loading/api/v1/builtin-agents"{
"$schema": "/api/v1/schemas/ListBuiltinAgentsResponse.json",
"agents": [
{
"description": "string",
"model": "string",
"name": "string",
"provisioned": true,
"slug": "string"
}
]
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}List lead-enrichment jobs
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Response Body
application/json
application/problem+json
curl -X GET "https://loading/api/v1/builtin-agents/lead/enrich"{
"$schema": "/api/v1/schemas/ListLeadEnrichmentJobsResponse.json",
"jobs": [
{
"attempts": 0,
"created_at": "2019-08-24T14:15:22Z",
"error": "string",
"id": "string",
"input": null,
"result": null,
"status": "string",
"updated_at": "2019-08-24T14:15:22Z"
}
]
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Enqueue an async lead-enrichment job
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Header Parameters
Stable retry key; repeated requests return the original job
length <= 255Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/lead/enrich" \ -H "Content-Type: application/json" \ -d '{ "lead": { "name": "string" } }'{
"$schema": "/api/v1/schemas/EnrichLeadResp.json",
"job_id": "string",
"status": "string"
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Get an async lead-enrichment job
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Enrichment job id
Response Body
application/json
application/problem+json
curl -X GET "https://loading/api/v1/builtin-agents/lead/enrich/string"{
"$schema": "/api/v1/schemas/EnrichJobView.json",
"error": "string",
"result": null,
"status": "string"
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Get the current lead-scoring calibration
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Response Body
application/json
application/problem+json
curl -X GET "https://loading/api/v1/builtin-agents/lead_score/calibration"{
"$schema": "/api/v1/schemas/Calibration.json",
"bands": [
{
"actual_rate": 0.1,
"avg_score": 0.1,
"band": "string",
"calibration_gap": 0.1,
"conversions": 0,
"n": 0,
"predicted_rate": 0.1
}
],
"base_rate": 0.1,
"segments": [
{
"adjust": 0,
"conversions": 0,
"n": 0,
"p_hat": 0.1,
"segment": "string"
}
],
"updated_at": "2019-08-24T14:15:22Z"
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Get the current lead-scoring model
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Response Body
application/json
application/problem+json
curl -X GET "https://loading/api/v1/builtin-agents/lead_score/model"{
"$schema": "/api/v1/schemas/ModelView.json",
"metrics": {
"accuracy": 0.1,
"auc": 0.1,
"epoch": 0,
"log_loss": 0.1
},
"n": 0,
"pending": 0,
"trained": true,
"weights": [
{
"name": "string",
"weight": 0.1
}
]
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Train the lead-scoring model (batch)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/lead_score/model/train" \ -H "Content-Type: application/json" \ -d '{}'{
"$schema": "/api/v1/schemas/TrainResult.json",
"algo": "string",
"final": {
"accuracy": 0.1,
"auc": 0.1,
"epoch": 0,
"log_loss": 0.1
},
"history": [
{
"accuracy": 0.1,
"auc": 0.1,
"epoch": 0,
"log_loss": 0.1
}
],
"n": 0,
"tuning": {
"best_cv_auc": 0.1,
"chosen": {
"gamma": 0.1,
"lambda": 0.1,
"learning_rate": 0.1,
"max_depth": 0,
"min_child_weight": 0.1,
"n_estimators": 0,
"subsample": 0.1
},
"summary": [
{
"cv_auc": 0.1,
"cv_logloss": 0.1,
"params": {
"gamma": 0.1,
"lambda": 0.1,
"learning_rate": 0.1,
"max_depth": 0,
"min_child_weight": 0.1,
"n_estimators": 0,
"subsample": 0.1
}
}
],
"trials": 0
},
"weights": [
{
"name": "string",
"weight": 0.1
}
]
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Recommend the Next-Best-Action for a lead
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/lead_score/nba" \ -H "Content-Type: application/json" \ -d '{ "features": { "property1": null, "property2": null } }'{
"$schema": "/api/v1/schemas/NBAResult.json",
"action_values": [
{
"masked": true,
"name": "string",
"q": 0.1
}
],
"recommended_action": "string",
"score_0_100": 0.1,
"value": 0.1
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Record a realized lead-scoring outcome
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/lead_score/outcome" \ -H "Content-Type: application/json" \ -d '{ "lead_ref": "string", "outcome": "string", "predicted_band": "string", "predicted_score": 0 }'{
"$schema": "/api/v1/schemas/Calibration.json",
"bands": [
{
"actual_rate": 0.1,
"avg_score": 0.1,
"band": "string",
"calibration_gap": 0.1,
"conversions": 0,
"n": 0,
"predicted_rate": 0.1
}
],
"base_rate": 0.1,
"segments": [
{
"adjust": 0,
"conversions": 0,
"n": 0,
"p_hat": 0.1,
"segment": "string"
}
],
"updated_at": "2019-08-24T14:15:22Z"
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Reset all learned lead-scoring state (demo blank-slate)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/lead_score/reset-learning"{
"$schema": "/api/v1/schemas/ResetLearningResp.json",
"reset": [
"string"
]
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Get the current Next-Best-Action RL policy
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Response Body
application/json
application/problem+json
curl -X GET "https://loading/api/v1/builtin-agents/lead_score/rl/policy"{
"$schema": "/api/v1/schemas/PolicyView.json",
"actions": [
"string"
],
"avg_return": 0.1,
"episodes": 0,
"features": [
"string"
],
"policy": [
{
"archetype": "string",
"recommended_action": "string",
"value": 0.1
}
],
"trained": true
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Train the Next-Best-Action RL policy
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/lead_score/rl/train" \ -H "Content-Type: application/json" \ -d '{}'{
"$schema": "/api/v1/schemas/RLTrainResult.json",
"algo": "string",
"episodes": 0,
"final_avg_return": 0.1,
"kl_divergence": 0.1,
"policy": [
{
"archetype": "string",
"recommended_action": "string",
"value": 0.1
}
],
"return_history": [
0.1
]
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Enable or disable closed-loop agent learning
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
true → closed loop enabled (default); false → auto-apply disabled.
Response Body
application/json
application/problem+json
curl -X PUT "https://loading/api/v1/builtin-agents/learning" \ -H "Content-Type: application/json" \ -d '{ "enabled": true }'{
"$schema": "/api/v1/schemas/SetAgentLearningEnabledResponse.json",
"enabled": true
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Record a realized outcome — improves the scoring model + the bandit in one call
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/ml/string/feedback" \ -H "Content-Type: application/json" \ -d '{}'{
"$schema": "/api/v1/schemas/FeedbackResponse.json",
"bandit_error": "string",
"bandit_n": 0,
"bandit_updated": true,
"converted": true,
"message": "string",
"ok": true,
"outcome_recorded": true,
"use_case": "string"
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Next-best-action over a per-tenant variable action set
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/ml/string/nba/decide" \ -H "Content-Type: application/json" \ -d '{ "actions": [ { "id": "string" } ] }'{
"$schema": "/api/v1/schemas/DecideResponse.json",
"action_id": "string",
"explore": true,
"model_n": 0,
"propensity": 0.1,
"scores": [
{
"action_id": "string",
"propensity": 0.1,
"score": 0.1
}
]
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Teach the bandit a realized (action, propensity, reward)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/ml/string/nba/learn" \ -H "Content-Type: application/json" \ -d '{ "action_id": "string", "reward": 0.1 }'{
"$schema": "/api/v1/schemas/LearnResponse.json",
"n": 0,
"ok": true
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Off-policy evaluation (IPS / SNIPS / doubly-robust + CI)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/ml/string/ope/evaluate" \ -H "Content-Type: application/json" \ -d '{ "logged": [ { "action_id": "string", "propensity": 0.1, "reward": 0.1 } ] }'{
"$schema": "/api/v1/schemas/OPEResponse.json",
"ci_high": 0.1,
"ci_low": 0.1,
"dr": 0.1,
"ess": 0.1,
"estimator_ci": "string",
"ips": 0.1,
"n": 0,
"snips": 0.1
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Score a record with the per-tenant model (falls back to the global prior)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/ml/string/scoring/predict" \ -H "Content-Type: application/json" \ -d '{ "features": { "property1": null, "property2": null } }'{
"$schema": "/api/v1/schemas/PredictResponse.json",
"calibration_method": "string",
"model_version": 0,
"raw": 0.1,
"score": 0.1,
"served_from": "string"
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Train the per-tenant scoring model (CatBoost + Optuna, calibrated)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/ml/string/scoring/train" \ -H "Content-Type: application/json" \ -d '{ "rows": [ { "features": { "property1": null, "property2": null }, "label": 0 } ] }'{
"$schema": "/api/v1/schemas/TrainResponse.json",
"auc": 0.1,
"best_params": {
"property1": null,
"property2": null
},
"brier": 0.1,
"brier_baseline": 0.1,
"brier_uncalibrated": 0.1,
"calibration_method": "string",
"ece": 0.1,
"importances": [
{
"gain": 0.1,
"name": "string"
}
],
"logloss": 0.1,
"model_version": 0,
"n": 0,
"trials": 0
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Single-call self-learning simulation (train → decide → learn → OPE over rounds)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/ml/string/simulate-rounds" \ -H "Content-Type: application/json" \ -d '{}'{
"$schema": "/api/v1/schemas/SimulateRoundsResponse.json",
"action_labels": {
"property1": "string",
"property2": "string"
},
"actions": [
{
"action_id": "string",
"label": "string",
"losses": 0,
"observed_win_rate": 0.1,
"selections": 0,
"simulated_expected_rate": 0.1,
"wins": 0
}
],
"model": null,
"ope": {
"ci_high": 0.1,
"ci_low": 0.1,
"dr": 0.1
},
"policy": null,
"scenario": "string",
"series": [
{
"auc": 0.1,
"best_action_share": 0.1,
"ci_high": 0.1,
"ci_low": 0.1,
"losses": 0,
"n": 0,
"nba_reward": 0.1,
"nba_value": 0.1,
"ope_dr": 0.1,
"round": 0,
"scoring_brier": 0.1,
"win_rate": 0.1,
"wins": 0
}
]
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Stream self-learning simulation rounds as they complete
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
text/event-stream
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/ml/string/simulate-rounds/stream" \ -H "Content-Type: application/json" \ -d '{}'{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Onboard a project onto a vertical
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/onboard" \ -H "Content-Type: application/json" \ -d '{ "vertical": "string" }'{
"$schema": "/api/v1/schemas/OnboardSummary.json",
"seeded_agents": [
"string"
],
"vertical_config": {
"$schema": "/api/v1/schemas/VerticalConfig.json",
"brands": [
"string"
],
"intent_signals": [
"string"
],
"label": "string",
"notes": "string",
"qualify_fields": [
"string"
],
"segment_features": [
"string"
],
"slug": "string",
"value_signals": [
"string"
]
}
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}List built-in agent chat sessions
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Query Parameters
50int64Response Body
application/json
application/problem+json
curl -X GET "https://loading/api/v1/builtin-agents/sessions"{
"$schema": "/api/v1/schemas/ListBuiltinAgentSessionsResponse.json",
"sessions": [
{
"$schema": "/api/v1/schemas/SessionBody.json",
"agent": "string",
"byok": true,
"cost_usd": 0.1,
"created_at": "2019-08-24T14:15:22Z",
"id": "string",
"model": "string",
"status": "string",
"title": "string"
}
]
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Start a chat session with a built-in agent
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/sessions" \ -H "Content-Type: application/json" \ -d '{ "agent": "string" }'{
"$schema": "/api/v1/schemas/SessionBody.json",
"agent": "string",
"byok": true,
"cost_usd": 0.1,
"created_at": "2019-08-24T14:15:22Z",
"id": "string",
"model": "string",
"status": "string",
"title": "string"
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Get a built-in agent session (status, billed usage, cost)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Response Body
application/json
application/problem+json
curl -X GET "https://loading/api/v1/builtin-agents/sessions/string"{
"$schema": "/api/v1/schemas/GetBuiltinAgentSessionResponse.json",
"billed_cache_creation_tokens": 0,
"billed_cache_read_tokens": 0,
"billed_input_tokens": 0,
"billed_output_tokens": 0
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Send a chat message to a built-in agent session
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Query Parameters
true → SSE of live agent events ending in a final result event
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/sessions/string/messages" \ -H "Content-Type: application/json" \ -d '{ "text": "string" }'{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Get the project's vertical config
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Response Body
application/json
application/problem+json
curl -X GET "https://loading/api/v1/builtin-agents/vertical"{
"$schema": "/api/v1/schemas/VerticalConfig.json",
"brands": [
"string"
],
"intent_signals": [
"string"
],
"label": "string",
"notes": "string",
"qualify_fields": [
"string"
],
"segment_features": [
"string"
],
"slug": "string",
"value_signals": [
"string"
]
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Set the project's vertical config
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X PUT "https://loading/api/v1/builtin-agents/vertical" \ -H "Content-Type: application/json" \ -d '{ "slug": "string" }'{
"$schema": "/api/v1/schemas/VerticalConfig.json",
"brands": [
"string"
],
"intent_signals": [
"string"
],
"label": "string",
"notes": "string",
"qualify_fields": [
"string"
],
"segment_features": [
"string"
],
"slug": "string",
"value_signals": [
"string"
]
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Get an agent's learned guidance
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Response Body
application/json
application/problem+json
curl -X GET "https://loading/api/v1/builtin-agents/string/guidance"{
"$schema": "/api/v1/schemas/GuidanceOutput.json",
"active": {
"$schema": "/api/v1/schemas/AgentGuidance.json",
"activated_at": "2019-08-24T14:15:22Z",
"agent_slug": "string",
"created_at": "2019-08-24T14:15:22Z",
"evidence": null,
"guidance": null,
"id": "string",
"metric_baseline": 0.1,
"metric_name": "string",
"project_id": "string",
"status": "string",
"tenant_id": "string",
"version": 0
},
"history": [
{
"$schema": "/api/v1/schemas/AgentGuidance.json",
"activated_at": "2019-08-24T14:15:22Z",
"agent_slug": "string",
"created_at": "2019-08-24T14:15:22Z",
"evidence": null,
"guidance": null,
"id": "string",
"metric_baseline": 0.1,
"metric_name": "string",
"project_id": "string",
"status": "string",
"tenant_id": "string",
"version": 0
}
]
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Roll back an agent's learned guidance
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/string/guidance/rollback"{
"$schema": "/api/v1/schemas/AgentGuidance.json",
"activated_at": "2019-08-24T14:15:22Z",
"agent_slug": "string",
"created_at": "2019-08-24T14:15:22Z",
"evidence": null,
"guidance": null,
"id": "string",
"metric_baseline": 0.1,
"metric_name": "string",
"project_id": "string",
"status": "string",
"tenant_id": "string",
"version": 0
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Run a built-in agent task
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Built-in agent slug, e.g. lead_research
Query Parameters
true → stream live agent progress as SSE; false → block and return JSON
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/string/invoke" \ -H "Content-Type: application/json" \ -d '{ "input": { "property1": null, "property2": null } }'{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Run one agent self-improvement cycle
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Built-in agent slug to improve (lead_score | lead_research | lead_qualifier | …)
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/builtin-agents/string/learn" \ -H "Content-Type: application/json" \ -d '{}'{
"$schema": "/api/v1/schemas/LearnResult.json",
"changed": true,
"guidance": {
"$schema": "/api/v1/schemas/AgentGuidance.json",
"activated_at": "2019-08-24T14:15:22Z",
"agent_slug": "string",
"created_at": "2019-08-24T14:15:22Z",
"evidence": null,
"guidance": null,
"id": "string",
"metric_baseline": 0.1,
"metric_name": "string",
"project_id": "string",
"status": "string",
"tenant_id": "string",
"version": 0
},
"reason": "string",
"violations": [
"string"
]
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Send-time & channel suggestion: next-best daypart/day-type/channel to contact (P3)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/ml/contact_timing/suggest" \ -H "Content-Type: application/json" \ -d '{ "channels": [ "string" ], "contact_id": "string" }'{
"$schema": "/api/v1/schemas/ContactTimingSuggestResponse.json",
"action_id": "string",
"channel": "string",
"propensity": 0.1,
"send_bucket": {
"day_type": "string",
"daypart": "string"
}
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Expected-value ranking: P(convert) × predicted deal value (P1)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/ml/ev" \ -H "Content-Type: application/json" \ -d '{ "features": { "property1": null, "property2": null } }'{
"$schema": "/api/v1/schemas/EvResponseBody.json",
"expected_value": 0.1,
"prob_served_from": "string",
"probability": 0.1,
"value": 0.1,
"value_served_from": "string"
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Pipeline revenue forecast: Monte Carlo over open-pipeline expected value (P4)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Query Parameters
Lookback window in days for 'open pipeline' (not yet converted, created within this window). Defaults to the tenant manifest's objective.attribution_window_days, else 90.
int64Response Body
application/json
application/problem+json
curl -X GET "https://loading/api/v1/ml/forecast"{
"$schema": "/api/v1/schemas/ForecastResponseBody.json",
"assumptions": [
"string"
],
"expected_revenue": 0.1,
"open_leads": 0,
"p10": 0.1,
"p50": 0.1,
"p90": 0.1
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Human-handoff timing: bandit over {escalate_now, wait_one_day, keep_automated} (P7)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/ml/handoff/suggest" \ -H "Content-Type: application/json" \ -d '{ "contact_id": "string", "context": { "property1": null, "property2": null } }'{
"$schema": "/api/v1/schemas/HandoffSuggestResponse.json",
"action_id": "string",
"approval_enqueued": true,
"approval_id": "string",
"gated": true,
"have": 0,
"needed": 0,
"propensity": 0.1
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Lookalike prospecting rank: non-converted leads ranked by similarity to the won-deal centroid (P6)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Query Parameters
Max leads to return. Defaults to 20.
int64Response Body
application/json
application/problem+json
curl -X GET "https://loading/api/v1/ml/lookalike/rank"{
"$schema": "/api/v1/schemas/LookalikeRankResponse.json",
"items": [
{
"lead_ref": "string",
"lookalike_score": 0.1
}
]
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Lookalike prospecting score: similarity to the project's won-deal centroid (P6)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/ml/lookalike/score" \ -H "Content-Type: application/json" \ -d '{}'{
"$schema": "/api/v1/schemas/LookalikeScoreResponse.json",
"centroid_won_profiles": 0,
"lookalike_score": 0.1,
"used_cached_dossier": true
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Offer suggestion: bandit over the tenant manifest's offer-type actions, margin-weighted (P7)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/ml/offers/suggest" \ -H "Content-Type: application/json" \ -d '{ "contact_id": "string" }'{
"$schema": "/api/v1/schemas/OfferSuggestResponse.json",
"gated": true,
"have": 0,
"needed": 0,
"suggestion": {
"action_id": "string",
"channel": "string",
"cost_hint": 0.1,
"intrusiveness": "string",
"label": "string",
"propensity": 0.1
}
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Latest computed dead-lead revival queue (P2)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Response Body
application/json
application/problem+json
curl -X GET "https://loading/api/v1/ml/revival-queue"{
"$schema": "/api/v1/schemas/RevivalQueueBody.json",
"computed_at": "string",
"items": [
{
"agent_id": "string",
"contact_id": "string",
"dormancy_days": 0.1,
"expected_value": 0.1,
"reason": "string",
"revival_score": 0.1
}
]
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Trigger an on-demand revival-queue sweep for this project (P2)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/ml/revival-queue/compute"{
"$schema": "/api/v1/schemas/RevivalQueueBody.json",
"computed_at": "string",
"items": [
{
"agent_id": "string",
"contact_id": "string",
"dormancy_days": 0.1,
"expected_value": 0.1,
"reason": "string",
"revival_score": 0.1
}
]
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Generate the Win/Loss Intelligence report (P5)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/ml/winloss/generate" \ -H "Content-Type: application/json" \ -d '{}'{
"$schema": "/api/v1/schemas/WinlossReportResponse.json",
"cached": true,
"created_at": "2019-08-24T14:15:22Z",
"evidence_stats": {
"attribution_window_days": 0,
"episodes_included": 0,
"episodes_truncated": 0,
"leads_skipped_no_identity": 0,
"lost_leads": 0,
"lost_leads_truncated": 0,
"pack_chars": 0,
"used_fallback_attribution_window": true,
"window_days": 0,
"won_leads": 0,
"won_leads_truncated": 0
},
"project_id": "string",
"report": {
"caveats": [
"string"
],
"objection_taxonomy": [
{
"cohort": "string",
"frequency_hint": "string",
"objection": "string"
}
],
"phrases_that_lost": [
{
"phrasing": "string",
"situation": "string"
}
],
"phrases_that_worked": [
{
"phrasing": "string",
"situation": "string"
}
],
"recommendations": [
{
"detail": "string",
"expected_impact": "string",
"title": "string"
}
],
"stall_points": [
"string"
]
},
"report_id": "string",
"violations": [
"string"
],
"window_end": "2019-08-24T14:15:22Z",
"window_start": "2019-08-24T14:15:22Z"
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Latest persisted Win/Loss Intelligence report (P5)
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Response Body
application/json
application/problem+json
curl -X GET "https://loading/api/v1/ml/winloss/latest"{
"$schema": "/api/v1/schemas/WinlossReportResponse.json",
"cached": true,
"created_at": "2019-08-24T14:15:22Z",
"evidence_stats": {
"attribution_window_days": 0,
"episodes_included": 0,
"episodes_truncated": 0,
"leads_skipped_no_identity": 0,
"lost_leads": 0,
"lost_leads_truncated": 0,
"pack_chars": 0,
"used_fallback_attribution_window": true,
"window_days": 0,
"won_leads": 0,
"won_leads_truncated": 0
},
"project_id": "string",
"report": {
"caveats": [
"string"
],
"objection_taxonomy": [
{
"cohort": "string",
"frequency_hint": "string",
"objection": "string"
}
],
"phrases_that_lost": [
{
"phrasing": "string",
"situation": "string"
}
],
"phrases_that_worked": [
{
"phrasing": "string",
"situation": "string"
}
],
"recommendations": [
{
"detail": "string",
"expected_impact": "string",
"title": "string"
}
],
"stall_points": [
"string"
]
},
"report_id": "string",
"violations": [
"string"
],
"window_end": "2019-08-24T14:15:22Z",
"window_start": "2019-08-24T14:15:22Z"
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}