# COWS

COWS

Status: LIVE
Price: $0.005 USDC
`GET /api/calc/cows`
HTML: https://magentlab.com/docs/cows
Markdown: https://magentlab.com/docs/cows.md

Not a medical device. Not a diagnosis, dose, or listing recommendation.

## What it computes

Sum the eleven Wesson 2003 Clinical Opiate Withdrawal Scale (COWS) items from caller-assigned appendix integers and return the published total (max 48) with the published severity cutoffs.

## When to use

When an agent has already assigned Wesson 2003 appendix integers for each COWS sign and needs the published total and severity, not a buprenorphine induction protocol.

## When not to use

- Not a diagnosis and not a buprenorphine, methadone, or other opioid-agonist induction or treatment protocol.
- Items are caller-assigned Wesson 2003 appendix integers only. magent does not observe the patient.
- Each sign accepts only the integers printed for that sign in the Wesson 2003 appendix (NIDA reprint of the same scale). Other integers return invalid_cows_item.
- Published severity is 5-12 mild, 13-24 moderate, 25-36 moderately severe, and >36 severe. Scores 0-4 are below the published mild cutoff and return severity none; that is not a new clinical stage.

## Formula

```
COWS = resting_pulse_rate + gi_upset + sweating + tremor + restlessness + yawning + pupil_size + anxiety_or_irritability + bone_or_joint_aches + gooseflesh_skin + runny_nose_or_tearing; Wesson 2003 appendix integers only; max 48
```

## Citation

[The Clinical Opiate Withdrawal Scale (COWS)](https://doi.org/10.1080/02791072.2003.10400007)
Wesson DR, Ling W
J Psychoactive Drugs. 2003;35(2):253-259
DOI: [10.1080/02791072.2003.10400007](https://doi.org/10.1080/02791072.2003.10400007)

## Worked example

### All items 0

Given: `anxiety_or_irritability=0, bone_or_joint_aches=0, gi_upset=0, gooseflesh_skin=0, pupil_size=0, resting_pulse_rate=0, restlessness=0, runny_nose_or_tearing=0, sweating=0, tremor=0, yawning=0`

1. resting_pulse_rate 0 + gi_upset 0 + sweating 0 + tremor 0 + restlessness 0 + yawning 0 + pupil_size 0 + anxiety_or_irritability 0 + bone_or_joint_aches 0 + gooseflesh_skin 0 + runny_nose_or_tearing 0
2. Score = 0 (max 48); severity none (below published mild 5-12)


### Every item at its printed maximum

Given: `anxiety_or_irritability=4, bone_or_joint_aches=4, gi_upset=5, gooseflesh_skin=5, pupil_size=5, resting_pulse_rate=4, restlessness=5, runny_nose_or_tearing=4, sweating=4, tremor=4, yawning=4`

1. 4+5+4+4+5+4+5+4+4+5+4 = 48
2. Score = 48 (max 48); severity severe (>36)


## Also searched as

- COWS
- Clinical Opiate Withdrawal Scale
- opioid withdrawal scale
- Wesson COWS
- opiate withdrawal score
- COWS score
- Clinical Opioid Withdrawal Scale

## Parameters

- `resting_pulse_rate` (integer, required): Caller-assigned Wesson 2003 resting pulse rate points (integer 0, 1, 2, or 4). magent does not observe the patient.
- `gi_upset` (integer, required): Caller-assigned Wesson 2003 GI upset points (integer 0, 1, 2, 3, or 5). magent does not observe the patient.
- `sweating` (integer, required): Caller-assigned Wesson 2003 sweating points (integer 0, 1, 2, 3, or 4). magent does not observe the patient.
- `tremor` (integer, required): Caller-assigned Wesson 2003 tremor points (integer 0, 1, 2, or 4). magent does not observe the patient.
- `restlessness` (integer, required): Caller-assigned Wesson 2003 restlessness points (integer 0, 1, 3, or 5). magent does not observe the patient.
- `yawning` (integer, required): Caller-assigned Wesson 2003 yawning points (integer 0, 1, 2, or 4). magent does not observe the patient.
- `pupil_size` (integer, required): Caller-assigned Wesson 2003 pupil size points (integer 0, 1, 2, or 5). magent does not observe the patient.
- `anxiety_or_irritability` (integer, required): Caller-assigned Wesson 2003 anxiety or irritability points (integer 0, 1, 2, or 4). magent does not observe the patient.
- `bone_or_joint_aches` (integer, required): Caller-assigned Wesson 2003 bone or joint aches points (integer 0, 1, 2, or 4). magent does not observe the patient.
- `gooseflesh_skin` (integer, required): Caller-assigned Wesson 2003 gooseflesh skin points (integer 0, 3, or 5). magent does not observe the patient.
- `runny_nose_or_tearing` (integer, required): Caller-assigned Wesson 2003 runny nose or tearing points (integer 0, 1, or 4). magent does not observe the patient.

## Bulk (POST)

POST the same path with a JSON items array. The first item is the GET unit; each additional item is $0.002. Invalid items return HTTP 400 before settlement.

Method: `POST /api/calc/cows`
Max items: 25
Price: unit_amount + extra_item_amount * (n - 1) (unit 5000 atomic, extra 2000 atomic)
Status: PREVIEW

- 1 to 25 items. Each item uses the same keys as the GET query parameters.
- POST of 1 item costs the same as GET. Lists longer than 25: chunk into multiple POSTs. Extra items still execute; do not pad dummy rows.
- The first invalid item fails the whole request (index in the 400 JSON). You are not charged.
- HTTP 200 is {count, path, items}. Each items[i] is the GET 200 body for that row.
- Catalog misses (empty matches, found=false) stay paid 200s inside that slot.
- x402 resource URL is this path plus n and body_sha256. Browsers that prefer text/html get the same paywall as GET; Pay retries POST with the same items.

Example request:

```json
{
  "items": [
    {
      "anxiety_or_irritability": "0",
      "bone_or_joint_aches": "0",
      "gi_upset": "0",
      "gooseflesh_skin": "0",
      "pupil_size": "0",
      "resting_pulse_rate": "0",
      "restlessness": "0",
      "runny_nose_or_tearing": "0",
      "sweating": "0",
      "tremor": "0",
      "yawning": "0"
    },
    {
      "anxiety_or_irritability": "0",
      "bone_or_joint_aches": "0",
      "gi_upset": "0",
      "gooseflesh_skin": "0",
      "pupil_size": "0",
      "resting_pulse_rate": "0",
      "restlessness": "0",
      "runny_nose_or_tearing": "0",
      "sweating": "0",
      "tremor": "0",
      "yawning": "0"
    }
  ]
}
```

Human paywall (two-item fixture): https://api.magentlab.com/paywall/bulk/cows

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/cows",
  "items": [
    {
      "components": [
        {
          "value": 0,
          "factor": "resting_pulse_rate",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "gi_upset",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "sweating",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "tremor",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "restlessness",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "yawning",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "pupil_size",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "anxiety_or_irritability",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "bone_or_joint_aches",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "gooseflesh_skin",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "runny_nose_or_tearing",
          "points": 0,
          "present": true
        }
      ],
      "severity": "none",
      "disclaimer": "Not a medical device. Deterministic published-formula or published-code output for autonomous agents. A licensed clinician remains responsible for patient care and billing submissions.",
      "citation": {
        "authors": "Wesson DR, Ling W",
        "doi": "10.1080/02791072.2003.10400007",
        "id": "wesson-2003",
        "pmid": "12924748",
        "source": "J Psychoactive Drugs. 2003;35(2):253-259",
        "title": "The Clinical Opiate Withdrawal Scale (COWS)"
      },
      "formula": "cows",
      "formula_expression": "COWS = resting_pulse_rate + gi_upset + sweating + tremor + restlessness + yawning + pupil_size + anxiety_or_irritability + bone_or_joint_aches + gooseflesh_skin + runny_nose_or_tearing; Wesson 2003 appendix integers only; max 48",
      "max_score": 48,
      "score": 0
    },
    {
      "components": [
        {
          "value": 0,
          "factor": "resting_pulse_rate",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "gi_upset",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "sweating",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "tremor",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "restlessness",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "yawning",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "pupil_size",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "anxiety_or_irritability",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "bone_or_joint_aches",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "gooseflesh_skin",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "runny_nose_or_tearing",
          "points": 0,
          "present": true
        }
      ],
      "severity": "none",
      "disclaimer": "Not a medical device. Deterministic published-formula or published-code output for autonomous agents. A licensed clinician remains responsible for patient care and billing submissions.",
      "citation": {
        "authors": "Wesson DR, Ling W",
        "doi": "10.1080/02791072.2003.10400007",
        "id": "wesson-2003",
        "pmid": "12924748",
        "source": "J Psychoactive Drugs. 2003;35(2):253-259",
        "title": "The Clinical Opiate Withdrawal Scale (COWS)"
      },
      "formula": "cows",
      "formula_expression": "COWS = resting_pulse_rate + gi_upset + sweating + tremor + restlessness + yawning + pupil_size + anxiety_or_irritability + bone_or_joint_aches + gooseflesh_skin + runny_nose_or_tearing; Wesson 2003 appendix integers only; max 48",
      "max_score": 48,
      "score": 0
    }
  ]
}
```

## Response fields

- `formula` (string): cows
- `formula_expression` (string): Exact expression used
- `score` (integer): COWS points 0-48
- `max_score` (integer): 48
- `severity` (string): Wesson 2003 appendix: none (0-4, below mild), mild (5-12), moderate (13-24), moderately_severe (25-36), severe (>36)
- `components` (array): Per-item caller-assigned points
- `citation` (object): Wesson and Ling J Psychoactive Drugs 2003 citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "components": [
    {
      "value": 0,
      "factor": "resting_pulse_rate",
      "points": 0,
      "present": true
    },
    {
      "value": 0,
      "factor": "gi_upset",
      "points": 0,
      "present": true
    },
    {
      "value": 0,
      "factor": "sweating",
      "points": 0,
      "present": true
    },
    {
      "value": 0,
      "factor": "tremor",
      "points": 0,
      "present": true
    },
    {
      "value": 0,
      "factor": "restlessness",
      "points": 0,
      "present": true
    },
    {
      "value": 0,
      "factor": "yawning",
      "points": 0,
      "present": true
    },
    {
      "value": 0,
      "factor": "pupil_size",
      "points": 0,
      "present": true
    },
    {
      "value": 0,
      "factor": "anxiety_or_irritability",
      "points": 0,
      "present": true
    },
    {
      "value": 0,
      "factor": "bone_or_joint_aches",
      "points": 0,
      "present": true
    },
    {
      "value": 0,
      "factor": "gooseflesh_skin",
      "points": 0,
      "present": true
    },
    {
      "value": 0,
      "factor": "runny_nose_or_tearing",
      "points": 0,
      "present": true
    }
  ],
  "severity": "none",
  "disclaimer": "Not a medical device. Deterministic published-formula or published-code output for autonomous agents. A licensed clinician remains responsible for patient care and billing submissions.",
  "citation": {
    "authors": "Wesson DR, Ling W",
    "doi": "10.1080/02791072.2003.10400007",
    "id": "wesson-2003",
    "pmid": "12924748",
    "source": "J Psychoactive Drugs. 2003;35(2):253-259",
    "title": "The Clinical Opiate Withdrawal Scale (COWS)"
  },
  "formula": "cows",
  "formula_expression": "COWS = resting_pulse_rate + gi_upset + sweating + tremor + restlessness + yawning + pupil_size + anxiety_or_irritability + bone_or_joint_aches + gooseflesh_skin + runny_nose_or_tearing; Wesson 2003 appendix integers only; max 48",
  "max_score": 48,
  "score": 0
}
```

## Errors

- HTTP 400 `invalid_cows_item`: each COWS item must be a Wesson 2003 appendix integer for that sign (not an arbitrary 0-5). Returned before settlement; you are not charged.
- HTTP 400 `invalid_items`: POST body must be a JSON object with only an items array Returned before settlement; you are not charged.
- HTTP 400 `invalid_item_count`: items must be an array of 1 to 25 objects Returned before settlement; you are not charged.
- HTTP 400 `invalid_item`: each items entry must be a JSON object Returned before settlement; you are not charged.

Shared HTTP 402 and 503: https://magentlab.com/docs/payments

## Related tools

- [CIWA-Ar](https://magentlab.com/docs/ciwa-ar) — Sum the ten Sullivan 1989 CIWA-Ar items (nine caller-assigned 0-7 plus orientation 0-4) and return the published total (max 67).
- [CAGE](https://magentlab.com/docs/cage) — Sum the four Ewing 1984 CAGE items and return whether two or more answers are affirmative.
- [AUDIT-C](https://magentlab.com/docs/audit-c) — Sum three caller-assigned Bush 1998 AUDIT-C integers (0-4) and return this paper's ≥3 and ≥4 screens.

## Payment

Unpaid requests return HTTP 402 even if query parameters or POST items are missing or invalid, so CDP and agents can index the path. After a PAYMENT-SIGNATURE, invalid params return HTTP 400 JSON before settlement. magent does not charge. Fix the params, then request a new 402 quote for that complete URL. Catalog misses (empty matches, found=false) are valid paid 200s.

- GET the tool with Accept: application/json (do not send Accept: text/html unless you want the human paywall).
- HTTP 402 means you have not paid. Decode the base64 PAYMENT-REQUIRED header. HTTP 503 is not a new quote.
- Sign accepts[0] (exact, EIP-3009) with validBefore = now + maxTimeoutSeconds (600 seconds), or accepts[1] (batch-settlement deposit/voucher) on product GET. Ping and POST {items} stay exact. Magent retries transient facilitator 429/5xx before answering.
- Retry the same URL with PAYMENT-SIGNATURE (base64 JSON echoing accepted, payload, and extensions when present).
- Success is HTTP 200 JSON plus PAYMENT-RESPONSE. exact settles before the tool. batch-settlement verifies (and deposit-settles) before the tool and commits the charge after HTTP 2xx. HTTP 503: retry the same PAYMENT-SIGNATURE. Mint a new exact nonce only after a new HTTP 402.

- offered `exact` on eip155:8453: Fixed-price USDC on Base. The buyer authorizes the advertised amount (EIP-3009). magent settles before the tool runs (paymentFlow upfront). extra.assetTransferMethod=eip3009 extra.paymentFlow=upfront.
- offered `batch-settlement` on eip155:8453: Payment-channel vouchers claimed later in batches. Exact stays accepts[0]. Same-path POST {items} is still exact. extra.assetTransferMethod=eip3009 extra.paymentFlow=authorization.

- not offered `upto`: Not offered. Usage-based: buyer authorizes a ceiling, seller settles the actual amount after work. Reserved for a future metered tool. Not for current calculators or code search.

Same-path POST {items} is still scheme exact: one EIP-3009 authorization for GET unit plus $0.002 per extra item. That is not x402 batch-settlement (payment channels / vouchers).

Shared HTTP 402 and 503 table: https://magentlab.com/docs/payments

Stdio MCP (one process per host): https://magentlab.com/docs/mcp

## Guarantees

- HTTP 402 is unpaid, including a missing query. After PAYMENT-SIGNATURE, invalid parameters return HTTP 400 before settlement. You are not charged.
- exact: settlement finishes before the tool (paymentFlow upfront). batch-settlement: verify/deposit before the tool; chargedCumulativeAmount commits after HTTP 2xx. Uncertain or failed settlement fails closed (HTTP 503). Retry the same PAYMENT-SIGNATURE.
- HTTP 402 is unpaid only. Do not sign a second authorization because of a 503.
- Execution is timeout-bounded and concurrency-capped.
- Calculator inputs are stored encrypted for allowlisted operators (Magent Console). They are not in public logs, SSH lookups, catalog, or rollups. Request logs store path without query.
