# Contract automation with an e-signature API

Contract automation fails in the boring places: a double send, a lost status, a missing copy. A headless signing API works when it treats those as the main job.

## Where these projects go wrong

Generating the PDF is usually the easy part. The trouble comes after. A job retries and sends two contracts. Nobody knows who has signed. The signed file sits in one inbox. So design for those first, and treat the signature as one step in a longer pipe.

## The pipe

1. **Generate.** Your system makes the PDF. docuinked doesn't draft contract text, and we think that is a feature. Your template stays yours.
2. **Create.** Call `create_document` with an `Idempotency-Key` from your own record, such as the deal ID.
3. **Place fields.** Add `{{signature:1}}` tags to your template once, or use anchor text such as `Signature:`. Tags survive small layout changes better than coordinates.
4. **Send.** Use a "Sends directly" key for a fixed template you trust, or "Needs my approval" if a person should look first.
5. **Track.** Take `signer.signed` and `document.completed` from [webhooks](/docs/webhooks). Don't poll on a timer if you can avoid it.
6. **File.** On completion, fetch `signed_pdf` and `evidence`, and store both in your own system.

## What to store on your side

Keep the docuinked document ID next to your record, plus `sealed_sha256`. If someone hands you a PDF later, you can hash it and compare, or use the [free checker](/tools/verify-pdf). Use `metadata` to carry your own IDs on the document.

## Common questions

### Can docuinked generate the contract text for me?

No. You bring a finished PDF. That keeps your legal wording in your own system, where your lawyers can review it.

### How do I stop duplicate contracts when a job retries?

Send an `Idempotency-Key` built from your record ID. Every retry with that key gets the first result, and only one document exists.

### Is a template better than sending a new PDF each time?

Use a template when the layout is fixed and only the signers change. Send a fresh PDF when terms are filled in per deal, with tags in the file to place the fields.
