Documents

Template Upload

POST
/documents/template/upload

Uploads one or more template files to Storage so they can be referenced in later requests such as document generation. Form-data only. Accepted formats: DOCX, XLSX, DOC, XLS. When several files are sent, their form-data order is preserved in the response. Each template is assigned a storage id. Uploaded templates are automatically removed from Storage after the next document-generation request that consumes them, whether it succeeds or fails — re-upload if needed. Max size is enforced at the gateway (20MB Production, 10MB Staging).

Authorization

AuthorizationBearer <token>

JWT token to authenticate the request.

In: header

X-Api-Key<token>

API key, sent as a request header.

In: header

Header Parameters

X-Service-Authorization?string

Service-to-service auth token, used as an alternative to Authorization for service-principal callers.

X-Client-Authorization?string

Client auth token, used as an alternative to Authorization for client-application callers.

X-Email?string

Caller email, used for identity resolution when authenticating via a service or client auth token.

X-OAuth-Flow?string

Indicates which OAuth flow variant issued the Authorization token.

X-Origin?string

Free-form caller-supplied origin identifier. Not validated; echoed back verbatim into the response envelope's origin field. Optional.

X-Storage-Type*string

Selects which storage container/validation branch handles the request. This operation expects the value document-template. Not strictly enforced as a closed enum server-side.

Request Body

multipart/form-data

TypeScript Definitions

Use the request body type in TypeScript.

body?unknown

Response Body

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/documents/template/upload" \  -H "X-Origin: https://app.mavenmule.com" \  -H "X-Storage-Type: document-template" \  -F file="[]"
{  "result": {    "data": {      "files": [        {          "id": "b1e6d2c9-77aa-4f3b-8c21-9d0e4a6f2b58",          "fileName": "quarterly-report-template.docx"        }      ]    },    "statusCode": 201,    "message": "Created"  },  "origin": "https://app.mavenmule.com",  "dateTime": "2026-07-14T09:32:15.0000000+00:00",  "operationId": "3a4b5c6d7e8f90112233445566778899"}
{  "error": {    "statusCode": 400,    "message": "The file 'notes.txt' has an unsupported format. Allowed: .docx,.xlsx,.doc,.xls",    "innerErrors": [      {        "code": "INVALID_TEMPLATE_FORMAT",        "message": "The file 'notes.txt' has an unsupported format. Allowed: .docx,.xlsx,.doc,.xls",        "userMessage": "This template format isn't supported. Upload a .docx, .xlsx, .doc or .xls file."      }    ]  },  "origin": "https://app.mavenmule.com",  "dateTime": "2026-07-14T09:32:15.0000000+00:00",  "operationId": "3a4b5c6d7e8f90112233445566778899"}
{  "error": {    "statusCode": 401,    "message": "The request could not be authenticated.",    "innerErrors": [      {        "code": "UNAUTHORIZED",        "message": "The request could not be authenticated.",        "userMessage": "Your session has expired or is invalid. Please sign in again."      }    ]  },  "origin": "https://app.mavenmule.com",  "dateTime": "2026-07-14T09:32:15.0000000+00:00",  "operationId": "3a4b5c6d7e8f90112233445566778899"}
{  "error": {    "statusCode": 500,    "message": "Failed to persist the uploaded file to storage.",    "innerErrors": [      {        "code": "FILE_UPLOAD_FAILED",        "message": "Failed to persist the uploaded file to storage.",        "userMessage": "Something went wrong while uploading. Please try again or contact support."      }    ]  },  "origin": "https://app.mavenmule.com",  "dateTime": "2026-07-14T09:32:15.0000000+00:00",  "operationId": "3a4b5c6d7e8f90112233445566778899"}