Skip to main content

REST API

API overview

  • These endpoints require the x-functions-key header.
  • Main integration operations are metadata extraction, model generation, document generation, and template listing.

Core resource groups

The function API surface is organized around template-processing flows:

  • Template metadata
    • GET /api/generateTemplateMetadata?templateId={guid}
    • Returns discovered placeholders and content controls.
  • Template model
    • POST /api/generateModel?templateId={guid}
    • Returns starter JSON payload aligned to template fields.
  • Document generation
    • POST /api/generateDocument
    • Accepts GenerateDocumentDto and returns file output (.docx or .pdf).
  • Template catalog
    • GET /api/getTemplates?pageNumber={n}&pageSize={n}
    • Returns paged templates available for generation endpoints.

Request and response conventions

Common response behavior:

  • Success responses return JSON for metadata/model/list endpoints.
  • generateDocument returns binary file content with download filename.
  • Invalid query/body values return 400 with structured error payloads.
  • Missing or invalid function key returns 401 Unauthorized.

Pagination and querying

List endpoint pagination:

  • getTemplates requires pageNumber and pageSize.

Error model

Error handling is centralized and consistent:

  • Validation failures (for example invalid templateId, invalid paging values) return bad request errors.
  • Authorization failures (missing key or inactive subscription key) are blocked before processing.

Code examples

Typical integration flow:

  1. Call getTemplates to select a template.
  2. Call generateTemplateMetadata or generateModel for schema guidance.
  3. Call generateDocument with template data.
  4. Save the returned file bytes as .docx or .pdf.

Example request (service key flow):

curl -X GET "https://your-host/api/getTemplates?pageNumber=1&pageSize=10" \
-H "x-functions-key: your_api_key"