Skip to main content
POST
/
v1
/
mathcad
/
{doc_id}
/
elements
Add Elements
curl --request POST \
  --url https://api.stru.ai/v1/mathcad/{doc_id}/elements \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '{
  "elements": [
    {}
  ],
  "position": "<string>"
}'

Overview

Add additional content (text, variables, formulas, images) to an existing Mathcad Prime (.mcdx) document. This allows you to build documents incrementally or update existing calculations.
Asynchronous Operation: Returns immediately with a job ID. Poll for the updated document download URL.

Authentication

Authorization
string
required
Bearer token (API key from app.stru.ai)

Path Parameters

doc_id
string
required
Document identifier (from previous create/read operation)
doc_abc123xyz

Request Body

elements
array
required
Array of new elements to add to the document
"elements": [
  {"type": "text", "content": "## Additional Calculations"},
  {"type": "variable", "name": "factor", "value": 1.5},
  {"type": "formula", "expression": "result = input * factor"}
]
position
string
Where to add elements: "append" (default) or "prepend"
"position": "append"

Element Types

Same as create-document operation:
  • Text: Headers and descriptions
  • Variables: Named values with units
  • Formulas: Mathematical expressions
  • Images: Embedded diagrams
See Create Document for full element schemas.

Example Request

curl -X POST https://api.stru.ai/v1/mathcad/doc_abc123/elements \
  -H "Authorization: Bearer sk_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "elements": [
      {
        "type": "text",
        "content": "## Additional Design Checks"
      },
      {
        "type": "variable",
        "name": "safety_factor",
        "value": 1.5,
        "description": "Safety factor per code"
      },
      {
        "type": "formula",
        "expression": "capacity = base_capacity * safety_factor",
        "description": "Adjusted capacity"
      }
    ],
    "position": "append"
  }'

Response

{
  "job_id": "job_mcd_add_abc123",
  "status": "pending",
  "created_at": "2025-10-17T10:35:00Z"
}
When complete, returns updated document download URL.

Use Cases

Build documents in stages:
  1. Create initial document with inputs
  2. Add calculations section
  3. Add results and summary
  4. Add final conclusions
Update existing calculations with new code requirements or design changes without recreating the entire document.
Start with a base template, then add project-specific calculations dynamically.

Best Practices

Verify dependencies - Ensure variables referenced in new formulas are already defined in the document
Use logical sections - Add section headers (text elements) to organize new content
Maintain order - Elements are added in the order provided in the array

Next Steps

Poll Get Job Status to retrieve the updated document download URL.