Account

Set or clear a key's daily and monthly spend caps

Sets or clears the spend caps on one of the session's own active API keys. A cap is the most the key may spend on metered company-data reads per Europe/Oslo calendar day (daily_cap_ore) or Europe/Oslo calendar month (monthly_cap_ore), in whole øre. Send either field or both; a field left out keeps its stored value, null clears it, 0 refuses every metered call. When a metered call would take the key's spend in the current day or month past a cap, it is refused BEFORE the debit with 402 SPEND_CAP_REACHED (nothing charged, no ledger row) naming the cap and resets_at. Spend is the key's debits in the window minus refunded ones. Caps apply only while credit enforcement is live; in shadow mode nothing is debited, so nothing is counted. Successful metered responses on a capped key carry _meta.spend_cap_remaining_nok. Session-cookie auth; the write is scoped to the session's consumer. The 404 collapses wrong owner, revoked key and unknown id (IDOR defence, as on DELETE). Inline rate limit 30 changes/hour per consumer, fail-CLOSED. Repeating the same request sets the same values again (each accepted call writes one audit row).

patch/api/v1/account/keys/{id}

Request

  • Base URL: https://www.apier.no
  • URL: https://www.apier.no/api/v1/account/keys/{id}
  • Auth: API key in cookie sb-access-token

Path parameters

idstring uuid required

Key id (UUID). 400 if not a valid UUID — the boundary Zod parse rejects before any DB call.

Request body

daily_cap_oreinteger nullable

Most this key may spend on metered calls per Europe/Oslo calendar day, in whole øre (100 øre = NOK 1). 0 refuses every metered call (a freeze). null clears the cap. Leave the field out to keep the stored value.

monthly_cap_oreinteger nullable

Most this key may spend on metered calls per Europe/Oslo calendar month, in whole øre (100 øre = NOK 1). 0 refuses every metered call (a freeze). null clears the cap. Leave the field out to keep the stored value.

Response

Caps stored. data echoes both caps as they now stand (null = no cap).

successtrue required

Example response

{
  "_meta": {
    "rulebook_version": "v1.0.0",
    "source": "apier.no",
    "data_source": "Brønnøysund Enhetsregisteret + Apier Universal Rulebook",
    "schema_version": "1.0.0",
    "legal_basis": "NLOD — public registry reuse",
    "response_timestamp": "2026-04-24T12:00:00.000Z",
    "response_hash": "sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    "source_snapshot_id": "brreg-2026-04-24T02:00:00.000Z",
    "cost_nok": 0.5,
    "wallet_remaining_nok": 9.5,
    "spend_cap_remaining_nok": 12.5
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.