Unlock Excel
PDF4me Unlock Excel is a REST endpoint that removes password protection from an Excel workbook when you supply the correct password. POST the protected file as Base64 to office/ApiV2Excel/ExcelUnlock, put the password inside unlockExcelAction, and save the decoded unprotected copy from the JSON response. It removes protection; it never cracks it.
Takes a protected workbook plus its password and returns an unprotected copy. File encryption, workbook structure protection, and worksheet locks are all removed in one pass, which is what automated pipelines need before they can read cells, add rows, or merge files: every other Excel action expects an unprotected workbook. The response is JSON with the result as Base64 content.
Authenticating Your API Request
Every PDF4me REST call must include your API key in the Authorization header as Basic auth. Get or rotate your key from the developer dashboard.
Endpoint
office/ApiV2Excel/ExcelUnlockImportant Facts You Should Not Miss
success: false.unlockExcelAction.password from an environment variable or secrets manager, the same rule as any credential.HTTP setup
Method: POST
URL: https://api.pdf4me.com/office/ApiV2Excel/ExcelUnlock
Content-Type: application/json
Authorization: Basic <your PDF4me API key>
The response is JSON: check the success flag, then Base64-decode the returned workbook content and save it with an .xlsx extension.
Which protections does unlocking remove?
Excel protection is layered, and the layers behave differently. Unlocking with the correct password removes all of them in one pass.
| Protection vs behavior | What it blocks | Removed by this API |
|---|---|---|
| File encryption | Opening the file at all without the password | Yes, with the correct password |
| Workbook structure protection | Adding, deleting, or reordering sheets | Yes |
| Worksheet protection | Editing cells on a locked sheet | Yes |
| An unknown, lost password | Everything above | No. The correct password is required |
API body fields
| Parameter | Required | Type | What it does | Example |
|---|---|---|---|---|
document | Required | object | Document reference carrying Name, the protected Excel filename with its extension. | { "Name": "data.xlsx" } |
docContent | Required | string | Base64-encoded bytes of the password-protected workbook. | UEsDBBQABgAIAAAA... |
unlockExcelAction | Required | object | Action configuration object holding the password and optional culture settings. | { "password": "..." } |
password | Required | string | Inside the action object. The password that was used to protect the file. Inject from a secret store; never hardcode. | {{EXCEL_PASSWORD}} |
cultureName | Optional | string | Inside the action object. Culture code applied during processing. | en-US |
Sample payloads
Unlock with a secret-injected password
{
"document": { "Name": "data.xlsx" },
"docContent": "UEsDBBQABgAIAAAA...",
"unlockExcelAction": {
"password": "{{EXCEL_PASSWORD}}"
}
}
Unlock with an explicit culture
{
"document": { "Name": "quarterly-report.xlsx" },
"docContent": "UEsDBBQABgAIAAAA...",
"unlockExcelAction": {
"password": "{{EXCEL_PASSWORD}}",
"cultureName": "en-US"
}
}
Postman collection tips
curl example
curl -X POST https://api.pdf4me.com/office/ApiV2Excel/ExcelUnlock \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-d '{
"document": { "Name": "data.xlsx" },
"docContent": "'"$(base64 -w 0 data.xlsx)"'",
"unlockExcelAction": {
"password": "'"$EXCEL_PASSWORD"'"
}
}' \
--output response.json
What does the API return?
A JSON result carrying the unprotected workbook as Base64.
| Field | Type | What it contains |
|---|---|---|
document | String (Base64) | The unprotected workbook content. Decode to bytes and save with an .xlsx extension. |
fileName | String | Output filename for the unlocked workbook. |
success | Boolean | true when unlocking succeeded. Check this before decoding content. |
errorMessage | String | Populated when success is false, including the wrong-password case. |
Code samples
Excel office endpoints are not yet covered by per-language sample folders; the samples repository carries the request pattern used by every PDF4me endpoint family:
FAQ
Why unlock via API instead of manually?
The manual route for a sheet-level lock is unprotecting the sheet in Excel: open the file, enter the password, Review tab, Unprotect Sheet, save, repeat per file. That does not scale to a nightly folder of protected reports. The API performs the same password-verified removal as one deterministic request per file, and the output stays a standard Office Open XML workbook ready for the rest of the pipeline.