# Remove the restrictions from a PDF

Clear all the permission restrictions from a PDF, restoring copying, printing, and editing. Supply the owner password that currently protects the flags.

Remove all permission restrictions from a PDF document, restoring the ability to
copy, print, and edit. The API is stateless: your document is processed in-region
and never stored.

<Note>
  This clears the permission flags (the copy, print, and edit restrictions),
  not the password required to open the file. To remove that, use
  [Remove the password](/docs/api/remove-password-from-pdf). For the full
  lifecycle, see [Protecting documents](/docs/api/protecting-documents).
</Note>

## Endpoint

<Endpoint method="POST" path="/v1/remove_restrictions" />

Available in every region. See [Regions & data residency](/docs/api/regions-and-data-residency)
for routing and data residency.

| Region         | URL                                                  |
| -------------- | ---------------------------------------------------- |
| Global         | `https://api.pdfblocks.com/v1/remove_restrictions`   |
| United States  | `https://us.api.pdfblocks.com/v1/remove_restrictions` |
| US HIPAA       | `https://hipaa.api.pdfblocks.com/v1/remove_restrictions` |
| European Union | `https://eu.api.pdfblocks.com/v1/remove_restrictions` |
| United Kingdom | `https://uk.api.pdfblocks.com/v1/remove_restrictions` |
| Canada         | `https://ca.api.pdfblocks.com/v1/remove_restrictions` |
| Australia      | `https://au.api.pdfblocks.com/v1/remove_restrictions` |
| Japan          | `https://jp.api.pdfblocks.com/v1/remove_restrictions` |
| India          | `https://in.api.pdfblocks.com/v1/remove_restrictions` |
| Brazil         | `https://br.api.pdfblocks.com/v1/remove_restrictions` |

## Authentication

Authenticate every request with your secret API key in the `X-API-Key` header,
over HTTPS. Create and manage keys from the
[dashboard](https://dashboard.pdfblocks.com). See
[Authentication](/docs/api/authentication) for details.

## Request

The endpoint accepts a `multipart/form-data` request body.

<ParamField name="file" type="file" required>
  The input PDF document.
</ParamField>

## Examples

Remove every permission restriction from a PDF:

<CodeGroup>

```bash title="cURL"
curl https://api.pdfblocks.com/v1/remove_restrictions \
  -H 'X-API-Key: your_api_key' \
  -F file=@input.pdf \
  -o unrestricted.pdf
```

```python title="Python"
# pip install requests
import requests

with open('input.pdf', 'rb') as file:
    response = requests.post(
        'https://api.pdfblocks.com/v1/remove_restrictions',
        headers={'X-API-Key': 'your_api_key'},
        files={'file': file},
    )

response.raise_for_status()
with open('unrestricted.pdf', 'wb') as output:
    output.write(response.content)
```

```javascript title="Node.js"
// Node.js 18+
import { readFile, writeFile } from 'node:fs/promises';

const body = new FormData();
body.set('file', new Blob([await readFile('input.pdf')]), 'input.pdf');

const response = await fetch('https://api.pdfblocks.com/v1/remove_restrictions', {
  method: 'POST',
  headers: { 'X-API-Key': 'your_api_key' },
  body,
});

if (!response.ok) throw new Error(`Request failed: ${response.status}`);
await writeFile('unrestricted.pdf', Buffer.from(await response.arrayBuffer()));
```

```php title="PHP"
<?php
$ch = curl_init('https://api.pdfblocks.com/v1/remove_restrictions');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ['X-API-Key: your_api_key'],
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => [
        'file' => new CURLFile('input.pdf', 'application/pdf'),
    ],
]);

$pdf = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200) {
    file_put_contents('unrestricted.pdf', $pdf);
}
```

```ruby title="Ruby"
# gem install http
require 'http'

response = HTTP
  .headers('X-API-Key' => 'your_api_key')
  .post('https://api.pdfblocks.com/v1/remove_restrictions', form: {
    file: HTTP::FormData::File.new('input.pdf'),
  })

File.write('unrestricted.pdf', response.body) if response.status.success?
```

```go title="Go"
package main

import (
	"bytes"
	"io"
	"mime/multipart"
	"net/http"
	"os"
)

func main() {
	var buf bytes.Buffer
	form := multipart.NewWriter(&buf)

	file, _ := os.Open("input.pdf")
	defer file.Close()
	part, _ := form.CreateFormFile("file", "input.pdf")
	io.Copy(part, file)

	form.Close()

	req, _ := http.NewRequest("POST", "https://api.pdfblocks.com/v1/remove_restrictions", &buf)
	req.Header.Set("Content-Type", form.FormDataContentType())
	req.Header.Set("X-API-Key", "your_api_key")

	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()

	out, _ := os.Create("unrestricted.pdf")
	defer out.Close()
	io.Copy(out, res.Body)
}
```

```csharp title="C#"
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "your_api_key");

using var form = new MultipartFormDataContent
{
    { new ByteArrayContent(File.ReadAllBytes("input.pdf")), "file", "input.pdf" },
};

var response = await client.PostAsync(
    "https://api.pdfblocks.com/v1/remove_restrictions", form);
response.EnsureSuccessStatusCode();
await File.WriteAllBytesAsync(
    "unrestricted.pdf", await response.Content.ReadAsByteArrayAsync());
```

</CodeGroup>

## Response

On success, the response is `200 OK` with the unrestricted PDF as the body:

```http
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Length: 48213
```

The output is the same document with its permission flags cleared: its pages and
content are unchanged. Stream the body straight to a file, as the examples above
do; nothing is stored on our side.

## Errors

Failed requests return an `application/problem+json` body. The most common one
for this endpoint is a `400`, returned when `file` isn't a readable PDF. The
`errors` object names each field:

```json
{
  "type": "https://www.pdfblocks.com/docs/api/v1/error/400",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "errors": {
    "file": ["Could not parse the PDF document. The file may be invalid or corrupt."]
  }
}
```

A missing or invalid `X-API-Key` returns a `401`. See
[Errors](/docs/api/errors) for every status code and the full response shape.

## Related actions

<CardGroup cols={2}>

<Card title="Add restrictions" href="/docs/api/add-restrictions-to-pdf">
  Re-apply permission flags.
</Card>

<Card title="Remove the password" href="/docs/api/remove-password-from-pdf">
  Remove the open password instead.
</Card>

<Card title="Add a password" href="/docs/api/add-password-to-pdf">
  Encrypt the document with a password.
</Card>

<Card title="Remove signatures" href="/docs/api/remove-signatures-from-pdf">
  Strip signatures from a document.
</Card>

</CardGroup>
