# How to Download a Document as Base64 Using the BoldSign API

You can retrieve a document in **Base64 format** by adding the `x-response-format` header with the value `base64` to your request. When enabled, the API returns the document as a Base64‑encoded string along with its content type and file name.

***
## Example curl Request (Base64 Response)

```shell
curl -X GET 'https://api.boldsign.com/v1/document/download?documentId=YOUR_DOCUMENT_ID' \
  -H 'accept: application/json' \
  -H 'X-API-KEY: {your-api-key}' \
  -H 'x-response-format: base64'
```
***
### Header Parameter

{% nestedtable %}
*   {% arguments name="x-response-format" /%}{% batch datatype="string" /%}
*   Set this to `base64` to receive the document content as a Base64‑encoded string.
{% /nestedtable %}

The response also includes a `fileName` field, which reflects a system‑generated file name. By default, it includes the predefined document title and its status (for example: `Contract_Completed.pdf`).

For more details, refer to: <https://support.boldsign.com/kb/article/18128/customize-signed-document-naming>

## Base64 Response Format

**200 – Success**

```json
{
  "fileName": "Contract_Completed.pdf",
  "contentType": "application/pdf",
  "file": "JVBERi0xLjcNCiVi...base64encodedstring...ZCVFDQo="
}
```

**Response Fields:**

*   **fileName** – The name of the downloaded file
*   **contentType** – The MIME type of the document (e.g., `application/pdf`)
*   **file** – The Base64‑encoded content of the file

## Other Endpoints Supporting Base64 Format

The `x-response-format: base64` header can also be used with the following endpoints:

*   **DownloadAuditTrail**
*   **DownloadAttachment**
*   **Template Download** endpoints

All of these endpoints follow the same Base64 retrieval pattern.

