> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.staple.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.staple.ai/_mcp/server.

# Redact Documents

POST https://api.staple.io/v2/redaction/document
Content-Type: application/json

This API endpoint allows you to redact PDF documents based on input data. The endpoint supports pre-configured formats, and only specific data can go into each PDF document.

Reference: https://docs.staple.ai/api-reference/v2/document-creation/redact-documents

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: v2
  version: 1.0.0
paths:
  /v2/redaction/document:
    post:
      operationId: redactDocuments
      summary: Redact Documents
      description: >-
        This API endpoint allows you to redact PDF documents based on input
        data. The endpoint supports pre-configured formats, and only specific
        data can go into each PDF document.
      tags:
        - documentCreation
      parameters:
        - name: x-api-key
          in: header
          description: API key issued by Staple.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Document
                  Creation_redactDocuments_Response_200
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                qid:
                  type: integer
                documentIds:
                  type: array
                  items:
                    type: integer
                redactedFields:
                  type: array
                  items:
                    type: string
servers:
  - url: https://api.staple.io
    description: https://api.staple.io
components:
  schemas:
    Document Creation_redactDocuments_Response_200:
      type: object
      properties: {}
      description: Empty response body
      title: Document Creation_redactDocuments_Response_200
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key issued by Staple.
    bearerAuth:
      type: http
      scheme: bearer
      description: JWT obtained from the login endpoint.

```

## Examples

### Redact Documents



**Request**

```json
undefined
```

**Response**

```json
{
  "createRedactedDocument": {
    "message": "The document(s) are being processed. Please wait a moment. Processing time will depend on the number of documents and their size.",
    "redactedDocuments": [
      {
        "documentId": 1,
        "trackingId": "f028c439-6ffd-4d11-9f60-d5bb72c3a574"
      },
      {
        "documentId": 2,
        "trackingId": "1620e1d6-e4fe-408b-b785-ded50b462633"
      }
    ]
  }
}
```

**SDK Code**

```python Redact Documents
import requests

url = "https://api.staple.io/v2/redaction/document"

headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Redact Documents
const url = 'https://api.staple.io/v2/redaction/document';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: undefined
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Redact Documents
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.staple.io/v2/redaction/document"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

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

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Redact Documents
require 'uri'
require 'net/http'

url = URI("https://api.staple.io/v2/redaction/document")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'

response = http.request(request)
puts response.read_body
```

```java Redact Documents
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.staple.io/v2/redaction/document")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .asString();
```

```php Redact Documents
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.staple.io/v2/redaction/document', [
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Redact Documents
using RestSharp;

var client = new RestClient("https://api.staple.io/v2/redaction/document");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
```

```swift Redact Documents
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.staple.io/v2/redaction/document")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Document Creation_redactDocuments_example



**Request**

```json
{
  "qid": 1,
  "documentIds": [
    1,
    2
  ],
  "redactedFields": [
    "AccountNumber",
    "CompanyName"
  ]
}
```

**Response**

```json
{
  "createRedactedDocument": {
    "message": "The document(s) are being processed. Please wait a moment. Processing time will depend on the number of documents and their size.",
    "redactedDocuments": [
      {
        "documentId": 1,
        "trackingId": "f028c439-6ffd-4d11-9f60-d5bb72c3a574"
      },
      {
        "documentId": 2,
        "trackingId": "1620e1d6-e4fe-408b-b785-ded50b462633"
      }
    ]
  }
}
```

**SDK Code**

```python Document Creation_redactDocuments_example
import requests

url = "https://api.staple.io/v2/redaction/document"

payload = {
    "qid": 1,
    "documentIds": [1, 2],
    "redactedFields": ["AccountNumber", "CompanyName"]
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Document Creation_redactDocuments_example
const url = 'https://api.staple.io/v2/redaction/document';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"qid":1,"documentIds":[1,2],"redactedFields":["AccountNumber","CompanyName"]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Document Creation_redactDocuments_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.staple.io/v2/redaction/document"

	payload := strings.NewReader("{\n  \"qid\": 1,\n  \"documentIds\": [\n    1,\n    2\n  ],\n  \"redactedFields\": [\n    \"AccountNumber\",\n    \"CompanyName\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

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

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Document Creation_redactDocuments_example
require 'uri'
require 'net/http'

url = URI("https://api.staple.io/v2/redaction/document")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"qid\": 1,\n  \"documentIds\": [\n    1,\n    2\n  ],\n  \"redactedFields\": [\n    \"AccountNumber\",\n    \"CompanyName\"\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Document Creation_redactDocuments_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.staple.io/v2/redaction/document")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"qid\": 1,\n  \"documentIds\": [\n    1,\n    2\n  ],\n  \"redactedFields\": [\n    \"AccountNumber\",\n    \"CompanyName\"\n  ]\n}")
  .asString();
```

```php Document Creation_redactDocuments_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.staple.io/v2/redaction/document', [
  'body' => '{
  "qid": 1,
  "documentIds": [
    1,
    2
  ],
  "redactedFields": [
    "AccountNumber",
    "CompanyName"
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Document Creation_redactDocuments_example
using RestSharp;

var client = new RestClient("https://api.staple.io/v2/redaction/document");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"qid\": 1,\n  \"documentIds\": [\n    1,\n    2\n  ],\n  \"redactedFields\": [\n    \"AccountNumber\",\n    \"CompanyName\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Document Creation_redactDocuments_example
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "qid": 1,
  "documentIds": [1, 2],
  "redactedFields": ["AccountNumber", "CompanyName"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.staple.io/v2/redaction/document")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```