0

Create private space

by
Published Oct 17, 2025

Creates a new space that is only visible to the creator. This method is the same as the [Create space](#api-space-post) method with permissions set to the current user only. 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 private space
9
 * Creates a new space that is only visible to the creator. This method is
10
the same as the [Create space](#api-space-post) method with permissions
11
set to the current user only. Note, currently you cannot set space
12
labels when creating a space.
13

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

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