Skip to navigation
Hidden

Password-Protected Files

Extend supports processing password-protected PDF files. You can provide the file’s password directly in your API request so that Extend can unlock and process the document.


Providing a Password via URL

When providing a file by URL (in parse, extract, classify, split, edit, or workflow runs), include the password in the settings object on the file input:

{
"file": {
"url": "https://example.com/protected.pdf",
"name": "protected.pdf",
"settings": {
"password": "your-file-password"
}
}
}
from extend_ai import Extend
client = Extend()
response = client.parse(
file={
"url": "https://example.com/protected.pdf",
"name": "protected.pdf",
"settings": {"password": "your-file-password"},
},
config={"target": "markdown"},
)

The settings object is available on URL-based file inputs across all run endpoints:

EndpointSupports settings.password
POST /parse / POST /parse_runs✅
POST /extract / POST /extract_runs✅
POST /classify / POST /classify_runs✅
POST /split / POST /split_runs✅
POST /edit / POST /edit_runs✅
Workflow runs✅

Password is only applicable to URL-based file inputs. When referencing a previously uploaded file by id, the file was already uploaded (and optionally password-unlocked) at upload time.


Providing a Password When Uploading a File

When uploading a file via POST /files/upload, include the password as a password field in the multipart/form-data request:

with open("protected.pdf", "rb") as f:
uploaded = client.files.upload(file=f, password="your-file-password")
# uploaded.id can now be used in subsequent requests via file={"id": uploaded.id}

Error Handling

If you attempt to process a password-protected file without providing a password, the API returns a PASSWORD_PROTECTED_FILE error:

{
"code": "PASSWORD_PROTECTED_FILE",
"message": "The file is password protected and cannot be parsed.",
"requestId": "req_abc123",
"retryable": false
}