---
title: "DWS Processor API with PHP"
canonical_url: "https://www.nutrient.io/guides/dws-processor/supported-languages/php/"
md_url: "https://www.nutrient.io/guides/dws-processor/supported-languages/php.md"
last_updated: "2026-05-27T15:15:53.462Z"
description: "Learn to use Nutrient DWS Processor API with PHP by making HTTP requests, installing dependencies, and preparing your payload."
---

# DWS Processor API with PHP

With Nutrient DWS Processor API, you can process your documents by making HTTP requests to one of our [50+ API tools](https://dashboard.nutrient.io/processor-api/playground/). You can make a single request to one tool or combine API actions to generate, edit, OCR, and convert your document (1 document can have multiple API actions).

This guide explains how to use PHP to make HTTP requests with Nutrient DWS Processor API. Keep in mind that you can use any HTTP client you want; this example uses `curl` to demonstrate the principles of interacting with Nutrient DWS Processor API.

It involves three main steps:

1. Installing the required dependencies

2. Preparing the payload

3. Making the request

## Installing the required dependencies

You’ll need to add the `document.pdf` and `logo.png` files to the root of your PHP project (the same folder you’ll be creating the `pspdfkit.php` file in). You can use the sample files provided by us — [document.pdf](https://www.nutrient.io/assets/guides/dws-processor/watermark/document.pdf) and [logo.png](https://www.nutrient.io/assets/guides/dws-processor/watermark/logo.png) — or use your own.

Now that you have your assets set up, you’re ready to start making requests to Nutrient DWS Processor API.

## Preparing the payload

First, define your `instructions` object:

```php

<?php
$instructions = '{
  "parts": [
    {
      "file": "document",
      "pages": {
        "end": -2
      }
    },
    {
      "file": "document",
      "pages": {
        "start": -1
      },
      "actions": [
        {
          "type": "watermark",
          "image": "company-logo",
          "width": "50%"
        }
      ]
    }
  ]
}';

```

You define your `instructions` as a JSON-formatted string. Keep in mind that if this isn’t valid JSON, Nutrient DWS Processor API will return an error.

In this example, you’ll be adding an image watermark. For examples of how the watermark API can be used (for example, adding multiple watermarks to the document, watermarking the last page of the document, and watermark alignments), refer to our [PDF watermark API](https://www.nutrient.io/api/pdf-watermark-api/) page.

## Making the request

Now, you’re ready to make a `curl` call. Make sure to replace the `your_api_key_here` placeholder with your actual API key if it hasn’t yet been replaced:

```php

$FileHandle = fopen('result.pdf', 'w+');

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.nutrient.io/build',
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_POSTFIELDS => array(
    'instructions' => $instructions,
    'document' => new CURLFILE('document.pdf'),
    'company-logo' => new CURLFILE('logo.png')
  ),
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer your_api_key_here'
  ),
  CURLOPT_FILE => $FileHandle,
));

$response = curl_exec($curl);

curl_close($curl);

fclose($FileHandle);

```

Here, you set up your `curl` object and configure it to make a request to Nutrient DWS Processor API. The `CURLOPT_POSTFIELDS` array contains all the parts you want to send. In this case, this means your `instructions` and the two required assets (the PDF and the watermark image).

You also set up your output using `CURLOPT_FILE`, which will save the resulting document as `result.pdf` in the same folder as your PHP file.

And with that, you're ready to make a request. Run your script by executing `php pspdfkit.php`, and the `result.pdf` should appear in the same folder.

While this example made use of our watermarking API, this same approach can be used for all our available [API tools](https://dashboard.nutrient.io/processor-api/playground/).

## Complete code

For your convenience, the complete code is below:

```php

<?php

$FileHandle = fopen('result.pdf', 'w+');

$curl = curl_init();

$instructions = '{
  "parts": [
    {
      "file": "document",
      "pages": {
        "end": -2
      }
    },
    {
      "file": "document",
      "pages": {
        "start": -1
      },
      "actions": [
        {
          "type": "watermark",
          "image": "company-logo",
          "width": "50%"
        }
      ]
    }
  ]
}';

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.nutrient.io/build',
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_POSTFIELDS => array(
    'instructions' => $instructions,
    'document' => new CURLFILE('document.pdf'),
    'company-logo' => new CURLFILE('logo.png')
  ),
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer your_api_key_here'
  ),
  CURLOPT_FILE => $FileHandle,
));

$response = curl_exec($curl);

curl_close($curl);

fclose($FileHandle);

```
---

## Related pages

- [Supported languages](/guides/dws-processor/supported-languages.md)
- [DWS Processor API with Java](/guides/dws-processor/supported-languages/java.md)
- [DWS Processor API with C#](/guides/dws-processor/supported-languages/csharp.md)
- [Enable enhanced code completion and documentation for Claude Code using the Nutrient DWS SDK.](/guides/dws-processor/supported-languages/javascript.md)
- [DWS Processor API with other languages](/guides/dws-processor/supported-languages/other.md)
- [Enable enhanced code completion and documentation for Claude Code using the Nutrient DWS SDK.](/guides/dws-processor/supported-languages/python.md)

