> ## Documentation Index > Fetch the complete documentation index at: https://devdocs.veriff.com/llms.txt > Use this file to discover all available pages before exploring further. # Download certificate source document > ### Returns the source document file that a certificate attests to #### When to use this endpoint - Use this endpoint to download a source document referenced by a certificate's `sourceDocuments` array - The document is the artefact whose integrity the certificate preserves (for example the generated session data PDF) - The `certificateId` and `fileId` values must be obtained first from [GET /v1/sessions/{id}/certificates](https://devdocs.veriff.com/apidocs/v1sessionsidcertificates-1) - This endpoint is currently available as part of the [Mexico - NOM-151 Certification solution](#) #### Getting the identifiers 1. Call [GET /v1/sessions/{id}/certificates](https://devdocs.veriff.com/apidocs/v1sessionsidcertificates-1) to retrieve the session certificates 2. Find the certificate `id` (the `certificateId`) and the `sourceDocuments[].id` (the `fileId`) of the document you want to download 3. Use both identifiers to download the file with this endpoint #### Response data - The endpoint returns a binary file with the `application/pdf` Content-Type - The file is returned as binary data in the response body #### Implementation notes - This endpoint requires session-level [HMAC signature](https://devdocs.veriff.com/docs/hmac-authentication-and-endpoint-security#public-api-v1) authentication - Set appropriate Content-Type handling in your HTTP client to receive binary data - Always ensure that you use the correct API URL to send requests. See the [API URL section](https://devdocs.veriff.com/apidocs/veriff-public-api-guides#api-url) for more info - The order of parameters in the real API response can differ from the order you see in this documentation. This is expected and part of the [Backwards compatible changes](https://devdocs.veriff.com/apidocs/veriff-public-api-guides#backwards-compatible-changes) requirements #### How to store response data to file? ```python import requests file_url = 'https://example-base-url/v1/sessions/d69a07cf-4434-4d36-be6c-d22af7dc01fb/certificates/27d303bb-6a1f-4c2e-9b1d-2f3a4b5c6d7e/files/a6a27f7a-3c4d-4e5f-8a9b-0c1d2e3f4a5b' headers = { 'X-AUTH-CLIENT': 'your-api-key', 'X-HMAC-SIGNATURE': '452bfca0e02f8ee0f56d97373cc6971067e43149f1b7e58b681d4e57353a2f6b', 'Content-Type': 'application/json', } response = requests.get(file_url, headers=headers) with open('certificate_source_document.pdf', 'wb') as write_file: write_file.write(response.content) ``` ## OpenAPI ````json GET /v1/sessions/{id}/certificates/{certificateId}/files/{fileId} { "openapi": "3.0.0", "info": { "title": "Veriff Public API", "version": "1.0.0" }, "servers": [ { "url": "https://example-base-url" } ], "tags": [ { "name": "Session management", "description": "Create and manage verification sessions" }, { "name": "Data submission", "description": "Upload media and submit verification data during the session" }, { "name": "Session results", "description": "Retrieve verification decisions and results" }, { "name": "Media management", "description": "Access and download verification media files and media file-related data" }, { "name": "Database verification", "description": "Validate identity against national registries and databases" }, { "name": "Certificate management", "description": "Retrieve long-term preservation certificates and their source documents for a verification session" } ], "paths": { "/v1/sessions/{id}/certificates/{certificateId}/files/{fileId}": { "get": { "summary": "Download certificate source document", "description": "### Returns the source document file that a certificate attests to\n\n#### When to use this endpoint\n\n- Use this endpoint to download a source document referenced by a certificate's `sourceDocuments` array\n- The document is the artefact whose integrity the certificate preserves (for example the generated session data PDF)\n- The `certificateId` and `fileId` values must be obtained first from [GET /v1/sessions/{id}/certificates](https://devdocs.veriff.com/apidocs/v1sessionsidcertificates-1)\n- This endpoint is currently available as part of the [Mexico - NOM-151 Certification solution](#)\n\n#### Getting the identifiers\n\n1. Call [GET /v1/sessions/{id}/certificates](https://devdocs.veriff.com/apidocs/v1sessionsidcertificates-1) to retrieve the session certificates\n2. Find the certificate `id` (the `certificateId`) and the `sourceDocuments[].id` (the `fileId`) of the document you want to download\n3. Use both identifiers to download the file with this endpoint\n\n#### Response data\n\n- The endpoint returns a binary file with the `application/pdf` Content-Type\n- The file is returned as binary data in the response body\n\n#### Implementation notes\n\n- This endpoint requires session-level [HMAC signature](https://devdocs.veriff.com/docs/hmac-authentication-and-endpoint-security#public-api-v1) authentication\n- Set appropriate Content-Type handling in your HTTP client to receive binary data\n- Always ensure that you use the correct API URL to send requests. See the [API URL section](https://devdocs.veriff.com/apidocs/veriff-public-api-guides#api-url) for more info\n- The order of parameters in the real API response can differ from the order you see in this documentation. This is expected and part of the [Backwards compatible changes](https://devdocs.veriff.com/apidocs/veriff-public-api-guides#backwards-compatible-changes) requirements\n\n#### How to store response data to file?\n\n```python\nimport requests\n\nfile_url = 'https://example-base-url/v1/sessions/d69a07cf-4434-4d36-be6c-d22af7dc01fb/certificates/27d303bb-6a1f-4c2e-9b1d-2f3a4b5c6d7e/files/a6a27f7a-3c4d-4e5f-8a9b-0c1d2e3f4a5b'\n\nheaders = {\n 'X-AUTH-CLIENT': 'your-api-key',\n 'X-HMAC-SIGNATURE': '452bfca0e02f8ee0f56d97373cc6971067e43149f1b7e58b681d4e57353a2f6b',\n 'Content-Type': 'application/json',\n}\n\nresponse = requests.get(file_url, headers=headers)\nwith open('certificate_source_document.pdf', 'wb') as write_file:\n write_file.write(response.content)\n```\n", "operationId": "retrieveSessionCertificateFile", "tags": [ "Certificate management" ], "parameters": [ { "name": "id", "in": "path", "required": "true", "description": "Verification session ID.", "schema": { "type": "string", "format": "uuid" }, "example": "d69a07cf-4434-4d36-be6c-d22af7dc01fb" }, { "name": "certificateId", "in": "path", "required": "true", "description": "Certificate ID, obtained from the session certificates list.", "schema": { "type": "string", "format": "uuid" }, "example": "27d303bb-6a1f-4c2e-9b1d-2f3a4b5c6d7e" }, { "name": "fileId", "in": "path", "required": "true", "description": "Source document ID, obtained from a certificate's `sourceDocuments` array.", "schema": { "type": "string", "format": "uuid" }, "example": "a6a27f7a-3c4d-4e5f-8a9b-0c1d2e3f4a5b" }, { "name": "X-AUTH-CLIENT", "in": "header", "required": "true", "description": "Your integration's API key (occasionally referred to as the \"Token\", \"API public key\" or \"Publishable key\").\nRequired for all API requests.\n\nYou can find your API key in the Veriff Customer Portal > Settings > API keys.\n", "schema": { "type": "string" }, "example": "your-api-key" }, { "name": "X-HMAC-SIGNATURE", "in": "header", "required": "true", "description": "Session ID signed with the shared secret key. Required to authenticate the request sender.", "schema": { "type": "string" }, "example": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6" } ], "responses": { "200": { "description": "Certificate source document file", "headers": { "Content-Type": { "description": "MIME type of the file being returned.", "schema": { "type": "string", "enum": [ "application/pdf" ], "example": "application/pdf" } }, "X-AUTH-CLIENT": { "description": "API key echoed back in response.", "schema": { "type": "string", "example": "your-api-key" } }, "X-HMAC-SIGNATURE": { "description": "Response body signed with the shared secret key. Required to authenticate the response sender.", "schema": { "type": "string", "example": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6" } } }, "content": { "application/pdf": { "schema": { "type": "string", "format": "binary" } } } }, "401": { "description": "Unauthorized", "headers": { "Content-Type": { "description": "Response content type.", "schema": { "type": "string", "example": "application/json" } }, "X-AUTH-CLIENT": { "description": "API key echoed back in response.", "schema": { "type": "string" } }, "X-HMAC-SIGNATURE": { "description": "Response body signed with the shared secret key.", "schema": { "type": "string" } } }, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UnauthorizedErrorResponse" }, "example": { "status": "fail", "code": "1101", "message": "Mandatory X-AUTH-CLIENT header containing the API key is missing from the request." } } } }, "404": { "description": "Certificate file not found", "headers": { "Content-Type": { "description": "Response content type.", "schema": { "type": "string", "example": "application/json" } }, "X-AUTH-CLIENT": { "description": "API key echoed back in response.", "schema": { "type": "string" } }, "X-HMAC-SIGNATURE": { "description": "Response body signed with the shared secret key.", "schema": { "type": "string" } } }, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/NotFoundErrorResponse" }, "example": { "status": "fail", "code": "1101", "message": "Certificate file not found" } } } }, "500": { "description": "Internal server error", "headers": { "Content-Type": { "description": "Response content type.", "schema": { "type": "string", "example": "application/json" } }, "X-AUTH-CLIENT": { "description": "API key echoed back in response.", "schema": { "type": "string" } }, "X-HMAC-SIGNATURE": { "description": "Response body signed with the shared secret key.", "schema": { "type": "string" } } }, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/InternalServerErrorResponse" }, "example": { "status": "fail", "code": "1101", "message": "Something went wrong" } } } } }, "x-d360-narrative-responses": "

Changelog

Date

Description

Sep 4, 2026

Documentation created

" } } }, "components": { "schemas": { "UnauthorizedErrorResponse": { "type": "object", "properties": { "status": { "type": "string", "enum": [ "fail" ], "example": "fail" }, "code": { "type": "string", "example": "1101" }, "message": { "type": "string", "example": "Mandatory X-AUTH-CLIENT header containing the API key is missing from the request." } }, "required": [ "status", "code", "message" ] }, "NotFoundErrorResponse": { "type": "object", "required": [ "status", "code", "message" ], "properties": { "status": { "type": "string", "enum": [ "fail" ], "example": "fail" }, "code": { "type": "string", "example": "1101" }, "message": { "type": "string", "example": "Resource not found" } } }, "InternalServerErrorResponse": { "type": "object", "properties": { "status": { "type": "string", "enum": [ "fail" ], "example": "fail" }, "code": { "type": "string", "example": "1101" }, "message": { "type": "string", "example": "Something went wrong" } }, "required": [ "status", "code", "message" ] } } } } ````