# Human-in-the-loop

Human-in-the-loop means an automated system stops at a set point and waits for a person to approve before an action with real effects goes ahead.

## In plain words

Automation is fast and tireless, and sometimes wrong. A human-in-the-loop step puts a person at the moment where a mistake would be costly. The machine does the preparing. The person makes the call.

The hard part is making that step real. If the pause lives in a prompt ("ask before sending"), the agent can skip it, misread it or be talked out of it. If it lives on the server, the agent has no way around it.

## An example

An agent in a hiring workflow fills an [offer letter](/templates/offer-letter) with a name, a salary and a start date. It asks to send it. HR gets a link, opens the draft and sees the salary is wrong by a digit. They reject it. The document goes back to being a draft, and no candidate ever saw the mistake.

## How it shows up in docuinked

In docuinked the loop is enforced on the server.

- An agent calls `create_document` and gets a `draft_hash`.
- It calls `send_document` with that hash. On a live agent key, nothing is sent. The reply has an `approval_url`.
- A named person on the account signs in, reads the draft as the server holds it, and approves or rejects.
- Approval binds to the exact hash. If the draft changed, the approval is refused.
- A request lasts 24 hours.
- There is no approve call in the API, so no key can approve its own request.

The evidence log records the key that asked and the person who approved, as separate entries. Read the [approvals docs](/docs/approvals) for the whole flow and its limits.

## Where the loop can be skipped

Your own server code, which you wrote and trust, can use a key set to "Sends directly". That key is for fixed flows such as a known template to a known kind of person. Don't give it to an agent. Anything over MCP counts as an agent whatever key it uses.

## Common confusions

**Human-in-the-loop is not human signing.** The approver decides the draft may go out. The signer still signs for themselves. They are two different people doing two different acts.

**Approval doesn't make a bad draft good.** A person can approve a mistake. The loop only helps if they read.

## Related terms

- [MCP](/glossary/mcp)
- [Hash](/glossary/hash)
- [Webhook](/glossary/webhook), for `approval.requested` and `approval.approved`

For the wider argument, see [can an AI agent sign a contract?](/guides/signing-from-an-ai-agent) and [agents](/agents).

## Common questions

### Who can approve an agent's send?

A signed-in person on the account. Pick someone who can check the draft against its source, because the record names them.

### What happens if nobody approves within 24 hours?

The request lapses and nothing is sent. The agent or a person can ask again, which starts a new request.

### Does test mode need a human approval?

No. In test mode the agent sees the same approval step, and `simulate_approval` stands in for the person so evals can run end to end; test keys email nobody. A live document always needs a person's approval.
