# Quickstart

Make your first authenticated call and hold a processed PDF in under five minutes.

The fastest path from zero to a processed PDF: get a key, make one call, save the
result. No SDK, no setup beyond an API key and a PDF on disk.

<Steps>

<Step title="Get an API key">

Sign in to the [dashboard](https://dashboard.pdfblocks.com) and create an API
key. Copy it somewhere safe — you send it on every request. See
[Authentication](/docs/api/authentication) for how keys work and how to keep
them secure.

</Step>

<Step title="Make one call">

Put a PDF named `input.pdf` in your working directory, swap `your_api_key` for
your key, and run one of these. Each stamps a watermark on the document and
writes the result to `watermarked.pdf`.

<CodeGroup>

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

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

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

response.raise_for_status()
with open('watermarked.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');
body.set('line_1', 'CONFIDENTIAL');

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

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

```php title="PHP"
<?php
$ch = curl_init('https://api.pdfblocks.com/v1/add_text_watermark');
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'),
        'line_1' => 'CONFIDENTIAL',
    ],
]);

$pdf = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200) {
    file_put_contents('watermarked.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/add_text_watermark', form: {
    file: HTTP::FormData::File.new('input.pdf'),
    line_1: 'CONFIDENTIAL',
  })

File.write('watermarked.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.WriteField("line_1", "CONFIDENTIAL")
	form.Close()

	req, _ := http.NewRequest("POST", "https://api.pdfblocks.com/v1/add_text_watermark", &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("watermarked.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" },
    { new StringContent("CONFIDENTIAL"), "line_1" },
};

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

</CodeGroup>

</Step>

<Step title="Open your PDF">

On success the API responds with `200 OK` and the watermarked document as the
body:

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

Open `watermarked.pdf` — it is your input with `CONFIDENTIAL` stamped across
every page. That is the whole contract: a PDF went in, a PDF came out, and
nothing was stored on our side.

</Step>

</Steps>

<Tip>
  No `200`? A missing or wrong key returns `401`, and an unreadable `file`
  returns `400` — both as `application/problem+json`. See
  [Errors](/docs/api/errors) for the full status catalog.
</Tip>

## Next steps

<CardGroup cols={2}>

<Card title="Authentication" href="/docs/api/authentication">
  Manage keys, rotate them, and keep them out of source control.
</Card>

<Card title="Actions overview" href="/docs/api/actions-overview">
  Browse all 17 actions and see how they compose.
</Card>

<Card title="Requests & responses" href="/docs/api/requests-and-responses">
  The uniform request and response shape every action shares.
</Card>

</CardGroup>
