# attachment_not_ready: HTTP 422
URL: https://emailforagents.ai/docs/errors/attachment_not_ready
Summary: The attachment exists but its scan has not completed cleanly, so it cannot be sent or downloaded. What triggers it in the implementation, and how to resolve it.

## attachment_not_ready

HTTP 422 Don’t retry REST and MCP

The attachment exists but its scan has not completed cleanly, so it cannot be sent or downloaded.

### How to fix it

1. Poll the upload with GET /projects/{project_id}/uploads/{upload_id} until it reports a clean scan, then send. Scanning is asynchronous and completing the upload does not complete the scan.
2. Complete the upload before attaching it. Reserve, PUT the content, then call complete; an attachment that skipped completion never reaches a scannable state.
3. If the scan rejected the file, do not retry with the same bytes. A rejected file stays rejected.
4. Attach the attachment_id the upload returns (att_…), not the upload id.

### Which rule fired

A file is usable only when every one of several states lines up: the attachment row is ready, its scan_status is clean, the underlying object is ready, and the recorded SHA-256 matches the object registry's digest. That last comparison is the interesting one. It means a file whose stored bytes no longer hash to what was scanned is treated as not ready, so a clean scan result cannot be inherited by different content. On the download side the same code covers a file that was purged or rejected.

| In error.message | Means |
| --- | --- |
| `This file cannot be downloaded until a successful scan marks it clean.` | Downloading a file whose scan_status is not clean, or whose status is purged or rejected. |
| `Stored content failed its integrity check.` | Downloading a file whose stored bytes no longer hash to the SHA-256 recorded for it. |
| `Every attachment must finish a successful scan before sending.` | Sending with an attachment that is not ready, not scanned clean, whose object is not ready, or whose recorded hash does not match the object registry digest. |

**Why it works this way:** Comparing the recorded hash against the object registry digest at send time, rather than trusting the scan flag alone, is what stops a clean verdict from being transferable to content that was swapped underneath it.

### Example

POST /v1/projects/{project_id}/inboxes/{inbox_id}/messages → 422

```
{
  "error": {
    "code": "attachment_not_ready",
    "message": "Every attachment must finish a successful scan before sending.",
    "request_id": "req_8Kd2x91",
    "retryable": false,
    "details": {}
  }
}
```

Over MCP, `send_message` and `create_draft` return it as text in a result marked `isError: true`, not as this body.

#### Where it appears

- `GET /projects/{project_id}/attachments/{attachment_id}/download`
- `POST /projects/{project_id}/inboxes/{inbox_id}/messages`
- `POST /projects/{project_id}/approvals/{approval_id}/approve`

Paths are relative to `https://api.emailforagents.ai/v1`.

### Often confused with

[payload_too_large](https://emailforagents.ai/docs/errors/payload_too_large) [not_found](https://emailforagents.ai/docs/errors/not_found)
