---
title: "Remove password protection from PDF"
method: POST
path: "/security/pdf/unlock"
tags: ["Security"]
---

# Remove password protection from PDF

`POST /security/pdf/unlock`

## Request

- Base URL: `https://api.filegraph.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.filegraph.ai/security/pdf/unlock`
- Auth: API key in header `X-API-Key`

Remove password protection from a PDF document.

## How It Works

- **With password**: Removes user (open) password protection. The document will open without a password.
- **Without password**: Removes only owner (permissions) password. The document keeps any user password but restrictions are lifted.

## Common Use Cases

1. **Unlock a PDF you can open but can't edit**:
   - Leave `password` empty
   - Owner restrictions will be removed

2. **Fully unlock a password-protected PDF**:
   - Provide the user password
   - Both user and owner protection removed

## Example

```python
import httpx

# Remove all protection (requires the open password)
response = httpx.post(
    "https://api.filegraph.ai/security/pdf/unlock",
    headers={"X-API-Key": "your-api-key"},
    files={"file": open("protected.pdf", "rb")},
    data={"password": "openme123"}
)

# Remove only owner restrictions (no password needed if document opens)
response = httpx.post(
    "https://api.filegraph.ai/security/pdf/unlock",
    headers={"X-API-Key": "your-api-key"},
    files={"file": open("restricted.pdf", "rb")}
)
```

## Response `200`

Successful Response

- UnlockResponse: Response for PDF unlock operation.
  - `filename` string, required: Output filename
  - `content_type` string, required: MIME type of the file
  - `size_bytes` integer, required: File size in bytes
  - `content_base64` string, required: Base64-encoded file content
  - `was_user_protected` boolean, required: Whether the document had user (open) password protection
  - `was_owner_protected` boolean, required: Whether the document had owner (permissions) password protection

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/filegraph/apis/docconvert-api.md) · [All operations](https://skmtc.dev/filegraph/apis/docconvert-api/llms.txt) · [OpenAPI document](https://skmtc.dev/filegraph/apis/docconvert-api/revisions/436255c85bd4?raw)
