Developer documentation

API Documentation

Reference material and integration guides for the Relational Manager API.

Rust (reqwest) Integration

Example POST /v1/score using reqwest.

Prereqs

  • RI_API_KEY (string)
  • BASE_URL (string), default https://www.relationalmanager.com/api
  • reqwest and serde_json
use reqwest::header::AUTHORIZATION;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let base_url = std::env::var("BASE_URL")
        .unwrap_or_else(|_| "https://www.relationalmanager.com/api".to_string());
    let api_key = std::env::var("RI_API_KEY").unwrap_or_default();

    let payload = json!({
        "lenses": [1, 4],
        "persist": false,
        "message": {
            "message_id": "m2",
            "conversation_id": "c1",
            "text": "I'm not sure this will work.",
            "channel_type": "chat",
            "channel_id": "support",
            "sender_id": "u2",
            "sender_type": "user",
            "lang": "en",
            "timestamp": "1716561012"
        },
        "previous_message": {
            "message_id": "m1",
            "conversation_id": "c1",
            "text": "We can try a few options.",
            "channel_type": "chat",
            "channel_id": "support",
            "sender_id": "u1",
            "sender_type": "agent",
            "lang": "en",
            "timestamp": "1716560950"
        }
    });

    let client = reqwest::Client::new();
    let resp = client
        .post(format!("{}/v1/score", base_url))
        .header(AUTHORIZATION, format!("Bearer {}", api_key))
        .json(&payload)
        .send()
        .await?;

    println!("{} {:?}", resp.status(), resp.headers().get("x-request-id"));
    println!("{}", resp.text().await?);

    Ok(())
}

Lens Aggregates, Indicators and Traffic Lights

Lens results expose weighted score, scoring_coverage, and traffic_light; questions expose question and scoring_status.

Use each question's indicator_name, score, scoring_status, and traffic_light for UI dials. The signal uses the parent lens ranges, while internal metric details remain private.

The lens prescriptions array contains prioritized guidance for yellow/red signals and is empty for green.

client.put(format!("{base_url}/v1/lenses/1/traffic-light-ranges"))
    .bearer_auth(&api_key)
    .json(&serde_json::json!({"traffic_light_ranges": {
        "red": {"min": -1.0, "max": -0.2},
        "yellow": {"min": -0.2, "max": 0.4},
        "green": {"min": 0.4, "max": 1.0}
    }}))
    .send().await?.error_for_status()?;

The update key requires org:write. Use scoring_status to distinguish an unscored zero.