POST/api/v1/pdf/remove-password

Remove Password

Remove password protection from an encrypted PDF. You must provide the current password to unlock the document. Optionally re-encrypt with a new password in a single step.

Content-Type: multipart/form-data

Parameters

ParameterTypeRequiredDefaultDescription
filefileRequired-The password-protected PDF file.
passwordstringRequired-The current password to unlock the PDF.
re_encrypt_passwordstringOptional-If provided, the output PDF will be re-encrypted with this new password. Omit to produce an unprotected PDF.

Code Examples

cURL

bash
# Remove password (output unprotected)
curl -X POST "https://app.alternapdf.com/api/v1/pdf/remove-password" \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "file=@encrypted.pdf" \
  -F "password=current_password123" \
  --output unlocked.pdf

# Change password (re-encrypt with new password)
curl -X POST "https://app.alternapdf.com/api/v1/pdf/remove-password" \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "file=@encrypted.pdf" \
  -F "password=current_password123" \
  -F "re_encrypt_password=new_password456" \
  --output re_encrypted.pdf

Python

python
import requests

url = "https://app.alternapdf.com/api/v1/pdf/remove-password"
headers = {"X-API-Key": "YOUR_API_KEY"}

files = {
    "file": ("encrypted.pdf", open("encrypted.pdf", "rb"), "application/pdf"),
}

# Remove password entirely
data = {
    "password": "current_password123",
}

# Or change password:
# data = {
#     "password": "current_password123",
#     "re_encrypt_password": "new_password456",
# }

response = requests.post(url, headers=headers, files=files, data=data)

with open("unlocked.pdf", "wb") as f:
    f.write(response.content)

print(f"Unlocked PDF saved ({len(response.content)} bytes)")

JavaScript

javascript
const fs = require("fs");
const FormData = require("form-data");
const axios = require("axios");

const form = new FormData();
form.append("file", fs.createReadStream("encrypted.pdf"));
form.append("password", "current_password123");
// Optionally re-encrypt:
// form.append("re_encrypt_password", "new_password456");

const response = await axios.post(
  "https://app.alternapdf.com/api/v1/pdf/remove-password",
  form,
  {
    headers: {
      "X-API-Key": "YOUR_API_KEY",
      ...form.getHeaders(),
    },
    responseType: "arraybuffer",
  }
);

fs.writeFileSync("unlocked.pdf", response.data);
console.log(`Unlocked PDF saved (${response.data.byteLength} bytes)`);

Response

200Unlocked or re-encrypted PDF binary
HeaderValue
Content-Typeapplication/pdf
Content-Dispositionattachment; filename="unlocked.pdf"

The response body contains the PDF binary with password protection removed (or re-encrypted if re_encrypt_password was provided). On error, a JSON object with a detail field is returned instead.