Summit CognitiveDocs

GUIDE

Code in your language

The Decision Receipt API is plain HTTPS with JSON request and response bodies. Any language with an HTTP client can call it — there is no SDK to install. This guide shows direct HTTP calls from Python, Node, and Go that submit a claim, read the verdict, and verify the returned receipt.

Every example does the same thing: it reads an API key from an environment variable, sends a minimal claim to POST /v1/evaluate with two evidence sources, and reads back the policy verdict and the receipt admissibility status. Write endpoints authenticate with an X-API-Key header; you can obtain a key with POST /v1/signup (it returns a key on the free tier). Store that key in an environment variable rather than hard-coding it.

Note

The base URL is https://decrec.summitcognitive.ai. The samples below use real endpoints and field names; set DECREC_API_KEY in your shell before running them.


Python

This sample uses requests, a popular third-party HTTP library (pip install requests). If you would rather avoid dependencies, the standard-library urllib.request works the same way — build a Request with the same headers and JSON body. The key is read from the environment with os.environ.

PYTHON

import os
import requests

BASE = "https://decrec.summitcognitive.ai"
api_key = os.environ["DECREC_API_KEY"]  # obtain one via POST /v1/signup

claim = {
    "claim_id": "demo-py-001",
    "entity": "acme-corp/widget-api",
    "claim": "PR #42: Add input validation",
    "sources": [
        {
            "id": "evd_test_1",
            "type": "test_result",
            "uri": "https://github.com/acme-corp/widget-api/actions/runs/99",
            "confidence": 0.9,
            "content": "All tests passing",
        },
        {
            "id": "evd_review_1",
            "type": "code_review",
            "uri": "https://github.com/acme-corp/widget-api/pull/42",
            "confidence": 0.85,
            "content": "Approved by two reviewers",
        },
    ],
}

resp = requests.post(
    f"{BASE}/v1/evaluate",
    headers={"Content-Type": "application/json", "X-API-Key": api_key},
    json=claim,
    timeout=30,
)
resp.raise_for_status()
result = resp.json()

print("verdict:", result["policy"]["verdict"])
print("admissibility:", result["receipt"]["admissibility"]["status"])

JavaScript / Node

Node 18 and later ship a built-in fetch, so no dependency is needed. Read the key from process.env and use async/await. The shape of the request and response is identical to the Python sample.

NODE (18+)

const BASE = "https://decrec.summitcognitive.ai";
const apiKey = process.env.DECREC_API_KEY; // obtain one via POST /v1/signup

const claim = {
  claim_id: "demo-node-001",
  entity: "acme-corp/widget-api",
  claim: "PR #42: Add input validation",
  sources: [
    {
      id: "evd_test_1",
      type: "test_result",
      uri: "https://github.com/acme-corp/widget-api/actions/runs/99",
      confidence: 0.9,
      content: "All tests passing",
    },
    {
      id: "evd_review_1",
      type: "code_review",
      uri: "https://github.com/acme-corp/widget-api/pull/42",
      confidence: 0.85,
      content: "Approved by two reviewers",
    },
  ],
};

async function main() {
  const resp = await fetch(`${BASE}/v1/evaluate`, {
    method: "POST",
    headers: { "Content-Type": "application/json", "X-API-Key": apiKey },
    body: JSON.stringify(claim),
  });
  if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
  const result = await resp.json();

  console.log("verdict:", result.policy.verdict);
  console.log("admissibility:", result.receipt.admissibility.status);
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});

Go

Go needs only the standard library: net/http to send the request and encoding/json to encode the claim and decode the response. Decode into a struct that mirrors only the fields you read.

GO

package main

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

const base = "https://decrec.summitcognitive.ai"

type source struct {
	ID         string  `json:"id"`
	Type       string  `json:"type"`
	URI        string  `json:"uri"`
	Confidence float64 `json:"confidence"`
	Content    string  `json:"content"`
}

type claim struct {
	ClaimID string   `json:"claim_id"`
	Entity  string   `json:"entity"`
	Claim   string   `json:"claim"`
	Sources []source `json:"sources"`
}

type evalResult struct {
	Policy struct {
		Verdict string `json:"verdict"`
	} `json:"policy"`
	Receipt struct {
		Admissibility struct {
			Status string `json:"status"`
		} `json:"admissibility"`
	} `json:"receipt"`
}

func main() {
	apiKey := os.Getenv("DECREC_API_KEY") // obtain one via POST /v1/signup

	c := claim{
		ClaimID: "demo-go-001",
		Entity:  "acme-corp/widget-api",
		Claim:   "PR #42: Add input validation",
		Sources: []source{
			{"evd_test_1", "test_result", "https://github.com/acme-corp/widget-api/actions/runs/99", 0.9, "All tests passing"},
			{"evd_review_1", "code_review", "https://github.com/acme-corp/widget-api/pull/42", 0.85, "Approved by two reviewers"},
		},
	}

	body, _ := json.Marshal(c)
	req, _ := http.NewRequest("POST", base+"/v1/evaluate", bytes.NewReader(body))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("X-API-Key", apiKey)

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

	var result evalResult
	if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
		panic(err)
	}

	fmt.Println("verdict:", result.Policy.Verdict)
	fmt.Println("admissibility:", result.Receipt.Admissibility.Status)
}

The verdict is one of ALLOWED BLOCKED ESCALATED, and the admissibility status is one of ACCEPTED, NON_DETERMINISTIC, or REJECTED.


Verify a receipt

The receipt returned under .receipt can be independently verified by anyone. Send the full receipt object to POST /v1/verify — this endpoint does not require an API key. The response includes a valid boolean that is true only when schema, hash integrity, and the Ed25519 signature all check out.

The pattern is the same in every language: take result.receipt from the evaluate response and POST it as the request body. In Python:

PYTHON — VERIFY

receipt = result["receipt"]

verify = requests.post(
    f"{BASE}/v1/verify",
    headers={"Content-Type": "application/json"},
    json=receipt,
    timeout=30,
)
verify.raise_for_status()
print("valid:", verify.json()["valid"])

In Node, post result.receipt the same way with fetch; in Go, marshal the receipt sub-object (or capture the raw bytes of that field) and send it to /v1/verify. For fully offline verification, fetch the server's Ed25519 public key from GET /v1/keys/server and validate the signature yourself.


Where to go next

These are direct HTTP calls — there is no official Summit Cognitive SDK. If your language is not shown here, the same three steps apply: set the X-API-Key header, send the JSON claim to /v1/evaluate, and read .policy.verdict and .receipt.admissibility.status.