Policies and test targets
Approval, routing, severity and ownership policies, severity previews, and where test-mode writes go.
Policies decide who approves fixes, how severity is scored, how issues are routed and how owners are found. Each mode has its own policies. These endpoints need a signed-in session.
The policies object#
| Field | Type | Description |
|---|---|---|
approval |
object | who (owners, team or role), role, min_approvals (1 to 5), risky_paths (globs), two_approvers_for_risky, risk_threshold (low, medium, high), channels (slack, email, in_app) |
timers |
object | remind_h, escalate_h (hours), expire_d (days) |
auto_approve |
object | enabled, categories, min_confidence (0 to 1), max_diff_lines |
routing |
object | P0..P4 → page, channel, ticket or none; quiet_hours: {from: "HH:MM", to: "HH:MM", tz, bypass: [severities]} or null |
severity_weights |
object | 0 to 10 each: users, rate, critical_paths, kind, customer_value, tickets, regression, platform_share, environment, release |
severity_thresholds |
object | Minimum score for P0..P3 (below P3 is P4); must go down from P0 to P3 |
critical_paths |
string[] | Globs of paths that raise severity |
owner_order |
string[] | Order of owner sources: codeowners, owners_file, rules, blame, introducing_pr, default_team |
owner_rules |
object[] | Up to 200: {match: {path, project, platform, title}, owner: {kind: user|team, id}} |
default_team_id |
uuid or null | Team that owns issues nothing else claims |
Get policies#
/api/v1/orgs/{org_id}/policiesThe policies for the current mode, with every default filled in.
Auth: session only. Secret keys get 403 api_key_not_allowed. The role needs issues.view.
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
org_id |
uuid | required | Organization id |
Response
The policies object.
curl "https://app.getmendloop.com/api/v1/orgs/ORG_ID/policies" \
--cookie "ml_session=…"const res = await fetch("https://app.getmendloop.com/api/v1/orgs/ORG_ID/policies", {
headers: { Cookie: "ml_session=…" },
});
if (!res.ok) throw new Error((await res.json()).error.message);
const data = await res.json();import requests
resp = requests.get(
"https://app.getmendloop.com/api/v1/orgs/ORG_ID/policies",
cookies={"ml_session": "…"},
timeout=30,
)
resp.raise_for_status()
data = resp.json(){
"approval": {
"who": "owners",
"role": null,
"min_approvals": 1,
"risky_paths": [
"**/payments/**",
"**/auth/**",
"**/migrations/**",
"**/*.sql",
"infra/**"
],
"two_approvers_for_risky": true,
"risk_threshold": "high",
"channels": [
"slack",
"in_app"
]
},
"timers": {
"remind_h": 4,
"escalate_h": 24,
"expire_d": 7
},
"auto_approve": {
"enabled": false,
"categories": [],
"min_confidence": 0.9,
"max_diff_lines": 20
},
"routing": {
"P0": "page",
"P1": "page",
"P2": "channel",
"P3": "ticket",
"P4": "ticket",
"quiet_hours": null
},
"severity_weights": {
"users": 3.0,
"rate": 2.0,
"critical_paths": 1.5,
"kind": 2.0,
"customer_value": 1.0,
"tickets": 0.5,
"regression": 1.0,
"platform_share": 1.0,
"environment": 1.0,
"release": 1.0
},
"severity_thresholds": {
"P0": 80,
"P1": 60,
"P2": 40,
"P3": 20
},
"critical_paths": [
"**/checkout/**",
"**/payments/**",
"**/auth/**",
"**/login/**"
],
"owner_order": [
"codeowners",
"owners_file",
"rules",
"blame",
"introducing_pr",
"default_team"
],
"owner_rules": [],
"default_team_id": null
}Replace policies#
/api/v1/orgs/{org_id}/policiesReplaces the policies for the current mode. Fields you leave out take their defaults; unknown fields are rejected. Audit logged.
Auth: session only. Secret keys get 403 api_key_not_allowed. The role needs policies.manage.
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
org_id |
uuid | required | Organization id |
Body (JSON)
| Parameter | Type | Required | Description |
|---|---|---|---|
approval, timers, auto_approve, routing, severity_weights, severity_thresholds, critical_paths, owner_order, owner_rules, default_team_id |
optional | As in the policies object |
Response
The saved policies object.
Errors
| Status | Code | When |
|---|---|---|
| 422 | invalid_input |
A field is unknown or out of range |
curl -X PUT "https://app.getmendloop.com/api/v1/orgs/ORG_ID/policies" \
--cookie "ml_session=…" \
-H "Content-Type: application/json" \
-d '{
"approval": {
"who": "owners",
"min_approvals": 2
},
"timers": {
"remind_h": 2,
"escalate_h": 12,
"expire_d": 3
}
}'const res = await fetch("https://app.getmendloop.com/api/v1/orgs/ORG_ID/policies", {
method: "PUT",
headers: { Cookie: "ml_session=…", "Content-Type": "application/json" },
body: JSON.stringify({
"approval": {
"who": "owners",
"min_approvals": 2
},
"timers": {
"remind_h": 2,
"escalate_h": 12,
"expire_d": 3
}
}),
});
if (!res.ok) throw new Error((await res.json()).error.message);
const data = await res.json();import requests
resp = requests.put(
"https://app.getmendloop.com/api/v1/orgs/ORG_ID/policies",
cookies={"ml_session": "…"},
json={
"approval": {
"who": "owners",
"min_approvals": 2
},
"timers": {
"remind_h": 2,
"escalate_h": 12,
"expire_d": 3
}
},
timeout=30,
)
resp.raise_for_status()
data = resp.json(){
"approval": {
"who": "owners",
"role": null,
"min_approvals": 2,
"risky_paths": [
"**/payments/**",
"**/auth/**",
"**/migrations/**",
"**/*.sql",
"infra/**"
],
"two_approvers_for_risky": true,
"risk_threshold": "high",
"channels": [
"slack",
"in_app"
]
},
"timers": {
"remind_h": 2,
"escalate_h": 12,
"expire_d": 3
},
"auto_approve": {
"enabled": false,
"categories": [],
"min_confidence": 0.9,
"max_diff_lines": 20
},
"routing": {
"P0": "page",
"P1": "page",
"P2": "channel",
"P3": "ticket",
"P4": "ticket",
"quiet_hours": null
},
"severity_weights": {
"users": 3.0,
"rate": 2.0,
"critical_paths": 1.5,
"kind": 2.0,
"customer_value": 1.0,
"tickets": 0.5,
"regression": 1.0,
"platform_share": 1.0,
"environment": 1.0,
"release": 1.0
},
"severity_thresholds": {
"P0": 80,
"P1": 60,
"P2": 40,
"P3": 20
},
"critical_paths": [
"**/checkout/**",
"**/payments/**",
"**/auth/**",
"**/login/**"
],
"owner_order": [
"codeowners",
"owners_file",
"rules",
"blame",
"introducing_pr",
"default_team"
],
"owner_rules": [],
"default_team_id": null
}Preview a severity#
/api/v1/orgs/{org_id}/policies/preview-severityScores one issue with trial weights. Nothing is saved.
Auth: session only. Secret keys get 403 api_key_not_allowed. The role needs issues.view.
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
org_id |
uuid | required | Organization id |
Body (JSON)
| Parameter | Type | Required | Description |
|---|---|---|---|
issue_id |
uuid | required | The issue to score |
weights |
object | optional | Severity weights to try; missing ones use the saved values |
Response
| Field | Type | Description |
|---|---|---|
severity |
string | P0 to P4 |
score |
integer | 0 to 100 |
factors |
object[] | {name, weight, value, detail, points} |
reason |
string | One-line reason |
Errors
| Status | Code | When |
|---|---|---|
| 404 | issue_not_found |
No such issue |
| 422 | invalid_input |
Weights must be numbers from 0 to 10 with known names |
curl -X POST "https://app.getmendloop.com/api/v1/orgs/ORG_ID/policies/preview-severity" \
--cookie "ml_session=…" \
-H "Content-Type: application/json" \
-d '{
"issue_id": "0193b7e2-0a4c-7f19-b8d2-51c3e9a7f604",
"weights": {
"users": 5
}
}'const res = await fetch("https://app.getmendloop.com/api/v1/orgs/ORG_ID/policies/preview-severity", {
method: "POST",
headers: { Cookie: "ml_session=…", "Content-Type": "application/json" },
body: JSON.stringify({
"issue_id": "0193b7e2-0a4c-7f19-b8d2-51c3e9a7f604",
"weights": {
"users": 5
}
}),
});
if (!res.ok) throw new Error((await res.json()).error.message);
const data = await res.json();import requests
resp = requests.post(
"https://app.getmendloop.com/api/v1/orgs/ORG_ID/policies/preview-severity",
cookies={"ml_session": "…"},
json={
"issue_id": "0193b7e2-0a4c-7f19-b8d2-51c3e9a7f604",
"weights": {
"users": 5
}
},
timeout=30,
)
resp.raise_for_status()
data = resp.json(){
"severity": "P1",
"score": 62,
"factors": [
{
"name": "users",
"weight": 5.0,
"value": 0.62,
"detail": "612 users",
"points": 31.0
}
],
"reason": "612 users in 24 h on a checkout path"
}Get test targets#
/api/v1/orgs/{org_id}/test-targetsWhere test-mode writes go. A write with no test target is simulated and recorded as what would have been done.
Auth: session only. Secret keys get 403 api_key_not_allowed. The role needs issues.view.
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
org_id |
uuid | required | Organization id |
Response
| Field | Type | Description |
|---|---|---|
slack_channel |
string or null | Channel for test-mode messages |
tickets |
object | Connection id → test project key |
github_repo |
string or null | owner/name for test-mode pull requests |
email_capture |
boolean | Capture test-mode email instead of sending it |
curl "https://app.getmendloop.com/api/v1/orgs/ORG_ID/test-targets" \
--cookie "ml_session=…"const res = await fetch("https://app.getmendloop.com/api/v1/orgs/ORG_ID/test-targets", {
headers: { Cookie: "ml_session=…" },
});
if (!res.ok) throw new Error((await res.json()).error.message);
const data = await res.json();import requests
resp = requests.get(
"https://app.getmendloop.com/api/v1/orgs/ORG_ID/test-targets",
cookies={"ml_session": "…"},
timeout=30,
)
resp.raise_for_status()
data = resp.json(){
"slack_channel": "C07TESTCHAN",
"tickets": {
"0193a8b0-2e4f-7d61-b5a3-9c0e1f7d4a26": "TEST"
},
"github_repo": "acme/rider-web-sandbox",
"email_capture": true
}Set test targets#
/api/v1/orgs/{org_id}/test-targetsReplaces the test targets. Audit logged.
Auth: session only. Secret keys get 403 api_key_not_allowed. The role needs policies.manage.
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
org_id |
uuid | required | Organization id |
Body (JSON)
| Parameter | Type | Required | Description |
|---|---|---|---|
slack_channel |
string or null | optional | Up to 200 characters |
tickets |
object | optional | Connection id → test project key |
github_repo |
string or null | optional | owner/name |
email_capture |
boolean | optional | Default true |
Response
The saved test targets.
curl -X PUT "https://app.getmendloop.com/api/v1/orgs/ORG_ID/test-targets" \
--cookie "ml_session=…" \
-H "Content-Type: application/json" \
-d '{
"slack_channel": "C07TESTCHAN",
"tickets": {
"0193a8b0-2e4f-7d61-b5a3-9c0e1f7d4a26": "TEST"
},
"github_repo": "acme/rider-web-sandbox"
}'const res = await fetch("https://app.getmendloop.com/api/v1/orgs/ORG_ID/test-targets", {
method: "PUT",
headers: { Cookie: "ml_session=…", "Content-Type": "application/json" },
body: JSON.stringify({
"slack_channel": "C07TESTCHAN",
"tickets": {
"0193a8b0-2e4f-7d61-b5a3-9c0e1f7d4a26": "TEST"
},
"github_repo": "acme/rider-web-sandbox"
}),
});
if (!res.ok) throw new Error((await res.json()).error.message);
const data = await res.json();import requests
resp = requests.put(
"https://app.getmendloop.com/api/v1/orgs/ORG_ID/test-targets",
cookies={"ml_session": "…"},
json={
"slack_channel": "C07TESTCHAN",
"tickets": {
"0193a8b0-2e4f-7d61-b5a3-9c0e1f7d4a26": "TEST"
},
"github_repo": "acme/rider-web-sandbox"
},
timeout=30,
)
resp.raise_for_status()
data = resp.json(){
"slack_channel": "C07TESTCHAN",
"tickets": {
"0193a8b0-2e4f-7d61-b5a3-9c0e1f7d4a26": "TEST"
},
"github_repo": "acme/rider-web-sandbox",
"email_capture": true
}