Repository navigation
Expand file tree
/
Copy pathopenapi.yaml
More file actions
1414 lines (1333 loc) · 55.7 KB
/
Copy pathopenapi.yaml
File metadata and controls
1414 lines (1333 loc) · 55.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.1.0
info:
title: LightBurn / MillMage REST API
version: 1.0.0
description: |
REST API for LightBurn and MillMage. Provides file upload and import,
read-only project and machine-state queries, cut-setting edits, and
real-time state streaming via Server-Sent Events.
## Authentication
All endpoints except `POST /api/connect` and `GET /`
require a Bearer token derived from a shared secret using HMAC-SHA256:
```
token = hex(HMAC-SHA256(secret, floor(unix_time / 60)))
```
The server accepts tokens for the current minute and the previous minute
to handle clock drift.
## Obtaining a Secret
Obtain a shared secret by pairing a local application:
- **Local application pairing (`POST /api/connect`)**: For localhost
applications only. Sends an `application_name` in the request body. The
application user is shown a consent dialog every time; if approved, a new
secret is generated and returned. The dialog has a 30-second timeout
after which the connection is automatically declined. Applications are
responsible for persisting their own secret. Each call produces a
distinct secret, even for the same `application_name`.
## Multiple instances
The port is served by one running copy of the application at a time. If
several copies are open, the one most recently brought to the foreground
serves it; switching windows moves the listener, and a request made during
the switch may fail to connect. Retry.
A secret is recognised by the copy that was running when you paired, and
may not be recognised by another copy until that one reloads its settings.
If a previously working secret starts returning `401` on a machine with
several copies open, pair again rather than assuming it was revoked.
Neither applies to a single running instance, which serves the port for as
long as it is open.
servers:
- url: http://localhost:19520
description: |
LightBurn. Port 19520, fixed per product — not user-overridable. Binds
loopback by default; enable "Allow API Access From Network" in
Settings > Extensions to accept connections on any interface.
`POST /api/connect` stays localhost-only either way.
The API listens while LightBurn is open. With more than one copy of
LightBurn running, the port is served by the most recently focused
window — see the Multiple instances note in the description above.
- url: http://localhost:19521
description: |
MillMage. Port 19521, fixed per product — not user-overridable. Binds
loopback by default; enable "Allow API Access From Network" in
Settings > Extensions to accept connections on any interface.
`POST /api/connect` stays localhost-only either way.
The API listens while MillMage is open. With more than one copy of
MillMage running, the port is served by the most recently focused
window — see the Multiple instances note in the description above.
security:
- bearerAuth: []
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
description: HMAC-SHA256 time-based token derived from shared secret
schemas:
ErrorResponse:
type: object
properties:
error:
type: string
example: Missing 'axis' parameter
Position:
type: object
description: |
Always in mm, regardless of display units. An axis the controller
doesn't report is omitted.
properties:
machine:
type: object
properties:
x: { type: number, example: 100.000 }
y: { type: number, example: 50.000 }
z: { type: number, example: -5.000 }
workpiece:
type: object
properties:
x: { type: number, example: 0.000 }
y: { type: number, example: 0.000 }
z: { type: number, example: -5.000 }
ConnectionStatus:
type: object
properties:
connected:
type: boolean
description: >
Whether a device link is open at this moment. On Ruida and some
other non-GCode controllers the link is brought up just in time
and closed again afterwards, so this is `false` whenever no
transfer is in progress — which does not mean the laser is absent
or unusable. Not a presence or health check; expect it to toggle
around activity. How long a link is held open varies by controller
and by how the device is connected.
device_name: { type: string, example: Shapeoko 5 Pro }
supports_z: { type: boolean }
supports_overrides: { type: boolean }
JogSettings:
type: object
properties:
xy_distance: { type: number, example: 10.0 }
z_distance: { type: number, example: 1.0 }
xy_speed: { type: number, example: 1500.0 }
z_speed: { type: number, example: 250.0 }
units:
type: string
enum: [mm/s, mm/min, in/s, in/min]
description: >
The speed unit. Distances use `distance_units` — do not infer them
from this field.
distance_units:
type: string
enum: [mm, in]
description: >
The distance unit. Reported separately because the application
supports mixed modes that pair inch distances with metric speeds.
SavedPosition:
type: object
properties:
index: { type: integer }
name: { type: string }
x: { type: number }
y: { type: number }
z: { type: number }
include_z: { type: boolean }
workpiece: { type: boolean }
JobState:
type: object
properties:
state:
type: string
enum: [idle, running, paused]
description: >
Whether the application is running a job on the controller. On
Ruida controllers this is always `idle` — while the job file is
being sent and while the machine cuts — because the controller
runs the job on its own once it has the file, and the application
does not track it. On Ruida, `idle` does not mean the machine is
free; `device.laser.controller` on `GET /api/project` identifies
the controller.
progress:
type: number
minimum: 0
maximum: 100
description: >
Percent complete. Optional — absent when not applicable: while
`state` is `idle`, and on controllers that cannot report progress.
Never present on Ruida controllers, whose `state` is always
`idle`. Treat absence as "unknown", not as zero.
Overrides:
type: object
properties:
speed_percent: { type: integer, example: 100 }
power_percent: { type: integer, example: 100 }
AuxState:
type: object
properties:
spindle_on: { type: boolean }
spindle_rpm: { type: integer }
coolant_on: { type: boolean }
vacuum_on: { type: boolean }
PollSnapshot:
type: object
properties:
position: { $ref: '#/components/schemas/Position' }
job: { $ref: '#/components/schemas/JobState' }
overrides: { $ref: '#/components/schemas/Overrides' }
aux: { $ref: '#/components/schemas/AuxState' }
connection: { $ref: '#/components/schemas/ConnectionStatus' }
settings: { $ref: '#/components/schemas/JogSettings' }
Error:
$ref: '#/components/schemas/ErrorResponse'
Point2:
type: object
properties:
x: { type: number }
y: { type: number }
LaserCut:
type: object
required: [index, name, kind, layer_index, enabled, priority, profile, params]
properties:
index: { type: integer }
name: { type: string }
kind: { type: string, enum: [normal, image] }
layer_index: { type: integer }
enabled: { type: boolean }
priority: { type: integer }
in_use:
type: boolean
description: >
True if any shape in the project uses this cut setting. Counted per
cut setting across every page, so a normal and an image cut sharing
a layer are reported separately — which the per-layer count in
`GET /api/layers` cannot do.
shape_count:
type: integer
description: Number of shapes using this cut setting.
profile:
type: string
enum: [galvo, gantry, unknown]
description: >
Which machine the settings should be read as. On `kind: "normal"`
cuts it therefore says which of `params.galvo` / `params.gantry`
is present; `kind: "image"` cuts carry a `profile` too but never a
machine block. Derived from the
selected device profile, so it is correct with no machine
physically connected. `unknown` means no device profile has been
set up yet. Switching the active device changes this, and the block
that comes with it, for an unchanged project — do not cache the
response shape.
global_passes:
type: integer
minimum: 1
description: >
Galvo only; absent otherwise. Repeats the entire sub-layer stack,
so the real number of passes is `global_passes` multiplied by the
per-layer `num_passes`.
negative: { type: boolean }
pass_through: { type: boolean }
enable_cleanup: { type: boolean }
sort_within_layer: { type: boolean }
tabs:
type: object
description: Tab (bridge) settings for this cut.
properties:
enabled: { type: boolean }
manual: { type: boolean, description: Manual placement rather than automatic. }
size: { type: number }
use_spacing: { type: boolean, description: "Use `spacing`; otherwise `count`." }
count: { type: integer, description: "-1 when unset." }
count_max: { type: integer, description: "-1 when unset." }
limit_max: { type: boolean }
spacing: { type: number }
skip_inner: { type: boolean }
cut_power: { type: number }
mode:
type: string
enum: [cut, scan, offset, image, tool]
description: Only present when `kind == "normal"`.
params:
description: Shape follows `kind`.
anyOf:
- $ref: '#/components/schemas/LaserCutParams'
- type: object
description: |
Image cut params (when `kind == "image"`), plus the source and
pulse fields of `LaserCutParams` except `min_power_2`.
properties:
speed: { type: number }
max_power: { type: number }
dpi: { type: number }
dither_mode: { type: string }
cells_per_inch: { type: number, description: Halftone cell size. }
halftone_angle: { type: number }
link_dpi_to_interval: { type: boolean }
max_power_2: { type: number }
laser1_enabled: { type: boolean }
laser2_enabled: { type: boolean }
alt_source: { type: boolean }
q_pulse_width: { type: number }
fiber_pulse_width: { type: integer }
sub_layers:
type: array
description: |
Only present when `kind == "normal"`. Additional sub-layers
beyond the base layer; the base layer itself is reported in
`mode` / `params` and is not repeated here. Empty when the
layer has no sub-layers.
items:
type: object
required: [index, name, enabled, mode, params]
properties:
index:
type: integer
minimum: 1
description: Sub-layer position within the cut (the base layer is 0).
name:
type: string
description: User-assigned sub-layer name; may be empty.
enabled:
type: boolean
description: Whether this sub-layer is output.
mode:
type: string
enum: [cut, scan, offset, image, tool]
params:
$ref: '#/components/schemas/LaserCutParams'
LaserCutParams:
type: object
description: |
Vector cut params, shared by a cut's base layer and its sub-layers.
Exactly one machine-specific block is present — `galvo` or `gantry`,
matching the entry's `profile`. The other machine's values remain
stored in the project but are not reported. When `profile` is
`unknown`, neither block is present.
properties:
speed: { type: number }
min_power: { type: number }
max_power: { type: number }
min_power_2: { type: number, description: Min power for laser 2 (dual-source). }
max_power_2: { type: number, description: Max power for laser 2 (dual-source). }
default_speed: { type: boolean, description: Use the device default speed. }
default_power1: { type: boolean }
default_power2: { type: boolean }
laser1_enabled: { type: boolean, description: Laser 1 fires on this layer (dual-source). }
laser2_enabled: { type: boolean, description: Laser 2 fires on this layer (dual-source). }
alt_source:
type: boolean
description: Galvo only — use the alternate (second) laser source.
num_passes: { type: integer, minimum: 1 }
z_offset: { type: number }
z_per_pass: { type: number, description: Z movement applied per pass. }
u_offset: { type: number, description: For machines with a U axis. }
angle_per_pass: { type: number, description: Scan angle rotation per pass, in degrees. }
kerf: { type: number }
frequency:
type: integer
description: Hz. Also the galvo pulse frequency when the device supports it.
override_frequency:
type: boolean
description: >
Whether `frequency` is applied at all. When false the device
default is used and the reported `frequency` has no effect — set
this alongside `frequency` when writing.
q_pulse_width:
type: number
description: MOPA pulse width in ns (when `device.laser.mopa_source` is not 0).
fiber_pulse_width:
type: integer
description: Fiber pulse width in ns, for gantry fiber sources (`laser1_fiber` / `laser2_fiber`).
bi_directional: { type: boolean }
cross_hatch: { type: boolean }
flood_fill: { type: boolean }
auto_rotate: { type: boolean, description: Continuous rotation between passes. }
scan_opt:
type: string
enum: [individual, by_group, merge_all]
description: How shapes are grouped when scanning.
angle: { type: number, description: Scan angle in degrees. }
interval: { type: number, description: Scan line interval. }
dot_width: { type: number }
use_dot_correction: { type: boolean }
ramp_length: { type: number }
ramp_outer: { type: boolean }
perforate: { type: boolean }
perf_len: { type: number }
perf_skip: { type: number }
tabs_enabled: { type: boolean }
overscan: { type: boolean }
overscan_percent: { type: number }
galvo:
$ref: '#/components/schemas/LaserGalvoParams'
gantry:
$ref: '#/components/schemas/LaserGantryParams'
LaserGalvoParams:
type: object
description: >
Present only when the entry's `profile` is `galvo`. `start_delay` and
`end_delay` are dot delays on a galvo; the same names mean pauses in
`LaserGantryParams`.
properties:
override_timings:
type: boolean
description: Gate for the timing constants below.
laser_on_tc: { type: integer, description: Laser-on time constant, microseconds. }
laser_off_tc: { type: integer, description: Laser-off time constant, microseconds. }
end_tc: { type: integer, description: End time constant, microseconds. }
polygon_tc: { type: integer, description: Polygon time constant, microseconds. }
jump_speed: { type: number }
min_jump_delay: { type: integer, description: Microseconds. }
max_jump_delay: { type: integer, description: Microseconds. }
jump_dist_limit: { type: number }
start_delay: { type: number, description: Dot delay at path start. }
end_delay: { type: number, description: Dot delay at path end. }
wobble_enable: { type: boolean }
wobble_step: { type: number }
wobble_size: { type: number }
LaserGantryParams:
type: object
description: >
Present only when the entry's `profile` is `gantry`. `start_delay` and
`end_delay` are pauses on a gantry; the same names mean dot delays in
`LaserGalvoParams`.
properties:
run_blower: { type: boolean, description: Air assist. }
auto_blower: { type: boolean }
blower_speed_override: { type: boolean }
blower_speed_percent: { type: number }
cut_through_start: { type: boolean }
cut_through_end: { type: boolean }
through_power: { type: number }
through_power_2: { type: number }
start_delay: { type: number, description: Pause at path start. }
end_delay: { type: number, description: Pause at path end. }
lead_in: { type: boolean }
lead_out: { type: boolean }
lead_angle: { type: number, description: Degrees. }
lead_length: { type: number }
lead_style: { type: string, enum: [line, arc] }
enable_ppi: { type: boolean }
ppi: { type: integer, description: Pulses per inch. }
dot_mode: { type: boolean }
dot_time: { type: number }
dot_spacing: { type: number }
force_constant_power: { type: boolean }
dcc_value: { type: number }
overcut: { type: number }
LaserCuts:
type: object
required: [product, cuts]
properties:
product: { type: string, enum: [lightburn] }
cuts:
type: array
items:
$ref: '#/components/schemas/LaserCut'
CncCut:
type: object
description: |
One MillMage operation. Operations attach to shapes, not layers, so
there is no `layer_index`. There is no `priority` either: operations
run in list order, which `index` already gives.
required: [index, name, kind, shape_count, enabled, operation, tool]
properties:
index:
type: integer
description: Position in the project's operation list (use with `/api/cuts/{index}`).
name: { type: string }
kind: { type: string, enum: [normal] }
shape_count:
type: integer
description: Number of shapes the operation is assigned to; 0 means unused.
enabled: { type: boolean }
operation:
type: string
enum:
- profile
- pocket
- rest_pocket
- drill
- dogbone_slot
- chamfer_profile
- inlay_female
- inlay_male
- flute
- surfacing
- face
- bore
- relief
- roughing
- texturing
- vcarve
- vcarve_clear
- image
- invalid
tool:
type: object
properties:
name: { type: string }
diameter: { type: number }
feed_rate: { type: number }
plunge_rate: { type: number }
spindle_rpm: { type: number }
settings:
type: object
description: |
The operation's stored properties, keyed by schema name; the set
depends on the operation type (e.g. `passDepth`, `feedRate`,
`stepOver`, `vacuum`, `coolant`). Distances in mm, speeds in
mm/s. Enum properties are names, e.g. `cutDirection: "climb"`.
Lists every stored property, including some the operation
dialog doesn't show for this type.
additionalProperties: true
example: { passDepth: 1.5, feedRate: 25, cutDirection: climb, whichSide: outside, vacuum: false }
shared_fields:
type: array
items: { type: string }
description: |
`settings` keys taken from the linked primary operation (e.g.
`startDepth`, `finalDepth`). Their values are the primary's, and
they can only be changed on the primary. Empty if not linked.
CncCuts:
type: object
required: [product, cuts]
properties:
product: { type: string, enum: [millmage] }
cuts:
type: array
items:
$ref: '#/components/schemas/CncCut'
responses:
Unauthorized:
description: Missing or invalid Bearer token
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error: Unauthorized
BadRequest:
description: Invalid or missing parameters
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
paths:
/:
get:
summary: Placeholder HTML app
security: []
responses:
'200':
description: HTML page
content:
text/html:
schema:
type: string
/api/connect:
post:
summary: Request localhost application pairing
description: |
Allows a local application to request a shared secret for API access,
scoped to a specific set of capabilities.
Only accepts connections from localhost (127.0.0.1 / ::1). The user is
shown a consent dialog listing the requesting application's name and
the capabilities it has asked for. If they approve, a new shared
secret is generated and returned, bound to that capability set for
its lifetime. If they decline (or the 30-second timeout expires), the
request is rejected with 403. Each approval produces a distinct
secret; applications are responsible for persisting their own secret.
Capabilities are immutable for the life of a token. To change scope,
the application re-pairs (and the user re-approves a new dialog).
### Capability values
| Wire string | Covers |
|---|---|
| `state` | Read-only machine and job state. `/api/status`, `/api/position`, `/api/jog/settings`, `/api/goto/saved`, `/api/units`, `/api/events`, `/api/events/poll`. |
| `project` | Read-only project data. `/api/project`, `/api/layers`, `/api/cuts`, `/api/cuts/{index}`, `/api/material-library`. |
| `upload` | Submit files for import. `/api/file/upload`, `/api/file/open`. |
| `project_write` | Change project data. `POST /api/cuts/{index}`. |
security: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [application_name, capabilities]
properties:
application_name:
type: string
description: Display name shown to the user in the consent dialog
example: My Automation Tool
capabilities:
type: array
minItems: 1
description: |
Capabilities the token should grant. Must be a non-empty
array of known wire strings; unknown entries fail with 400.
items:
type: string
enum: [state, project, upload, project_write]
example: [state, project]
responses:
'200':
description: Connection approved, secret returned
content:
application/json:
schema:
type: object
properties:
status: { type: string, example: ok }
secret:
type: string
description: Shared secret for deriving Bearer tokens
example: aB3dE7fG9hJ1kL5m
'400':
$ref: '#/components/responses/BadRequest'
'403':
description: Connection rejected by user, timed out, or not from localhost
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/api/status:
get:
summary: Connection status
description: |
When no machine is attached, `connected` and the `supports_*` flags are
`false` and `device_name` still names the selected device profile. The
endpoint always answers — it does not fail or return an empty body
because nothing is connected.
**`connected: false` does not mean the laser is unavailable.** On
Ruida and some other non-GCode controllers the device link is opened
just in time and closed again once the transfer finishes, so `false`
is the normal resting state for a laser that is present, powered on
and ready to run. It reports only whether LightBurn is actively
exchanging data with the device at that moment.
Treat `connected` as "a transfer is in progress", not as a presence or
health check, and expect it to toggle around jobs and queries. Don't
surface it to users as a fault or a disconnected machine. How long a
link is held open varies by controller and by how the device is
connected — a networked device may report differently from the same
controller over USB — so don't infer a device's behaviour from this
field. `device_name` is the reliable way to tell which device profile
is selected.
responses:
'200':
description: Current connection state and device capabilities
content:
application/json:
schema:
$ref: '#/components/schemas/ConnectionStatus'
'401':
$ref: '#/components/responses/Unauthorized'
/api/position:
get:
summary: Current position snapshot
responses:
'200':
description: Machine and workpiece coordinates
content:
application/json:
schema:
$ref: '#/components/schemas/Position'
'401':
$ref: '#/components/responses/Unauthorized'
/api/jog/settings:
get:
summary: Get jog distance and speed settings
responses:
'200':
description: Current jog settings in display units
content:
application/json:
schema:
$ref: '#/components/schemas/JogSettings'
'401':
$ref: '#/components/responses/Unauthorized'
/api/goto/saved:
get:
summary: List saved positions
responses:
'200':
description: Array of saved positions from device profile
content:
application/json:
schema:
type: object
properties:
positions:
type: array
items:
$ref: '#/components/schemas/SavedPosition'
'401':
$ref: '#/components/responses/Unauthorized'
/api/units:
get:
summary: Get current display units
description: |
The user's display units, as two independent axes: `units` is the
speed unit, `distance_units` the distance unit.
They are separate because the application's control-unit modes include
mixed combinations — inch distances with metric speeds — that a single
string cannot express. Read `distance_units` to convert distances;
do not infer the distance unit from `units`.
responses:
'200':
description: Current units
content:
application/json:
schema:
type: object
properties:
units:
type: string
enum: [mm/s, mm/min, in/s, in/min]
distance_units:
type: string
enum: [mm, in]
example:
units: mm/min
distance_units: mm
'401':
$ref: '#/components/responses/Unauthorized'
/api/file/upload:
post:
summary: Upload a file to import
description: |
Send the file as the raw request body. Include the filename in the
`X-Filename` header. Returns 202 immediately; the import result is
reported asynchronously via the `file_imported` SSE event.
parameters:
- name: X-Filename
in: header
schema:
type: string
default: upload.lbrn2
description: Filename for the uploaded file
- name: X-Group-Shapes
in: header
schema:
type: string
enum: ["true", "false"]
default: "false"
description: |
When "true", imported shapes are kept as a group. When "false"
(default), the application's global grouping preference applies.
- name: X-Position-X
in: header
required: false
schema: { type: number }
description: |
Optional X coordinate (workspace mm, workpiece origin) for the
anchor point of the imported shapes' bounding box. Must be paired
with `X-Position-Y`. When omitted, the import lands at the
current view center (the default "drop point").
- name: X-Position-Y
in: header
required: false
schema: { type: number }
description: |
Optional Y coordinate (workspace mm, workpiece origin). Must be
paired with `X-Position-X`.
- name: X-Origin
in: header
required: false
schema:
type: string
enum:
- top-left
- top-center
- top-right
- middle-left
- center
- middle-right
- bottom-left
- bottom-center
- bottom-right
default: center
description: |
Which corner of the imported shapes' bounding box should be
anchored at (`X-Position-X`, `X-Position-Y`). Ignored unless
both position headers are present. Defaults to `center`.
requestBody:
required: true
content:
application/octet-stream:
schema:
type: string
format: binary
responses:
'202':
description: File received, import in progress
content:
application/json:
schema:
type: object
properties:
status: { type: string, example: accepted }
filename: { type: string, example: design.svg }
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
/api/file/open:
post:
summary: Upload a file and open it as the new project
description: |
Replaces the current project with the uploaded file (File → Open
semantics). The current project is closed first; if it has unsaved
changes the desktop shows the standard save-changes prompt before
the open proceeds. Unlike `/api/file/upload`, no shapes are merged
into the existing project — the project is replaced wholesale.
Same authorization scope as `/api/file/upload` (`upload` capability).
No position or grouping headers — irrelevant for the replace-project
flow. Returns 202 immediately; the result is reported by the
`file_imported` SSE event.
**`success` is reliable only for native project files** — `.lbrn` /
`.lbrn2` on LightBurn, `.mage` on MillMage. Opening a template
(`.lbt`, `.mmt`) or any other format (SVG, DXF, images, …) reports
`{"success": false}` with an `error` message even when the file opened
correctly, so for those formats `false` does not distinguish success
from failure. To confirm such an open, read `GET /api/project` after
the event: a successful open leaves `filename` empty and `shape_count`
counts the opened shapes. The `error` text is translated for display;
don't match on it. `/api/file/upload` is not affected.
parameters:
- name: X-Filename
in: header
schema:
type: string
default: upload.lbrn2
description: Filename hint; picks the loader/translator.
requestBody:
required: true
content:
application/octet-stream:
schema:
type: string
format: binary
responses:
'202':
description: File received, open in progress
content:
application/json:
schema:
type: object
properties:
status: { type: string, example: accepted }
filename: { type: string, example: project.lbrn2 }
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
/api/project:
get:
summary: Current project metadata
description: |
Top-level read-only snapshot of the loaded project: filename,
modified flag, shape count, workspace dimensions, and the connected
device. `workspace` values are always in mm. `units` names the
user's display units (`distance` is the translated UI label). With
no project loaded, only `filename`, `modified` and `shape_count`
are returned.
responses:
'200':
description: Project metadata
content:
application/json:
schema:
type: object
properties:
filename: { type: string }
modified: { type: boolean }
shape_count: { type: integer }
units:
type: object
properties:
distance: { type: string, example: mm }
speed: { type: string, example: mm/s }
workspace:
type: object
properties:
machine_size:
$ref: '#/components/schemas/Point2'
workpiece_size:
$ref: '#/components/schemas/Point2'
workpiece_offset:
$ref: '#/components/schemas/Point2'
machine_view: { type: boolean }
device:
type: object
properties:
name: { type: string }
supports_z: { type: boolean }
laser:
type: object
description: |
LightBurn only, and only while a machine profile is
loaded. Capabilities that decide which cut
source/pulse fields apply.
LightBurn doesn't classify CO2 / diode / fiber in
general; `controller` is given so clients can infer.
properties:
controller: { type: string, example: Ruida }
galvo: { type: boolean }
flying_galvo: { type: boolean }
uv: { type: boolean }
sources:
type: integer
description: Laser sources the controller supports (2 = dual-source).
sources_enabled:
type: integer
description: Sources enabled in the device settings.
mopa_source:
type: integer
enum: [0, 1, 2]
description: Which source is MOPA (0 = none); enables `q_pulse_width`.
laser1_fiber:
type: boolean
description: Laser 1 is a fiber source (gantry); enables `fiber_pulse_width`.
laser2_fiber: { type: boolean }
'401':
$ref: '#/components/responses/Unauthorized'
/api/layers:
get:
summary: All 32 layer definitions
description: |
Returns every layer slot (not just the ones in use). Clients that
want to display only used layers should filter on `in_use == true`.
Colors are `"#RRGGBB"` hex strings for direct CSS use.
responses:
'200':
description: Layers snapshot
content:
application/json:
schema:
type: object
properties:
active_index:
type: integer
description: Index of the currently selected layer, or -1.
layers:
type: array
items:
type: object
properties:
index: { type: integer }
name: { type: string }
color:
type: string
example: "#000000"
pattern: "^#[0-9a-fA-F]{6}$"
type:
type: string
enum: [normal, tool, none]
hidden: { type: boolean }
in_use:
type: boolean
description: True if any shape references this layer.
shape_count:
type: integer
description: Number of shapes referencing this layer.
'401':
$ref: '#/components/responses/Unauthorized'
/api/cuts:
get:
summary: Cut settings for all layers
description: |
Product-specific response: the payload shape differs between
LightBurn (laser cuts + image cuts) and MillMage (CNC operations).
Inspect the `product` field to dispatch client-side.
Image cut settings are included inline in the LightBurn response
with `kind: "image"`; regular cuts use `kind: "normal"`. Each
entry's `index` is a dense global 0..N-1 position across both
kinds in the returned array — use that value with `/api/cuts/{index}`.
The `layer_index` field is separate from `index` and maps to the
actual layer slot on the desktop.