This endpoint returns different response structures depending on whether the
template is fully created or still being processed. Use this endpoint to poll
for completion when creating templates with AI.
GET https://api.pdfnoodle.com/v1/integration/templates/:templateId
Request
curl --location 'https://api.pdfnoodle.com/v1/integration/templates/invoice-template-001' \
--header 'Authorization: Bearer pdfnoodle_api_123456789'
Response
This endpoint returns different response structures depending on the template’s status:
Completed Template Response
Success - Completed Template (200 OK)
{
"template" : {
"id" : "invoice-template-001" ,
"displayName" : "Standard Invoice" ,
"createdAt" : "2024-01-15T10:30:00.000Z" ,
"updatedAt" : "2024-01-15T10:30:00.000Z" ,
"style" : {
"header" : { "showHeader" : true , "headerText" : "..." },
"footer" : { "showFooter" : true , "footerText" : "..." }
},
"type" : "HTML" ,
"html" : "<html>...</html>"
}
}
Template Creation Status Response
ONGOING - Template Being Created (200 OK)
SUCCESS - Template Creation Completed (200 OK)
FAILED - Template Creation Failed (200 OK)
{
"status" : "ONGOING" ,
"templateId" : "a1b2c3d4e5" ,
"templateHtml" : "" ,
"metadata" : {}
}
Path Parameters
Template identifier. This can be: - The name field from an existing template
(same as id from list templates response) - The templateId returned from
the create template endpoint
Response Fields
Completed Template Response
Status Response (for templates being created)
Status Checking
When creating a template with AI, use this endpoint to poll for completion:
ONGOING : Template creation is still in progress. Continue polling.
SUCCESS : Template has been created successfully. The templateHtml field contains the generated template.
FAILED : Template creation failed. Check metadata.errorMessage for details.
Status information for templates being created is cached in Redis for 24
hours. Once a template is fully created, the response format changes to the
full template object.
Polling Strategy
When polling for template creation status:
Poll every 10-30 seconds after initial creation
Stop polling once status is SUCCESS or FAILED
For completed templates, the response format changes to the full template object
If a template doesn’t exist and isn’t in the creation queue, you’ll receive a 404 Not Found error
Usage Example
Here’s a complete example of checking template status:
async function checkTemplateStatus ( templateId ) {
const response = await fetch (
`https://api.pdfnoodle.com/v1/integration/templates/ ${ templateId } ` ,
{
headers: { Authorization: "Bearer pdfnoodle_api_123456789" },
}
);
const data = await response . json ();
// Check if template is complete
if ( data . template ) {
console . log ( "Template is complete:" , data . template );
return data . template ;
}
// Check creation status
if ( data . status === "SUCCESS" ) {
console . log ( "Template created successfully!" );
console . log ( "Time to create:" , data . metadata . timeToCreateTemplate );
console . log ( "Template HTML:" , data . templateHtml );
return data ;
} else if ( data . status === "FAILED" ) {
throw new Error ( `Template creation failed: ${ data . metadata . errorMessage } ` );
} else if ( data . status === "ONGOING" ) {
console . log ( "Template creation is still in progress..." );
return null ; // Continue polling
}
}
// Polling example
async function pollTemplateStatus ( templateId ) {
const maxAttempts = 40 ; // Poll for up to 10 minutes (40 * 15 seconds)
let attempts = 0 ;
while ( attempts < maxAttempts ) {
const result = await checkTemplateStatus ( templateId );
if ( result ) {
return result ; // Template is ready or failed
}
// Wait 15 seconds before checking again
await new Promise (( resolve ) => setTimeout ( resolve , 15000 ));
attempts ++ ;
}
throw new Error ( "Template creation timed out" );
}
import requests
import time
def check_template_status ( template_id ):
response = requests.get(
f 'https://api.pdfnoodle.com/v1/integration/templates/ { template_id } ' ,
headers = { 'Authorization' : 'Bearer pdfnoodle_api_123456789' }
)
data = response.json()
# Check if template is complete
if 'template' in data:
print ( 'Template is complete:' , data[ 'template' ])
return data[ 'template' ]
# Check creation status
if data.get( 'status' ) == 'SUCCESS' :
print ( 'Template created successfully!' )
print ( 'Time to create:' , data[ 'metadata' ][ 'timeToCreateTemplate' ])
print ( 'Template HTML:' , data[ 'templateHtml' ])
return data
elif data.get( 'status' ) == 'FAILED' :
raise Exception ( f "Template creation failed: { data[ 'metadata' ][ 'errorMessage' ] } " )
elif data.get( 'status' ) == 'ONGOING' :
print ( 'Template creation is still in progress...' )
return None # Continue polling
# Polling example
def poll_template_status ( template_id ):
max_attempts = 40 # Poll for up to 10 minutes (40 * 15 seconds)
attempts = 0
while attempts < max_attempts:
result = check_template_status(template_id)
if result:
return result # Template is ready or failed
# Wait 15 seconds before checking again
time.sleep( 15 )
attempts += 1
raise Exception ( 'Template creation timed out' )
Error Responses
401 Unauthorized
{
"message" : "Unauthorized"
}
Occurs when: The API key is missing or invalid.
404 Not Found
{
"message" : "Couldnt find this template."
}
Occurs when: The requested template doesn’t exist and isn’t in the creation queue.
500 Internal Server Error
{
"message" : "Error message describing what went wrong"
}
Occurs when: An internal server error prevents the operation from completing.
If the status is FAILED, check the metadata.errorMessage field for
details about what went wrong. You may need to contact support if the error
persists.