ApexCloud Retention Operations API — Reusable Skill
Environment
- Base URL:
http://34.46.77.124:8004
- All task prompts may reference
localhost:8074 or 127.0.0.1:8074; ignore those — always use the base URL above.
- Never run
env/setup.sh, never use localhost/127.0.0.1.
API Endpoint Reference
These endpoint families are available. Use the one that matches the task's data requirements.
Account & Metrics
| Endpoint |
Purpose |
GET /api/accounts/<account_id> |
Account profile (ARR, tenure, segment, lifecycle stage, renewal date) |
GET /api/accounts/<account_id>/metrics?start=YYYY-MM&end=YYYY-MM |
Monthly metrics: revenue, usage trend, SLA, etc. |
GET /api/accounts/<account_id>/tickets?start=YYYY-MM-DD&end=YYYY-MM-DD |
Support tickets with SLA status per ticket |
GET /api/accounts/<account_id>/nps?start=YYYY-MM-DD&end=YYYY-MM-DD |
NPS survey responses by month |
Financial & Pipeline
| Endpoint |
Purpose |
GET /api/finance/ar-aging?as_of=YYYY-MM-DD |
A/R aging with customer names, balances, aging buckets |
GET /api/finance/billing-snapshot?as_of=YYYY-MM-DD |
Billing snapshot with current ARR per account |
GET /api/opportunities?start=YYYY-MM-DD&end=YYYY-MM-DD |
CRM pipeline: won, lost, open opportunities with product lines |
Operations Context
| Endpoint |
Purpose |
GET /api/hr/summary?quarter=YYYY-QN |
HR headcount, unpaid claims |
GET /api/events/performance?event=<name>&quarter=YYYY-QN |
Event orders and revenue |
Exports
| Endpoint |
Purpose |
GET /exports/churn/train.csv |
Churn model training dataset (CSV) |
GET /exports/churn/validation.csv |
Churn model validation dataset (CSV) |
GET /exports/churn/candidates.csv |
Candidate accounts for churn prediction (CSV) |
Additional Endpoints (infer from task needs)
GET /api/accounts/<account_id>/usage?start=YYYY-MM&end=YYYY-MM — product usage data
GET /api/accounts/<account_id>/expansion?quarter=YYYY-QN — expansion pipeline per account
Numeric Precision Rules
| Data type |
Precision |
Example |
| Currency (ARR, revenue, overdue_balance, pipeline, claims) |
2 decimals |
1416439.47, 0.00 |
| Percentages (SLA, win_rate, accuracy) |
1 decimal |
93.3, 75.0, 100.0 |
| Churn probability |
3 decimals |
0.102, 0.039, 0.001 |
| Counts (tickets, headcount, orders, rows) |
integer |
13, 377, 445 |
| Risk scores |
integer |
100, 60, 15 |
Controlled Vocabularies (Enums)
Risk Levels (descending severity)
critical > high > medium > low
Primary Actions
| Action |
When to use |
collections_followup |
Overdue receivables present; A/R-driven risk |
technical_recovery |
SLA degradation, usage decline, NPS drop; product/tech-driven risk |
renewal_save |
Account is in or near a renewal window with elevated risk |
executive_qbr |
Strategic/escalation — highest-touch intervention |
nurture_monitor |
Low risk; monitor and engage lightly |
no_action |
Lowest risk tier; no active intervention needed |
Reason Codes
| Code |
Trigger |
overdue_receivable |
Account has an overdue balance in A/R aging |
low_tenure_high_churn |
Low-tenure account in a high-churn segment/cohort |
sla_degradation |
SLA compliance below threshold or declining |
nps_drop |
NPS declined vs prior period or below benchmark |
usage_decline |
Product usage trending down |
renewal_window |
Renewal date falls within analysis window or near term |
expansion_offset |
Open expansion pipeline partially offsets risk (mitigating factor) |
clean_billings |
No overdue balance — billing is current (positive signal) |
Metric Sources (use these exact labels)
crm_closed_won — revenue from CRM won deals
support_export — support ticket counts
sla_report — SLA compliance data
nps_survey — NPS survey responses
billing_snapshot — billing/ARR data
ar_aging — accounts receivable aging
pipeline_crm — CRM pipeline/opportunity data
event_dashboard — event performance data
hr_report — HR/headcount data
Ticket Trend
improving | worsening | flat
— Compare ticket counts month-over-month across the period. Fewer tickets each month = improving.
Accuracy Band (churn model)
below_70 | 70_to_79 | 80_to_89 | 90_plus
Tenure / Coefficient Direction
negative | positive | not_assessed | zero
Link Status (A/R to CRM matching)
linked | unlinked
— When an A/R customer cannot be matched to any CRM account_id, it is unlinked and account_id is null.
Review Owner
solutions_engineering | customer_success | finance_ops
Agenda Topics (QBR)
partnership_overview | q2_metrics | performance_highlights | q3_initiatives | technical_recovery | commercial_expansion
Business Logic Rules
Risk Score Computation
Risk score is a composite integer (0-100) derived from these weighted signals:
- Overdue receivables (high weight)
- NPS decline (medium-high weight)
- SLA degradation (medium weight)
- Usage decline (medium weight)
- Renewal window proximity (medium weight)
- Low tenure / high churn segment (medium weight)
- Expansion pipeline partially offsets (subtractive)
Score-to-level mapping:
- 70–100 →
critical
- 50–69 →
high
- 20–49 →
medium
- 0–19 →
low
Reaching for Expansion Pipeline
The expansion_pipeline field (in retention boards) is the total open opportunity value for the account within the quarter. Include it even when zero (use 0.0).
Net Revenue Exposure
net_revenue_exposure = arr_at_risk - open_expansion_pipeline
Compute to 2 decimal places.
ARR at Risk
Sum of current_arr for all accounts ranked critical or high. Compute to 2 decimal places.
Overdue Balance
When zero, output 0.0 (not null). Add clean_billings as a reason code when there is no overdue balance — this is a positive signal.
Sorting Rules
- Risk accounts / action board: Sort by risk score descending (highest risk first). Within ties, higher ARR first.
- Overdue follow-ups: Sort by
customer_name ascending (alphabetical).
- QBR metrics: Order months chronologically.
NPS Handling
- Use the latest NPS score in the period as
latest_nps.
- For trends, compare across months. Peak NPS is the highest monthly score.
SLA Compliance
Compute from ticket data: (tickets_within_sla / total_tickets) * 100, rounded to 1 decimal. If there are 0 tickets, SLA is 100.0.
Support Ticket Counting
Count only "clean" (non-spam, non-duplicate) tickets. The API may return a clean_ticket_count or you may need to filter by ticket status.
Churn Model Validation
- Read the CSV exports directly; they contain labeled rows.
training_rows: row count of train.csv (excluding header)
validation_rows: row count of validation.csv (excluding header)
feature_count: number of feature columns (excluding ID and label columns)
accuracy_pct: from the model metadata or computed from validation results
tenure_coefficient_direction: extracted from model coefficients; negative means higher tenure → lower churn risk
- Accuracy band is binned from accuracy_pct
Churn Candidate Ranking
- Read candidates.csv for the candidate accounts listed in the prompt.
- Rank by
predicted_churn_probability descending, take top 5.
- Map churn probability to outreach action:
- ≥ 0.05 →
collections_followup or renewal_save (depending on root cause)
- 0.01–0.05 →
renewal_save or technical_recovery
- < 0.01 →
nurture_monitor
A/R-to-CRM Linking
- Take customer names from the A/R aging endpoint.
- Match against CRM accounts by name (fuzzy — watch for "Inc.", "LLC", "Ltd.", "Group" suffix variations).
- If a match is found:
link_status = "linked", populate account_id.
- If no match:
link_status = "unlinked", account_id = null.
Policy Codes
Policy codes appear in responses from the API itself. Read them from the API response payloads — do not invent them. Common code families:
RS-* — risk scoring protocol
REV-* — revenue/ARR source
SUP-* — support hygiene
ACT-* — action priority
RCP-* — receivable trigger
CM-* — CRM match rules
PW-* — pipeline window
FS-* — follow-up scope
MOD-* — model protocol (churn)
PRB-* — probability scale (churn)
DEP-* — deployment rules (churn)
OUT-* — outreach mapping (churn)
BORD-* — board sort order
EXP-* — exposure formula
CAL-* — calendar policy
Always include the policy_codes block when the answer template has one. Copy the codes from the relevant API response(s).
Follow-up Due Dates
When the task gives due dates by action type, use them exactly:
collections_followup → typically 15 days after as-of date
technical_recovery → typically 18 days after as-of date
renewal_save → typically 22 days after as-of date
executive_qbr → typically 29 days after as-of date
nurture_monitor → typically 36 days after as-of date
The exact dates will be provided in the task prompt. For no_action, next_touch_due_date is null.
Portfolio / Segment Summaries
accounts_reviewed: total accounts evaluated
critical_or_high_count: count of accounts with risk_level critical or high
collections_count: count of accounts with primary_action collections_followup
technical_recovery_count: count of accounts with primary_action technical_recovery
strategic_accounts / enterprise_accounts: from account segment field in API
Workflow Procedure
Step 1: Orient
- Read
environment_access.md for the base URL.
- Read the task prompt. Extract: task type, account IDs, date ranges, as-of dates, quarter, months, and any special parameters.
- Read
input/payloads/answer_template.json to understand the required output shape, enum options, and which sections are expected.
Step 2: Fetch Data
- Determine which endpoint families are needed based on the output shape and task description.
- Call each endpoint with the correct parameters. Use the date formats exactly:
YYYY-MM-DD for dates, YYYY-MM for months, YYYY-QN for quarters.
- For per-account endpoints, iterate over all specified account_ids.
- For churn tasks, fetch the CSV exports and parse them.
Step 3: Compute & Transform
- Apply the numeric precision rules consistently.
- Compute derived values (risk scores, averages, sums, win rates) from raw API data.
- Map raw signals to controlled enum values using the vocabularies above.
- Sort lists according to the sorting rules.
- Compute segment summaries by aggregating over the ranked accounts.
Step 4: Assemble Output
- Start from the answer template structure.
- Populate every field. Never omit a key from the template.
- Use
null for genuinely absent values (e.g., account_id for unlinked customers, next_touch_due_date for no_action).
- Use
0.0 (not null) for zero-value currency/percentage fields.
- Include policy_codes read from API responses.
- Output pure JSON only — no markdown fences, no explanatory text, no trailing commas.
Pitfalls & Edge Cases
- Port mismatch: Task prompts say port 8074; always use port 8004 from environment_access.md.
- A/R customer name variants: "North Star Finance Services" vs "Northstar Finance Group Inc." — these are different entities. Match carefully; when in doubt, leave unlinked.
- Zero tickets in a month: SLA compliance is 100.0, not undefined.
- Multiple NPS scores per month: Use the most recent survey response within that month.
- Null vs 0.0: Currency fields use
0.0 for zero, null only when the data is genuinely absent (e.g., account_id for unlinked).
- Sort stability: When risk scores tie, use ARR descending as secondary sort. When names tie (unlikely), preserve API order.
- Policy codes are read, not computed: Don't guess policy codes. They come from the API response payloads. If an endpoint doesn't return them, the code may be embedded in a different endpoint's response.
- Month format consistency: API path params use
YYYY-MM, date range params use YYYY-MM-DD. Don't mix them.
- CSV parsing: The churn exports have a header row.
training_rows = total rows minus 1 (the header). Feature count = total columns minus label and ID columns.
- Expansion pipeline is additive: An account can have both risk signals AND expansion pipeline —
expansion_offset is a reason code, not a risk eliminator. It offsets but doesn't cancel risk.
- Output is always pure JSON: Never wrap in ```json fences or add commentary. The evaluator expects raw parseable JSON.
1---2name: fewshot-attempt-02-303description: ApexCloud Retention Operations API — Reusable Skill4---5# ApexCloud Retention Operations API — Reusable Skill67## Environment89- **Base URL**: `http://34.46.77.124:8004`10- All task prompts may reference `localhost:8074` or `127.0.0.1:8074`; ignore those — always use the base URL above.11- Never run `env/setup.sh`, never use localhost/127.0.0.1.1213---1415## API Endpoint Reference1617These endpoint families are available. Use the one that matches the task's data requirements.1819### Account & Metrics20| Endpoint | Purpose |21|---|---|22| `GET /api/accounts/<account_id>` | Account profile (ARR, tenure, segment, lifecycle stage, renewal date) |23| `GET /api/accounts/<account_id>/metrics?start=YYYY-MM&end=YYYY-MM` | Monthly metrics: revenue, usage trend, SLA, etc. |24| `GET /api/accounts/<account_id>/tickets?start=YYYY-MM-DD&end=YYYY-MM-DD` | Support tickets with SLA status per ticket |25| `GET /api/accounts/<account_id>/nps?start=YYYY-MM-DD&end=YYYY-MM-DD` | NPS survey responses by month |2627### Financial & Pipeline28| Endpoint | Purpose |29|---|---|30| `GET /api/finance/ar-aging?as_of=YYYY-MM-DD` | A/R aging with customer names, balances, aging buckets |31| `GET /api/finance/billing-snapshot?as_of=YYYY-MM-DD` | Billing snapshot with current ARR per account |32| `GET /api/opportunities?start=YYYY-MM-DD&end=YYYY-MM-DD` | CRM pipeline: won, lost, open opportunities with product lines |3334### Operations Context35| Endpoint | Purpose |36|---|---|37| `GET /api/hr/summary?quarter=YYYY-QN` | HR headcount, unpaid claims |38| `GET /api/events/performance?event=<name>&quarter=YYYY-QN` | Event orders and revenue |3940### Exports41| Endpoint | Purpose |42|---|---|43| `GET /exports/churn/train.csv` | Churn model training dataset (CSV) |44| `GET /exports/churn/validation.csv` | Churn model validation dataset (CSV) |45| `GET /exports/churn/candidates.csv` | Candidate accounts for churn prediction (CSV) |4647### Additional Endpoints (infer from task needs)48- `GET /api/accounts/<account_id>/usage?start=YYYY-MM&end=YYYY-MM` — product usage data49- `GET /api/accounts/<account_id>/expansion?quarter=YYYY-QN` — expansion pipeline per account5051---5253## Numeric Precision Rules5455| Data type | Precision | Example |56|---|---|---|57| Currency (ARR, revenue, overdue_balance, pipeline, claims) | **2 decimals** | `1416439.47`, `0.00` |58| Percentages (SLA, win_rate, accuracy) | **1 decimal** | `93.3`, `75.0`, `100.0` |59| Churn probability | **3 decimals** | `0.102`, `0.039`, `0.001` |60| Counts (tickets, headcount, orders, rows) | **integer** | `13`, `377`, `445` |61| Risk scores | **integer** | `100`, `60`, `15` |6263---6465## Controlled Vocabularies (Enums)6667### Risk Levels (descending severity)68`critical` > `high` > `medium` > `low`6970### Primary Actions71| Action | When to use |72|---|---|73| `collections_followup` | Overdue receivables present; A/R-driven risk |74| `technical_recovery` | SLA degradation, usage decline, NPS drop; product/tech-driven risk |75| `renewal_save` | Account is in or near a renewal window with elevated risk |76| `executive_qbr` | Strategic/escalation — highest-touch intervention |77| `nurture_monitor` | Low risk; monitor and engage lightly |78| `no_action` | Lowest risk tier; no active intervention needed |7980### Reason Codes81| Code | Trigger |82|---|---|83| `overdue_receivable` | Account has an overdue balance in A/R aging |84| `low_tenure_high_churn` | Low-tenure account in a high-churn segment/cohort |85| `sla_degradation` | SLA compliance below threshold or declining |86| `nps_drop` | NPS declined vs prior period or below benchmark |87| `usage_decline` | Product usage trending down |88| `renewal_window` | Renewal date falls within analysis window or near term |89| `expansion_offset` | Open expansion pipeline partially offsets risk (mitigating factor) |90| `clean_billings` | No overdue balance — billing is current (positive signal) |9192### Metric Sources (use these exact labels)93- `crm_closed_won` — revenue from CRM won deals94- `support_export` — support ticket counts95- `sla_report` — SLA compliance data96- `nps_survey` — NPS survey responses97- `billing_snapshot` — billing/ARR data98- `ar_aging` — accounts receivable aging99- `pipeline_crm` — CRM pipeline/opportunity data100- `event_dashboard` — event performance data101- `hr_report` — HR/headcount data102103### Ticket Trend104`improving` | `worsening` | `flat`105— Compare ticket counts month-over-month across the period. Fewer tickets each month = improving.106107### Accuracy Band (churn model)108`below_70` | `70_to_79` | `80_to_89` | `90_plus`109110### Tenure / Coefficient Direction111`negative` | `positive` | `not_assessed` | `zero`112113### Link Status (A/R to CRM matching)114`linked` | `unlinked`115— When an A/R customer cannot be matched to any CRM account_id, it is `unlinked` and `account_id` is `null`.116117### Review Owner118`solutions_engineering` | `customer_success` | `finance_ops`119120### Agenda Topics (QBR)121`partnership_overview` | `q2_metrics` | `performance_highlights` | `q3_initiatives` | `technical_recovery` | `commercial_expansion`122123---124125## Business Logic Rules126127### Risk Score Computation128Risk score is a composite integer (0-100) derived from these weighted signals:129- Overdue receivables (high weight)130- NPS decline (medium-high weight)131- SLA degradation (medium weight)132- Usage decline (medium weight)133- Renewal window proximity (medium weight)134- Low tenure / high churn segment (medium weight)135- Expansion pipeline partially offsets (subtractive)136137**Score-to-level mapping:**138- 70–100 → `critical`139- 50–69 → `high`140- 20–49 → `medium`141- 0–19 → `low`142143### Reaching for Expansion Pipeline144The `expansion_pipeline` field (in retention boards) is the total open opportunity value for the account within the quarter. Include it even when zero (use `0.0`).145146### Net Revenue Exposure147`net_revenue_exposure = arr_at_risk - open_expansion_pipeline`148Compute to 2 decimal places.149150### ARR at Risk151Sum of `current_arr` for all accounts ranked `critical` or `high`. Compute to 2 decimal places.152153### Overdue Balance154When zero, output `0.0` (not `null`). Add `clean_billings` as a reason code when there is no overdue balance — this is a positive signal.155156### Sorting Rules157- **Risk accounts / action board**: Sort by risk score descending (highest risk first). Within ties, higher ARR first.158- **Overdue follow-ups**: Sort by `customer_name` ascending (alphabetical).159- **QBR metrics**: Order months chronologically.160161### NPS Handling162- Use the **latest** NPS score in the period as `latest_nps`.163- For trends, compare across months. Peak NPS is the highest monthly score.164165### SLA Compliance166Compute from ticket data: `(tickets_within_sla / total_tickets) * 100`, rounded to 1 decimal. If there are 0 tickets, SLA is `100.0`.167168### Support Ticket Counting169Count only "clean" (non-spam, non-duplicate) tickets. The API may return a `clean_ticket_count` or you may need to filter by ticket status.170171### Churn Model Validation172- Read the CSV exports directly; they contain labeled rows.173- `training_rows`: row count of train.csv (excluding header)174- `validation_rows`: row count of validation.csv (excluding header)175- `feature_count`: number of feature columns (excluding ID and label columns)176- `accuracy_pct`: from the model metadata or computed from validation results177- `tenure_coefficient_direction`: extracted from model coefficients; `negative` means higher tenure → lower churn risk178- Accuracy band is binned from accuracy_pct179180### Churn Candidate Ranking181- Read candidates.csv for the candidate accounts listed in the prompt.182- Rank by `predicted_churn_probability` descending, take top 5.183- Map churn probability to outreach action:184 - ≥ 0.05 → `collections_followup` or `renewal_save` (depending on root cause)185 - 0.01–0.05 → `renewal_save` or `technical_recovery`186 - < 0.01 → `nurture_monitor`187188### A/R-to-CRM Linking189- Take customer names from the A/R aging endpoint.190- Match against CRM accounts by name (fuzzy — watch for "Inc.", "LLC", "Ltd.", "Group" suffix variations).191- If a match is found: `link_status = "linked"`, populate `account_id`.192- If no match: `link_status = "unlinked"`, `account_id = null`.193194### Policy Codes195Policy codes appear in responses from the API itself. Read them from the API response payloads — do not invent them. Common code families:196- `RS-*` — risk scoring protocol197- `REV-*` — revenue/ARR source198- `SUP-*` — support hygiene199- `ACT-*` — action priority200- `RCP-*` — receivable trigger201- `CM-*` — CRM match rules202- `PW-*` — pipeline window203- `FS-*` — follow-up scope204- `MOD-*` — model protocol (churn)205- `PRB-*` — probability scale (churn)206- `DEP-*` — deployment rules (churn)207- `OUT-*` — outreach mapping (churn)208- `BORD-*` — board sort order209- `EXP-*` — exposure formula210- `CAL-*` — calendar policy211212**Always include the policy_codes block** when the answer template has one. Copy the codes from the relevant API response(s).213214### Follow-up Due Dates215When the task gives due dates by action type, use them exactly:216- `collections_followup` → typically 15 days after as-of date217- `technical_recovery` → typically 18 days after as-of date218- `renewal_save` → typically 22 days after as-of date219- `executive_qbr` → typically 29 days after as-of date220- `nurture_monitor` → typically 36 days after as-of date221222The exact dates will be provided in the task prompt. For `no_action`, `next_touch_due_date` is `null`.223224### Portfolio / Segment Summaries225- `accounts_reviewed`: total accounts evaluated226- `critical_or_high_count`: count of accounts with risk_level critical or high227- `collections_count`: count of accounts with primary_action `collections_followup`228- `technical_recovery_count`: count of accounts with primary_action `technical_recovery`229- `strategic_accounts` / `enterprise_accounts`: from account segment field in API230231---232233## Workflow Procedure234235### Step 1: Orient2361. Read `environment_access.md` for the base URL.2372. Read the task prompt. Extract: task type, account IDs, date ranges, as-of dates, quarter, months, and any special parameters.2383. Read `input/payloads/answer_template.json` to understand the required output shape, enum options, and which sections are expected.239240### Step 2: Fetch Data2411. Determine which endpoint families are needed based on the output shape and task description.2422. Call each endpoint with the correct parameters. Use the date formats exactly: `YYYY-MM-DD` for dates, `YYYY-MM` for months, `YYYY-QN` for quarters.2433. For per-account endpoints, iterate over all specified account_ids.2444. For churn tasks, fetch the CSV exports and parse them.245246### Step 3: Compute & Transform2471. Apply the numeric precision rules consistently.2482. Compute derived values (risk scores, averages, sums, win rates) from raw API data.2493. Map raw signals to controlled enum values using the vocabularies above.2504. Sort lists according to the sorting rules.2515. Compute segment summaries by aggregating over the ranked accounts.252253### Step 4: Assemble Output2541. Start from the answer template structure.2552. Populate every field. Never omit a key from the template.2563. Use `null` for genuinely absent values (e.g., `account_id` for unlinked customers, `next_touch_due_date` for no_action).2574. Use `0.0` (not null) for zero-value currency/percentage fields.2585. Include policy_codes read from API responses.2596. Output **pure JSON only** — no markdown fences, no explanatory text, no trailing commas.260261---262263## Pitfalls & Edge Cases2642651. **Port mismatch**: Task prompts say port 8074; always use port 8004 from environment_access.md.2662. **A/R customer name variants**: "North Star Finance Services" vs "Northstar Finance Group Inc." — these are different entities. Match carefully; when in doubt, leave unlinked.2673. **Zero tickets in a month**: SLA compliance is 100.0, not undefined.2684. **Multiple NPS scores per month**: Use the most recent survey response within that month.2695. **Null vs 0.0**: Currency fields use `0.0` for zero, `null` only when the data is genuinely absent (e.g., account_id for unlinked).2706. **Sort stability**: When risk scores tie, use ARR descending as secondary sort. When names tie (unlikely), preserve API order.2717. **Policy codes are read, not computed**: Don't guess policy codes. They come from the API response payloads. If an endpoint doesn't return them, the code may be embedded in a different endpoint's response.2728. **Month format consistency**: API path params use `YYYY-MM`, date range params use `YYYY-MM-DD`. Don't mix them.2739. **CSV parsing**: The churn exports have a header row. `training_rows` = total rows minus 1 (the header). Feature count = total columns minus label and ID columns.27410. **Expansion pipeline is additive**: An account can have both risk signals AND expansion pipeline — `expansion_offset` is a reason code, not a risk eliminator. It offsets but doesn't cancel risk.27511. **Output is always pure JSON**: Never wrap in ```json fences or add commentary. The evaluator expects raw parseable JSON.