# Create PDF

Using `/v1/create` API endpoint you can generate PDFs using `template_id` and update data fields using `identifiers`

You can get the template ID from any of the [templates](https://pdfgen.com/templates) from PDFgen app. If you don't have any templates, you can create one from the generations list.

You can grab the data idenfiers(which are used as keys in the JSON `data` request body) from the template page by clicking the respective data items. (Click the highlighted data fields to open a side drawer and there you can see the identifier to copy).&#x20;

## Create PDF

<mark style="color:green;">`POST`</mark> `https://pdfgen.com/api/v1/create`

Create PDFs with customized data using your templates

**Headers**

<table><thead><tr><th width="253">Name</th><th width="120">Type</th><th>Value</th></tr></thead><tbody><tr><td>Content-Type</td><td>string</td><td>application/json <code>or</code> application/pdf</td></tr><tr><td>X-API-Key</td><td>string</td><td>&#x3C;API-Key></td></tr></tbody></table>

**Request body**

<table><thead><tr><th width="251">Name</th><th width="122">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>template_id</code><mark style="color:red;">*</mark></td><td>string</td><td>Template ID (Get from PDFgen app)</td></tr><tr><td><code>export_type</code></td><td>string</td><td>"url" or "file" <br>Default: "file"</td></tr><tr><td><code>file_name</code></td><td>string</td><td>Name for the generated PDF</td></tr><tr><td><code>expiry_time</code></td><td>number</td><td>Expiry time(in minutes) for the PDF URL. <br>e.g., 1<br>Default: 5</td></tr><tr><td><code>data</code></td><td>object</td><td><p>key: Identifier, value: Content<br>e.g, </p><pre class="language-postman_json"><code class="lang-postman_json">{
  "invoice_title": "Invoice",
  "customer_name": "John",
  "invoice_date": "Date: 2024/08/12"
}
</code></pre></td></tr><tr><td><code>protect_pdf</code></td><td>boolean</td><td>To protect the generated PDF with a password<br>Default: false</td></tr><tr><td><code>password</code></td><td>string</td><td>Password if <code>protect_pdf</code> is true</td></tr><tr><td><code>self_storage</code></td><td>boolean</td><td>To store PDFs in user's AWS S3 storage. <br>Default: false<br><br>Note: User need to have a "Business" plan to use this feature</td></tr></tbody></table>

**Response**

If the `export_type` is set to "`url`," a successful response will return a JSON object containing a download link in the `url` parameter, available until the expiry time. If the `export_type` is set to "`file`", a successful response will return the binary data of the PDF file.

{% tabs %}
{% tab title="200: For export\_type: 'url' " %}

```json
{
  "url": "URL of the PDF generated"
}
```

{% endtab %}

{% tab title="400: No API key present or Bad request" %}

```json
{
  "error": "No API Key present"
}
```

{% endtab %}

{% tab title="401: Invalid API key " %}

```json
{
  "error": "Invalid API key"
}
```

{% endtab %}
{% endtabs %}
