Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

## 0.9.0 (2026-11-15)

Follows API 1.20.10. The saved spec has 163 operations and the models are regenerated from it.
Every operation has a method on both clients.

New parameter: `billing.get_topup_session(topup_session_id, check_checkout=True)` asks Stripe about the hosted Checkout of an open top-up.
The new field `TopupSession.checkout_status` reads `open`, `complete`, `processing` or `expired`, and `None` when not asked.
`complete` means the person paid, and the wallet is credited when Stripe's event arrives. `processing` is a payment that confirms later, such as a bank debit.
The default is `False`, and the request is then the same as in 0.8.0.

New field: `Delivery.webhook_deleted`, which only `DeliveryDetail` had. The API sends it on every delivery.
It is optional on `Delivery`, so a payload without it still parses.
`webhooks.replay_delivery` on a delivery whose webhook was deleted raises `ConflictError` with `details["reason"]` set to `webhook_deleted`.
Deleting a webhook ends the deliveries that were waiting for it. They read `failed`, with no next attempt.

`OneTimeCoverCheck` describes the limits of `create`: `to_name` 120 characters, `subject` 200 and `message` 2,000.
`one_time_sends.check_cover` says a longer field raises `InvalidRequestError`, as `create` does.
`billing.cancel_topup_session` says `details["reason"]` is `paid` when the payment came in before the cancel.
New descriptions on the counters of `PolicyUsage` and on `policy_name` and `version` of `PolicyVerdict` and `PolicyEvaluation`.

Nothing is removed. Other model names, fields and optionality are kept.

## 0.8.0 (2026-11-15)

Follows API 1.20.9. The saved spec has 163 operations and the models are regenerated from it.
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ The same in async form, with `AsyncClient` and `await` on every call.
a document by file name, or a received fax's file by the sender's number.
- `one_time_sends.preview(file=...)` counts the pages of a document before any order exists, with no key.
`one_time_sends.check_cover(message=...)` says whether a cover message fits on its page.
- `billing.get_topup_session(id, check_checkout=True)` asks Stripe about the hosted Checkout of an open
top-up. `checkout_status` reads `open`, `complete`, `processing` or `expired` while the wallet waits
for Stripe's event.
- `faxes.wait(fax_id)` and `approvals.wait(approval_id)` poll with a timeout.
- `verify_webhook(secret, headers, body)` checks the Standard Webhooks signature on a delivery.
- Models are pydantic v2, generated from the public OpenAPI document. Money is an integer count of
Expand Down Expand Up @@ -312,10 +315,11 @@ ruff check src tests && mypy src
sh scripts/truthcheck.sh
```

`spec/openapi.yaml` follows the public document at API version 1.20.9 and keeps the schemas of the earlier live documents.
`spec/openapi.yaml` follows the public document at API version 1.20.10 and keeps the schemas of the earlier live documents.
The two validation error schemas are the exception. 0.5.0 removed them because the server never sent that shape.
0.6.0 removed two cost fields of an extraction, because the server stopped sending them.
0.8.0 replaced five fields it had declared itself with the public ones, such as `Quote.policy_evaluation`.
0.9.0 leaves `Delivery.webhook_deleted` optional, where the public document requires it.
It also retains earlier public model names and route-documented response additions.
To refresh it, merge the live schemas while preserving existing declarations, then run `uv run python scripts/gen_models.py`.
Keep new response fields optional so older payloads and existing callers remain valid.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "faxforagents"
version = "0.8.0"
version = "0.9.0"
description = "Python client for Fax for Agents: a fax API, a hosted MCP server and SDKs built so AI agents can send and receive faxes."
readme = "README.md"
requires-python = ">=3.10"
Expand Down
238 changes: 200 additions & 38 deletions spec/openapi.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/faxforagents/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from __future__ import annotations

__version__ = "0.8.0"
__version__ = "0.9.0"

from faxforagents._http import ORDER_TOKEN_HEADER
from faxforagents.async_client import AsyncClient
Expand Down
37 changes: 30 additions & 7 deletions src/faxforagents/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,10 @@ async def update(
)

async def delete(self, webhook_id: str, *, idempotency_key: str | None = None) -> m.Deleted:
"""Remove a destination. Scope: webhook:admin."""
"""Remove a destination. Scope: webhook:admin.

The deliveries that were waiting for it end at once, as ``failed`` with no next attempt. Every
delivery to it then reads ``webhook_deleted`` true and cannot be replayed."""
return await self._h.request(
"DELETE", f"/v1/webhooks/{webhook_id}", model=m.Deleted, idempotency_key=idempotency_key
)
Expand Down Expand Up @@ -442,7 +445,10 @@ async def get_delivery(self, delivery_id: str) -> m.DeliveryDetail:
return await self._h.request("GET", f"/v1/webhook-deliveries/{delivery_id}", model=m.DeliveryDetail)

async def replay_delivery(self, delivery_id: str, *, idempotency_key: str | None = None) -> m.Delivery:
"""Deliver the event again with the same event id. Scope: webhook:admin."""
"""Deliver the event again with the same event id. Scope: webhook:admin.

A delivery whose ``webhook_deleted`` is true cannot be replayed. It raises ``ConflictError``
with ``details["reason"]`` ``webhook_deleted``."""
return await self._h.request(
"POST",
f"/v1/webhook-deliveries/{delivery_id}/replay",
Expand Down Expand Up @@ -566,9 +572,21 @@ def iter_topup_sessions(self, *, limit: int | None = None) -> AsyncIterator[m.To
"""Every top-up session, following next_cursor."""
return apaginate(self.list_topup_sessions, {"limit": limit})

async def get_topup_session(self, topup_session_id: str) -> m.TopupSession:
"""Read a top-up session. Scope: billing:read."""
return await self._h.request("GET", f"/v1/topup-sessions/{topup_session_id}", model=m.TopupSession)
async def get_topup_session(
self, topup_session_id: str, *, check_checkout: bool = False
) -> m.TopupSession:
"""Read a top-up session. Scope: billing:read.

``check_checkout=True`` also asks Stripe about the hosted Checkout of an open top-up. Its state
is in ``checkout_status``: ``open``, ``complete``, ``processing`` or ``expired``. ``complete``
means the person paid, and the wallet is credited when Stripe's event arrives. ``processing``
means they paid with a method that confirms later, such as a bank debit. ``checkout_status``
is ``None`` when not asked, for a top-up that is not open, or when Stripe could not be read.
The read changes nothing. The default, ``False``, sends no query parameter."""
params = {"check_checkout": True} if check_checkout else None
return await self._h.request(
"GET", f"/v1/topup-sessions/{topup_session_id}", model=m.TopupSession, params=params
)

async def cancel_topup_session(
self, topup_session_id: str, *, idempotency_key: str | None = None
Expand All @@ -578,7 +596,8 @@ async def cancel_topup_session(

Canceling a setup payment also turns off the auto top-up that waited on it. A top-up already
canceled or expired comes back as it is. One that was paid, declined or charged off session
raises ``ConflictError``, with the top-up's status in ``details["status"]``."""
raises ``ConflictError``, with the top-up's status in ``details["status"]``. ``details["reason"]``
is ``paid`` when the payment came in before the cancel."""
return await self._h.request(
"POST",
f"/v1/topup-sessions/{topup_session_id}/cancel",
Expand Down Expand Up @@ -1623,7 +1642,11 @@ async def check_cover(
Pass the cover fields typed so far, as ``create`` takes them, and leave out the rest. ``fits``
says whether the message fits on the one cover page, and ``lines_left`` how many more lines
fit. When it runs over, ``fits_chars`` is how much of its start fits. ``create`` refuses a
cover that does not fit."""
cover that does not fit.

``to_name``, ``subject`` and ``message`` have the limits of ``create``: 120, 200 and 2,000
characters, not counting spaces at either end. A longer one raises ``InvalidRequestError``,
as ``create`` does."""
body = m.OneTimeCoverCheck(
sender_name=sender_name, email=email, to=to, to_name=to_name, subject=subject, message=message
)
Expand Down
35 changes: 28 additions & 7 deletions src/faxforagents/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,10 @@ def update(self, webhook_id: str, *, idempotency_key: str | None = None, **chang
)

def delete(self, webhook_id: str, *, idempotency_key: str | None = None) -> m.Deleted:
"""Remove a destination. Scope: webhook:admin."""
"""Remove a destination. Scope: webhook:admin.

The deliveries that were waiting for it end at once, as ``failed`` with no next attempt. Every
delivery to it then reads ``webhook_deleted`` true and cannot be replayed."""
return self._h.request(
"DELETE", f"/v1/webhooks/{webhook_id}", model=m.Deleted, idempotency_key=idempotency_key
)
Expand Down Expand Up @@ -483,7 +486,10 @@ def get_delivery(self, delivery_id: str) -> m.DeliveryDetail:
return self._h.request("GET", f"/v1/webhook-deliveries/{delivery_id}", model=m.DeliveryDetail)

def replay_delivery(self, delivery_id: str, *, idempotency_key: str | None = None) -> m.Delivery:
"""Deliver the event again with the same event id. Scope: webhook:admin."""
"""Deliver the event again with the same event id. Scope: webhook:admin.

A delivery whose ``webhook_deleted`` is true cannot be replayed. It raises ``ConflictError``
with ``details["reason"]`` ``webhook_deleted``."""
return self._h.request(
"POST",
f"/v1/webhook-deliveries/{delivery_id}/replay",
Expand Down Expand Up @@ -603,9 +609,19 @@ def iter_topup_sessions(self, *, limit: int | None = None) -> Iterator[m.TopupSe
"""Every top-up session, following next_cursor."""
return paginate(lambda p: self.list_topup_sessions(**p), {"limit": limit})

def get_topup_session(self, topup_session_id: str) -> m.TopupSession:
"""Read a top-up session. Scope: billing:read."""
return self._h.request("GET", f"/v1/topup-sessions/{topup_session_id}", model=m.TopupSession)
def get_topup_session(self, topup_session_id: str, *, check_checkout: bool = False) -> m.TopupSession:
"""Read a top-up session. Scope: billing:read.

``check_checkout=True`` also asks Stripe about the hosted Checkout of an open top-up. Its state
is in ``checkout_status``: ``open``, ``complete``, ``processing`` or ``expired``. ``complete``
means the person paid, and the wallet is credited when Stripe's event arrives. ``processing``
means they paid with a method that confirms later, such as a bank debit. ``checkout_status``
is ``None`` when not asked, for a top-up that is not open, or when Stripe could not be read.
The read changes nothing. The default, ``False``, sends no query parameter."""
params = {"check_checkout": True} if check_checkout else None
return self._h.request(
"GET", f"/v1/topup-sessions/{topup_session_id}", model=m.TopupSession, params=params
)

def cancel_topup_session(
self, topup_session_id: str, *, idempotency_key: str | None = None
Expand All @@ -615,7 +631,8 @@ def cancel_topup_session(

Canceling a setup payment also turns off the auto top-up that waited on it. A top-up already
canceled or expired comes back as it is. One that was paid, declined or charged off session
raises ``ConflictError``, with the top-up's status in ``details["status"]``."""
raises ``ConflictError``, with the top-up's status in ``details["status"]``. ``details["reason"]``
is ``paid`` when the payment came in before the cancel."""
return self._h.request(
"POST",
f"/v1/topup-sessions/{topup_session_id}/cancel",
Expand Down Expand Up @@ -1634,7 +1651,11 @@ def check_cover(
Pass the cover fields typed so far, as ``create`` takes them, and leave out the rest. ``fits``
says whether the message fits on the one cover page, and ``lines_left`` how many more lines
fit. When it runs over, ``fits_chars`` is how much of its start fits. ``create`` refuses a
cover that does not fit."""
cover that does not fit.

``to_name``, ``subject`` and ``message`` have the limits of ``create``: 120, 200 and 2,000
characters, not counting spaces at either end. A longer one raises ``InvalidRequestError``,
as ``create`` does."""
body = m.OneTimeCoverCheck(
sender_name=sender_name, email=email, to=to, to_name=to_name, subject=subject, message=message
)
Expand Down
Loading
Loading