# Send contracts from a Clay table

You can send contracts from Clay today with the HTTP API column. The trick is one header: an Idempotency-Key built from the row ID, so a rerun can never send a second contract.

## What works today

| Route | Status |
|---|---|
| HTTP API column | Works now |
| Second HTTP column to read status | Works now |
| Clay webhook source for events | Works now, if your plan has it |
| Native Clay integration | Coming soon |

## Why reruns are the risk

Clay reruns columns. You edit an upstream cell, or you rerun a table, and every row fires again. For an enrichment call that wastes a credit. For a contract it mails a stranger twice. An `Idempotency-Key` fixes this on the server: the same key returns the first result and sends nothing new.

## The recipe

**1. Store your key.** In the HTTP API column, use a saved account, so the key is stored encrypted for the workspace. Don't type the key into the Headers field, because anyone with table access can read it there.

**2. Add a Ready column.** Use a formula so a row runs only when it is complete: the stage is won, the email is valid, and Contract ID is empty.

**3. Add an HTTP API column.** Set the run condition to Ready. Use `/` to insert your columns.

- Method: `POST`
- Endpoint: `https://docuinked.com/v1/documents`
- Headers: `Authorization: Bearer di_test_...`, `Content-Type: application/json`, and `Idempotency-Key: clay-contract-` followed by your `/Row ID` column
- Rate limit: 2 requests per 1000 ms, which stays under our 120 a minute

```json
{
  "title": "Order form for /Legal Name",
  "pdf_url": "/Contract PDF URL",
  "signers": [{"name": "/Signer Name", "email": "/Signer Email"}],
  "metadata": {"clay_row": "/Row ID"},
  "send": true
}
```

**4. Return the fields you need.** Map `data.id` to a Contract ID column and `data.status` to Contract Status.

**5. Read status.** Add a second HTTP API column that runs when Contract ID is set: `GET https://docuinked.com/v1/documents/` followed by `/Contract ID`. Return `data.status`. A webhook can do the same job: point `create_webhook` at a Clay webhook source URL, then match on the `document` field.

## Pick the right key

Start with a test key and the signer `sign@test.docuinked.com`. Then choose. A live key set to "Needs my approval" returns an `approval_url` in `data`, and a person approves each contract. A key set to "Sends directly" sends on run. Use that only when the PDF and the formula are ones you trust. During the beta, live sends are capped at 100 a day per account, so a big table will stop there and fail safe.

## Common questions

### What if I rerun the whole table?

Each row sends the same `Idempotency-Key` as before, so each gets its first result back and nothing new goes out. The Ready formula is a second guard, since Contract ID is no longer empty.

### Can I change a contract and resend from the same row?

Not with the same key, since that key is tied to the first result. To send a new version on purpose, add a version to the key, such as `clay-contract-v2-` and the row ID.

### Should each Clay row have its own PDF link?

Yes, if the terms differ. Generate the PDF first and pass its public https link in a column. The link must be reachable by our server when the column runs.

### Is docuinked in Clay's marketplace?

No. A native integration is coming soon. Nothing here needs one, because the HTTP API column is built for this.
