# Recipes

Sequences of calls for common tasks. Tool names are the MCP names; in REST the same operations live under `https://api.propertrust.com/v1` (see the reference).

## Check the connection

1. `pt_whoami` → the account, its identity level, the scopes of your key.
2. If `identity.may_create_agreements` is false, stop and tell your principal: the account must confirm its e-mail first.

## Timestamp a file

1. `pt_document_deposit` with `title` and the content (`text`, or `content_base64` with `filename`).
2. Report `sha256` and `proof_url`. The anchor is `pending` now.
3. Later: `pt_document_get` → `anchors[0].status` is `confirmed` with the Bitcoin block.

To check a file without uploading it: compute its SHA-256 yourself and call `pt_proof_lookup`.

## An NDA between your principal and one other company, by e-mail

1. `pt_catalog` → look up `contract_types.nda` and the `governing_laws` key your principal wants.
2. `pt_contract_compose` with `contract_type: "nda"`, a title, both parties with name, country and address, a `purpose`, and `save_draft: true`.
3. Show your principal the wording (or the draft `url`) and wait for a yes. Say that it is standard wording and not legal advice.
4. `pt_agreement_create` with `draft: <id>` and `idempotency_key`. If the other party's e-mail was not in the draft, pass `parties: [{name, email}]`.
5. Tell your principal: the invitation is sent, and they themselves still have to read and sign in the panel.
6. `pt_agreement_get` from time to time. When `status` is `completed`, report with `verify_url`, and `pt_agreement_bundle` if they want the record.

## A sale from the shop: template and order number

1. Once: your principal saves the contract as a template with a key, for example `shop.product-x`, in the panel.
2. Per order: `pt_agreement_create` with `template`, `variables`, the buyer as party, and `idempotency_key` = the order number. A repeated call for the same order returns the same agreement.
3. Store the returned `id` with the order. Poll `pt_agreement_get` until `completed`.

## A party you can reach only on Telegram

1. `pt_agreement_create` with the wording and `parties: [{ "name": "Jane Buyer", "telegram": "@jane_buyer" }]`.
2. Look at `telegram[0].status` in the answer.
   - `contacted`: the bot has written to her. Done.
   - `needs_start_link`: give `telegram[0].start_link` to your principal with a sentence like "Please send Jane this link; the ProperTrust bot will show her the contract." Do not send it anywhere yourself unless your principal told you where.
3. `pt_agreement_get` → `parties[].telegram.state` goes to `opened`, then `status` to `joined`, `read`, `signed`.
4. If nothing happens and your principal asks for a reminder: `pt_agreement_remind`.

## A crew that already talks in a Telegram group

1. `pt_telegram_groups` → find the group; it must show `on_the_record: true`. If it does not, the members still have to accept the terms in the private chat with the bot: tell your principal.
2. `pt_agreement_create` with the wording and no parties.
3. `pt_telegram_moderate` with the group id and the agreement id. The members of the group become the parties.
4. `pt_agreement_get` until `completed`.

## Somebody sent your principal a ProperTrust document

1. Read the code next to the QR on the document.
2. `pt_verify_code` → issuer, status, how many signed, hash, anchor.
3. If you have the file: compute its SHA-256 and compare it with `document_sha256`. Equal means it is the registered version, byte for byte.
4. Report what is confirmed and what is not. A code that is `registered: false` is not a ProperTrust document.

## An existing PDF that only needs signatures

1. `pt_agreement_create` with `title`, `file_base64`, `filename` and the parties.
2. The parties confirm once that they read the document, then sign. There are no clauses.

## Correct a mistake in a frozen wording

1. `pt_agreement_cancel` on the wrong one. Tell the parties why; they already got an invitation.
2. Create the corrected agreement. Use a new `idempotency_key`.

## Add somebody later

1. Create the agreement with `open_for_parties: true`.
2. `pt_agreement_add_party` whenever a further party is known.
3. When everybody has signed: `pt_agreement_close`. Only then the agreement completes.
