View as Markdown

Mandate · Guide

Sign with two parties

Use two-sided agreements when both sides must confirm exactly the same content, such as a services agreement, a consent or an escrow handoff. Each party confirms with a passkey over the document's hash and their own role, so a different copy or a swapped party can't complete the agreement. When both have signed, you get a receipt anyone can verify offline.

Before you begin: export the sandbox account key. Provenance never receives the document, only its SHA-256 hash.

export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5

Limitations: this is evidence of who agreed to which content and when, for your contract or e-signature workflow. It isn't an e-signature service and makes no claim about legal validity.

1. Create the agreement

Hash the document and create the agreement with POST /v1/mandate/agreements. In parallel mode both parties can sign at once; in sequential mode the second party's link opens only after the first signs.

printf 'Services agreement v3 between Brindlecote Supplies and Acme Corp\n' > agreement.txt
export CONTENT_HASH=$(shasum -a 256 agreement.txt | cut -d' ' -f1)

curl -s $PROVENANCE_API/v1/mandate/agreements \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content_hash": "'"$CONTENT_HASH"'",
    "content_description": "Services agreement v3",
    "mode": "parallel",
    "parties": [
      { "label": "Provider", "email": "ops@brindlecote.example" },
      { "label": "Client", "email": "legal@acme.example" }
    ]
  }' | tee agreement.json
export AGREEMENT_ID=$(jq -r .id agreement.json)
export SIGN_TOKEN=$(jq -r '.signing_links[0].url' agreement.json | sed 's#.*/sign/##')

The response, trimmed:

{
  "id": "agr_01M5Q2KJMKC7J3XJPD6BEYMFGB",
  "object": "agreement",
  "content_description": "Services agreement v3",
  "mode": "parallel",
  "status": "pending",
  "parties": [
    { "party_id": "pty_01M5Q2KJMKVY6QJKSJXEA6T7VB", "label": "Provider", "status": "pending", "signed_at": null, "tier": null },
    { "party_id": "pty_01M5Q2KJMKWE1BBYXSTFF2Q836", "label": "Client", "status": "pending", "signed_at": null, "tier": null }
  ],
  "signing_links": [
    { "party_id": "pty_01M5Q2KJMKVY6QJKSJXEA6T7VB", "label": "Provider" },
    { "party_id": "pty_01M5Q2KJMKWE1BBYXSTFF2Q836", "label": "Client" }
  ]
}

Each entry in signing_links also has the party's url, which opens the hosted signing page in the console. Its last path segment is a token that works only for that party and that agreement. Agreements expire after seven days.

2. Show each party what they're signing

Deliver each party their link, which opens the hosted signing page. To sign inside your own product instead, use the <provenance-sign> embed, or build a page on GET /v1/mandate/agreements/sign, which needs no API key:

curl "$PROVENANCE_API/v1/mandate/agreements/sign?token=$SIGN_TOKEN"
{
  "id": "agr_01M5Q2KJMKC7J3XJPD6BEYMFGB",
  "object": "agreement",
  "content_description": "Services agreement v3",
  "mode": "parallel",
  "overall_status": "pending",
  "party": { "party_id": "pty_01M5Q2KJMKVY6QJKSJXEA6T7VB", "label": "Provider", "status": "pending" },
  "other_parties": [{ "label": "Client", "status": "pending" }],
  "sign_challenge": "hP3r08-W2ilfltScyxEPE6TVcRqSPAQ790k3KQKZ9DY",
  "can_sign": true
}

Show the content_hash and let the party check their own copy against it before signing; the embed hashes the file in the browser without uploading it.

3. Each party signs with a passkey

The party signs sign_challenge with their passkey (navigator.credentials.get, as in biometric approval) on a device enrolled with one, then posts the result to POST /v1/mandate/agreements/sign. The challenge is derived from the agreement, the content hash and the party, so the same assertion can't sign for another party or another document.

curl "$PROVENANCE_API/v1/mandate/agreements/sign?token=$SIGN_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{ \"action\": \"sign\", \"device_id\": \"$DEVICE_ID\", \"assertion\": $(cat assertion.json) }"
{
  "id": "agr_01M5Q2KJMKC7J3XJPD6BEYMFGB",
  "object": "agreement",
  "party_status": "signed",
  "overall_status": "pending"
}

To refuse, a party posts { "action": "decline" }; the agreement becomes declined and can't be completed.

4. Check the agreement

Read it with GET /v1/mandate/agreements/{id}. It's completed when every party has signed; each party shows when they signed and their device's hardware tier.

curl $PROVENANCE_API/v1/mandate/agreements/$AGREEMENT_ID \
  -H "Authorization: Bearer $PROVENANCE_KEY"
{
  "id": "agr_01M5Q2KJMKC7J3XJPD6BEYMFGB",
  "object": "agreement",
  "status": "pending",
  "completed_at": null
}

The mandate.agreement.completed and mandate.agreement.declined webhooks tell you without polling.

5. Get the completion receipt

Once completed, GET /v1/mandate/agreements/{id}/receipt returns a receipt object: claims covers the agreement and each party's signing evidence, token is the ES256 JWS that signs them, and verify_url opens the console's Verify a proof page. It verifies offline against the published keys with the free verify endpoint, and holds the content's hash, never the content.

curl $PROVENANCE_API/v1/mandate/agreements/$AGREEMENT_ID/receipt \
  -H "Authorization: Bearer $PROVENANCE_KEY"
{
  "object": "receipt",
  "id": "rcpt_3e9a71c0d2b84f5e8a6c1d0b9f2e4a7c",
  "claims": { "receipt_id": "rcpt_3e9a71c0d2b84f5e8a6c1d0b9f2e4a7c", "type": "agreement_completion", "agreement_id": "agr_01M5Q2KJMKC7J3XJPD6BEYMFGB", "status": "completed" },
  "token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZ3JlZW1lbnRfaWQiOiJhZ3JfMDFNNVEyS0pNS0M3SjNYSlBENkJFWU1GR0IifQ.c2lnbmF0dXJl",
  "verify_url": "https://…/developers/verify?receipt=eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9…"
}

Errors you might see

SymptomCauseFix
400 agreement_invalid, "agreement is not completed"The receipt was requested before every party signedWait for mandate.agreement.completed.
400 agreement_invalid, "the first party must sign first"A sequential agreement's second party signed earlySign in order.
400 agreement_invalid, "biometric assertion failed"The assertion wasn't over this party's challenge, or came from another deviceSign the sign_challenge from this party's link with the enrolled device.
401 agreement_link_invalidThe signing token is malformed or expiredUse the link from the create response.

See also