3D printing API recipes: quotes, upload checks and CI
Three integrations you can copy, each one a working script built on the Python SDK. A print shop gets an instant quote with a price for each infill. A storefront checks every customer upload and flags the ones a person should look at. A pull request fails when an exported STL or STEP file isn't printable. The code on this page is the code that was run, not a sketch. You'll need API keys and the SDK from the repository's sdk/ folder (pip install ./sdk), which isn't on PyPI yet.
Recipe 1: instant quotes for a print shop
A customer uploads a part and wants a price. You want that price to come from the real print, not a guess from the part's volume. A quote does that: it slices the part with a real printer profile, then prices the print time and filament weight with a formula you set.
The script uploads the part, saves a built-in printer as a profile, creates a formula, and asks for a quote with three items. The items are the same part with different slice settings, each with a label. That is how you offer variants: one quote, one item per option. Each item is sliced with its own settings, and each line comes back with its own price.
The formula
A formula is your pricing, stored once: a rate for each field you charge on, a fee per part, a fee for the quote and a minimum. This one charges 6 cents a gram of filament and $4 an hour of print time, plus $3 a part to handle it, with a minimum of $8. Quantity discounts, other printers with their own rates, a build volume check and a quote's validity period are also part of the formula; the API reference lists them all.
"""Recipe 1: an instant quote for a print shop, with a price for each infill level.
PROPERMESH_ACCESS_KEY=... PROPERMESH_SECRET_KEY=... python quote_variants.py bracket.stl --quantity 5
It uploads the part, slices it once per variant (each slice is what the quote is priced from), waits for
the quote and prints one line per variant. With --warnings it also runs the thickness and overhang
analyses, for the notes a customer sees next to the price.
"""
import argparse
import os
from typing import Optional, Sequence, TypedDict
from propermesh import ProperMeshClient, Units
from propermesh.client import QuoteFormula, QuoteItem
# The built-in printers (GET /slice/presets): a real printer, so the print time and filament weight are real
PRINTER = 'prusa-mk4s-0.4'
# What the shop offers: a label, and the slice settings that make it. Add a filament by adding a profile
# (create_profile_from_preset) and a printer_profile_id to the item
VARIANTS: list[tuple[str, dict[str, float]]] = [
('Draft, 10% infill', {'infill_percentage': 10}),
('Standard, 20% infill', {'infill_percentage': 20}),
('Strong, 40% infill', {'infill_percentage': 40}),
]
class PricedLine(TypedDict):
label: Optional[str]
quantity: int
unit_price: str
line_total: str
def formula(profile_id: str) -> QuoteFormula:
"""The shop's prices: $0.06 per gram of filament, $4 an hour of printer time, $3 a part to handle it,
$8 for the quote at least"""
return {
'name': 'Print shop', 'currency': 'USD', 'printer_profile_id': profile_id,
'terms': [{'field': 'filament_weight_g', 'rate': '0.06'}, {'field': 'print_time_hours', 'rate': '4'}],
'per_part_fee': '3', 'minimum_price': '8',
}
def items(part_id: str, quantity: int) -> list[QuoteItem]:
"""One item per variant. They share the part, and differ in their slice settings and label"""
return [{'part_id': part_id, 'quantity': quantity, 'label': label, 'slice_settings': settings} # type: ignore[typeddict-item]
for label, settings in VARIANTS]
def line_items(price_items: Sequence[PricedLine], currency: str) -> list[str]:
"""The lines to show: each variant's price per part and for the order. unit_price is already after
any quantity discount"""
return [f"{line['label'] or 'Part'}: {currency} {line['unit_price']} each, "
f"{currency} {line['line_total']} for {line['quantity']}" for line in price_items]
def dfm_warnings(is_watertight: Optional[bool], thin_percent: float, overhang_percent: float, min_wall_mm: float,
thin_limit_percent: float = 1.0, overhang_limit_percent: float = 15.0) -> list[str]:
"""The notes to show beside the price. The thresholds are your call: these are only starting points"""
warnings = []
if is_watertight is False:
warnings.append('The file has holes, so the print may fail. Send a repaired file, or we can try one.')
if thin_percent > thin_limit_percent:
warnings.append(f'{thin_percent:.1f}% of the surface is thinner than {min_wall_mm} mm and may not print.')
if overhang_percent > overhang_limit_percent:
warnings.append(f'{overhang_percent:.0f}% of the surface overhangs and needs support, which adds cost.')
return warnings
def percent(part: Optional[float], whole: Optional[float]) -> float:
return 100 * part / whole if part is not None and whole else 0.0
def parse_args(argv: Optional[Sequence[str]] = None) -> argparse.Namespace:
parser = argparse.ArgumentParser(description='Quote an STL or STEP file at three infill levels')
parser.add_argument('file')
parser.add_argument('--quantity', type=int, default=1)
parser.add_argument('--units', default='mm', choices=[unit.value for unit in Units])
parser.add_argument('--min-wall', type=float, default=0.8, help='mm: thinner than this gets a warning')
parser.add_argument('--warnings', action='store_true', help='also check thickness and overhangs')
return parser.parse_args(argv)
def main(argv: Optional[Sequence[str]] = None) -> None:
args = parse_args(argv)
client = ProperMeshClient(os.environ['PROPERMESH_ACCESS_KEY'], os.environ['PROPERMESH_SECRET_KEY'],
domain=os.environ.get('PROPERMESH_URL', 'https://propermesh.com'))
part_id = client.upload_part_file(args.file, args.units)
profile_id = client.create_profile_from_preset(PRINTER)['id']
formula_id = client.create_quote_formula(formula(profile_id)).json()['id']
# Starting the thickness and overhang jobs now lets them run while the slices do
if args.warnings:
thickness_id = client.start_thickness_analysis_job(part_id, args.min_wall).json()['id']
overhang_id = client.start_overhang_analysis_job(part_id, 45).json()['id']
quote_id = client.create_quote(formula_id, items(part_id, args.quantity)).json()['id']
quote = client.wait_for_quote_to_complete(quote_id).json()
if quote['status'] != 'complete':
raise SystemExit(f"The quote failed: {quote['failure_reason']}")
for line in line_items(quote['price']['items'], quote['currency']):
print(line)
# quote['total'] adds the variants up, so it's no one price: the customer orders one, as a quote of one item
if args.warnings:
geometry = client.wait_for_part_geometry_analysis_to_complete(part_id).json()
thickness = client.wait_for_thickness_analysis_job_to_complete(thickness_id).json()
overhang = client.wait_for_overhang_analysis_job_to_complete(overhang_id).json()
for warning in dfm_warnings(geometry['is_watertight'],
percent(thickness['thin_surface_area'], thickness['total_surface_area']),
percent(overhang['overhang_surface_area'], geometry['surface_area']), args.min_wall):
print('Note:', warning)
if __name__ == '__main__':
main()
# The SDK isn't on PyPI yet: install it from a checkout of the repository (pip install ./sdk)
export PROPERMESH_ACCESS_KEY="your access key"
export PROPERMESH_SECRET_KEY="your secret key"
python quote_variants.py bracket.stl --quantity 2Draft, 10% infill: USD 7.74 each, USD 15.48 for 2
Standard, 20% infill: USD 8.75 each, USD 17.50 for 2
Strong, 40% infill: USD 10.75 each, USD 21.49 for 2Read each line's unit_price and line_total as that variant's price. The quote's total adds the variants up, so it's no customer's price. When the customer picks one, create a second quote with that one item. It reuses the slice you already have, so it is complete at once.
Add DFM warnings
A price for a part that won't print is a bad quote. Run --warnings and the script also starts thickness and overhang analyses beside the slices, so they cost no extra wait, and turns their results into notes to show next to the price: the file has holes, a share of the surface is thinner than your minimum wall, or a share of it overhangs and needs support. The cut-offs in dfm_warnings are starting points. Set them from the parts your shop declines or reprints. The wall thickness and overhangs guides explain what those numbers mean.
Recipe 2: check customer uploads in a storefront
A customer uploads a model at checkout. An analysis takes seconds to minutes, so don't make the request wait for it. Accept the file, start the checks, and let a webhook tell you when they're done. Propermesh sends a signed POST to your URL each time a job finishes, so there's nothing to poll.
The script is a small web server from the standard library, with three jobs:
- Receive the upload.
POST /uploadwrites the file to a temporary path, uploads it to Propermesh and starts a thickness analysis. Uploading already started the geometry analysis. The customer's filename supplies only the extension, so a name like../../x.stlcan't pick a path. STL and OBJ files don't say what unit they use, so the script assumes millimeters. ChangeUNITSif your customers use something else. - Receive the webhook.
POST /webhooks/propermeshchecks the signature, skips events it has seen, and records each result on the order. - Decide. When both analyses are done, the order is
okorneeds review. The rule is one pure function,review_reasons: the model isn't watertight, or more than 1% of its surface is thinner than 0.8 mm, or an analysis failed.
"""Recipe 2: check a customer's upload in a storefront, with webhooks.
PROPERMESH_ACCESS_KEY=... PROPERMESH_SECRET_KEY=... python storefront.py register https://shop.example.com/webhooks/propermesh
PROPERMESH_WEBHOOK_SECRET=<the secret it printed> ... python storefront.py
`register` runs once. Without arguments it serves: POST /upload takes a file as the body (its name in
X-Filename), sends it to Propermesh and starts its geometry and thickness analyses, and the webhook marks
the order "needs review" or "ok" when both have finished. GET /orders/<part id> shows it. An in-memory
dict stands in for your orders table.
"""
import json
import os
import sys
import tempfile
from dataclasses import dataclass, field
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from typing import Optional, TypedDict
from propermesh import ProperMeshAPIError, ProperMeshClient
from propermesh.webhooks import verify_webhook
MIN_WALL_MM = 0.8
# STL and OBJ files don't say what unit they're in, so the shop decides (a STEP file does say)
UNITS = 'mm'
# More thin surface than this share of the part's surface sends it to review
MAX_THIN_PERCENT = 1.0
ANALYSES = ('geometry', 'thickness')
EXTENSIONS = ('.stl', '.obj', '.step', '.stp')
class EventData(TypedDict):
job_type: str
job_id: str
part_id: str
status: str
failure_reason: Optional[str]
class Event(TypedDict):
id: str
type: str # job.completed or job.failed
occurred_at: str
data: EventData
@dataclass
class Order:
part_id: str
filename: str
is_watertight: Optional[bool] = None
thin_percent: Optional[float] = None
# The analyses that finished, and why any failed
finished: set[str] = field(default_factory=set)
failures: dict[str, str] = field(default_factory=dict)
status: str = 'analyzing'
reasons: list[str] = field(default_factory=list)
def review_reasons(order: Order) -> list[str]:
"""Why a person should look at the order; empty means it can go ahead. Pure, so it's easy to test and tune"""
reasons = [f'{name} analysis failed: {reason}' for name, reason in sorted(order.failures.items())]
if order.is_watertight is False:
reasons.append('the model is not watertight')
if order.thin_percent is not None and order.thin_percent > MAX_THIN_PERCENT:
reasons.append(f'{order.thin_percent:.1f}% of the surface is thinner than {MIN_WALL_MM} mm')
return reasons
def settle(order: Order) -> None:
"""Sets the order's status once every analysis is done, finished or failed, and not before"""
if not set(ANALYSES) <= order.finished | set(order.failures):
return
order.reasons = review_reasons(order)
order.status = 'needs review' if order.reasons else 'ok'
def is_new_event(event_id: str, seen: set[str]) -> bool:
"""Deliveries repeat (a retry after a timeout, a duplicate), so an event that was handled is skipped.
Add the id to seen only after handling succeeded, or a failed attempt's retry would be skipped too"""
return event_id not in seen
ORDERS: dict[str, Order] = {}
SEEN_EVENTS: set[str] = set()
def client_from_env() -> ProperMeshClient:
return ProperMeshClient(os.environ['PROPERMESH_ACCESS_KEY'], os.environ['PROPERMESH_SECRET_KEY'],
domain=os.environ.get('PROPERMESH_URL', 'https://propermesh.com'))
def start_checks(client: ProperMeshClient, filename: str, data: bytes) -> Order:
suffix = os.path.splitext(filename)[1].lower()
if suffix not in EXTENSIONS:
raise ValueError(f'unsupported file type {suffix!r}')
with tempfile.TemporaryDirectory() as directory:
# The customer's filename only supplies the extension: never build a path from it
path = os.path.join(directory, 'upload' + suffix)
with open(path, 'wb') as f:
f.write(data)
part_id = client.upload_part_file(path, UNITS)
# Uploading started the geometry analysis. Thickness is started here
client.start_thickness_analysis_job(part_id, MIN_WALL_MM)
order = Order(part_id=part_id, filename=filename)
ORDERS[part_id] = order
return order
def handle_event(client: ProperMeshClient, event: Event) -> None:
"""Applies one verified event: job.completed or job.failed for a job we started"""
data = event['data']
job_type, job_id, part_id = data['job_type'], data['job_id'], data['part_id']
if job_type not in ANALYSES:
return
order = ORDERS.get(part_id)
if order is None:
# The event can beat the upload's own response, which is what registers the order. Fail the
# delivery, so it's retried a minute later
raise LookupError(f'no order for part {part_id}')
if event['type'] == 'job.failed':
# Don't reject the customer's order over it: a person looks at it
order.failures[job_type] = data['failure_reason'] or 'unknown'
elif job_type == 'geometry':
# The job is complete, so waiting for it returns at once
order.is_watertight = client.wait_for_geometry_analysis_job_to_complete(job_id).json()['is_watertight']
order.finished.add('geometry')
else:
thickness = client.wait_for_thickness_analysis_job_to_complete(job_id).json()
total = thickness['total_surface_area']
order.thin_percent = 100 * thickness['thin_surface_area'] / total if total else None
order.finished.add('thickness')
settle(order)
class Handler(BaseHTTPRequestHandler):
def do_POST(self) -> None:
body = self.rfile.read(int(self.headers.get('Content-Length') or 0))
if self.path == '/upload':
self._upload(body)
elif self.path == '/webhooks/propermesh':
self._webhook(body)
else:
self._reply(404, {})
def do_GET(self) -> None:
order = ORDERS.get(self.path.removeprefix('/orders/'))
if order is None:
self._reply(404, {})
else:
self._reply(200, order.__dict__ | {'finished': sorted(order.finished)})
def _upload(self, body: bytes) -> None:
try:
order = start_checks(client_from_env(), self.headers.get('X-Filename', 'upload.stl'), body)
except ValueError as error:
self._reply(400, {'detail': str(error)})
return
except ProperMeshAPIError as error:
# A 429 is a plan limit (see Retry-After): tell the customer to try later, not that the file is bad
self._reply(503 if error.status_code == 429 else 502, {'detail': error.detail})
return
self._reply(202, {'part_id': order.part_id, 'status': order.status})
def _webhook(self, body: bytes) -> None:
# Verify the raw bytes, before parsing them
signature = self.headers.get('Propermesh-Signature', '')
if not verify_webhook(body, signature, os.environ['PROPERMESH_WEBHOOK_SECRET']):
self._reply(400, {'detail': 'bad signature'})
return
event = json.loads(body)
if is_new_event(event['id'], SEEN_EVENTS):
try:
handle_event(client_from_env(), event)
except (LookupError, ProperMeshAPIError):
# Not a 2xx, so Propermesh retries it
self._reply(503, {'detail': 'try again'})
return
SEEN_EVENTS.add(event['id'])
# A 2xx stops the retries, including for an event that was handled before
self._reply(200, {})
def _reply(self, status: int, payload: object) -> None:
data = json.dumps(payload).encode()
self.send_response(status)
self.send_header('Content-Type', 'application/json')
self.send_header('Content-Length', str(len(data)))
self.end_headers()
self.wfile.write(data)
def register(url: str) -> None:
"""Run once. The secret is only returned here, so keep it as PROPERMESH_WEBHOOK_SECRET"""
endpoint = client_from_env().create_webhook(url, list(ANALYSES)).json()
print('PROPERMESH_WEBHOOK_SECRET=' + endpoint['secret'])
if __name__ == '__main__':
if len(sys.argv) == 3 and sys.argv[1] == 'register':
register(sys.argv[2])
else:
ThreadingHTTPServer(('0.0.0.0', int(os.environ.get('PORT', '8000'))), Handler).serve_forever()
Register the webhook
Register your URL once. It must be public https, and the response holds the signing secret, which is shown only then. job_types limits which jobs send events. Leave it out to get every job.
# Once per endpoint. The URL must be public https. "secret" is only in this response
curl -s https://propermesh.com/api/v0.1/webhooks \
-H "x-access-key: $PROPERMESH_ACCESS_KEY" \
-H "x-secret-access-key: $PROPERMESH_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://shop.example.com/webhooks/propermesh", "job_types": ["geometry", "thickness"]}'export PROPERMESH_ACCESS_KEY="your access key"
export PROPERMESH_SECRET_KEY="your secret key"
# Once: registers the endpoint and prints its secret
python storefront.py register https://shop.example.com/webhooks/propermesh
export PROPERMESH_WEBHOOK_SECRET="the secret it printed"
# Serve uploads and the webhook (put it behind https)
python storefront.py
# A customer uploads a file; the order shows "analyzing" until both webhooks arrive
curl -s localhost:8000/upload -H "X-Filename: bracket.stl" --data-binary @bracket.stl
curl -s localhost:8000/orders/<part id>What arrives, and what to do with it
{
"id": "evt_5c1f0c8f2a3e5b7e9d1f4a6b8c0d2e4f",
"type": "job.completed",
"occurred_at": "2026-11-26T18:07:49Z",
"data": {
"job_type": "thickness",
"job_id": "0b9f6c1e-6a52-4d0c-9c43-1f4f2a8d7e11",
"part_id": "2aff23f1-6e0c-4b55-9109-83b01997c93e",
"status": "complete",
"failure_reason": null
}
}- Verify the raw bytes.
Propermesh-Signatureis an HMAC of the timestamp and the body, and the SDK'sverify_webhookchecks it, and that it's recent. Verify before you parse the JSON, because parsing and writing it again can change the bytes. - Dedupe on the event
id. The same event can arrive twice: a retry after your server was slow, or a job that was delivered twice. Itsidis the same every time. The example keeps ids in a set, adding one only after the event was handled, so a failed attempt is retried. A real shop keeps them in its database, with the order update in the same transaction. - Answer with a 2xx quickly. A delivery that doesn't get a 2xx within 10 seconds is retried for about 50 minutes, and an endpoint that fails 50 deliveries in a row is disabled. Do slow work after you reply.
- Handle
job.failed. A job that failed has afailure_reasonand no result. The example sends that order to review instead of rejecting it, because a failed analysis says nothing about the part. A 429 from the API is a plan limit rather than a bad file, and the example answers it with a 503.
To follow an order in the browser, return the order's status from GET /orders/{id} and show "checking your file" until it settles.
Recipe 3: fail a pull request on a non-printable export
If your repository holds exported STL or STEP files, a bad export can sit there until someone slices it. A check on the pull request catches it when it's cheap to fix. The script takes file paths and thresholds, uploads each file, waits for its geometry and thickness analyses, prints a table and exits non-zero when a file fails.
"""Recipe 3: fail a pull request when an exported STL or STEP file isn't printable.
PROPERMESH_ACCESS_KEY=... PROPERMESH_SECRET_KEY=... python scripts/check_printability.py parts/*.stl
It uploads each file, waits for its geometry and thickness analyses, prints a table and exits 1 if any file
is open (not watertight) or has more of its surface thinner than --min-wall than --max-thin-percent allows.
The exit code is 2 when a file couldn't be analyzed at all.
"""
import argparse
import os
import sys
from dataclasses import dataclass
from typing import Optional, Sequence
from propermesh import ProperMeshClient, ProperMeshAPIError
@dataclass(frozen=True)
class Result:
path: str
# None when the analysis didn't finish
is_watertight: Optional[bool]
thin_percent: Optional[float]
error: Optional[str] = None
def thin_percent(thin_area: Optional[float], total_area: Optional[float]) -> Optional[float]:
"""The share of the surface thinner than the threshold, or None when the analysis has no areas"""
if thin_area is None or not total_area:
return None
return 100 * thin_area / total_area
def problems(result: Result, max_thin_percent: float, allow_open: bool) -> list[str]:
"""Why a file fails, empty when it passes. A file that couldn't be analyzed always fails"""
if result.error is not None:
return [result.error]
found = []
if result.is_watertight is False and not allow_open:
found.append('not watertight')
if result.thin_percent is not None and result.thin_percent > max_thin_percent:
found.append(f'{result.thin_percent:.1f}% of the surface is too thin')
return found
def exit_code(results: Sequence[Result], max_thin_percent: float, allow_open: bool) -> int:
"""0 when every file passes, 1 when a file is not printable, 2 when one couldn't be checked"""
if any(result.error is not None for result in results):
return 2
return 1 if any(problems(result, max_thin_percent, allow_open) for result in results) else 0
def table(results: Sequence[Result], max_thin_percent: float, allow_open: bool) -> str:
rows = [('file', 'watertight', 'thin %', 'result')]
for result in results:
found = problems(result, max_thin_percent, allow_open)
rows.append((result.path, {True: 'yes', False: 'no', None: '?'}[result.is_watertight],
'?' if result.thin_percent is None else f'{result.thin_percent:.1f}',
'FAIL: ' + ', '.join(found) if found else 'ok'))
widths = [max(len(row[column]) for row in rows) for column in range(3)]
return '\n'.join(' '.join(cell.ljust(width) for cell, width in zip(row, widths)) + ' ' + row[3] for row in rows)
def parse_args(argv: Optional[Sequence[str]] = None) -> argparse.Namespace:
parser = argparse.ArgumentParser(description='Check STL and STEP files for printability')
parser.add_argument('files', nargs='*', help='the files to check; none is fine (nothing changed)')
parser.add_argument('--min-wall', type=float, default=0.8, help='mm: surface thinner than this counts as thin')
parser.add_argument('--max-thin-percent', type=float, default=1.0, help='fail above this share of thin surface')
parser.add_argument('--allow-open', action='store_true', help="don't fail files that aren't watertight")
parser.add_argument('--units', default='mm', help='what the files are in: mm or inches')
return parser.parse_args(argv)
def check_file(client: ProperMeshClient, path: str, args: argparse.Namespace) -> Result:
try:
part_id = client.upload_part_file(path, args.units)
thickness_job = client.start_thickness_analysis_job(part_id, args.min_wall).json()
# Uploading started the geometry analysis. The two run in parallel on the workers
geometry = client.wait_for_part_geometry_analysis_to_complete(part_id).json()
thickness = client.wait_for_thickness_analysis_job_to_complete(thickness_job['id']).json()
except ProperMeshAPIError as error:
return Result(path, None, None, f'API error {error.status_code}: {error.detail}')
for job in (geometry, thickness):
if job['status'] != 'complete':
return Result(path, None, None, f"analysis {job['status']}: {job['failure_reason']}")
return Result(path, geometry['is_watertight'], thin_percent(thickness['thin_surface_area'], thickness['total_surface_area']))
def main(argv: Optional[Sequence[str]] = None) -> int:
args = parse_args(argv)
if not args.files:
print('No files to check.')
return 0
client = ProperMeshClient(os.environ['PROPERMESH_ACCESS_KEY'], os.environ['PROPERMESH_SECRET_KEY'],
domain=os.environ.get('PROPERMESH_URL', 'https://propermesh.com'))
results = [check_file(client, path, args) for path in args.files]
print(table(results, args.max_thin_percent, args.allow_open))
return exit_code(results, args.max_thin_percent, args.allow_open)
if __name__ == '__main__':
sys.exit(main())
python scripts/check_printability.py parts/*.stl --min-wall 1.0 --max-thin-percent 0.5file watertight thin % result
parts/cube.stl yes 0.0 ok
parts/broken-model-with-hole.stl no 100.0 FAIL: not watertight, 100.0% of the surface is too thinThe exit code is 0 when every file passes, 1 when one isn't printable, and 2 when a file couldn't be checked at all, such as an upload that was rejected. Treating 2 as a failure keeps a broken check from passing quietly. Tune the two thresholds to your parts: --min-wall is the thinnest wall you'll accept in millimeters, and --max-thin-percent is how much of the surface may be thinner than that. --allow-open skips the watertight check for files you know are open.
The workflow
This GitHub Actions workflow runs on pull requests that touch an STL or STEP file, and checks only the files the pull request adds or changes. Store the keys as the repository secrets PROPERMESH_ACCESS_KEY and PROPERMESH_SECRET_KEY.
name: Printability
on:
pull_request:
paths: ["**/*.stl", "**/*.step", "**/*.stp"]
jobs:
printability:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.13"
# The SDK isn't on PyPI yet: keep a copy of its sdk/ folder in your repository
- run: pip install ./vendor/propermesh-sdk
- name: Check the STL and STEP files this pull request changes
env:
PROPERMESH_ACCESS_KEY: ${{ secrets.PROPERMESH_ACCESS_KEY }}
PROPERMESH_SECRET_KEY: ${{ secrets.PROPERMESH_SECRET_KEY }}
run: |
git diff --name-only --diff-filter=AM "origin/${{ github.base_ref }}...HEAD" \
-- '*.stl' '*.step' '*.stp' > changed.txt
# One file name per line, so spaces in names are fine. xargs exits non-zero when the check fails
xargs -d '\n' python scripts/check_printability.py --min-wall 1.0 < changed.txtCheck only the changed files, as above. Every file you upload counts as a part against your plan's parts per month, so checking a whole repository on every push would use the allowance quickly. The pricing page lists each plan's limits. A 429 from the API means you hit one, and the script reports it as a file it couldn't check.
FAQ
Can I test the storefront webhook on my own machine?
A webhook URL has to be public https, so register a tunnel's address, or skip registering and post a signed body to your handler yourself. The signature is an HMAC-SHA256 of <timestamp>.<body> with your endpoint's secret, sent as t=<timestamp>,v1=<hex>. Take the job ids from a part you analyzed.
Why does the quote slice the part instead of using its volume?
Volume doesn't say how long a part takes or how much filament it uses: infill, supports and walls change both. A slice gives you the print time and filament weight for the settings you'll print with, so the price follows them. A formula can also charge on geometry fields, such as volume or bounding box, if you prefer.
Can I poll instead of using webhooks?
Yes. The SDK's wait_for_* calls poll for you, and the CI recipe uses them. Webhooks suit a server that handles many uploads and shouldn't hold a connection open for each one.
What does a STEP file need that an STL doesn't?
A STEP file is converted to a mesh first, which adds a step before its analyses run. It records its own units, so you don't pass them. Both recipes accept STEP files with no other change.