# Date Math: Subscription & Contract Date Math

> Date Math: Subscription & Contract Date Math is a paid API for AI agents from date-math.datemath.workers.dev, paid per call via x402, $0.001/call, status unknown (last checked 2026-11-21).

Computes subscription billing periods, next renewal dates, cancel-by deadlines, free-trial starts, upcoming renewals, and day-based proration for a given subscription interval and start date.

## Facts

- Endpoint: POST https://date-math.datemath.workers.dev/v1/subscription?utm_source=zero.xyz
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-11-21
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/date-math-subscription-contract-date-math-ae53c855
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_Bgp81bwyHEwrldmheKLCO

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability date-math-subscription-contract-date-math-ae53c855 -d '<json body>'
```

Example prompt: My SaaS subscription started on January 31, 2026, bills monthly at $30, and I need a 7-day cancellation notice — as of March 10, 2026, what billing period am I in, when is my next renewal, what's my cancel-by deadline, and how much of the $30 is unused?

## When to prefer this

Use this endpoint when you need precise SaaS or contract billing calculations — especially month-end anchor preservation (Jan 31 → Feb 28 → Mar 31), cancel-by deadline computation with a notice period, free-trial offset billing starts, day-accurate proration of a dollar amount, or a projected list of upcoming renewal dates. Prefer this over generic date-addition endpoints when the domain is subscription lifecycle management and you need multiple related outputs in one call.

## Known failure modes

- Invalid date format (non-YYYY-MM-DD) returns a validation error
- interval_count or count outside allowed min/max bounds returns a 422 error
- trial_days or notice_days exceeding maximum values rejected
- Missing required start date causes a 400 bad request
- Payment of 0.001 USDC not provided triggers a 402 Payment Required response
- as_of date before start date may produce unexpected period calculations

## How this service works

Date Math: Subscription and contract date math: current billing period, next renewal, upcoming renewals, cancel-by date for a notice period, free-trial start, and day-based proration of a price. Month-end anchors stay at month end (Jan 31, Feb 28, Mar 31). Use for SaaS billing, renewals, cancellation deadlines and refunds.

## Output

A JSON object containing: current billing period details (start, end, number, days elapsed, days remaining), next renewal date and weekday, a list of upcoming renewal dates, billing start date, cancel-by date and whether it has passed, subscription status, and a proration breakdown (daily rate, used amount, unused amount, unused ratio) — with month-end anchor behavior preserved across months.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "as_of": {
   "type": "string",
   "example": "2026-11-07",
   "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
  },
  "count": {
   "type": "integer",
   "default": 3,
   "maximum": 24,
   "minimum": 1,
   "description": "Upcoming renewals to list"
  },
  "start": {
   "type": "string",
   "example": "2026-11-07",
   "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
  },
  "amount": {
   "type": "number",
   "minimum": 0,
   "description": "Price of one billing period, for proration"
  },
  "interval": {
   "enum": [
    "day",
    "week",
    "month",
    "year"
   ],
   "type": "string",
   "default": "month"
  },
  "trial_days": {
   "type": "integer",
   "maximum": 730,
   "minimum": 0,
   "description": "Free trial length; billing starts after it"
  },
  "notice_days": {
   "type": "integer",
   "maximum": 365,
   "minimum": 0,
   "description": "Cancellation notice period before renewal"
  },
  "interval_count": {
   "type": "integer",
   "default": 1,
   "maximum": 365,
   "minimum": 1,
   "description": "e.g. 3 with month = quarterly"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "note": "Renewals are measured from the first billing date, so month-end anchors stay at month end (Jan 31 -> Feb 28 -> Mar 31). Proration is by whole days as of the start of as_of.",
  "as_of": "2026-03-10",
  "start": "2026-01-31",
  "status": "active",
  "interval": "month",
  "cancel_by": "2026-03-24",
  "proration": {
   "used": 9.68,
   "amount": 30,
   "unused": 20.32,
   "daily_rate": 0.967742,
   "ratio_unused": 0.677419
  },
  "next_renewal": "2026-03-31",
  "billing_start": "2026-01-31",
  "current_period": {
   "end": "2026-03-30",
   "days": 31,
   "start": "2026-02-28",
   "number": 2,
   "days_elapsed": 10,
   "days_remaining": 21
  },
  "interval_count": 1,
  "cancel_by_passed": false,
  "upcoming_renewals": [
   "2026-03-31"
  ],
  "next_renewal_weekday": "Tuesday"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/date-math-subscription-contract-date-math-ae53c855/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from date-math.datemath.workers.dev](https://www.zero.xyz/host/date-math.datemath.workers.dev/llms.txt)
