Developer documentation

API Documentation

Reference material and integration guides for the Relational Manager API.

Swift Integration

Example POST /v1/score using URLSession.

Prereqs

  • RI_API_KEY (string)
  • BASE_URL (string), default https://www.relationalmanager.com/api
import Foundation

let baseUrl = ProcessInfo.processInfo.environment["BASE_URL"] ?? "https://www.relationalmanager.com/api"
let apiKey = ProcessInfo.processInfo.environment["RI_API_KEY"] ?? ""

let payload: [String: Any] = [
    "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 url = URL(string: "\(baseUrl)/v1/score")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try JSONSerialization.data(withJSONObject: payload, options: [])

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let error = error {
        print(error)
        return
    }
    if let http = response as? HTTPURLResponse {
        print(http.statusCode, http.value(forHTTPHeaderField: "X-Request-Id") ?? "")
    }
    if let data = data {
        print(String(data: data, encoding: .utf8) ?? "")
    }
}

task.resume()
RunLoop.main.run()

Lens Aggregates, Indicators and Traffic Lights

Decode score, scoring_coverage, and traffic_light from each lens. Questions include full question text 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.

var update = URLRequest(url: URL(string: "\(baseUrl)/v1/lenses/1/traffic-light-ranges")!)
update.httpMethod = "PUT"
update.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
update.setValue("application/json", forHTTPHeaderField: "Content-Type")
update.httpBody = try JSONSerialization.data(withJSONObject: ["traffic_light_ranges": [
    "red": ["min": -1.0, "max": -0.2],
    "yellow": ["min": -0.2, "max": 0.4],
    "green": ["min": 0.4, "max": 1.0]
]])

The update key requires org:write. Inspect scoring_status before interpreting a zero.