Integrate blockchain-based document certification directly into your applications.
The CertVera API allows you to programmatically certify documents on the blockchain, verify document authenticity, and manage your certified documents. Our API follows RESTful principles and uses standard HTTP response codes.
Base URL: https://certvera.com/api/v1
All API requests must use HTTPS. Requests made over plain HTTP will be rejected.
The CertVera API uses API keys for authentication. You can generate an API key from your dashboard or by making a specific API request.
To generate an API key, you must first authenticate through the web interface. Then you can make the following request:
Request Body:
{
"action": "generate_key"
}
Response:
{
"success": true,
"api_key": "your-api-key",
"message": "Store this API key securely. It will not be displayed again."
}
Include your API key in the Authorization header of all API requests:
Authorization: Bearer your-api-key
The Documents API allows you to upload and manage your certified documents.
Returns a list of all documents uploaded by the authenticated user.
Response:
[
{
"id": 123,
"original_filename": "contract.pdf",
"file_hash": "a1b2c3d4e5f6...",
"uploaded_at": "2025-04-14 15:30:45",
"status": "confirmed",
"virus_scan_status": "safe",
"file_size": 1048576,
"txid": "abcdef1234567890...",
"block_height": 800123,
"confirmation_time": "2025-04-14 15:45:22",
"fee_paid_usd": 0.50
},
...
]
Returns detailed information about a specific document.
Response:
{
"id": 123,
"original_filename": "contract.pdf",
"file_hash": "a1b2c3d4e5f6...",
"uploaded_at": "2025-04-14 15:30:45",
"status": "confirmed",
"virus_scan_status": "safe",
"file_size": 1048576,
"txid": "abcdef1234567890...",
"block_height": 800123,
"confirmation_time": "2025-04-14 15:45:22",
"fee_paid_usd": 0.50
}
Uploads a new document for certification.
Request:
This endpoint expects a multipart/form-data request with a file field named 'document'.
Response:
{
"success": true,
"file_id": 123,
"file_hash": "a1b2c3d4e5f6...",
"status": "pending",
"message": "Document uploaded successfully and is being processed"
}
The Verification API allows you to verify the authenticity of documents.
Verifies a document using its SHA-256 hash.
Response:
{
"verified": true,
"file_hash": "a1b2c3d4e5f6...",
"original_filename": "contract.pdf",
"uploaded_at": "2025-04-14 15:30:45",
"status": "confirmed",
"txid": "abcdef1234567890...",
"block_height": 800123,
"confirmation_time": "2025-04-14 15:45:22",
"op_return": "CertVera.com|a1b2c3d4e5f6...",
"certificate_url": "https://certvera.com/hash_details?hash=a1b2c3d4e5f6..."
}
Verifies a document by uploading the file. The API will calculate the hash and check if it exists in the system.
Request:
This endpoint expects a multipart/form-data request with a file field named 'document'.
Response:
{
"verified": true,
"file_hash": "a1b2c3d4e5f6...",
"original_filename": "contract.pdf",
"uploaded_at": "2025-04-14 15:30:45",
"status": "confirmed",
"txid": "abcdef1234567890...",
"block_height": 800123,
"confirmation_time": "2025-04-14 15:45:22",
"op_return": "CertVera.com|a1b2c3d4e5f6...",
"certificate_url": "https://certvera.com/hash_details?hash=a1b2c3d4e5f6..."
}
The API uses standard HTTP status codes to indicate the success or failure of an API request.
Status Code | Description |
---|---|
200 OK | The request was successful. |
400 Bad Request | The request was invalid or cannot be served. The exact error is explained in the response body. |
401 Unauthorized | Authentication credentials were missing or incorrect. |
404 Not Found | The requested resource could not be found. |
405 Method Not Allowed | The requested method is not supported for the specified endpoint. |
409 Conflict | The request could not be completed due to a conflict with the current state of the resource. |
500 Internal Server Error | An error occurred on the server. |
Error responses will have the following format:
{
"error": "Error message describing what went wrong"
}
// Assumes you're already logged in via the web interface
fetch('https://certvera.com/api/v1/auth', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
action: 'generate_key'
})
})
.then(response => response.json())
.then(data => {
console.log('API Key:', data.api_key);
// Store this key securely
})
.catch(error => console.error('Error:', error));
$apiKey = 'your-api-key';
$filePath = '/path/to/your/document.pdf';
$curl = curl_init();
$postFields = array(
'document' => new CURLFile($filePath)
);
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://certvera.com/api/v1/documents',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $postFields,
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer ' . $apiKey
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "Error: " . $err;
} else {
$result = json_decode($response, true);
echo "File ID: " . $result['file_id'] . "\n";
echo "File Hash: " . $result['file_hash'] . "\n";
}
import requests
# Verify by hash
file_hash = 'a1b2c3d4e5f6...'
response = requests.get(
f'https://certvera.com/api/v1/verify/{file_hash}'
)
if response.status_code == 200:
result = response.json()
if result['verified']:
print(f"Document verified! Confirmed on: {result['confirmation_time']}")
print(f"Transaction ID: {result['txid']}")
else:
print("Document found but not yet confirmed on blockchain")
else:
print(f"Error: {response.json()['error']}")
# Verify by file upload
file_path = '/path/to/your/document.pdf'
with open(file_path, 'rb') as f:
files = {'document': f}
response = requests.post(
'https://certvera.com/api/v1/verify',
files=files
)
if response.status_code == 200:
result = response.json()
if result['verified']:
print(f"Document verified! Confirmed on: {result['confirmation_time']}")
print(f"Transaction ID: {result['txid']}")
else:
print("Document found but not yet confirmed on blockchain")
else:
print(f"Error: {response.json()['error']}")