An agent loop that faxes a document on the sandbox with the Python SDK.
pip install faxforagents # until it is on PyPI: pip install "faxforagents @ git+https://github.com/faxforagents/sdk-python@main"
export FAXFORAGENTS_API_KEY=ffa_test_... # created at https://app.faxforagents.com
python agent.py --to +15550000001 --text "Hello from an agent."What it does, in order.
documents.create(ordocuments.uploadfor a PDF or an image: PNG, JPG, TIFF) turns the input into an immutable document with a sha256 and a page count.quotes.createprices that document to that destination. The quote lives ten minutes.- When the quote says
authorization_required,policies.evaluateis the dry run. If no policy allows the send,approvals.requestopens a request and the loop waits for a person. faxes.createqueues the fax with anIdempotency-Key. The answer isqueued, never delivered.faxes.waitpolls untildelivered,partial,failedorunknown.
The exit code is 0 only for delivered with evidence. partial and unknown return 1 and the loop
never resends on its own. For unknown it opens a help request so a person reconciles.
Try the other sandbox outcomes with the destination: +15550000003 is partial, +15550000004 is no
answer, +15550000005 is unknown.