> ## Documentation Index
> Fetch the complete documentation index at: https://docs.canary.effectiveai.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Programs on Effective

> Release an RSL program on Effective, rate requests against a release, and keep the log of each submission through the API.

A **program** is an RSL bundle that Effective hosts for your organization. Its entry file is a
rating function (a rater), or a process (a guideline) with the raters it uses. Each rater is also
a program with the same ID.

You put a program on Effective once for each version, then call it through the API:

```mermaid theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': 'whitesmoke', 'primaryTextColor': 'black', 'primaryBorderColor': 'gray', 'lineColor': 'silver', 'edgeLabelBackground': 'whitesmoke', 'tertiaryColor': 'whitesmoke', 'clusterBkg': 'white', 'clusterBorder': 'gray'}}}%%
flowchart TD
    C["<b>Check and package</b><br/>rslc check, rslc export"] --> R["<b>Upload and release</b>"]
    R --> E["<b>Evaluate</b><br/>rate one request"]
    R -- "a process entry" --> O["<b>Open a log</b><br/>one per subject"]
    O --> W["<b>Write and read</b><br/>answers, decisions, acts; status and entries"]
    class C,R,E,O,W box;
    classDef box fill:whitesmoke,stroke:gray,color:black,stroke-width:1px;
    linkStyle default stroke:silver,stroke-width:1px,color:black;
```

A **release** names one uploaded bundle by a version number. A release stays as it is, so a
caller that names a version gets the same answer each time.

## Releases

1. Check the entry file with `rslc check`, and fix each message. [Write your first rater](https://docs.canary.effectiveai.app/rsl/tutorial/first-rater.md) shows the check.
2. Test it on your machine: [test a rater](https://docs.canary.effectiveai.app/rsl/how-to/test-a-rater.md) against its filed examples, and for a guideline [run a submission](https://docs.canary.effectiveai.app/rsl/how-to/run-a-submission.md) through each path its rules take. An uploaded bundle answers no call until it is released, and a release stays as it is, so the tests you run here are the ones that count.
3. Package it with `rslc export rater.rsl --format bundle --out rater.zip`. For a guideline, export `guideline.rsl`: the bundle carries the raters it uses.
4. [Upload the bundle](https://docs.canary.effectiveai.app/api-reference/your-programs/upload-a-program-bundle.md). Effective checks it and returns a `bundleId`. The bundle serves calls only once you release it.
5. [Release the bundle](https://docs.canary.effectiveai.app/api-reference/your-programs/release-an-uploaded-program-bundle.md) under a version number. A version above the latest one makes it the latest release.

`rslc export` is how any program reaches Effective. To rate a book of policies with
Relativities instead, [package a program](https://docs.canary.effectiveai.app/relativities/how-to/package-a-program.md) with its
`prepare` function and its examples; a guideline does not use that package.
[Versions and releases](https://docs.canary.effectiveai.app/rsl/concepts/versions.md) explains what a release pins.

## Roles

A guideline's rules name the role that answers each question and takes each act, such as `uw`
for the underwriter and `manager` for referrals. Releasing a guideline makes you the holder of
each role it declares. To let your team work submissions,
[replace who holds the program's roles](https://docs.canary.effectiveai.app/api-reference/your-programs/replace-who-holds-the-program%E2%80%99s-roles).
The body names every role you keep bound; a role you leave out has no holders on this program:

```bash theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
curl --request PUT \
  --url "https://api.canary.effectiveai.app/api/v2/rsl/example-staffing/roles" \
  --header "Authorization: Bearer $EFFECTIVE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "roles": [
      { "name": "assistant", "holders": [] },
      { "name": "uw", "holders": [{ "type": "group", "id": "<your underwriters group ID>" }] },
      { "name": "manager", "holders": [{ "type": "group", "id": "<your managers group ID>" }] }
    ]
  }'
```

## Rating

A rater release takes one request and returns its outcomes, such as the premium. Read the
[release's contract](https://docs.canary.effectiveai.app/api-reference/your-programs/get-the-contract-of-a-program-release.md) first:
it holds the JSON schema of the inputs.

* [Evaluate a program's latest release](https://docs.canary.effectiveai.app/api-reference/your-programs/evaluate-a-program%E2%80%99s-latest-release), or [evaluate one release](https://docs.canary.effectiveai.app/api-reference/your-programs/evaluate-a-program-release.md) by its version.
* For a guideline entry, [evaluate a used rater](https://docs.canary.effectiveai.app/api-reference/your-programs/evaluate-a-used-rater-of-a-program-release.md) by the alias of its `use` line.
* A guideline release also evaluates one quote request with its answers and acts. It plays them on a log in memory and returns the status, so it suits a quick quote.

A rater's inputs go under `inputs`, inside the contract's root record, such as `Policy`:

```bash theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
curl --request POST \
  --url "https://api.canary.effectiveai.app/api/v2/rsl/example-staffing/releases/1/ts/evaluate" \
  --header "Authorization: Bearer $EFFECTIVE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{"inputs": {"Policy": {"payroll": 2500000, "experience": "no_claims", "limit": 1000000}}}'
```

```json theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
{
  "component": "rater",
  "programId": "example-staffing",
  "releaseVersion": 1,
  "alias": "ts",
  "result": { "Policy": { "premium": 5000 } }
}
```

A guideline evaluate takes `answers` by input path. `because` is an object keyed by the same
paths, one reason for each answer that needs one, and `acts` lists the acts to take in order:

```bash theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
curl --request POST \
  --url "https://api.canary.effectiveai.app/api/v2/rsl/example-staffing/releases/1/evaluate" \
  --header "Authorization: Bearer $EFFECTIVE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "answers": {"operation": "staffing", "years_in_operation": 2, "policy.payroll": 2500000, "policy.limit": 1000000, "policy.experience": "no_claims"},
    "because": {"policy.experience": "Loss runs show no claims in three years"},
    "acts": [{"act": "quote", "name": "q1"}, {"act": "bind", "name": "q1"}]
  }'
```

```json theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
{
  "code": "command_refused",
  "refusal": {
    "code": "NOT_READY",
    "message": "the offer `q1` is referred; `bind` takes an offer once no rule holds it",
    "candidates": ["new_venture"]
  }
}
```

This firm is two years old, so the program's `new_venture` rule refers it: the quote is recorded
but held, and `bind` is refused until a manager approves.

An evaluate call leaves the program as it was, so a caller repeats it safely. A request that breaks a check
gets the check's code and message. [Rating a product](https://docs.canary.effectiveai.app/rsl/uses/rating.md) describes the rater use.

## Submission logs

A release with a guideline entry keeps one **log** for each subject, such as a submission. Each
log is pinned to one release, and that release decides every write to it. To populate a log from
an uploaded application and read the resulting premium, follow
[Rate a submission from broker documents](https://docs.canary.effectiveai.app/guides/underwriting/rate-a-submission.md).

1. [Open a log](https://docs.canary.effectiveai.app/api-reference/your-programs/open-a-log.md) under a UUID you choose, such as the ID of the case it decides. The open entry pins the log to a release.
2. [Write to the log](https://docs.canary.effectiveai.app/api-reference/your-programs/write-to-a-log.md): answers, sign-offs and acts. The commands of one write land together, or the log refuses them all.
3. [Preview a write](https://docs.canary.effectiveai.app/api-reference/your-programs/preview-a-write-to-a-log.md) to see the entries and the status it gives. A preview leaves the log as it was.
4. [Get the status](https://docs.canary.effectiveai.app/api-reference/your-programs/get-the-status-of-a-log.md): one word for where the log stands, its open questions with the role that answers each, its referrals, its offers and its outcomes.

A caller writes in a program role that it holds. A workspace admin, program owner, or someone with
an explicit **Manager** grant on the program can
[bind users and groups to its roles](https://docs.canary.effectiveai.app/api-reference/your-programs/replace-who-holds-the-program%E2%80%99s-roles).
Workspace admins can assign roles across every program that declares them.
[Underwriting a submission](https://docs.canary.effectiveai.app/rsl/uses/underwriting.md) describes the
guideline use, and [Processes and the log](https://docs.canary.effectiveai.app/rsl/concepts/processes.md) explains how a log folds into a status.

## Log entry fields

A log only grows. Each entry is one JSON line with the same fields:
`seq`, `at`, `by`, `kind`, `on`, `value`, `in`, `from`, `reason`, `note` and `stamp`.
Its `kind` is one of eight:

| `kind` | The entry records | Written by |
| - | - | - |
| `open` | The program and the release the log is pinned to | Open a log |
| `answer` | A value for an input, with the document it cites | An `answer` command |
| `tool` | A value that a host tool gave, with the request it got | An `answer` with a `call` |
| `decide` | A sign-off of a referral, `Approved` or `Declined`, and what it read | An `answer` to the referral |
| `attach` | A document kept under a name, with its pin | An `attach` command |
| `retract` | An answer or a sign-off taken back, or an offer withdrawn | `retract`, `withdraw` |
| `note` | A new name or a receipt on a saved offer | `rename`, `receipt` |
| `act` | An act of the program, such as `quote`, `bind` or `decline` | An `act` command |

[Submission log](https://docs.canary.effectiveai.app/rsl/reference/submission-log.md) gives the fields of each kind, the statuses and
the refusal codes.

A log stays on the engine that its release pins. A log that an older release wrote replays on
that release's engine, so its statuses stay as they were. The API returns its entries in the
same eight kinds. Release the guideline again with the current `rslc` to put new logs on the
current engine.

## Operations by job

Each link opens the operation in the API reference, with its parameters and responses.

| Job | Operations |
| - | - |
| Find a program | [List programs](https://docs.canary.effectiveai.app/api-reference/your-programs/list-programs.md), [get a program](https://docs.canary.effectiveai.app/api-reference/your-programs/get-a-program.md) |
| Release a version | [Upload a bundle](https://docs.canary.effectiveai.app/api-reference/your-programs/upload-a-program-bundle.md), [release it](https://docs.canary.effectiveai.app/api-reference/your-programs/release-an-uploaded-program-bundle.md), [list releases](https://docs.canary.effectiveai.app/api-reference/your-programs/list-program-releases.md), [get a release](https://docs.canary.effectiveai.app/api-reference/your-programs/get-a-program-release.md), [download a release](https://docs.canary.effectiveai.app/api-reference/your-programs/download-a-program-release-bundle.md) |
| Read what a release takes | [Latest contract](https://docs.canary.effectiveai.app/api-reference/your-programs/get-the-contract-of-a-program%E2%80%99s-latest-release), [contract of a release](https://docs.canary.effectiveai.app/api-reference/your-programs/get-the-contract-of-a-program-release.md), [contract of a used rater](https://docs.canary.effectiveai.app/api-reference/your-programs/get-the-contract-of-a-used-rater-of-a-program-release.md), [used rater, latest release](https://docs.canary.effectiveai.app/api-reference/your-programs/get-the-contract-of-a-used-rater-of-a-program%E2%80%99s-latest-release) |
| Rate a request | [Evaluate the latest release](https://docs.canary.effectiveai.app/api-reference/your-programs/evaluate-a-program%E2%80%99s-latest-release), [evaluate a release](https://docs.canary.effectiveai.app/api-reference/your-programs/evaluate-a-program-release.md), [evaluate a used rater](https://docs.canary.effectiveai.app/api-reference/your-programs/evaluate-a-used-rater-of-a-program-release.md), [used rater, latest release](https://docs.canary.effectiveai.app/api-reference/your-programs/evaluate-a-used-rater-of-a-program%E2%80%99s-latest-release) |
| Assign roles | [Get who holds the roles](https://docs.canary.effectiveai.app/api-reference/your-programs/get-who-holds-the-program%E2%80%99s-roles), [replace who holds them](https://docs.canary.effectiveai.app/api-reference/your-programs/replace-who-holds-the-program%E2%80%99s-roles) |
| Write to a log | [Open a log](https://docs.canary.effectiveai.app/api-reference/your-programs/open-a-log.md), [write to it](https://docs.canary.effectiveai.app/api-reference/your-programs/write-to-a-log.md), [preview a write](https://docs.canary.effectiveai.app/api-reference/your-programs/preview-a-write-to-a-log.md) |
| Read a log | [Get a log](https://docs.canary.effectiveai.app/api-reference/your-programs/get-a-log.md), [its status](https://docs.canary.effectiveai.app/api-reference/your-programs/get-the-status-of-a-log.md), [its answers](https://docs.canary.effectiveai.app/api-reference/your-programs/get-the-answers-in-a-log.md), [its entries](https://docs.canary.effectiveai.app/api-reference/your-programs/list-the-entries-of-a-log.md), [its refused writes](https://docs.canary.effectiveai.app/api-reference/your-programs/list-the-refused-writes-to-a-log.md) |
| Record work after a log | [Record a receipt](https://docs.canary.effectiveai.app/api-reference/your-programs/record-a-receipt-on-a-log.md), [list receipts](https://docs.canary.effectiveai.app/api-reference/your-programs/list-the-receipts-on-a-log.md) |
| Find logs | [A program's logs](https://docs.canary.effectiveai.app/api-reference/your-programs/list-a-program%E2%80%99s-logs), [logs across your programs](https://docs.canary.effectiveai.app/api-reference/your-programs/list-logs-across-your-programs.md), [how your guideline programs run](https://docs.canary.effectiveai.app/api-reference/your-programs/list-how-your-guideline-programs-run.md) |

A receipt records what a system outside the log did after a final act, such as issuing a
policy. A log that stands accepted, refused or ended takes receipts and refuses every other write.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.