forked from ComposioHQ/sample-openapi-spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notion-openapi.yaml
4283 lines (4269 loc) · 160 KB
/
notion-openapi.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.0.3
info:
title: Notion API
description: >-
Notion is a new tool that blends your everyday work apps into one. It's the
all-in-one workspace for you and your team.
version: '1'
x-konfig-ignore:
object-with-no-properties: true
potential-incorrect-type: true
servers:
- url: https://api.notion.com
tags:
- name: Block
- name: Page
- name: Database
- name: User
- name: Comment
- name: Token
- name: Search
paths:
/v1/oauth/token:
post:
tags:
- Token
summary: Create a token
operationId: Token_generateAccess
description: >-
Creates an access token that a third-party service can use to
authenticate with Notion.
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/TokenGenerateAccessRequest'
responses:
'200':
description: '200'
content:
application/json:
examples:
Result:
value: |-
{
"access_token": "e202e8c9-0990-40af-855f-ff8f872b1ec6c",
"bot_id": "b3414d659-1224-5ty7-6ffr-cc9d8773drt601288f",
"duplicated_template_id": null,
"owner": {
"workspace": true
},
"workspace_icon": "https://website.domain/images/image.png",
"workspace_id": "j565j4d7x3-2882-61bs-564a-jj9d9ui-c36hxfr7x",
"workspace_name": "Ada's Notion Workspace"
}
schema:
$ref: '#/components/schemas/TokenGenerateAccessResponse'
'400':
description: '400'
content:
application/json:
examples:
Result:
value: |-
{
"error": "invalid_request",
"error_description": "body failed validation: body.redirect_uri should be defined, instead was `undefined`."
}
schema:
$ref: '#/components/schemas/TokenGenerateAccess400Response'
deprecated: false
x-readme:
code-samples:
- language: curl
code: >-
curl --location --request POST
'https://api.notion.com/v1/oauth/token' \
--header 'Authorization: Basic '"$BASE64_ENCODED_ID_AND_SECRET"''
\
--header 'Content-Type: application/json' \
--header 'Notion-Version: 2022-06-28' \
--data '{
"grant_type": "authorization_code",
"code": "e202e8c9-0990-40af-855f-ff8f872b1ec6",
"redirect_uri": "https://wwww.my-integration-endpoint.dev/callback",
"external_account": {
"key": "A83823453409384",
"name": "Notion - [email protected]"
}
}'
name: Create a token for a Link Preview
- language: curl
code: "curl --location --request POST 'https://api.notion.com/v1/databases/' \\\n--header 'Authorization: Bearer '\"$NOTION_API_KEY\"'' \\\n--header 'Content-Type: application/json' \\\n--header 'Notion-Version: 2022-06-28' \\\n--data '{\n\t\"grant_type\": \"authorization_code\",\n \"code\": \"e202e8c9-0990-40af-855f-ff8f872b1ec6\",\n \"redirect_uri\": \"https://example.com/auth/notion/callback\"\n}'"
name: Create a token for a public integration
samples-languages:
- curl
/v1/blocks/{block_id}/children:
patch:
tags:
- Block
summary: Append block children
operationId: Block_appendChildren
security: []
description: ''
parameters:
- description: >-
Identifier for a [block](ref:block). Also accepts a [page](ref:page)
ID.
name: block_id
in: path
schema:
type: string
required: true
- name: Notion-Version
in: header
required: true
schema:
type: string
default: '2022-06-28'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/BlockAppendChildrenRequest'
responses:
'200':
description: '200'
content:
application/json:
examples:
Result:
value: "{\n\t\"object\": \"list\",\n\t\"results\": [\n\t\t{\n\t\t\t\"object\": \"block\",\n\t\t\t\"id\": \"c02fc1d3-db8b-45c5-a222-27595b15aea7\",\n\t\t\t\"parent\": {\n\t\t\t\t\"type\": \"page_id\",\n\t\t\t\t\"page_id\": \"59833787-2cf9-4fdf-8782-e53db20768a5\"\n\t\t\t},\n\t\t\t\"created_time\": \"2022-03-01T19:05:00.000Z\",\n\t\t\t\"last_edited_time\": \"2022-07-06T19:41:00.000Z\",\n\t\t\t\"created_by\": {\n\t\t\t\t\"object\": \"user\",\n\t\t\t\t\"id\": \"ee5f0f84-409a-440f-983a-a5315961c6e4\"\n\t\t\t},\n\t\t\t\"last_edited_by\": {\n\t\t\t\t\"object\": \"user\",\n\t\t\t\t\"id\": \"ee5f0f84-409a-440f-983a-a5315961c6e4\"\n\t\t\t},\n\t\t\t\"has_children\": false,\n\t\t\t\"archived\": false,\n\t\t\t\"type\": \"heading_2\",\n\t\t\t\"heading_2\": {\n\t\t\t\t\"rich_text\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"type\": \"text\",\n\t\t\t\t\t\t\"text\": {\n\t\t\t\t\t\t\t\"content\": \"Lacinato kale\",\n\t\t\t\t\t\t\t\"link\": null\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"annotations\": {\n\t\t\t\t\t\t\t\"bold\": false,\n\t\t\t\t\t\t\t\"italic\": false,\n\t\t\t\t\t\t\t\"strikethrough\": false,\n\t\t\t\t\t\t\t\"underline\": false,\n\t\t\t\t\t\t\t\"code\": false,\n\t\t\t\t\t\t\t\"color\": \"default\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"plain_text\": \"Lacinato kale\",\n\t\t\t\t\t\t\"href\": null\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\t\"color\": \"default\",\n \"is_toggleable\": false\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"object\": \"block\",\n\t\t\t\"id\": \"acc7eb06-05cd-4603-a384-5e1e4f1f4e72\",\n\t\t\t\"parent\": {\n\t\t\t\t\"type\": \"page_id\",\n\t\t\t\t\"page_id\": \"59833787-2cf9-4fdf-8782-e53db20768a5\"\n\t\t\t},\n\t\t\t\"created_time\": \"2022-03-01T19:05:00.000Z\",\n\t\t\t\"last_edited_time\": \"2022-07-06T19:51:00.000Z\",\n\t\t\t\"created_by\": {\n\t\t\t\t\"object\": \"user\",\n\t\t\t\t\"id\": \"ee5f0f84-409a-440f-983a-a5315961c6e4\"\n\t\t\t},\n\t\t\t\"last_edited_by\": {\n\t\t\t\t\"object\": \"user\",\n\t\t\t\t\"id\": \"0c3e9826-b8f7-4f73-927d-2caaf86f1103\"\n\t\t\t},\n\t\t\t\"has_children\": false,\n\t\t\t\"archived\": false,\n\t\t\t\"type\": \"paragraph\",\n\t\t\t\"paragraph\": {\n\t\t\t\t\"rich_text\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"type\": \"text\",\n\t\t\t\t\t\t\"text\": {\n\t\t\t\t\t\t\t\"content\": \"Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.\",\n\t\t\t\t\t\t\t\"link\": {\n\t\t\t\t\t\t\t\t\"url\": \"https://en.wikipedia.org/wiki/Lacinato_kale\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"annotations\": {\n\t\t\t\t\t\t\t\"bold\": false,\n\t\t\t\t\t\t\t\"italic\": false,\n\t\t\t\t\t\t\t\"strikethrough\": false,\n\t\t\t\t\t\t\t\"underline\": false,\n\t\t\t\t\t\t\t\"code\": false,\n\t\t\t\t\t\t\t\"color\": \"default\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"plain_text\": \"Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.\",\n\t\t\t\t\t\t\"href\": \"https://en.wikipedia.org/wiki/Lacinato_kale\"\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\t\"color\": \"default\"\n\t\t\t}\n\t\t}\n\t],\n\t\"next_cursor\": null,\n\t\"has_more\": false,\n\t\"type\": \"block\",\n\t\"block\": {}\n}"
schema:
$ref: '#/components/schemas/BlockAppendChildrenResponse'
'400':
description: '400'
content:
application/json:
examples:
Result:
value: '{}'
schema:
$ref: '#/components/schemas/BlockAppendChildren400Response'
deprecated: false
x-readme:
code-samples:
- language: javascript
code: |-
const { Client } = require('@notionhq/client');
const notion = new Client({ auth: process.env.NOTION_API_KEY });
(async () => {
const blockId = 'b55c9c91-384d-452b-81db-d1ef79372b75';
const response = await notion.blocks.children.append({
block_id: blockId,
children: [
{
"heading_2": {
"rich_text": [
{
"text": {
"content": "Lacinato kale"
}
}
]
}
},
{
"paragraph": {
"rich_text": [
{
"text": {
"content": "Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.",
"link": {
"url": "https://en.wikipedia.org/wiki/Lacinato_kale"
}
}
}
]
}
}
],
});
console.log(response);
})();
name: Notion SDK for JavaScript
- language: curl
code: "curl -X PATCH 'https://api.notion.com/v1/blocks/b55c9c91-384d-452b-81db-d1ef79372b75/children' \\\n -H 'Authorization: Bearer '\"$NOTION_API_KEY\"'' \\\n -H \"Content-Type: application/json\" \\\n -H \"Notion-Version: 2022-06-28\" \\\n --data '{\n\t\"children\": [\n\t\t{\n\t\t\t\"object\": \"block\",\n\t\t\t\"type\": \"heading_2\",\n\t\t\t\"heading_2\": {\n\t\t\t\t\"rich_text\": [{ \"type\": \"text\", \"text\": { \"content\": \"Lacinato kale\" } }]\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"object\": \"block\",\n\t\t\t\"type\": \"paragraph\",\n\t\t\t\"paragraph\": {\n\t\t\t\t\"rich_text\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"type\": \"text\",\n\t\t\t\t\t\t\"text\": {\n\t\t\t\t\t\t\t\"content\": \"Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.\",\n\t\t\t\t\t\t\t\"link\": { \"url\": \"https://en.wikipedia.org/wiki/Lacinato_kale\" }\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t]\n}'"
samples-languages:
- javascript
- curl
get:
tags:
- Block
summary: Retrieve block children
operationId: Block_getChildren
security: []
description: ''
parameters:
- description: Identifier for a [block](ref:block)
name: block_id
in: path
schema:
type: string
required: true
- description: >-
If supplied, this endpoint will return a page of results starting
after the cursor provided. If not supplied, this endpoint will
return the first page of results.
name: start_cursor
in: query
schema:
type: string
- description: >-
The number of items from the full list desired in the response.
Maximum: 100
name: page_size
in: query
schema:
type: integer
format: int32
default: 100
- name: Notion-Version
in: header
required: true
schema:
type: string
default: '2022-06-28'
responses:
'200':
description: '200'
content:
application/json:
examples:
Result:
value: "{\n\t\"object\": \"list\",\n\t\"results\": [\n\t\t{\n\t\t\t\"object\": \"block\",\n\t\t\t\"id\": \"c02fc1d3-db8b-45c5-a222-27595b15aea7\",\n\t\t\t\"parent\": {\n\t\t\t\t\"type\": \"page_id\",\n\t\t\t\t\"page_id\": \"59833787-2cf9-4fdf-8782-e53db20768a5\"\n\t\t\t},\n\t\t\t\"created_time\": \"2022-03-01T19:05:00.000Z\",\n\t\t\t\"last_edited_time\": \"2022-03-01T19:05:00.000Z\",\n\t\t\t\"created_by\": {\n\t\t\t\t\"object\": \"user\",\n\t\t\t\t\"id\": \"ee5f0f84-409a-440f-983a-a5315961c6e4\"\n\t\t\t},\n\t\t\t\"last_edited_by\": {\n\t\t\t\t\"object\": \"user\",\n\t\t\t\t\"id\": \"ee5f0f84-409a-440f-983a-a5315961c6e4\"\n\t\t\t},\n\t\t\t\"has_children\": false,\n\t\t\t\"archived\": false,\n\t\t\t\"type\": \"heading_2\",\n\t\t\t\"heading_2\": {\n\t\t\t\t\"rich_text\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"type\": \"text\",\n\t\t\t\t\t\t\"text\": {\n\t\t\t\t\t\t\t\"content\": \"Lacinato kale\",\n\t\t\t\t\t\t\t\"link\": null\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"annotations\": {\n\t\t\t\t\t\t\t\"bold\": false,\n\t\t\t\t\t\t\t\"italic\": false,\n\t\t\t\t\t\t\t\"strikethrough\": false,\n\t\t\t\t\t\t\t\"underline\": false,\n\t\t\t\t\t\t\t\"code\": false,\n\t\t\t\t\t\t\t\"color\": \"default\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"plain_text\": \"Lacinato kale\",\n\t\t\t\t\t\t\"href\": null\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\t\"color\": \"default\",\n \"is_toggleable\": false\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"object\": \"block\",\n\t\t\t\"id\": \"acc7eb06-05cd-4603-a384-5e1e4f1f4e72\",\n\t\t\t\"parent\": {\n\t\t\t\t\"type\": \"page_id\",\n\t\t\t\t\"page_id\": \"59833787-2cf9-4fdf-8782-e53db20768a5\"\n\t\t\t},\n\t\t\t\"created_time\": \"2022-03-01T19:05:00.000Z\",\n\t\t\t\"last_edited_time\": \"2022-03-01T19:05:00.000Z\",\n\t\t\t\"created_by\": {\n\t\t\t\t\"object\": \"user\",\n\t\t\t\t\"id\": \"ee5f0f84-409a-440f-983a-a5315961c6e4\"\n\t\t\t},\n\t\t\t\"last_edited_by\": {\n\t\t\t\t\"object\": \"user\",\n\t\t\t\t\"id\": \"ee5f0f84-409a-440f-983a-a5315961c6e4\"\n\t\t\t},\n\t\t\t\"has_children\": false,\n\t\t\t\"archived\": false,\n\t\t\t\"type\": \"paragraph\",\n\t\t\t\"paragraph\": {\n\t\t\t\t\"rich_text\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"type\": \"text\",\n\t\t\t\t\t\t\"text\": {\n\t\t\t\t\t\t\t\"content\": \"Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.\",\n\t\t\t\t\t\t\t\"link\": {\n\t\t\t\t\t\t\t\t\"url\": \"https://en.wikipedia.org/wiki/Lacinato_kale\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"annotations\": {\n\t\t\t\t\t\t\t\"bold\": false,\n\t\t\t\t\t\t\t\"italic\": false,\n\t\t\t\t\t\t\t\"strikethrough\": false,\n\t\t\t\t\t\t\t\"underline\": false,\n\t\t\t\t\t\t\t\"code\": false,\n\t\t\t\t\t\t\t\"color\": \"default\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"plain_text\": \"Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.\",\n\t\t\t\t\t\t\"href\": \"https://en.wikipedia.org/wiki/Lacinato_kale\"\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\t\"color\": \"default\"\n\t\t\t}\n\t\t}\n\t],\n\t\"next_cursor\": null,\n\t\"has_more\": false,\n\t\"type\": \"block\",\n\t\"block\": {}\n}"
schema:
$ref: '#/components/schemas/BlockGetChildrenResponse'
'400':
description: '400'
content:
application/json:
examples:
Result:
value: '{}'
schema:
$ref: '#/components/schemas/BlockGetChildren400Response'
deprecated: false
x-readme:
code-samples:
- language: javascript
code: |-
const { Client } = require('@notionhq/client');
const notion = new Client({ auth: process.env.NOTION_API_KEY });
(async () => {
const blockId = '59833787-2cf9-4fdf-8782-e53db20768a5';
const response = await notion.blocks.children.list({
block_id: blockId,
page_size: 50,
});
console.log(response);
})();
name: Notion SDK for JavaScript
- language: curl
code: >-
curl
'https://api.notion.com/v1/blocks/b55c9c91-384d-452b-81db-d1ef79372b75/children?page_size=100'
\
-H 'Authorization: Bearer '"$NOTION_API_KEY"'' \
-H "Notion-Version: 2022-06-28"
samples-languages:
- javascript
- curl
/v1/blocks/{block_id}:
get:
tags:
- Block
summary: Retrieve a block
operationId: Block_getDetails
security: []
description: ''
parameters:
- description: Identifier for a Notion block
name: block_id
in: path
schema:
type: string
required: true
- name: Notion-Version
in: header
schema:
type: string
default: '2022-06-28'
responses:
'200':
description: '200'
content:
application/json:
examples:
Result:
value: "{\n\t\"object\": \"block\",\n\t\"id\": \"c02fc1d3-db8b-45c5-a222-27595b15aea7\",\n\t\"parent\": {\n\t\t\"type\": \"page_id\",\n\t\t\"page_id\": \"59833787-2cf9-4fdf-8782-e53db20768a5\"\n\t},\n\t\"created_time\": \"2022-03-01T19:05:00.000Z\",\n\t\"last_edited_time\": \"2022-03-01T19:05:00.000Z\",\n\t\"created_by\": {\n\t\t\"object\": \"user\",\n\t\t\"id\": \"ee5f0f84-409a-440f-983a-a5315961c6e4\"\n\t},\n\t\"last_edited_by\": {\n\t\t\"object\": \"user\",\n\t\t\"id\": \"ee5f0f84-409a-440f-983a-a5315961c6e4\"\n\t},\n\t\"has_children\": false,\n\t\"archived\": false,\n\t\"type\": \"heading_2\",\n\t\"heading_2\": {\n\t\t\"rich_text\": [\n\t\t\t{\n\t\t\t\t\"type\": \"text\",\n\t\t\t\t\"text\": {\n\t\t\t\t\t\"content\": \"Lacinato kale\",\n\t\t\t\t\t\"link\": null\n\t\t\t\t},\n\t\t\t\t\"annotations\": {\n\t\t\t\t\t\"bold\": false,\n\t\t\t\t\t\"italic\": false,\n\t\t\t\t\t\"strikethrough\": false,\n\t\t\t\t\t\"underline\": false,\n\t\t\t\t\t\"code\": false,\n\t\t\t\t\t\"color\": \"default\"\n\t\t\t\t},\n\t\t\t\t\"plain_text\": \"Lacinato kale\",\n\t\t\t\t\"href\": null\n\t\t\t}\n\t\t],\n\t\t\"color\": \"default\",\n \"is_toggleable\": false\n\t}\n}"
schema:
$ref: '#/components/schemas/BlockGetDetailsResponse'
'400':
description: '400'
content:
application/json:
examples:
Result:
value: '{}'
schema:
$ref: '#/components/schemas/BlockGetDetails400Response'
deprecated: false
x-readme:
code-samples:
- language: javascript
code: |-
const { Client } = require('@notionhq/client');
const notion = new Client({ auth: process.env.NOTION_API_KEY });
(async () => {
const blockId = 'c02fc1d3-db8b-45c5-a222-27595b15aea7';
const response = await notion.blocks.retrieve({
block_id: blockId,
});
console.log(response);
})();
name: Notion SDK for JavaScript
- language: curl
code: >-
curl
'https://api.notion.com/v1/blocks/0c940186-ab70-4351-bb34-2d16f0635d49'
\
-H 'Authorization: Bearer '"$NOTION_API_KEY"'' \
-H 'Notion-Version: 2022-06-28'
samples-languages:
- javascript
- curl
patch:
tags:
- Block
summary: Update a block
operationId: Block_updateBlockById
security: []
description: ''
parameters:
- description: Identifier for a Notion block
name: block_id
in: path
schema:
type: string
required: true
- name: Notion-Version
in: header
schema:
type: string
default: '2022-06-28'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/BlockUpdateBlockByIdRequest'
responses:
'200':
description: '200'
content:
application/json:
examples:
Result:
value: "{\n\t\"object\": \"block\",\n\t\"id\": \"c02fc1d3-db8b-45c5-a222-27595b15aea7\",\n\t\"parent\": {\n\t\t\"type\": \"page_id\",\n\t\t\"page_id\": \"59833787-2cf9-4fdf-8782-e53db20768a5\"\n\t},\n\t\"created_time\": \"2022-03-01T19:05:00.000Z\",\n\t\"last_edited_time\": \"2022-07-06T19:41:00.000Z\",\n\t\"created_by\": {\n\t\t\"object\": \"user\",\n\t\t\"id\": \"ee5f0f84-409a-440f-983a-a5315961c6e4\"\n\t},\n\t\"last_edited_by\": {\n\t\t\"object\": \"user\",\n\t\t\"id\": \"ee5f0f84-409a-440f-983a-a5315961c6e4\"\n\t},\n\t\"has_children\": false,\n\t\"archived\": false,\n\t\"type\": \"heading_2\",\n\t\"heading_2\": {\n\t\t\"rich_text\": [\n\t\t\t{\n\t\t\t\t\"type\": \"text\",\n\t\t\t\t\"text\": {\n\t\t\t\t\t\"content\": \"Lacinato kale\",\n\t\t\t\t\t\"link\": null\n\t\t\t\t},\n\t\t\t\t\"annotations\": {\n\t\t\t\t\t\"bold\": false,\n\t\t\t\t\t\"italic\": false,\n\t\t\t\t\t\"strikethrough\": false,\n\t\t\t\t\t\"underline\": false,\n\t\t\t\t\t\"code\": false,\n\t\t\t\t\t\"color\": \"green\"\n\t\t\t\t},\n\t\t\t\t\"plain_text\": \"Lacinato kale\",\n\t\t\t\t\"href\": null\n\t\t\t}\n\t\t],\n\t\t\"color\": \"default\",\n \"is_toggleable\": false\n\t}\n}"
schema:
$ref: '#/components/schemas/BlockUpdateBlockByIdResponse'
'400':
description: '400'
content:
application/json:
examples:
Result:
value: '{}'
schema:
$ref: '#/components/schemas/BlockUpdateBlockById400Response'
deprecated: false
x-readme:
code-samples:
- language: javascript
code: "const { Client } = require('@notionhq/client');\n\nconst notion = new Client({ auth: process.env.NOTION_API_KEY });\n\n(async () => {\n const blockId = '9bc30ad4-9373-46a5-84ab-0a7845ee52e6';\n const response = await notion.blocks.update({\n\t\"block_id\": blockId,\n\t\"heading_2\": {\n\t\t\"rich_text\": [\n\t\t\t{\n\t\t\t\t\"text\": {\n\t\t\t\t\t\"content\": \"Lacinato kale\"\n\t\t\t\t},\n\t\t\t\t\"annotations\": {\n\t\t\t\t\t\"color\": \"green\"\n\t\t\t\t}\n\t\t\t}\n\t\t]\n\t}\n});\n console.log(response);\n})();"
name: Notion SDK for JavaScript
- language: curl
code: >-
curl
https://api.notion.com/v1/blocks/9bc30ad4-9373-46a5-84ab-0a7845ee52e6
\
-H 'Authorization: Bearer '"$NOTION_API_KEY"'' \
-H "Content-Type: application/json" \
-H "Notion-Version: 2022-06-28" \
-X PATCH \
--data '{
"to_do": {
"rich_text": [{
"text": { "content": "Lacinato kale" }
}],
"checked": false
}
}'
samples-languages:
- javascript
- curl
delete:
tags:
- Block
summary: Delete a block
operationId: Block_removeBlockById
security: []
description: ''
parameters:
- description: Identifier for a Notion block
name: block_id
in: path
schema:
type: string
required: true
- name: Notion-Version
in: header
schema:
type: string
default: '2022-06-28'
responses:
'200':
description: '200'
content:
application/json:
examples:
Result:
value: "{\n\t\"object\": \"block\",\n\t\"id\": \"7985540b-2e77-4ac6-8615-c3047e36f872\",\n\t\"parent\": {\n\t\t\"type\": \"page_id\",\n\t\t\"page_id\": \"59833787-2cf9-4fdf-8782-e53db20768a5\"\n\t},\n\t\"created_time\": \"2022-07-06T19:52:00.000Z\",\n\t\"last_edited_time\": \"2022-07-06T19:52:00.000Z\",\n\t\"created_by\": {\n\t\t\"object\": \"user\",\n\t\t\"id\": \"0c3e9826-b8f7-4f73-927d-2caaf86f1103\"\n\t},\n\t\"last_edited_by\": {\n\t\t\"object\": \"user\",\n\t\t\"id\": \"ee5f0f84-409a-440f-983a-a5315961c6e4\"\n\t},\n\t\"has_children\": false,\n\t\"archived\": true,\n\t\"type\": \"paragraph\",\n\t\"paragraph\": {\n\t\t\"rich_text\": [],\n\t\t\"color\": \"default\"\n\t}\n}"
schema:
$ref: '#/components/schemas/BlockRemoveBlockByIdResponse'
'400':
description: '400'
content:
application/json:
examples:
Result:
value: '{}'
schema:
$ref: '#/components/schemas/BlockRemoveBlockById400Response'
deprecated: false
x-readme:
code-samples:
- language: javascript
code: |-
const { Client } = require('@notionhq/client');
const notion = new Client({ auth: process.env.NOTION_API_KEY });
(async () => {
const blockId = '7985540b-2e77-4ac6-8615-c3047e36f872';
const response = await notion.blocks.delete({
block_id: blockId,
});
console.log(response);
})();
name: Notion SDK for JavaScript
- language: curl
code: >-
curl -X DELETE
'https://api.notion.com/v1/blocks/9bc30ad4-9373-46a5-84ab-0a7845ee52e6'
\
-H 'Authorization: Bearer '"$NOTION_API_KEY"'' \
-H 'Notion-Version: 2022-06-28'
samples-languages:
- javascript
- curl
/v1/pages:
post:
tags:
- Page
summary: Create a page
operationId: Page_createNewPage
security: []
description: ''
parameters:
- name: Notion-Version
in: header
required: true
schema:
type: string
default: '2022-06-28'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/PageCreateNewPageRequest'
responses:
'200':
description: '200'
content:
application/json:
examples:
Result:
value: |-
{
"object": "page",
"id": "59833787-2cf9-4fdf-8782-e53db20768a5",
"created_time": "2022-03-01T19:05:00.000Z",
"last_edited_time": "2022-07-06T19:16:00.000Z",
"created_by": {
"object": "user",
"id": "ee5f0f84-409a-440f-983a-a5315961c6e4"
},
"last_edited_by": {
"object": "user",
"id": "ee5f0f84-409a-440f-983a-a5315961c6e4"
},
"cover": {
"type": "external",
"external": {
"url": "https://upload.wikimedia.org/wikipedia/commons/6/62/Tuscankale.jpg"
}
},
"icon": {
"type": "emoji",
"emoji": "🥬"
},
"parent": {
"type": "database_id",
"database_id": "d9824bdc-8445-4327-be8b-5b47500af6ce"
},
"archived": false,
"properties": {
"Store availability": {
"id": "%3AUPp"
},
"Food group": {
"id": "A%40Hk"
},
"Price": {
"id": "BJXS"
},
"Responsible Person": {
"id": "Iowm"
},
"Last ordered": {
"id": "Jsfb"
},
"Cost of next trip": {
"id": "WOd%3B"
},
"Recipes": {
"id": "YfIu"
},
"Description": {
"id": "_Tc_"
},
"In stock": {
"id": "%60%5Bq%3F"
},
"Number of meals": {
"id": "zag~"
},
"Photo": {
"id": "%7DF_L"
},
"Name": {
"id": "title"
}
},
"url": "https://www.notion.so/Tuscan-Kale-598337872cf94fdf8782e53db20768a5"
}
schema:
$ref: '#/components/schemas/PageCreateNewPageResponse'
'400':
description: '400'
content:
application/json:
examples:
Result:
value: '{}'
schema:
$ref: '#/components/schemas/PageCreateNewPage400Response'
'404':
description: '404'
content:
application/json:
examples:
Result:
value: |-
{
"object": "error",
"status": 404,
"code": "object_not_found",
"message": "Could not find page with ID: 4cc3b486-0b48-4cfe-8ce9-67c47100eb6a. Make sure the relevant pages and databases are shared with your integration."
}
schema:
$ref: '#/components/schemas/PageCreateNewPage404Response'
'429':
description: '429'
content:
application/json:
examples:
Result:
value: |-
{
"object": "error",
"status": 429,
"code": "rate_limited",
"message": "You have been rate limited. Please try again in a few minutes."
}
schema:
$ref: '#/components/schemas/PageCreateNewPage429Response'
deprecated: false
x-readme:
code-samples:
- language: javascript
code: |-
const { Client } = require('@notionhq/client');
const notion = new Client({ auth: process.env.NOTION_API_KEY });
(async () => {
const response = await notion.pages.create({
"cover": {
"type": "external",
"external": {
"url": "https://upload.wikimedia.org/wikipedia/commons/6/62/Tuscankale.jpg"
}
},
"icon": {
"type": "emoji",
"emoji": "🥬"
},
"parent": {
"type": "database_id",
"database_id": "d9824bdc-8445-4327-be8b-5b47500af6ce"
},
"properties": {
"Name": {
"title": [
{
"text": {
"content": "Tuscan kale"
}
}
]
},
"Description": {
"rich_text": [
{
"text": {
"content": "A dark green leafy vegetable"
}
}
]
},
"Food group": {
"select": {
"name": "🥬 Vegetable"
}
}
},
"children": [
{
"object": "block",
"heading_2": {
"rich_text": [
{
"text": {
"content": "Lacinato kale"
}
}
]
}
},
{
"object": "block",
"paragraph": {
"rich_text": [
{
"text": {
"content": "Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.",
"link": {
"url": "https://en.wikipedia.org/wiki/Lacinato_kale"
}
},
"href": "https://en.wikipedia.org/wiki/Lacinato_kale"
}
],
"color": "default"
}
}
]
});
console.log(response);
})();
name: Notion SDK for JavaScript
- language: curl
code: "curl 'https://api.notion.com/v1/pages' \\\n -H 'Authorization: Bearer '\"$NOTION_API_KEY\"'' \\\n -H \"Content-Type: application/json\" \\\n -H \"Notion-Version: 2022-06-28\" \\\n --data '{\n\t\"parent\": { \"database_id\": \"d9824bdc84454327be8b5b47500af6ce\" },\n \"icon\": {\n \t\"emoji\": \"🥬\"\n },\n\t\"cover\": {\n\t\t\"external\": {\n\t\t\t\"url\": \"https://upload.wikimedia.org/wikipedia/commons/6/62/Tuscankale.jpg\"\n\t\t}\n\t},\n\t\"properties\": {\n\t\t\"Name\": {\n\t\t\t\"title\": [\n\t\t\t\t{\n\t\t\t\t\t\"text\": {\n\t\t\t\t\t\t\"content\": \"Tuscan Kale\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"Description\": {\n\t\t\t\"rich_text\": [\n\t\t\t\t{\n\t\t\t\t\t\"text\": {\n\t\t\t\t\t\t\"content\": \"A dark green leafy vegetable\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"Food group\": {\n\t\t\t\"select\": {\n\t\t\t\t\"name\": \"Vegetable\"\n\t\t\t}\n\t\t},\n\t\t\"Price\": { \"number\": 2.5 }\n\t},\n\t\"children\": [\n\t\t{\n\t\t\t\"object\": \"block\",\n\t\t\t\"type\": \"heading_2\",\n\t\t\t\"heading_2\": {\n\t\t\t\t\"rich_text\": [{ \"type\": \"text\", \"text\": { \"content\": \"Lacinato kale\" } }]\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"object\": \"block\",\n\t\t\t\"type\": \"paragraph\",\n\t\t\t\"paragraph\": {\n\t\t\t\t\"rich_text\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"type\": \"text\",\n\t\t\t\t\t\t\"text\": {\n\t\t\t\t\t\t\t\"content\": \"Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.\",\n\t\t\t\t\t\t\t\"link\": { \"url\": \"https://en.wikipedia.org/wiki/Lacinato_kale\" }\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t]\n}'"
samples-languages:
- javascript
- curl
components:
securitySchemes:
token:
type: http
scheme: bearer
schemas:
TokenGenerateAccessRequest:
type: object
required:
- code
- grant_type
- redirect_uri
properties:
code:
description: >-
A unique random code that Notion generates to authenticate with your
service, generated when a user initiates the OAuth flow.
type: string
grant_type:
description: 'A constant string: "authorization_code".'
type: string
default: '"authorization_code"'
redirect_uri:
description: >-
The `"redirect_uri"` that was provided in the OAuth Domain & URI
section of the integration's Authorization settings. Do not include
this field if a `"redirect_uri"` query param was not included in the
Authorization URL provided to users. In most cases, this field is
required.
type: string
external_account:
description: >-
Required if and only when building [Link
Preview](https://developers.notion.com/docs/link-previews)
integrations (otherwise ignored). An object with `key` and `name`
properties. `key` should be a unique identifier for the account.
Notion uses the `key` to determine whether or not the user is
re-connecting the same account. `name` should be some way for the
user to know which account they used to authenticate with your
service. If a user has authenticated Notion with your integration
before and `key` is the same but `name` is different, then Notion
updates the `name` associated with your integration.
type: object
properties: {}
BlockAppendChildrenRequest:
type: object
required:
- children
properties:
children:
description: >-
Child content to append to a container block as an array of [block
objects](ref:block)
type: array
items:
description: >-
WARNING: Missing items property in array schema. Missing items
property has been filled with this AnyType schema.
after:
description: >-
The ID of the existing block that the new block should be appended
after.
type: string
BlockUpdateBlockByIdRequest:
type: object
properties:
'{type}':
description: >-
The [block object `type`](ref:block#block-object-keys) value with
the properties to be updated. Currently only `text` (for supported
block types) and `checked` (for `to_do` blocks) fields can be
updated.
type: object
properties: {}
archived:
description: >-
Set to true to archive (delete) a block. Set to false to un-archive
(restore) a block.
type: boolean
default: true
PageCreateNewPageRequest:
type: object
required:
- parent
- properties
properties:
parent:
description: >-
The parent page or database where the new page is inserted,
represented as a JSON object with a `page_id` or `database_id` key,
and the corresponding ID.
type: string
format: json
properties:
description: >-
The values of the page’s properties. If the `parent` is a database,
then the schema must match the parent database’s properties. If the
`parent` is a page, then the only valid object key is `title`.
type: string
format: json
children:
description: >-
The content to be rendered on the new page, represented as an array
of [block objects](https://developers.notion.com/reference/block).
type: array
items:
type: string
icon:
description: >-
The icon of the new page. Either an [emoji
object](https://developers.notion.com/reference/emoji-object) or an
[external file
object](https://developers.notion.com/reference/file-object)..
type: string
format: json
cover:
description: >-
The cover image of the new page, represented as a [file
object](https://developers.notion.com/reference/file-object).
type: string
format: json
PageUpdatePropertiesRequest:
type: object
properties:
properties:
description: >-
The property values to update for the page. The keys are the names
or IDs of the property and the values are property values. If a page
property ID is not included, then it is not changed.
type: string
format: json
archived:
description: >-
Whether the page is archived (deleted). Set to true to archive a
page. Set to false to un-archive (restore) a page.
type: boolean
icon:
description: >-
A page icon for the page. Supported types are [external file
object](https://developers.notion.com/reference/file-object) or
[emoji
object](https://developers.notion.com/reference/emoji-object).
type: string
format: json
cover:
description: >-
A cover image for the page. Only [external file
objects](https://developers.notion.com/reference/file-object) are
supported.
type: string
format: json
DatabaseCreateNewDatabaseRequest:
type: object
required:
- parent
- properties
properties:
title:
description: >-
Title of database as it appears in Notion. An array of [rich text
objects](ref:rich-text).
type: array
items:
description: >-
WARNING: Missing items property in array schema. Missing items
property has been filled with this AnyType schema.
parent:
description: A [page parent](/reference/database#page-parent)
type: string
format: json
properties:
description: >-
Property schema of database. The keys are the names of properties as
they appear in Notion and the values are [property schema
objects](https://developers.notion.com/reference/property-schema-object).
type: string
format: json
DatabaseExecuteQueryRequest:
type: object
properties:
filter:
description: >-
When supplied, limits which pages are returned based on the [filter
conditions](ref:post-database-query-filter).
type: string
format: json
sorts:
description: >-
When supplied, orders the results based on the provided [sort
criteria](ref:post-database-query-sort).
type: array
items:
description: >-
WARNING: Missing items property in array schema. Missing items
property has been filled with this AnyType schema.
start_cursor:
description: >-
When supplied, returns a page of results starting after the cursor
provided. If not supplied, this endpoint will return the first page
of results.
type: string
page_size:
description: >-
The number of items from the full list desired in the response.
Maximum: 100
type: integer
default: 100
format: int32
DatabaseUpdateDatabaseRequest:
type: object
properties:
title:
description: >-
An array of [rich text
objects](https://developers.notion.com/reference/rich-text) that
represents the title of the database that is displayed in the Notion
UI. If omitted, then the database title remains unchanged.
type: array
items:
description: >-
WARNING: Missing items property in array schema. Missing items
property has been filled with this AnyType schema.
description:
description: >-
An array of [rich text
objects](https://developers.notion.com/reference/rich-text) that
represents the description of the database that is displayed in the
Notion UI. If omitted, then the database description remains
unchanged.
type: array
items:
description: >-
WARNING: Missing items property in array schema. Missing items
property has been filled with this AnyType schema.
properties:
description: >-
The properties of a database to be changed in the request, in the
form of a JSON object. If updating an existing property, then the
keys are the names or IDs of the properties as they appear in
Notion, and the values are [property schema
objects](ref:property-schema-object). If adding a new property, then
the key is the name of the new database property and the value is a
[property schema object](ref:property-schema-object).
type: string
format: json
CommentCreateNewRequest:
type: object
required:
- rich_text
properties:
parent:
description: >-
A [page parent](/reference/database#page-parent). Either this or a
discussion_id is required (not both)
type: string
format: json
discussion_id:
description: >-
A UUID identifier for a discussion thread. Either this or a parent
object is required (not both)
type: string
rich_text:
description: A [rich text object](ref:rich-text)
type: string
format: json
SearchByTitleRequest:
type: object
properties:
query:
description: The text that the API compares page and database titles against.
type: string
sort:
description: >-
A set of criteria, `direction` and `timestamp` keys, that orders the
results. The **only** supported timestamp value is
`"last_edited_time"`. Supported `direction` values are `"ascending"`
and `"descending"`. If `sort` is not provided, then the most
recently edited results are returned first.
type: object
properties:
direction:
description: >-
The direction to sort. Possible values include `ascending` and
`descending`.
type: string
timestamp:
description: >-
The name of the timestamp to sort against. Possible values
include `last_edited_time`.
type: string
filter:
description: >-
A set of criteria, `value` and `property` keys, that limits the
results to either only pages or only databases. Possible `value`