# Prepare definition attachment upload

`application_definitions.prepare_attachment_upload`

Prepare a five-minute upload for a PDF of at most 25 MiB to a file/signature block. Read get_config first and hash the local file. POST multipart field attachment to the returned URL, using transfer_token as the Bearer credential. This replaces the draft attachment only after upload; it does not publish. Keep the token out of logs and user-facing text. Retry identical bytes only.

[Application definitions guide](https://docs.levr.ai/mcp/resources/application_definitions.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.

## Input schema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "client_request_id": {
      "maxLength": 255,
      "minLength": 1,
      "type": "string"
    },
    "content_sha256": {
      "description": "SHA-256 of exact file bytes; not the application definition content digest.",
      "pattern": "^[0-9a-f]{64}$",
      "type": "string"
    },
    "definition_slug": {
      "description": "Application form definition returned by application_definitions.list. Prefix: appdef_.",
      "maxLength": 255,
      "minLength": 1,
      "type": "string"
    },
    "expected_revision": {
      "description": "Copy revision from application_definitions.get_config.",
      "minimum": 0,
      "type": "integer"
    },
    "filename": {
      "maxLength": 255,
      "minLength": 1,
      "pattern": "\\.[pP][dD][fF]$",
      "type": "string"
    },
    "provider_slug": {
      "description": "Provider that owns the application form definition. Copy provider_slug from providers.list; named slugs are valid.",
      "maxLength": 255,
      "minLength": 1,
      "type": "string"
    },
    "size_bytes": {
      "maximum": 26214400,
      "minimum": 1,
      "type": "integer"
    },
    "stable_block_id": {
      "description": "Copy the file/signature block’s stable_block_id from application_definitions.get_config.",
      "maxLength": 255,
      "minLength": 1,
      "type": "string"
    }
  },
  "required": [
    "provider_slug",
    "definition_slug",
    "stable_block_id",
    "expected_revision",
    "filename",
    "content_sha256",
    "size_bytes",
    "client_request_id"
  ],
  "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"
        },
        "instructions": {
          "type": "string"
        },
        "method": {
          "enum": [
            "GET",
            "POST"
          ],
          "type": "string"
        },
        "transfer_token": {
          "type": "string"
        },
        "url": {
          "format": "uri",
          "type": "string"
        }
      },
      "required": [
        "url",
        "method",
        "transfer_token",
        "expires_in_seconds",
        "instructions"
      ],
      "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.
