Skip to main content

Get Document

Retrieve details of a specific document using its ID.

API Endpoint#

GET https://api.documentpro.ai/v1/documents/{document_id}

Path Parameters#

  • document_id (required): The unique identifier of the document.

Headers#

  • x-api-key (required): Your API key for authentication.
  • Accept (optional): Specify the desired response format (e.g., "application/json", "application/xml").

Example Implementation#

import requests
document_id = "c946e1cf-5cfd-4428-abbe-dd930d7d317b"url = f"https://api.documentpro.ai/v1/documents/{document_id}"
headers = {    "x-api-key": "YOUR_API_KEY",    "Accept": "application/json"}
response = requests.get(url, headers=headers)
if response.status_code == 200:    print("Document retrieved successfully:")    print(response.json())else:    print("Failed to retrieve document")    print(response.text)

Response#

Successful Response (Status Code: 200)#

{    "document_id": "c946e1cf-5cfd-4428-abbe-dd930d7d317b",    "user_id": "244vbx5a-9bba-4de4-be67-c06233d2f305",    "source_name": "api",    "s3_key": "https://documentpro-user-accounts.s3.amazonaws.com/...",    "file_name": "example_document.pdf",    "file_extension": "pdf",    "num_pages": 5,    "meta_tags": {},    "parser_runs": [        {            "template_id": "a62e2b5f-ccc2-4e2a-8fda-d7bd6579a692",            "template_title": "Invoice",            "request_id": "185e337c-0294-4cf8-b684-1310c8cd6a4e",            "params": {                "page_ranges": "1-5",                "use_ocr": true,                "detect_tables": true,                "query_model": "gpt-4o-mini"            },            "datetime": "2024-07-25T10:01:06.536970"        }    ],    "created_at": "2024-07-25T09:30:00.123456",    "updated_at": "2024-07-25T10:01:06.536970"}

Error Response (Status Codes: 400, 401, 403, 404, 500)#

{    "success": false,    "error": "error_code",    "message": "descriptive error message"}

Important Notes#

  1. The s3_key URL is temporary and will expire after a certain period.
  2. parser_runs shows the history of parsing operations performed on the document.
  3. Ensure you have the necessary permissions to access the document.

Next Steps#