Skip to Content
NotebooksPDFE-signing

E-signing

Download notebook (.ipynb)

List your signing sessions with the Indox SDK. Creating a session, resending an invite and requesting the one-time code all email the participants, so they run only with SEND_EMAILS = True.

Config

Add your settings to the repo .env (local) or Colab Secrets — this cell reads them with get(...): INDOX_API_KEY (your ak_… key) and INDOX_BASE_URL (https://indox.org; the SDK adds /api/v1/… itself). A missing key stops here with its name.

import json, logging, re, sys, tempfile from pathlib import Path REPO = Path.cwd().parents[1] sys.path[:0] = [str(REPO), str(REPO / "languages" / "python")] try: from google.colab import userdata get = userdata.get except ImportError: from tools.env import require_env as get from indox_client import Indox logging.basicConfig(format="→ %(message)s", force=True) logging.getLogger("urllib3.connectionpool").setLevel(logging.DEBUG) def _mask(record): record.msg = re.sub(r"/(public|sign)/[^/ ]+", r"/\1/***", record.getMessage()) record.args = () return True logging.getLogger("urllib3.connectionpool").addFilter(_mask) def show(data, limit=2500): print(json.dumps(data, indent=2, default=str)[:limit]) client = Indox(api_key=get("INDOX_API_KEY"), base_url=get("INDOX_BASE_URL")) start_credits = client.billing.credits_balance()["credit_amount"] SAMPLES = REPO / "colab" out = Path(tempfile.mkdtemp()) pdf = SAMPLES / "pdf" / "samples" / "bitcoin.pdf" SEND_EMAILS = False
sessions = client.pdf.list_signing_sessions(limit=5) show(sessions) assert sessions["limit"] == 5 and isinstance(sessions["sessions"], list)
if SEND_EMAILS: session = client.pdf.create_signing_session(pdf, emails=[get("INDOX_EMAIL")], title="SDK demo") show(session) assert session["participants"] status = client.pdf.get_signing_session(session["id"]) show(status) resent = client.pdf.resend_signing_invite(session["id"], session["participants"][0]["id"]) show(resent) else: print("skipped: create_signing_session / resend_signing_invite email the participants (SEND_EMAILS = False)")
if SEND_EMAILS: token = input("sign token from the invite link: ") view = client.pdf.get_sign_token(token) show(view) show(client.pdf.request_sign_otp(token)) signed = client.pdf.submit_sign(token, input("one-time code from the email: ")) show(signed) else: print("skipped: request_sign_otp emails the code that submit_sign(token, otp) needs (SEND_EMAILS = False)")

Usage

now = client.billing.credits_balance()["credit_amount"] print(f"credits used by this notebook: {start_credits - now} (balance {now})") show(client.billing.usage_by_feature())