Skip to main content

What is Stru Mathcad API?

The Stru Mathcad API enables programmatic generation and manipulation of Mathcad Prime (.mcdx) documents. Automate calculation package creation, standardize engineering documentation, and integrate Mathcad into your workflows without manual file creation. Base URL: https://api.stru.ai/v1 Authentication: Bearer token (API key from app.stru.ai)

Core Concepts

Document Generation

Create Mathcad Prime (.mcdx) files from scratch programmatically. Build complete calculation documents element by element.

Element-Based Building

Add text blocks, variables, formulas, images, and metadata to build rich, professional documents.

Async Jobs

All document operations run asynchronously. Submit a job, receive a job ID, then poll for the generated file download URL.

AI-Enhanced Formatting

Optional AI-powered layout optimization adjusts element positioning for professional presentation.

Key Features

  • Document Automation: Generate complete .mcdx files programmatically without opening Mathcad
  • Element Control: Add text, variables, formulas, images with precise control
  • Template Standard: Create company-standard calculation templates dynamically
  • PDF Generation: Convert generated .mcdx documents to PDFs for distribution
  • Legacy Conversion: Convert old .xmcd files to modern .mcdx format
  • Document Reading: Parse existing .mcdx files to extract structure and formulas
  • Secure Downloads: Generated files available via time-limited signed URLs (24-hour retention)

Supported File Formats

Fully Supported - The API operates exclusively with the modern Mathcad Prime .mcdx format.
  • Create new .mcdx documents
  • Read/parse existing .mcdx files
  • Modify and update .mcdx documents
  • Generate PDFs from .mcdx files
Limited Support - Legacy .xmcd files can be converted to .mcdx format via the /convert endpoint.
  • One-way conversion: .xmcd → .mcdx
  • No direct editing of .xmcd files
  • Conversion is best-effort (some complex elements may require manual adjustment)
Not Supported - Binary .mcd files from Mathcad 14 and earlier are not supported.Workaround: Open in Mathcad 15 and save as .xmcd, then use the conversion endpoint.

Quick Start

1

Get Your API Key

Sign in to app.stru.ai and generate an API key from your dashboard.
# Your API key will look like:
sk_live_abc123...
2

Create a Document Job

Submit a job to create a new Mathcad document.
curl -X POST https://api.stru.ai/v1/mathcad/jobs \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "create_document",
    "document_name": "Beam Design Calculation",
    "elements": [
      {"type": "text", "content": "# Beam Design\n\nProject: Sample Building"},
      {"type": "variable", "name": "L", "value": 20, "unit": "ft", "description": "Beam span"},
      {"type": "formula", "expression": "M = w * L^2 / 8", "description": "Maximum moment"}
    ],
    "metadata": {
      "author": "John Doe",
      "project": "Sample Project"
    }
  }'
Response:
{
  "job_id": "job_mcd_abc123",
  "status": "pending",
  "created_at": "2025-10-17T10:30:00Z"
}
3

Poll for Completion

Check the job status until complete.
curl https://api.stru.ai/v1/jobs/job_mcd_abc123 \
  -H "Authorization: Bearer YOUR_API_KEY"
When complete:
{
  "job_id": "job_mcd_abc123",
  "status": "completed",
  "results": {
    "file_url": "https://storage.stru.ai/temp/beam-calc.mcdx?signature=...",
    "file_type": "mcdx",
    "expires_at": "2025-10-18T10:30:00Z"
  }
}
4

Download the File

Use the signed URL to download your generated .mcdx file.
curl -o beam-design.mcdx "https://storage.stru.ai/temp/beam-calc.mcdx?signature=..."

Document Elements

Build rich documents by combining these element types:

Text Blocks

Add headers, descriptions, and documentation
{
  "type": "text",
  "content": "# Introduction\n\nThis calculation determines..."
}

Variables

Define input values with units
{
  "type": "variable",
  "name": "L",
  "value": 20,
  "unit": "ft",
  "description": "Beam span"
}

Formulas

Add calculations and equations
{
  "type": "formula",
  "expression": "M = w * L^2 / 8",
  "description": "Maximum moment"
}

Images

Embed diagrams and photos
{
  "type": "image",
  "url": "https://example.com/diagram.png",
  "caption": "Beam loading diagram"
}

Common Workflows

Create complete, multi-page Mathcad reports directly from structural analysis software output.Workflow:
  1. Run analysis in ETABS/SAP2000/etc.
  2. Extract results (forces, deflections, utilization ratios)
  3. Use Mathcad API to generate .mcdx with:
    • Project header (text)
    • Input parameters (variables)
    • Code checks (formulas)
    • Result tables (formatted text)
  4. Generate PDF for submittal package
Generate company-standard calculation templates programmatically based on project parameters.Workflow:
  1. User selects project type (building, bridge, retaining wall)
  2. API generates .mcdx template with:
    • Standard company header
    • Relevant code references
    • Pre-configured variables
    • Applicable formulas
  3. Engineer opens in Mathcad and fills in values
Assemble project calculations from various sources into a single, consistent .mcdx file.Workflow:
  1. Collect calculation data from multiple sources
  2. Standardize format and layout
  3. Generate unified .mcdx document
  4. Add table of contents and metadata
  5. Export to PDF for archival
Integrate with Search API to create documented calculations that reference specific code sections.Workflow:
  1. Search API finds relevant code clause (e.g., “ACI 318-19 Section 10.5.3”)
  2. Extract requirements and formulas
  3. Mathcad API generates .mcdx that:
    • References the code section (text)
    • Shows the requirement (quoted text)
    • Performs the check (formula)
    • Displays result (variable)

API Operations

OperationEndpointDescription
Create DocumentPOST /v1/mathcad/jobsGenerate a new .mcdx file
Add ElementsPOST /v1/mathcad/{doc_id}/elementsAdd content to existing document
Read DocumentPOST /v1/mathcad/jobs (operation: read)Parse .mcdx to extract structure
Generate PDFPOST /v1/mathcad/jobs (operation: pdf)Convert .mcdx to PDF
Convert LegacyPOST /v1/mathcad/convertConvert .xmcd to .mcdx

Best Practices

Structure your document with clear sections using text headers.
[
  {"type": "text", "content": "# 1. Input Parameters"},
  {"type": "variable", "name": "L", "value": 20},
  {"type": "text", "content": "# 2. Calculations"},
  {"type": "formula", "expression": "M = w * L^2 / 8"}
]
Make formulas readable with clear variable naming.Good: beam_length, moment_capacity, steel_yield_strengthBad: l, m, fy
Include description fields to document what each element represents.
{
  "type": "variable",
  "name": "fc_prime",
  "value": 4000,
  "unit": "psi",
  "description": "Concrete compressive strength (ACI 318-19)"
}
For documents with many elements, use the AI formatting option to optimize layout.
{
  "operation": "create_document",
  "elements": [...],
  "options": {
    "ai_formatting": true
  }
}
Generated files expire after 24 hours. Download and store them in your system.
# Download immediately after job completes
if job['status'] == 'completed':
    file_url = job['results']['file_url']
    response = requests.get(file_url)
    with open('calculation.mcdx', 'wb') as f:
        f.write(response.content)

Rate Limits & Quotas

TierRequests/MinuteMax Elements/DocFile Retention
Free10501 hour
Pro6050024 hours
EnterpriseCustomUnlimitedCustom
Rate limits apply per API key. Document generation jobs typically take 5-15 seconds depending on complexity.

File Retention & Downloads

Important: Generated files are stored temporarily and automatically deleted after the retention period.
  • Files are available via signed URLs with 24-hour expiration (Pro tier)
  • URLs are valid for one-time download or multiple downloads within the expiration window
  • After expiration, files are permanently deleted from storage
  • Always download and store files in your system immediately after generation

Integration with Other Stru APIs

The Mathcad API works seamlessly with other Stru services:
1

Search for Code Requirements

Use Search API to find relevant building code sections
POST /v1/search/jobs
query: "ACI 318-19 beam shear requirements"
2

Generate Calculation

Use Mathcad API to create documented calculation referencing the code
{
  "elements": [
    {"type": "text", "content": "## Code Reference\nACI 318-19 Section 22.5"},
    {"type": "variable", "name": "Vc", "value": 12500, "unit": "lb"},
    {"type": "formula", "expression": "phi * Vc >= Vu"}
  ]
}
3

Create Summary Report

Use Excel API to build a summary table of all calculations
POST /v1/excel/jobs
Include links to generated .mcdx files

Next Steps