0

Create space

by
Published Oct 17, 2025

Creates a new space. Note, currently you cannot set space labels when creating a space. **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Create Space(s)' global permission.

Script confluence Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Confluence = {
3
	email: string
4
	apiToken: string
5
	domain: string
6
}
7
/**
8
 * Create space
9
 * Creates a new space. Note, currently you cannot set space labels when
10
creating a space.
11

12
**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
13
'Create Space(s)' global permission.
14
 */
15
export async function main(
16
	auth: Confluence,
17
	body: {
18
		name: string
19
		key?: string
20
		alias?: string
21
		description?: { plain: { value?: string; representation?: string } }
22
		permissions?: {
23
			subjects?: {
24
				user?: {
25
					results: {
26
						type: 'known' | 'unknown' | 'anonymous' | 'user'
27
						username?: string
28
						userKey?: string
29
						accountId?: string
30
						accountType?: '' | 'atlassian' | 'app'
31
						email?: string
32
						publicName?: string
33
						profilePicture?: {
34
							path: string
35
							width: number
36
							height: number
37
							isDefault: false | true
38
						}
39
						displayName?: string
40
						timeZone?: string
41
						externalCollaborator?: false | true
42
						isExternalCollaborator?: false | true
43
						isGuest?: false | true
44
						operations?: {
45
							operation:
46
								| 'administer'
47
								| 'archive'
48
								| 'clear_permissions'
49
								| 'copy'
50
								| 'create'
51
								| 'create_space'
52
								| 'delete'
53
								| 'export'
54
								| 'move'
55
								| 'purge'
56
								| 'purge_version'
57
								| 'read'
58
								| 'restore'
59
								| 'restrict_content'
60
								| 'update'
61
								| 'use'
62
							targetType: string
63
						}[]
64
						details?: {
65
							business?: {
66
								position?: string
67
								department?: string
68
								location?: string
69
							}
70
							personal?: {
71
								phone?: string
72
								im?: string
73
								website?: string
74
								email?: string
75
							}
76
						}
77
						personalSpace?: {
78
							id?: number
79
							key: string
80
							alias?: string
81
							name: string
82
							icon?: {
83
								path: string
84
								width: number
85
								height: number
86
								isDefault: false | true
87
							}
88
							description?: {
89
								plain?: {
90
									value: string
91
									representation: 'plain' | 'view'
92
									embeddedContent: {}[]
93
								}
94
								view?: {
95
									value: string
96
									representation: 'plain' | 'view'
97
									embeddedContent: {}[]
98
								}
99
								_expandable?: { view?: string; plain?: string }
100
							}
101
							homepage?: {
102
								id?: string
103
								type: string
104
								status: string
105
								title?: string
106
								space?: {}
107
								history?: {
108
									latest: false | true
109
									createdBy?: {}
110
									ownedBy?: {}
111
									lastOwnedBy?: {}
112
									createdDate?: string
113
									lastUpdated?: {
114
										by?: {}
115
										when: string
116
										friendlyWhen?: string
117
										message?: string
118
										number: number
119
										minorEdit: false | true
120
										content?: {}
121
										collaborators?: {
122
											users?: {}[]
123
											userKeys?: string[]
124
											_links?: {}
125
										}
126
										_expandable?: { content?: string; collaborators?: string }
127
										_links?: {}
128
										contentTypeModified?: false | true
129
										confRev?: string
130
										syncRev?: string
131
										syncRevSource?: string
132
									}
133
									previousVersion?: {
134
										by?: {}
135
										when: string
136
										friendlyWhen?: string
137
										message?: string
138
										number: number
139
										minorEdit: false | true
140
										content?: {}
141
										collaborators?: {
142
											users?: {}[]
143
											userKeys?: string[]
144
											_links?: {}
145
										}
146
										_expandable?: { content?: string; collaborators?: string }
147
										_links?: {}
148
										contentTypeModified?: false | true
149
										confRev?: string
150
										syncRev?: string
151
										syncRevSource?: string
152
									}
153
									contributors?: {
154
										publishers?: {
155
											users?: {}[]
156
											userKeys?: string[]
157
											_links?: {}
158
										}
159
									}
160
									nextVersion?: {
161
										by?: {}
162
										when: string
163
										friendlyWhen?: string
164
										message?: string
165
										number: number
166
										minorEdit: false | true
167
										content?: {}
168
										collaborators?: {
169
											users?: {}[]
170
											userKeys?: string[]
171
											_links?: {}
172
										}
173
										_expandable?: { content?: string; collaborators?: string }
174
										_links?: {}
175
										contentTypeModified?: false | true
176
										confRev?: string
177
										syncRev?: string
178
										syncRevSource?: string
179
									}
180
									_expandable?: {
181
										lastUpdated?: string
182
										previousVersion?: string
183
										contributors?: string
184
										nextVersion?: string
185
										ownedBy?: string
186
										lastOwnedBy?: string
187
									}
188
									_links?: {}
189
								}
190
								version?: {
191
									by?: {}
192
									when: string
193
									friendlyWhen?: string
194
									message?: string
195
									number: number
196
									minorEdit: false | true
197
									content?: {}
198
									collaborators?: {
199
										users?: {}[]
200
										userKeys?: string[]
201
										_links?: {}
202
									}
203
									_expandable?: { content?: string; collaborators?: string }
204
									_links?: {}
205
									contentTypeModified?: false | true
206
									confRev?: string
207
									syncRev?: string
208
									syncRevSource?: string
209
								}
210
								ancestors?: {}[]
211
								operations?: {
212
									operation:
213
										| 'administer'
214
										| 'archive'
215
										| 'clear_permissions'
216
										| 'copy'
217
										| 'create'
218
										| 'create_space'
219
										| 'delete'
220
										| 'export'
221
										| 'move'
222
										| 'purge'
223
										| 'purge_version'
224
										| 'read'
225
										| 'restore'
226
										| 'restrict_content'
227
										| 'update'
228
										| 'use'
229
									targetType: string
230
								}[]
231
								children?: {
232
									attachment?: {
233
										results: {}[]
234
										start?: number
235
										limit?: number
236
										size: number
237
										_links: {}
238
									}
239
									comment?: {
240
										results: {}[]
241
										start?: number
242
										limit?: number
243
										size: number
244
										_links: {}
245
									}
246
									page?: {
247
										results: {}[]
248
										start?: number
249
										limit?: number
250
										size: number
251
										_links: {}
252
									}
253
									whiteboard?: {
254
										results: {}[]
255
										start?: number
256
										limit?: number
257
										size: number
258
										_links: {}
259
									}
260
									database?: {
261
										results: {}[]
262
										start?: number
263
										limit?: number
264
										size: number
265
										_links: {}
266
									}
267
									embed?: {
268
										results: {}[]
269
										start?: number
270
										limit?: number
271
										size: number
272
										_links: {}
273
									}
274
									folder?: {
275
										results: {}[]
276
										start?: number
277
										limit?: number
278
										size: number
279
										_links: {}
280
									}
281
									_expandable?: {
282
										attachment?: string
283
										comment?: string
284
										page?: string
285
										whiteboard?: string
286
										database?: string
287
										embed?: string
288
										folder?: string
289
									}
290
									_links?: {}
291
								}
292
								childTypes?: {
293
									attachment?: { value: false | true; _links: {} }
294
									comment?: { value: false | true; _links: {} }
295
									page?: { value: false | true; _links: {} }
296
									_expandable?: {
297
										all?: string
298
										attachment?: string
299
										comment?: string
300
										page?: string
301
										whiteboard?: string
302
										database?: string
303
										embed?: string
304
										folder?: string
305
									}
306
								}
307
								descendants?: {
308
									attachment?: {
309
										results: {}[]
310
										start?: number
311
										limit?: number
312
										size: number
313
										_links: {}
314
									}
315
									comment?: {
316
										results: {}[]
317
										start?: number
318
										limit?: number
319
										size: number
320
										_links: {}
321
									}
322
									page?: {
323
										results: {}[]
324
										start?: number
325
										limit?: number
326
										size: number
327
										_links: {}
328
									}
329
									whiteboard?: {
330
										results: {}[]
331
										start?: number
332
										limit?: number
333
										size: number
334
										_links: {}
335
									}
336
									database?: {
337
										results: {}[]
338
										start?: number
339
										limit?: number
340
										size: number
341
										_links: {}
342
									}
343
									embed?: {
344
										results: {}[]
345
										start?: number
346
										limit?: number
347
										size: number
348
										_links: {}
349
									}
350
									folder?: {
351
										results: {}[]
352
										start?: number
353
										limit?: number
354
										size: number
355
										_links: {}
356
									}
357
									_expandable?: {
358
										attachment?: string
359
										comment?: string
360
										page?: string
361
										whiteboard?: string
362
										database?: string
363
										embed?: string
364
										folder?: string
365
									}
366
									_links?: {}
367
								}
368
								container?: {}
369
								body?: {
370
									view?: {
371
										value: string
372
										representation:
373
											| 'view'
374
											| 'export_view'
375
											| 'styled_view'
376
											| 'storage'
377
											| 'editor'
378
											| 'editor2'
379
											| 'anonymous_export_view'
380
											| 'wiki'
381
											| 'atlas_doc_format'
382
											| 'raw'
383
										embeddedContent?: {
384
											entityId?: number
385
											entityType?: string
386
											entity?: {}
387
										}[]
388
										webresource?: {
389
											_expandable?: { uris?: string | {} }
390
											keys?: string[]
391
											contexts?: string[]
392
											uris?: {
393
												all?: string | string[]
394
												css?: string | string[]
395
												js?: string | string[]
396
												_expandable?: {
397
													css?: string | string[]
398
													js?: string | string[]
399
												}
400
											}
401
											tags?: {
402
												all?: string
403
												css?: string
404
												data?: string
405
												js?: string
406
												_expandable?: {}
407
											}
408
											superbatch?: {
409
												uris?: {
410
													all?: string | string[]
411
													css?: string | string[]
412
													js?: string | string[]
413
												}
414
												tags?: {
415
													all?: string
416
													css?: string
417
													data?: string
418
													js?: string
419
												}
420
												metatags?: string
421
												_expandable?: {}
422
											}
423
										}
424
										mediaToken?: {
425
											collectionIds?: string[]
426
											contentId?: string
427
											expiryDateTime?: string
428
											fileIds?: string[]
429
											token?: string
430
										}
431
										_expandable?: {
432
											content?: string
433
											embeddedContent?: string
434
											webresource?: string
435
											mediaToken?: string
436
										}
437
										_links?: {}
438
									}
439
									export_view?: {
440
										value: string
441
										representation:
442
											| 'view'
443
											| 'export_view'
444
											| 'styled_view'
445
											| 'storage'
446
											| 'editor'
447
											| 'editor2'
448
											| 'anonymous_export_view'
449
											| 'wiki'
450
											| 'atlas_doc_format'
451
											| 'raw'
452
										embeddedContent?: {
453
											entityId?: number
454
											entityType?: string
455
											entity?: {}
456
										}[]
457
										webresource?: {
458
											_expandable?: { uris?: string | {} }
459
											keys?: string[]
460
											contexts?: string[]
461
											uris?: {
462
												all?: string | string[]
463
												css?: string | string[]
464
												js?: string | string[]
465
												_expandable?: {
466
													css?: string | string[]
467
													js?: string | string[]
468
												}
469
											}
470
											tags?: {
471
												all?: string
472
												css?: string
473
												data?: string
474
												js?: string
475
												_expandable?: {}
476
											}
477
											superbatch?: {
478
												uris?: {
479
													all?: string | string[]
480
													css?: string | string[]
481
													js?: string | string[]
482
												}
483
												tags?: {
484
													all?: string
485
													css?: string
486
													data?: string
487
													js?: string
488
												}
489
												metatags?: string
490
												_expandable?: {}
491
											}
492
										}
493
										mediaToken?: {
494
											collectionIds?: string[]
495
											contentId?: string
496
											expiryDateTime?: string
497
											fileIds?: string[]
498
											token?: string
499
										}
500
										_expandable?: {
501
											content?: string
502
											embeddedContent?: string
503
											webresource?: string
504
											mediaToken?: string
505
										}
506
										_links?: {}
507
									}
508
									styled_view?: {
509
										value: string
510
										representation:
511
											| 'view'
512
											| 'export_view'
513
											| 'styled_view'
514
											| 'storage'
515
											| 'editor'
516
											| 'editor2'
517
											| 'anonymous_export_view'
518
											| 'wiki'
519
											| 'atlas_doc_format'
520
											| 'raw'
521
										embeddedContent?: {
522
											entityId?: number
523
											entityType?: string
524
											entity?: {}
525
										}[]
526
										webresource?: {
527
											_expandable?: { uris?: string | {} }
528
											keys?: string[]
529
											contexts?: string[]
530
											uris?: {
531
												all?: string | string[]
532
												css?: string | string[]
533
												js?: string | string[]
534
												_expandable?: {
535
													css?: string | string[]
536
													js?: string | string[]
537
												}
538
											}
539
											tags?: {
540
												all?: string
541
												css?: string
542
												data?: string
543
												js?: string
544
												_expandable?: {}
545
											}
546
											superbatch?: {
547
												uris?: {
548
													all?: string | string[]
549
													css?: string | string[]
550
													js?: string | string[]
551
												}
552
												tags?: {
553
													all?: string
554
													css?: string
555
													data?: string
556
													js?: string
557
												}
558
												metatags?: string
559
												_expandable?: {}
560
											}
561
										}
562
										mediaToken?: {
563
											collectionIds?: string[]
564
											contentId?: string
565
											expiryDateTime?: string
566
											fileIds?: string[]
567
											token?: string
568
										}
569
										_expandable?: {
570
											content?: string
571
											embeddedContent?: string
572
											webresource?: string
573
											mediaToken?: string
574
										}
575
										_links?: {}
576
									}
577
									storage?: {
578
										value: string
579
										representation:
580
											| 'view'
581
											| 'export_view'
582
											| 'styled_view'
583
											| 'storage'
584
											| 'editor'
585
											| 'editor2'
586
											| 'anonymous_export_view'
587
											| 'wiki'
588
											| 'atlas_doc_format'
589
											| 'raw'
590
										embeddedContent?: {
591
											entityId?: number
592
											entityType?: string
593
											entity?: {}
594
										}[]
595
										webresource?: {
596
											_expandable?: { uris?: string | {} }
597
											keys?: string[]
598
											contexts?: string[]
599
											uris?: {
600
												all?: string | string[]
601
												css?: string | string[]
602
												js?: string | string[]
603
												_expandable?: {
604
													css?: string | string[]
605
													js?: string | string[]
606
												}
607
											}
608
											tags?: {
609
												all?: string
610
												css?: string
611
												data?: string
612
												js?: string
613
												_expandable?: {}
614
											}
615
											superbatch?: {
616
												uris?: {
617
													all?: string | string[]
618
													css?: string | string[]
619
													js?: string | string[]
620
												}
621
												tags?: {
622
													all?: string
623
													css?: string
624
													data?: string
625
													js?: string
626
												}
627
												metatags?: string
628
												_expandable?: {}
629
											}
630
										}
631
										mediaToken?: {
632
											collectionIds?: string[]
633
											contentId?: string
634
											expiryDateTime?: string
635
											fileIds?: string[]
636
											token?: string
637
										}
638
										_expandable?: {
639
											content?: string
640
											embeddedContent?: string
641
											webresource?: string
642
											mediaToken?: string
643
										}
644
										_links?: {}
645
									}
646
									wiki?: {
647
										value: string
648
										representation:
649
											| 'view'
650
											| 'export_view'
651
											| 'styled_view'
652
											| 'storage'
653
											| 'editor'
654
											| 'editor2'
655
											| 'anonymous_export_view'
656
											| 'wiki'
657
											| 'atlas_doc_format'
658
											| 'raw'
659
										embeddedContent?: {
660
											entityId?: number
661
											entityType?: string
662
											entity?: {}
663
										}[]
664
										webresource?: {
665
											_expandable?: { uris?: string | {} }
666
											keys?: string[]
667
											contexts?: string[]
668
											uris?: {
669
												all?: string | string[]
670
												css?: string | string[]
671
												js?: string | string[]
672
												_expandable?: {
673
													css?: string | string[]
674
													js?: string | string[]
675
												}
676
											}
677
											tags?: {
678
												all?: string
679
												css?: string
680
												data?: string
681
												js?: string
682
												_expandable?: {}
683
											}
684
											superbatch?: {
685
												uris?: {
686
													all?: string | string[]
687
													css?: string | string[]
688
													js?: string | string[]
689
												}
690
												tags?: {
691
													all?: string
692
													css?: string
693
													data?: string
694
													js?: string
695
												}
696
												metatags?: string
697
												_expandable?: {}
698
											}
699
										}
700
										mediaToken?: {
701
											collectionIds?: string[]
702
											contentId?: string
703
											expiryDateTime?: string
704
											fileIds?: string[]
705
											token?: string
706
										}
707
										_expandable?: {
708
											content?: string
709
											embeddedContent?: string
710
											webresource?: string
711
											mediaToken?: string
712
										}
713
										_links?: {}
714
									}
715
									editor?: {
716
										value: string
717
										representation:
718
											| 'view'
719
											| 'export_view'
720
											| 'styled_view'
721
											| 'storage'
722
											| 'editor'
723
											| 'editor2'
724
											| 'anonymous_export_view'
725
											| 'wiki'
726
											| 'atlas_doc_format'
727
											| 'raw'
728
										embeddedContent?: {
729
											entityId?: number
730
											entityType?: string
731
											entity?: {}
732
										}[]
733
										webresource?: {
734
											_expandable?: { uris?: string | {} }
735
											keys?: string[]
736
											contexts?: string[]
737
											uris?: {
738
												all?: string | string[]
739
												css?: string | string[]
740
												js?: string | string[]
741
												_expandable?: {
742
													css?: string | string[]
743
													js?: string | string[]
744
												}
745
											}
746
											tags?: {
747
												all?: string
748
												css?: string
749
												data?: string
750
												js?: string
751
												_expandable?: {}
752
											}
753
											superbatch?: {
754
												uris?: {
755
													all?: string | string[]
756
													css?: string | string[]
757
													js?: string | string[]
758
												}
759
												tags?: {
760
													all?: string
761
													css?: string
762
													data?: string
763
													js?: string
764
												}
765
												metatags?: string
766
												_expandable?: {}
767
											}
768
										}
769
										mediaToken?: {
770
											collectionIds?: string[]
771
											contentId?: string
772
											expiryDateTime?: string
773
											fileIds?: string[]
774
											token?: string
775
										}
776
										_expandable?: {
777
											content?: string
778
											embeddedContent?: string
779
											webresource?: string
780
											mediaToken?: string
781
										}
782
										_links?: {}
783
									}
784
									editor2?: {
785
										value: string
786
										representation:
787
											| 'view'
788
											| 'export_view'
789
											| 'styled_view'
790
											| 'storage'
791
											| 'editor'
792
											| 'editor2'
793
											| 'anonymous_export_view'
794
											| 'wiki'
795
											| 'atlas_doc_format'
796
											| 'raw'
797
										embeddedContent?: {
798
											entityId?: number
799
											entityType?: string
800
											entity?: {}
801
										}[]
802
										webresource?: {
803
											_expandable?: { uris?: string | {} }
804
											keys?: string[]
805
											contexts?: string[]
806
											uris?: {
807
												all?: string | string[]
808
												css?: string | string[]
809
												js?: string | string[]
810
												_expandable?: {
811
													css?: string | string[]
812
													js?: string | string[]
813
												}
814
											}
815
											tags?: {
816
												all?: string
817
												css?: string
818
												data?: string
819
												js?: string
820
												_expandable?: {}
821
											}
822
											superbatch?: {
823
												uris?: {
824
													all?: string | string[]
825
													css?: string | string[]
826
													js?: string | string[]
827
												}
828
												tags?: {
829
													all?: string
830
													css?: string
831
													data?: string
832
													js?: string
833
												}
834
												metatags?: string
835
												_expandable?: {}
836
											}
837
										}
838
										mediaToken?: {
839
											collectionIds?: string[]
840
											contentId?: string
841
											expiryDateTime?: string
842
											fileIds?: string[]
843
											token?: string
844
										}
845
										_expandable?: {
846
											content?: string
847
											embeddedContent?: string
848
											webresource?: string
849
											mediaToken?: string
850
										}
851
										_links?: {}
852
									}
853
									anonymous_export_view?: {
854
										value: string
855
										representation:
856
											| 'view'
857
											| 'export_view'
858
											| 'styled_view'
859
											| 'storage'
860
											| 'editor'
861
											| 'editor2'
862
											| 'anonymous_export_view'
863
											| 'wiki'
864
											| 'atlas_doc_format'
865
											| 'raw'
866
										embeddedContent?: {
867
											entityId?: number
868
											entityType?: string
869
											entity?: {}
870
										}[]
871
										webresource?: {
872
											_expandable?: { uris?: string | {} }
873
											keys?: string[]
874
											contexts?: string[]
875
											uris?: {
876
												all?: string | string[]
877
												css?: string | string[]
878
												js?: string | string[]
879
												_expandable?: {
880
													css?: string | string[]
881
													js?: string | string[]
882
												}
883
											}
884
											tags?: {
885
												all?: string
886
												css?: string
887
												data?: string
888
												js?: string
889
												_expandable?: {}
890
											}
891
											superbatch?: {
892
												uris?: {
893
													all?: string | string[]
894
													css?: string | string[]
895
													js?: string | string[]
896
												}
897
												tags?: {
898
													all?: string
899
													css?: string
900
													data?: string
901
													js?: string
902
												}
903
												metatags?: string
904
												_expandable?: {}
905
											}
906
										}
907
										mediaToken?: {
908
											collectionIds?: string[]
909
											contentId?: string
910
											expiryDateTime?: string
911
											fileIds?: string[]
912
											token?: string
913
										}
914
										_expandable?: {
915
											content?: string
916
											embeddedContent?: string
917
											webresource?: string
918
											mediaToken?: string
919
										}
920
										_links?: {}
921
									}
922
									atlas_doc_format?: {
923
										value: string
924
										representation:
925
											| 'view'
926
											| 'export_view'
927
											| 'styled_view'
928
											| 'storage'
929
											| 'editor'
930
											| 'editor2'
931
											| 'anonymous_export_view'
932
											| 'wiki'
933
											| 'atlas_doc_format'
934
											| 'raw'
935
										embeddedContent?: {
936
											entityId?: number
937
											entityType?: string
938
											entity?: {}
939
										}[]
940
										webresource?: {
941
											_expandable?: { uris?: string | {} }
942
											keys?: string[]
943
											contexts?: string[]
944
											uris?: {
945
												all?: string | string[]
946
												css?: string | string[]
947
												js?: string | string[]
948
												_expandable?: {
949
													css?: string | string[]
950
													js?: string | string[]
951
												}
952
											}
953
											tags?: {
954
												all?: string
955
												css?: string
956
												data?: string
957
												js?: string
958
												_expandable?: {}
959
											}
960
											superbatch?: {
961
												uris?: {
962
													all?: string | string[]
963
													css?: string | string[]
964
													js?: string | string[]
965
												}
966
												tags?: {
967
													all?: string
968
													css?: string
969
													data?: string
970
													js?: string
971
												}
972
												metatags?: string
973
												_expandable?: {}
974
											}
975
										}
976
										mediaToken?: {
977
											collectionIds?: string[]
978
											contentId?: string
979
											expiryDateTime?: string
980
											fileIds?: string[]
981
											token?: string
982
										}
983
										_expandable?: {
984
											content?: string
985
											embeddedContent?: string
986
											webresource?: string
987
											mediaToken?: string
988
										}
989
										_links?: {}
990
									}
991
									dynamic?: {
992
										value: string
993
										representation:
994
											| 'view'
995
											| 'export_view'
996
											| 'styled_view'
997
											| 'storage'
998
											| 'editor'
999
											| 'editor2'
1000
											| 'anonymous_export_view'
1001
											| 'wiki'
1002
											| 'atlas_doc_format'
1003
											| 'raw'
1004
										embeddedContent?: {
1005
											entityId?: number
1006
											entityType?: string
1007
											entity?: {}
1008
										}[]
1009
										webresource?: {
1010
											_expandable?: { uris?: string | {} }
1011
											keys?: string[]
1012
											contexts?: string[]
1013
											uris?: {
1014
												all?: string | string[]
1015
												css?: string | string[]
1016
												js?: string | string[]
1017
												_expandable?: {
1018
													css?: string | string[]
1019
													js?: string | string[]
1020
												}
1021
											}
1022
											tags?: {
1023
												all?: string
1024
												css?: string
1025
												data?: string
1026
												js?: string
1027
												_expandable?: {}
1028
											}
1029
											superbatch?: {
1030
												uris?: {
1031
													all?: string | string[]
1032
													css?: string | string[]
1033
													js?: string | string[]
1034
												}
1035
												tags?: {
1036
													all?: string
1037
													css?: string
1038
													data?: string
1039
													js?: string
1040
												}
1041
												metatags?: string
1042
												_expandable?: {}
1043
											}
1044
										}
1045
										mediaToken?: {
1046
											collectionIds?: string[]
1047
											contentId?: string
1048
											expiryDateTime?: string
1049
											fileIds?: string[]
1050
											token?: string
1051
										}
1052
										_expandable?: {
1053
											content?: string
1054
											embeddedContent?: string
1055
											webresource?: string
1056
											mediaToken?: string
1057
										}
1058
										_links?: {}
1059
									}
1060
									raw?: {
1061
										value: string
1062
										representation:
1063
											| 'view'
1064
											| 'export_view'
1065
											| 'styled_view'
1066
											| 'storage'
1067
											| 'editor'
1068
											| 'editor2'
1069
											| 'anonymous_export_view'
1070
											| 'wiki'
1071
											| 'atlas_doc_format'
1072
											| 'raw'
1073
										embeddedContent?: {
1074
											entityId?: number
1075
											entityType?: string
1076
											entity?: {}
1077
										}[]
1078
										webresource?: {
1079
											_expandable?: { uris?: string | {} }
1080
											keys?: string[]
1081
											contexts?: string[]
1082
											uris?: {
1083
												all?: string | string[]
1084
												css?: string | string[]
1085
												js?: string | string[]
1086
												_expandable?: {
1087
													css?: string | string[]
1088
													js?: string | string[]
1089
												}
1090
											}
1091
											tags?: {
1092
												all?: string
1093
												css?: string
1094
												data?: string
1095
												js?: string
1096
												_expandable?: {}
1097
											}
1098
											superbatch?: {
1099
												uris?: {
1100
													all?: string | string[]
1101
													css?: string | string[]
1102
													js?: string | string[]
1103
												}
1104
												tags?: {
1105
													all?: string
1106
													css?: string
1107
													data?: string
1108
													js?: string
1109
												}
1110
												metatags?: string
1111
												_expandable?: {}
1112
											}
1113
										}
1114
										mediaToken?: {
1115
											collectionIds?: string[]
1116
											contentId?: string
1117
											expiryDateTime?: string
1118
											fileIds?: string[]
1119
											token?: string
1120
										}
1121
										_expandable?: {
1122
											content?: string
1123
											embeddedContent?: string
1124
											webresource?: string
1125
											mediaToken?: string
1126
										}
1127
										_links?: {}
1128
									}
1129
									_expandable?: {
1130
										editor?: string
1131
										view?: string
1132
										export_view?: string
1133
										styled_view?: string
1134
										storage?: string
1135
										editor2?: string
1136
										anonymous_export_view?: string
1137
										atlas_doc_format?: string
1138
										wiki?: string
1139
										dynamic?: string
1140
										raw?: string
1141
									}
1142
								}
1143
								restrictions?: {
1144
									read?: {
1145
										operation:
1146
											| 'administer'
1147
											| 'copy'
1148
											| 'create'
1149
											| 'delete'
1150
											| 'export'
1151
											| 'move'
1152
											| 'purge'
1153
											| 'purge_version'
1154
											| 'read'
1155
											| 'restore'
1156
											| 'update'
1157
											| 'use'
1158
										restrictions?: {
1159
											user?: {
1160
												results: {}[]
1161
												start?: number
1162
												limit?: number
1163
												size?: number
1164
												totalSize?: number
1165
												_links?: {}
1166
											}
1167
											group?: {
1168
												results: {
1169
													type: 'group'
1170
													name: string
1171
													id: string
1172
													_links?: {}
1173
												}[]
1174
												start: number
1175
												limit: number
1176
												size: number
1177
											}
1178
											_expandable?: { user?: string; group?: string }
1179
										}
1180
										content?: {}
1181
										_expandable: { restrictions?: string; content?: string }
1182
										_links: {}
1183
									}
1184
									update?: {
1185
										operation:
1186
											| 'administer'
1187
											| 'copy'
1188
											| 'create'
1189
											| 'delete'
1190
											| 'export'
1191
											| 'move'
1192
											| 'purge'
1193
											| 'purge_version'
1194
											| 'read'
1195
											| 'restore'
1196
											| 'update'
1197
											| 'use'
1198
										restrictions?: {
1199
											user?: {
1200
												results: {}[]
1201
												start?: number
1202
												limit?: number
1203
												size?: number
1204
												totalSize?: number
1205
												_links?: {}
1206
											}
1207
											group?: {
1208
												results: {
1209
													type: 'group'
1210
													name: string
1211
													id: string
1212
													_links?: {}
1213
												}[]
1214
												start: number
1215
												limit: number
1216
												size: number
1217
											}
1218
											_expandable?: { user?: string; group?: string }
1219
										}
1220
										content?: {}
1221
										_expandable: { restrictions?: string; content?: string }
1222
										_links: {}
1223
									}
1224
									_expandable?: { read?: string; update?: string }
1225
									_links?: {}
1226
								}
1227
								metadata?: {
1228
									currentuser?: {
1229
										favourited?: {
1230
											isFavourite?: false | true
1231
											favouritedDate?: string
1232
										}
1233
										lastmodified?: {
1234
											version?: {
1235
												by?: {}
1236
												when: string
1237
												friendlyWhen?: string
1238
												message?: string
1239
												number: number
1240
												minorEdit: false | true
1241
												content?: {}
1242
												collaborators?: {
1243
													users?: {}[]
1244
													userKeys?: string[]
1245
													_links?: {}
1246
												}
1247
												_expandable?: {
1248
													content?: string
1249
													collaborators?: string
1250
												}
1251
												_links?: {}
1252
												contentTypeModified?: false | true
1253
												confRev?: string
1254
												syncRev?: string
1255
												syncRevSource?: string
1256
											}
1257
											friendlyLastModified?: string
1258
										}
1259
										lastcontributed?: { status?: string; when?: string }
1260
										viewed?: { lastSeen?: string; friendlyLastSeen?: string }
1261
										scheduled?: {}
1262
										_expandable?: {
1263
											favourited?: string
1264
											lastmodified?: string
1265
											lastcontributed?: string
1266
											viewed?: string
1267
											scheduled?: string
1268
										}
1269
									}
1270
									properties?: {}
1271
									frontend?: {}
1272
									labels?:
1273
										| {
1274
												results: {
1275
													prefix: string
1276
													name: string
1277
													id: string
1278
													label: string
1279
												}[]
1280
												start?: number
1281
												limit?: number
1282
												size: number
1283
												_links?: {}
1284
										  }
1285
										| {
1286
												prefix: string
1287
												name: string
1288
												id: string
1289
												label: string
1290
										  }[]
1291
								}
1292
								macroRenderedOutput?: {}
1293
								extensions?: {}
1294
								_expandable?: {
1295
									childTypes?: string
1296
									container?: string
1297
									metadata?: string
1298
									operations?: string
1299
									children?: string
1300
									restrictions?: string
1301
									history?: string
1302
									ancestors?: string
1303
									body?: string
1304
									version?: string
1305
									descendants?: string
1306
									space?: string
1307
									extensions?: string
1308
									schedulePublishDate?: string
1309
									schedulePublishInfo?: string
1310
									macroRenderedOutput?: string
1311
								}
1312
								_links?: {}
1313
							}
1314
							type: string
1315
							metadata?: {
1316
								labels?: {
1317
									results: {
1318
										prefix: string
1319
										name: string
1320
										id: string
1321
										label: string
1322
									}[]
1323
									start?: number
1324
									limit?: number
1325
									size: number
1326
									_links?: {}
1327
								}
1328
								_expandable?: {}
1329
							}
1330
							operations?: {
1331
								operation:
1332
									| 'administer'
1333
									| 'archive'
1334
									| 'clear_permissions'
1335
									| 'copy'
1336
									| 'create'
1337
									| 'create_space'
1338
									| 'delete'
1339
									| 'export'
1340
									| 'move'
1341
									| 'purge'
1342
									| 'purge_version'
1343
									| 'read'
1344
									| 'restore'
1345
									| 'restrict_content'
1346
									| 'update'
1347
									| 'use'
1348
								targetType: string
1349
							}[]
1350
							permissions?: {
1351
								id?: number
1352
								subjects?: {
1353
									user?: {
1354
										results: {}[]
1355
										size: number
1356
										start?: number
1357
										limit?: number
1358
									}
1359
									group?: {
1360
										results: {
1361
											type: 'group'
1362
											name: string
1363
											id: string
1364
											_links?: {}
1365
										}[]
1366
										size: number
1367
										start?: number
1368
										limit?: number
1369
									}
1370
									_expandable?: { user?: string; group?: string }
1371
								}
1372
								operation: {
1373
									operation:
1374
										| 'administer'
1375
										| 'archive'
1376
										| 'clear_permissions'
1377
										| 'copy'
1378
										| 'create'
1379
										| 'create_space'
1380
										| 'delete'
1381
										| 'export'
1382
										| 'move'
1383
										| 'purge'
1384
										| 'purge_version'
1385
										| 'read'
1386
										| 'restore'
1387
										| 'restrict_content'
1388
										| 'update'
1389
										| 'use'
1390
									targetType: string
1391
								}
1392
								anonymousAccess: false | true
1393
								unlicensedAccess: false | true
1394
							}[]
1395
							status: string
1396
							settings?: {
1397
								routeOverrideEnabled: false | true
1398
								editor?: { page: string; blogpost: string; default: string }
1399
								spaceKey?: string
1400
								_links: {}
1401
							}
1402
							theme?: {
1403
								themeKey: string
1404
								name?: string
1405
								description?: string
1406
								icon?: {
1407
									path: string
1408
									width: number
1409
									height: number
1410
									isDefault: false | true
1411
								}
1412
								_links?: {}
1413
							}
1414
							lookAndFeel?: {
1415
								headings: { color: string }
1416
								links: { color: string }
1417
								menus: {
1418
									hoverOrFocus: { backgroundColor: string }
1419
									color: string
1420
								}
1421
								header: {
1422
									backgroundColor: string
1423
									button: { backgroundColor: string; color: string }
1424
									primaryNavigation: {
1425
										color: string
1426
										highlightColor?: string
1427
										hoverOrFocus: { backgroundColor: string; color: string }
1428
									}
1429
									secondaryNavigation: {
1430
										color: string
1431
										highlightColor?: string
1432
										hoverOrFocus: { backgroundColor: string; color: string }
1433
									}
1434
									search: { backgroundColor: string; color: string }
1435
								}
1436
								horizontalHeader?: {
1437
									backgroundColor: string
1438
									button?: { backgroundColor: string; color: string }
1439
									primaryNavigation: {
1440
										color?: string
1441
										highlightColor: string
1442
										hoverOrFocus?: { backgroundColor?: string; color?: string }
1443
									}
1444
									secondaryNavigation?: {
1445
										color: string
1446
										highlightColor?: string
1447
										hoverOrFocus: { backgroundColor: string; color: string }
1448
									}
1449
									search?: { backgroundColor: string; color: string }
1450
								}
1451
								content: {
1452
									screen?: {
1453
										background: string
1454
										backgroundAttachment?: string
1455
										backgroundBlendMode?: string
1456
										backgroundClip?: string
1457
										backgroundColor?: string
1458
										backgroundImage?: string
1459
										backgroundOrigin?: string
1460
										backgroundPosition?: string
1461
										backgroundRepeat?: string
1462
										backgroundSize?: string
1463
										layer?: { width?: string; height?: string }
1464
										gutterTop?: string
1465
										gutterRight?: string
1466
										gutterBottom?: string
1467
										gutterLeft?: string
1468
									}
1469
									container?: {
1470
										background: string
1471
										backgroundAttachment?: string
1472
										backgroundBlendMode?: string
1473
										backgroundClip?: string
1474
										backgroundColor: string
1475
										backgroundImage: string
1476
										backgroundOrigin?: string
1477
										backgroundPosition?: string
1478
										backgroundRepeat?: string
1479
										backgroundSize: string
1480
										padding: string
1481
										borderRadius: string
1482
									}
1483
									header?: {
1484
										background: string
1485
										backgroundAttachment?: string
1486
										backgroundBlendMode?: string
1487
										backgroundClip?: string
1488
										backgroundColor: string
1489
										backgroundImage: string
1490
										backgroundOrigin?: string
1491
										backgroundPosition?: string
1492
										backgroundRepeat?: string
1493
										backgroundSize: string
1494
										padding: string
1495
										borderRadius: string
1496
									}
1497
									body?: {
1498
										background: string
1499
										backgroundAttachment?: string
1500
										backgroundBlendMode?: string
1501
										backgroundClip?: string
1502
										backgroundColor: string
1503
										backgroundImage: string
1504
										backgroundOrigin?: string
1505
										backgroundPosition?: string
1506
										backgroundRepeat?: string
1507
										backgroundSize: string
1508
										padding: string
1509
										borderRadius: string
1510
									}
1511
								}
1512
								bordersAndDividers: { color: string }
1513
								spaceReference?: {}
1514
							}
1515
							history?: { createdDate: string; createdBy?: {} }
1516
							_expandable: {
1517
								settings?: string
1518
								metadata?: string
1519
								operations?: string
1520
								lookAndFeel?: string
1521
								permissions?: string
1522
								icon?: string
1523
								description?: string
1524
								theme?: string
1525
								history?: string
1526
								homepage?: string
1527
								identifiers?: string
1528
							}
1529
							_links: {}
1530
						}
1531
						_expandable?: {
1532
							operations?: string
1533
							details?: string
1534
							personalSpace?: string
1535
						}
1536
						_links?: {}
1537
					}[]
1538
					size: number
1539
				}
1540
				group?: { results: { type: 'group'; id?: string }[]; size: number }
1541
			}
1542
			operation: {
1543
				operation:
1544
					| 'administer'
1545
					| 'archive'
1546
					| 'clear_permissions'
1547
					| 'copy'
1548
					| 'create'
1549
					| 'create_space'
1550
					| 'delete'
1551
					| 'export'
1552
					| 'move'
1553
					| 'purge'
1554
					| 'purge_version'
1555
					| 'read'
1556
					| 'restore'
1557
					| 'restrict_content'
1558
					| 'update'
1559
					| 'use'
1560
				targetType: string
1561
			}
1562
			anonymousAccess: false | true
1563
			unlicensedAccess: false | true
1564
		}[]
1565
	}
1566
) {
1567
	const url = new URL(`https://${auth.domain}/wiki/rest/api/space`)
1568

1569
	const response = await fetch(url, {
1570
		method: 'POST',
1571
		headers: {
1572
			'Content-Type': 'application/json',
1573
			Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
1574
		},
1575
		body: JSON.stringify(body)
1576
	})
1577
	if (!response.ok) {
1578
		const text = await response.text()
1579
		throw new Error(`${response.status} ${text}`)
1580
	}
1581
	return await response.json()
1582
}
1583