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 /. 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/##')
import { createHash } from "node:crypto";
import { readFileSync } from "node:fs";
import { Provenance } from "@provenanceauth/sdk";
const prov = new Provenance({ apiKey: process.env.PROVENANCE_KEY!, baseUrl: process.env.PROVENANCE_API });
const contentHash = createHash("sha256").update(readFileSync("agreement.txt")).digest("hex");
const agreement = await prov.mandate.agreements.create({
contentHash,
contentDescription: "Services agreement v3",
mode: "parallel",
parties: [
{ label: "Provider", email: "ops@brindlecote.example" },
{ label: "Client", email: "legal@acme.example" },
],
});
import hashlib, os
import httpx
api, headers = os.environ["PROVENANCE_API"], {"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}
content_hash = hashlib.sha256(open("agreement.txt", "rb").read()).hexdigest()
agreement = httpx.post(f"{api}/v1/mandate/agreements", json={
"content_hash": content_hash,
"content_description": "Services agreement v3",
"mode": "parallel",
"parties": [
{"label": "Provider", "email": "ops@brindlecote.example"},
{"label": "Client", "email": "legal@acme.example"},
],
}, headers=headers).json()
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"
const token = agreement.signingLinks[0]!.url.split("/sign/")[1];
const signing = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/agreements/sign?token=${encodeURIComponent(token)}`)).json();
token = agreement["signing_links"][0]["url"].split("/sign/")[1]
signing = httpx.get(f"{api}/v1/mandate/agreements/sign", params={"token": token}).json()
{
"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) }"
await fetch(`${process.env.PROVENANCE_API}/v1/mandate/agreements/sign?token=${encodeURIComponent(token)}`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ action: "sign", device_id: deviceId, assertion }),
});
httpx.post(f"{api}/v1/mandate/agreements/sign", params={"token": token}, json={"action": "sign", "device_id": device_id, "assertion": assertion})
{
"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 /. 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"
const current = await prov.mandate.agreements.get(agreement.id);
current = httpx.get(f"{api}/v1/mandate/agreements/{agreement['id']}", headers=headers).json()
{
"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 / 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"
const { token: receiptToken, verifyUrl } = await prov.mandate.agreements.receipt(agreement.id);
receipt = httpx.get(f"{api}/v1/mandate/agreements/{agreement['id']}/receipt", headers=headers).json()
{
"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
| Symptom | Cause | Fix |
|---|---|---|
400 agreement_, "agreement is not completed" | The receipt was requested before every party signed | Wait for mandate.. |
400 agreement_, "the first party must sign first" | A sequential agreement's second party signed early | Sign in order. |
400 agreement_, "biometric assertion failed" | The assertion wasn't over this party's challenge, or came from another device | Sign the sign_ from this party's link with the enrolled device. |
401 agreement_ | The signing token is malformed or expired | Use the link from the create response. |