Template Creation
This service allows you to create custom templates that can later be used to fill out documents for signature.
POST /template
Authentication
Include your private key in the Authorization header.
Authorization: prk_xxx...
Creation Parameters
| Property | Type | Required | Description |
|---|---|---|---|
name | string | Required | Name of the automation |
config | array | Required | Array of questions for the user |
signatureProfile | array | Required | Definition of signers and approvers |
sign | array | Required | Names of required questions |
preBuild | boolean | Required | If true, includes automatic pre-fill |
custom | object | Required | Object that allows customizing template characteristics |
Creation Examples
- curl
- Python
- Node.js
curl -X POST https://dev.auco.ai/v1.5/ext/template \
-H "Content-Type: application/json" \
-H "Authorization: your_private_key" \
-d '{
"name": "Test document variable modification",
"config": [
{
"name": "client_name",
"type": "name",
"description": "Enter the client name"
},
{
"description": "Select the document type for the client",
"name": "client_document_type",
"type": "clausula",
"value": "id_card",
"options": [
{
"name": "National ID Card",
"value": "id_card"
},
{
"name": "Foreign ID Card",
"value": "foreign_id"
}
]
},
{
"description": "Enter the national ID card number for the client",
"name": "client_id_card",
"type": "number",
"prereq": [
{
"k": "client_document_type",
"v": "id_card"
}
]
},
{
"description": "Enter the foreign ID number for the client",
"name": "client_foreign_id",
"type": "number",
"prereq": [
{
"k": "client_document_type",
"v": "foreign_id"
}
]
},
{
"name": "client_email",
"type": "email",
"description": "Enter the client email"
},
{
"name": "client_phone",
"type": "phone",
"description": "Enter the client phone"
}
],
"sign": [
"client_name",
"client_id_card",
"client_foreign_id",
"client_email",
"client_phone"
],
"signatureProfile": [
{
"email": "client_email",
"phone": "client_phone",
"identification": "client_id_card|client_foreign_id",
"name": "client_name",
"type": "client"
}
]
}'
import requests
import json
template_data = {
"name": "Test document variable modification",
"config": [
{
"name": "client_name",
"type": "name",
"description": "Enter the client name"
},
{
"description": "Select the document type for the client",
"name": "client_document_type",
"type": "clausula",
"value": "id_card",
"options": [
{
"name": "National ID Card",
"value": "id_card"
},
{
"name": "Foreign ID Card",
"value": "foreign_id"
}
]
},
{
"description": "Enter the national ID card number for the client",
"name": "client_id_card",
"type": "number",
"prereq": [
{
"k": "client_document_type",
"v": "id_card"
}
]
},
{
"description": "Enter the foreign ID number for the client",
"name": "client_foreign_id",
"type": "number",
"prereq": [
{
"k": "client_document_type",
"v": "foreign_id"
}
]
},
{
"name": "client_email",
"type": "email",
"description": "Enter the client email"
},
{
"name": "client_phone",
"type": "phone",
"description": "Enter the client phone"
}
],
"sign": [
"client_name",
"client_id_card",
"client_foreign_id",
"client_email",
"client_phone"
],
"signatureProfile": [
{
"email": "client_email",
"phone": "client_phone",
"identification": "client_id_card|client_foreign_id",
"name": "client_name",
"type": "client"
}
]
}
def create_template():
url = "https://dev.auco.ai/v1.5/ext/template"
headers = {
"Content-Type": "application/json",
"Authorization": "your_private_key"
}
try:
response = requests.post(
url,
json=template_data,
headers=headers
)
response.raise_for_status()
result = response.json()
print("Template created successfully!")
print(f"Template ID: {result['data']['template_id']}")
print(f"Signed URL: {result['data']['signed_url']}")
return result['data']
except requests.exceptions.RequestException as error:
print(f"Error creating template: {error.response.json() if hasattr(error, 'response') else error}")
if __name__ == "__main__":
create_template()
const axios = require('axios');
const templateData = {
name: 'Test document variable modification',
config: [
{
name: 'client_name',
type: 'name',
description: 'Enter the client name',
},
{
description: 'Select the document type for the client',
name: 'client_document_type',
type: 'clausula',
value: 'id_card',
options: [
{
name: 'National ID Card',
value: 'id_card',
},
{
name: 'Foreign ID Card',
value: 'foreign_id',
},
],
},
{
description: 'Enter the national ID card number for the client',
name: 'client_id_card',
type: 'number',
prereq: [
{
k: 'client_document_type',
v: 'id_card',
},
],
},
{
description: 'Enter the foreign ID number for the client',
name: 'client_foreign_id',
type: 'number',
prereq: [
{
k: 'client_document_type',
v: 'foreign_id',
},
],
},
{
name: 'client_email',
type: 'email',
description: 'Enter the client email',
},
{
name: 'client_phone',
type: 'phone',
description: 'Enter the client phone',
},
],
sign: ['client_name', 'client_id_card', 'client_foreign_id', 'client_email', 'client_phone'],
signatureProfile: [
{
email: 'client_email',
phone: 'client_phone',
identification: 'client_id_card|client_foreign_id',
name: 'client_name',
type: 'client',
},
],
};
async function createTemplate() {
try {
const response = await axios.post('https://dev.auco.ai/v1.5/ext/template', templateData, {
headers: {
'Content-Type': 'application/json',
Authorization: 'your_private_key',
},
});
console.log('Template created successfully!');
console.log('Template ID:', response.data.data.template_id);
console.log('Signed URL:', response.data.data.signed_url);
return response.data.data;
} catch (error) {
console.error('Error creating template:', error.response?.data || error.message);
}
}
createTemplate();
Response Example
{
"id": "template_id",
"urls": {
"mask": "https://signed_url_mask",
"complete": "https://signed_url_complete"
}
}
Uploading HTML Complete and HTML Mask:
In the creation service response, you will find two response URLs. These have a lifespan of 5 minutes; after this time, they will no longer be valid. At this point, you should have the HTML Complete and HTML Mask files ready and upload the Base64 of these files in PUT requests to each of these URLs.
- curl
- Python
- Node.js
# Upload HTML Mask
curl -X PUT https://signed_url_mask \
-H "Content-Type: text/html" \
-d @mask.html
# Upload HTML Complete
curl -X PUT https://signed_url_complete \
-H "Content-Type: text/html" \
-d @complete.html
import requests
def upload_html_files(mask_url, complete_url):
"""
Uploads HTML files to the signed URLs
Args:
mask_url (str): Signed URL for the HTML Mask
complete_url (str): Signed URL for the HTML Complete
"""
try:
# Read HTML files
with open('mask.html', 'r', encoding='utf-8') as f:
mask_html = f.read()
with open('complete.html', 'r', encoding='utf-8') as f:
complete_html = f.read()
headers = {'Content-Type': 'text/html'}
# Upload Mask HTML
response_mask = requests.put(mask_url, data=mask_html, headers=headers)
print(f"Mask HTML uploaded: {response_mask.status_code}")
# Upload Complete HTML
response_complete = requests.put(complete_url, data=complete_html, headers=headers)
print(f"Complete HTML uploaded: {response_complete.status_code}")
except requests.exceptions.RequestException as error:
print(f"Error uploading: {error}")
# Usage from the previous response
mask_url = "https://signed_url_mask"
complete_url = "https://signed_url_complete"
upload_html_files(mask_url, complete_url)
const fs = require('fs');
const axios = require('axios');
/**
* Uploads HTML files to the signed URLs
* @param {string} maskUrl - Signed URL for the HTML Mask
* @param {string} completeUrl - Signed URL for the HTML Complete
*/
async function uploadHtmlFiles(maskUrl, completeUrl) {
try {
// Read HTML files
const maskHtml = fs.readFileSync('mask.html', 'utf-8');
const completeHtml = fs.readFileSync('complete.html', 'utf-8');
const headers = { 'Content-Type': 'text/html' };
// Upload Mask HTML
await axios.put(maskUrl, maskHtml, { headers });
console.log('Mask HTML uploaded successfully');
// Upload Complete HTML
await axios.put(completeUrl, completeHtml, { headers });
console.log('Complete HTML uploaded successfully');
} catch (error) {
console.error('Error uploading files:', error.message);
}
}
// Usage from the previous response
const maskUrl = 'https://signed_url_mask';
const completeUrl = 'https://signed_url_complete';
uploadHtmlFiles(maskUrl, completeUrl);
Important
Signed URLs expire in 5 minutes. You must complete the upload before this time expires.