Skip to content
Available today

Python SDK

The official library for Python 3.10 or newer, standard library only. Create a task, wait for the decision and check the callback's signature before you act, with a synchronous client and one for `asyncio`.

Where it fits

  1. Python SDK
  2. TaskToHuman
  3. The person who decides
  4. Signed decision back to your code

What it does

  • create_task, get_task, list_tasks (or every page with iter_tasks) and cancel_task; AsyncTaskToHuman does the same with asyncio.
  • wait_for_decision checks the task until a person decides, for scripts, tests and short agent turns; in production, a callback brings the decision.
  • verify_callback checks the TTH-Signature header against the raw body and returns the task, or raises SignatureVerificationError.
  • No dependencies, an idempotency_key on every create and safe retries. Open source under the Apache License 2.0.

Set it up

  1. Run pip install tasktohuman.

  2. Create an API key for the workspace, a test key first, and keep it in TTH_API_KEY. Use it on your server only.

  3. Create a task with create_task, then act on the verified callback, or wait with wait_for_decision.

# pip install tasktohumanimport osfrom tasktohuman import TaskToHumantth = TaskToHuman(os.environ["TTH_API_KEY"])task = tth.create_task(    "approve_refund",    title="Refund €249 to order #4821?",    payload={"order_id": "4821", "amount": 249, "reason": "Arrived damaged"},    callback_url="https://shop.example.com/hooks/tasktohuman",    deadline_minutes=120,    idempotency_key="refund-4821",  # a retry with the same key returns the same task)# task["state"] is "notified"; the decision comes to callback_url, signed.

Put a human where it matters.

Start with one task type and one person to answer it.

Your humans answer from a link, no account needed.