Developer documentation

API Documentation

Reference material and integration guides for the Relational Manager API.

Go Integration

Example POST /v1/score using net/http.

Prereqs

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

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
    "os"
)

func main() {
    baseURL := os.Getenv("BASE_URL")
    if baseURL == "" {
        baseURL = "https://www.relationalmanager.com/api"
    }
    apiKey := os.Getenv("RI_API_KEY")

    payload := map[string]any{
        "lenses":  []int{1, 4},
        "persist": false,
        "message": map[string]any{
            "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": map[string]any{
            "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",
        },
    }

    body, _ := json.Marshal(payload)
    req, _ := http.NewRequest("POST", baseURL+"/v1/score", bytes.NewReader(body))
    req.Header.Set("Authorization", "Bearer "+apiKey)
    req.Header.Set("Content-Type", "application/json")

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    respBody, _ := io.ReadAll(resp.Body)
    fmt.Println(resp.StatusCode, resp.Header.Get("X-Request-Id"))
    fmt.Println(string(respBody))
}

Lens Aggregates, Indicators and Traffic Lights

Lens results include weighted score, scoring_coverage, and traffic_light; 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.

ranges := []byte(`{"traffic_light_ranges":{"red":{"min":-1.0,"max":-0.2},"yellow":{"min":-0.2,"max":0.4},"green":{"min":0.4,"max":1.0}}}`)
update, _ := http.NewRequest(http.MethodPut, baseURL+"/v1/lenses/1/traffic-light-ranges", bytes.NewReader(ranges))
update.Header.Set("Authorization", "Bearer "+apiKey)
update.Header.Set("Content-Type", "application/json")
_, err := http.DefaultClient.Do(update)

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