# Chat Prepare_Upload

`chat.prepare_upload`

Prepare one attachment upload for the selected conversation or eligible client contact. The returned HTTP contract accepts multipart file with Authorization: Bearer transfer_token. A completed upload returns an attachment ID; preparation alone neither uploads nor sends.

[Chat and messages guide](https://docs.levr.ai/mcp/resources/chat.md)

Availability depends on live discovery and your access to the record. Do not infer MCP calls from REST paths.

Operation: write. Required OAuth scopes: mcp.

## Client portal input schema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "contact_id": {
      "description": "For a client first message, use a contact ID from chat.contacts instead of conversation_id.",
      "maxLength": 64,
      "type": "string"
    },
    "conversation_id": {
      "description": "Conversation slug returned in the id field by chat.list. Copy it exactly; do not use the group name or a database ID.",
      "maxLength": 64,
      "type": "string"
    },
    "filename": {
      "maxLength": 255,
      "minLength": 1,
      "type": "string"
    },
    "idempotency_key": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "organization_slug": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "provider_slug": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "sha256": {
      "pattern": "^[0-9a-f]{64}$",
      "type": "string"
    },
    "size_bytes": {
      "maximum": 26214400,
      "minimum": 1,
      "type": "integer"
    }
  },
  "required": [
    "provider_slug",
    "idempotency_key",
    "filename",
    "size_bytes",
    "sha256",
    "organization_slug"
  ],
  "type": "object"
}
```

## Provider portal input schema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "contact_id": {
      "description": "For a client first message, use a contact ID from chat.contacts instead of conversation_id.",
      "maxLength": 64,
      "type": "string"
    },
    "conversation_id": {
      "description": "Conversation slug returned in the id field by chat.list. Copy it exactly; do not use the group name or a database ID.",
      "maxLength": 64,
      "type": "string"
    },
    "filename": {
      "maxLength": 255,
      "minLength": 1,
      "type": "string"
    },
    "idempotency_key": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "provider_slug": {
      "description": "Copy the provider slug from providers.list or your client workspace.",
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "sha256": {
      "pattern": "^[0-9a-f]{64}$",
      "type": "string"
    },
    "size_bytes": {
      "maximum": 26214400,
      "minimum": 1,
      "type": "integer"
    }
  },
  "required": [
    "provider_slug",
    "idempotency_key",
    "filename",
    "size_bytes",
    "sha256"
  ],
  "type": "object"
}
```

## Output schema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "oneOf": [
    {
      "not": {
        "required": [
          "error"
        ]
      },
      "properties": {
        "ok": {
          "const": true
        }
      },
      "required": [
        "data"
      ]
    },
    {
      "not": {
        "required": [
          "data"
        ]
      },
      "properties": {
        "ok": {
          "const": false
        }
      },
      "required": [
        "error"
      ]
    }
  ],
  "properties": {
    "data": {
      "additionalProperties": false,
      "properties": {
        "expires_in_seconds": {
          "type": "integer"
        },
        "method": {
          "enum": [
            "GET",
            "POST"
          ],
          "type": "string"
        },
        "transfer_token": {
          "type": "string"
        },
        "url": {
          "type": "string"
        }
      },
      "required": [
        "url",
        "method",
        "transfer_token",
        "expires_in_seconds"
      ],
      "type": "object"
    },
    "error": {
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string"
        },
        "details": {
          "additionalProperties": true,
          "description": "Optional bounded, agent-safe correction or recovery facts.",
          "type": "object"
        },
        "message": {
          "type": "string"
        },
        "retryable": {
          "type": "boolean"
        }
      },
      "required": [
        "code",
        "message",
        "retryable"
      ],
      "type": "object"
    },
    "meta": {
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "type": "string"
        }
      },
      "required": [
        "request_id"
      ],
      "type": "object"
    },
    "ok": {
      "description": "Whether the tool completed successfully.",
      "type": "boolean"
    }
  },
  "required": [
    "ok",
    "meta"
  ],
  "type": "object"
}
```

Check the result, then read the affected record to confirm your change.
