# calendar.business-days

Count business days in [startDate, endDate) or add signed business days from startDate. Weekends and observed public holidays are excluded.

- REST: `POST https://api.kanagu.dev/v1/calendar/business-days`
- MCP tool: `calendar.business-days` at https://api.kanagu.dev/mcp
- Price: $0.001 USD per successful call. Trial: 10 calls per IP per UTC day without a key, shared by REST and MCP.
- Auth: `Authorization: Bearer <key>` for billed calls. Retries: reuse `Idempotency-Key`.

## Request body

- `country` ("AD" | "AE" | "AG" | "AI" | "AL" | "AM" | … (207 values), required): Country or territory code. GB defaults to England and Wales.
- `subdivision` (string (max 24 chars)): date-holidays subdivision code, e.g. CA or US-CA, BY or DE-BY, SCT or GB-SCT.
- `startDate` (string (date), required): Calendar date (YYYY-MM-DD), 2020–2035.

Then exactly one of these shapes:

1. With endDate:

- `endDate` (string (date), required): Exclusive end date (2020–2035).

2. With days:

- `days` (integer (-4000 to 4000), required): Signed number of business days. The start date is skipped.

## Response

- `country` ("AD" | "AE" | "AG" | "AI" | "AL" | "AM" | … (207 values), required): Country or territory code. GB defaults to England and Wales.
- `businessDays` (integer (-9007199254740991 to 9007199254740991)): Count mode result.
- `date` (string (date)): Add mode result.

## Example

```sh
curl https://api.kanagu.dev/v1/calendar/business-days \
  -H "Authorization: Bearer $KANAGU_KEY" \
  -H "Content-Type: application/json" \
  -d '{"country":"US","startDate":"2026-11-25","days":2}'
```

```ts
const res = await fetch("https://api.kanagu.dev/v1/calendar/business-days", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KANAGU_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "country": "US",
    "startDate": "2026-11-25",
    "days": 2
  }),
});
if (!res.ok) throw new Error((await res.json()).error.message);
const result = await res.json();
```

## Errors

JSON `{"error":{"code","message"}}`.

- 400 `invalid_input`: The body does not match the request schema. The message names each field.
- 400 `invalid_json`: The body is missing or is not valid JSON.
- 400 `invalid_idempotency_key`: Idempotency-Key must be 1–128 visible ASCII characters.
- 401 `invalid_api_key`: The Bearer key is missing, malformed, invalid or inactive.
- 402 `free_allowance_exhausted`: This month's free usage is used up and the account has no subscription. Subscribe from the dashboard, or wait for the next UTC month; Retry-After gives the seconds left.
- 404 `not_found`: No operation at this path.
- 409 `idempotency_conflict`: The Idempotency-Key was already used with a different body.
- 413 `payload_too_large`: JSON bodies may be at most 64 KiB.
- 429 `trial_limit`: The anonymous trial allows 10 calls per IP per UTC day, shared by REST and MCP. Retry-After gives the seconds left.
- 500 `internal_error`: The call failed on our side. It is not billed; retry with the same Idempotency-Key.

## JSON Schema

Request:
```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "country": {
          "type": "string",
          "enum": [
            "AD",
            "AE",
            "AG",
            "AI",
            "AL",
            "AM",
            "AO",
            "AR",
            "AS",
            "AT",
            "AU",
            "AW",
            "AX",
            "AZ",
            "BA",
            "BB",
            "BD",
            "BE",
            "BF",
            "BG",
            "BH",
            "BI",
            "BJ",
            "BL",
            "BM",
            "BN",
            "BO",
            "BQ",
            "BR",
            "BS",
            "BW",
            "BY",
            "BZ",
            "CA",
            "CC",
            "CD",
            "CF",
            "CG",
            "CH",
            "CI",
            "CK",
            "CL",
            "CM",
            "CN",
            "CO",
            "CR",
            "CU",
            "CV",
            "CW",
            "CX",
            "CY",
            "CZ",
            "DE",
            "DJ",
            "DK",
            "DM",
            "DO",
            "DZ",
            "EC",
            "EE",
            "EG",
            "EH",
            "ER",
            "ES",
            "ET",
            "FI",
            "FJ",
            "FO",
            "FR",
            "GA",
            "GB",
            "GD",
            "GE",
            "GF",
            "GG",
            "GH",
            "GI",
            "GL",
            "GM",
            "GN",
            "GP",
            "GQ",
            "GR",
            "GT",
            "GU",
            "GW",
            "GY",
            "HK",
            "HN",
            "HR",
            "HT",
            "HU",
            "IC",
            "ID",
            "IE",
            "IL",
            "IM",
            "IN",
            "IR",
            "IS",
            "IT",
            "JE",
            "JM",
            "JP",
            "KE",
            "KM",
            "KN",
            "KR",
            "KY",
            "KZ",
            "LC",
            "LI",
            "LK",
            "LR",
            "LS",
            "LT",
            "LU",
            "LV",
            "LY",
            "MA",
            "MC",
            "MD",
            "ME",
            "MF",
            "MG",
            "MK",
            "ML",
            "MQ",
            "MR",
            "MS",
            "MT",
            "MU",
            "MW",
            "MX",
            "MY",
            "MZ",
            "NA",
            "NC",
            "NE",
            "NF",
            "NG",
            "NI",
            "NL",
            "NO",
            "NZ",
            "PA",
            "PE",
            "PF",
            "PH",
            "PK",
            "PL",
            "PM",
            "PR",
            "PT",
            "PY",
            "RE",
            "RO",
            "RS",
            "RU",
            "RW",
            "SA",
            "SC",
            "SD",
            "SE",
            "SG",
            "SH",
            "SI",
            "SJ",
            "SK",
            "SL",
            "SM",
            "SN",
            "SO",
            "SR",
            "SS",
            "ST",
            "SV",
            "SX",
            "SZ",
            "TC",
            "TD",
            "TG",
            "TH",
            "TN",
            "TO",
            "TR",
            "TT",
            "TW",
            "TZ",
            "UA",
            "UG",
            "US",
            "UY",
            "UZ",
            "VA",
            "VC",
            "VE",
            "VG",
            "VI",
            "VN",
            "VU",
            "WF",
            "XK",
            "YT",
            "ZA",
            "ZM",
            "ZW"
          ],
          "description": "Country or territory code. GB defaults to England and Wales."
        },
        "subdivision": {
          "description": "date-holidays subdivision code, e.g. CA or US-CA, BY or DE-BY, SCT or GB-SCT.",
          "type": "string",
          "maxLength": 24,
          "pattern": "^[A-Z0-9]+(?:-[A-Z0-9]+){0,2}$"
        },
        "startDate": {
          "type": "string",
          "format": "date",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
          "description": "Calendar date (YYYY-MM-DD), 2020–2035."
        },
        "endDate": {
          "type": "string",
          "format": "date",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
          "description": "Exclusive end date (2020–2035)."
        }
      },
      "required": [
        "country",
        "startDate",
        "endDate"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "country": {
          "type": "string",
          "enum": [
            "AD",
            "AE",
            "AG",
            "AI",
            "AL",
            "AM",
            "AO",
            "AR",
            "AS",
            "AT",
            "AU",
            "AW",
            "AX",
            "AZ",
            "BA",
            "BB",
            "BD",
            "BE",
            "BF",
            "BG",
            "BH",
            "BI",
            "BJ",
            "BL",
            "BM",
            "BN",
            "BO",
            "BQ",
            "BR",
            "BS",
            "BW",
            "BY",
            "BZ",
            "CA",
            "CC",
            "CD",
            "CF",
            "CG",
            "CH",
            "CI",
            "CK",
            "CL",
            "CM",
            "CN",
            "CO",
            "CR",
            "CU",
            "CV",
            "CW",
            "CX",
            "CY",
            "CZ",
            "DE",
            "DJ",
            "DK",
            "DM",
            "DO",
            "DZ",
            "EC",
            "EE",
            "EG",
            "EH",
            "ER",
            "ES",
            "ET",
            "FI",
            "FJ",
            "FO",
            "FR",
            "GA",
            "GB",
            "GD",
            "GE",
            "GF",
            "GG",
            "GH",
            "GI",
            "GL",
            "GM",
            "GN",
            "GP",
            "GQ",
            "GR",
            "GT",
            "GU",
            "GW",
            "GY",
            "HK",
            "HN",
            "HR",
            "HT",
            "HU",
            "IC",
            "ID",
            "IE",
            "IL",
            "IM",
            "IN",
            "IR",
            "IS",
            "IT",
            "JE",
            "JM",
            "JP",
            "KE",
            "KM",
            "KN",
            "KR",
            "KY",
            "KZ",
            "LC",
            "LI",
            "LK",
            "LR",
            "LS",
            "LT",
            "LU",
            "LV",
            "LY",
            "MA",
            "MC",
            "MD",
            "ME",
            "MF",
            "MG",
            "MK",
            "ML",
            "MQ",
            "MR",
            "MS",
            "MT",
            "MU",
            "MW",
            "MX",
            "MY",
            "MZ",
            "NA",
            "NC",
            "NE",
            "NF",
            "NG",
            "NI",
            "NL",
            "NO",
            "NZ",
            "PA",
            "PE",
            "PF",
            "PH",
            "PK",
            "PL",
            "PM",
            "PR",
            "PT",
            "PY",
            "RE",
            "RO",
            "RS",
            "RU",
            "RW",
            "SA",
            "SC",
            "SD",
            "SE",
            "SG",
            "SH",
            "SI",
            "SJ",
            "SK",
            "SL",
            "SM",
            "SN",
            "SO",
            "SR",
            "SS",
            "ST",
            "SV",
            "SX",
            "SZ",
            "TC",
            "TD",
            "TG",
            "TH",
            "TN",
            "TO",
            "TR",
            "TT",
            "TW",
            "TZ",
            "UA",
            "UG",
            "US",
            "UY",
            "UZ",
            "VA",
            "VC",
            "VE",
            "VG",
            "VI",
            "VN",
            "VU",
            "WF",
            "XK",
            "YT",
            "ZA",
            "ZM",
            "ZW"
          ],
          "description": "Country or territory code. GB defaults to England and Wales."
        },
        "subdivision": {
          "description": "date-holidays subdivision code, e.g. CA or US-CA, BY or DE-BY, SCT or GB-SCT.",
          "type": "string",
          "maxLength": 24,
          "pattern": "^[A-Z0-9]+(?:-[A-Z0-9]+){0,2}$"
        },
        "startDate": {
          "type": "string",
          "format": "date",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
          "description": "Calendar date (YYYY-MM-DD), 2020–2035."
        },
        "days": {
          "type": "integer",
          "minimum": -4000,
          "maximum": 4000,
          "description": "Signed number of business days. The start date is skipped."
        }
      },
      "required": [
        "country",
        "startDate",
        "days"
      ],
      "additionalProperties": false
    }
  ],
  "examples": [
    {
      "country": "US",
      "startDate": "2026-11-25",
      "days": 2
    }
  ],
  "type": "object"
}
```

Response:
```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "country": {
      "type": "string",
      "enum": [
        "AD",
        "AE",
        "AG",
        "AI",
        "AL",
        "AM",
        "AO",
        "AR",
        "AS",
        "AT",
        "AU",
        "AW",
        "AX",
        "AZ",
        "BA",
        "BB",
        "BD",
        "BE",
        "BF",
        "BG",
        "BH",
        "BI",
        "BJ",
        "BL",
        "BM",
        "BN",
        "BO",
        "BQ",
        "BR",
        "BS",
        "BW",
        "BY",
        "BZ",
        "CA",
        "CC",
        "CD",
        "CF",
        "CG",
        "CH",
        "CI",
        "CK",
        "CL",
        "CM",
        "CN",
        "CO",
        "CR",
        "CU",
        "CV",
        "CW",
        "CX",
        "CY",
        "CZ",
        "DE",
        "DJ",
        "DK",
        "DM",
        "DO",
        "DZ",
        "EC",
        "EE",
        "EG",
        "EH",
        "ER",
        "ES",
        "ET",
        "FI",
        "FJ",
        "FO",
        "FR",
        "GA",
        "GB",
        "GD",
        "GE",
        "GF",
        "GG",
        "GH",
        "GI",
        "GL",
        "GM",
        "GN",
        "GP",
        "GQ",
        "GR",
        "GT",
        "GU",
        "GW",
        "GY",
        "HK",
        "HN",
        "HR",
        "HT",
        "HU",
        "IC",
        "ID",
        "IE",
        "IL",
        "IM",
        "IN",
        "IR",
        "IS",
        "IT",
        "JE",
        "JM",
        "JP",
        "KE",
        "KM",
        "KN",
        "KR",
        "KY",
        "KZ",
        "LC",
        "LI",
        "LK",
        "LR",
        "LS",
        "LT",
        "LU",
        "LV",
        "LY",
        "MA",
        "MC",
        "MD",
        "ME",
        "MF",
        "MG",
        "MK",
        "ML",
        "MQ",
        "MR",
        "MS",
        "MT",
        "MU",
        "MW",
        "MX",
        "MY",
        "MZ",
        "NA",
        "NC",
        "NE",
        "NF",
        "NG",
        "NI",
        "NL",
        "NO",
        "NZ",
        "PA",
        "PE",
        "PF",
        "PH",
        "PK",
        "PL",
        "PM",
        "PR",
        "PT",
        "PY",
        "RE",
        "RO",
        "RS",
        "RU",
        "RW",
        "SA",
        "SC",
        "SD",
        "SE",
        "SG",
        "SH",
        "SI",
        "SJ",
        "SK",
        "SL",
        "SM",
        "SN",
        "SO",
        "SR",
        "SS",
        "ST",
        "SV",
        "SX",
        "SZ",
        "TC",
        "TD",
        "TG",
        "TH",
        "TN",
        "TO",
        "TR",
        "TT",
        "TW",
        "TZ",
        "UA",
        "UG",
        "US",
        "UY",
        "UZ",
        "VA",
        "VC",
        "VE",
        "VG",
        "VI",
        "VN",
        "VU",
        "WF",
        "XK",
        "YT",
        "ZA",
        "ZM",
        "ZW"
      ],
      "description": "Country or territory code. GB defaults to England and Wales."
    },
    "businessDays": {
      "description": "Count mode result.",
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "date": {
      "description": "Add mode result.",
      "type": "string",
      "format": "date",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
    }
  },
  "required": [
    "country"
  ],
  "additionalProperties": false
}
```
