Coverage for notion_client/api_endpoints.py: 100%
130 statements
« prev ^ index » next coverage.py v7.17.0, created at 2026-10-30 15:22 +0000
« prev ^ index » next coverage.py v7.17.0, created at 2026-10-30 15:22 +0000
1"""Notion API endpoints.""" # noqa: E501
3from typing import TYPE_CHECKING, Any
5from notion_client.helpers import pick
6from notion_client.typing import SyncAsync
8if TYPE_CHECKING: # pragma: no cover
9 from notion_client.client import BaseClient
12class Endpoint:
13 def __init__(self, parent: "BaseClient") -> None:
14 self.parent = parent
17class BlocksChildrenEndpoint(Endpoint):
18 def append(self, block_id: str, **kwargs: Any) -> SyncAsync[Any]:
19 """Create and append new children blocks to the block using the ID specified.
21 *[🔗 Endpoint documentation](https://developers.notion.com/reference/patch-block-children)*
22 """ # noqa: E501
23 return self.parent.request(
24 path=f"blocks/{block_id}/children",
25 method="PATCH",
26 body=pick(kwargs, "children", "after", "position", "notifications"),
27 auth=kwargs.get("auth"),
28 )
30 def list(self, block_id: str, **kwargs: Any) -> SyncAsync[Any]:
31 """Return a paginated array of child [block objects](https://developers.notion.com/reference/block) contained in the block.
33 *[🔗 Endpoint documentation](https://developers.notion.com/reference/get-block-children)*
34 """ # noqa: E501
35 return self.parent.request(
36 path=f"blocks/{block_id}/children",
37 method="GET",
38 query=pick(kwargs, "start_cursor", "page_size"),
39 auth=kwargs.get("auth"),
40 )
43class BlocksMeetingNotesEndpoint(Endpoint):
44 def create(self, **kwargs: Any) -> SyncAsync[Any]:
45 """Create a meeting note from a file upload or an existing block.
47 *[🔗 Endpoint documentation](https://developers.notion.com/reference/create-meeting-note)*
48 """ # noqa: E501
49 return self.parent.request(
50 path="blocks/meeting_notes",
51 method="POST",
52 body=pick(kwargs, "title", "language", "options", "source", "parent"),
53 auth=kwargs.get("auth"),
54 )
56 def query(self, **kwargs: Any) -> SyncAsync[Any]:
57 """Query meeting notes.
59 *[🔗 Endpoint documentation](https://developers.notion.com/reference/query-meeting-notes)*
60 """ # noqa: E501
61 return self.parent.request(
62 path="blocks/meeting_notes/query",
63 method="POST",
64 body=pick(kwargs, "filter", "sort", "limit"),
65 auth=kwargs.get("auth"),
66 )
69class BlocksEndpoint(Endpoint):
70 def __init__(self, *args: Any, **kwargs: Any) -> None:
71 super().__init__(*args, **kwargs)
72 self.children = BlocksChildrenEndpoint(*args, **kwargs)
73 self.meeting_notes = BlocksMeetingNotesEndpoint(*args, **kwargs)
75 def retrieve(self, block_id: str, **kwargs: Any) -> SyncAsync[Any]:
76 """Retrieve a [Block object](https://developers.notion.com/reference/block) using the ID specified.
78 *[🔗 Endpoint documentation](https://developers.notion.com/reference/retrieve-a-block)*
79 """ # noqa: E501
80 return self.parent.request(
81 path=f"blocks/{block_id}", method="GET", auth=kwargs.get("auth")
82 )
84 def update(self, block_id: str, **kwargs: Any) -> SyncAsync[Any]:
85 """Update the content for the specified `block_id` based on the block type.
87 *[🔗 Endpoint documentation](https://developers.notion.com/reference/update-a-block)*
88 """ # noqa: E501
89 return self.parent.request(
90 path=f"blocks/{block_id}",
91 method="PATCH",
92 body=pick(
93 kwargs,
94 "embed",
95 "type",
96 "archived",
97 "in_trash",
98 "bookmark",
99 "image",
100 "video",
101 "pdf",
102 "file",
103 "audio",
104 "code",
105 "equation",
106 "divider",
107 "breadcrumb",
108 "tab",
109 "table_of_contents",
110 "link_to_page",
111 "table_row",
112 "heading_1",
113 "heading_2",
114 "heading_3",
115 "heading_4",
116 "paragraph",
117 "bulleted_list_item",
118 "numbered_list_item",
119 "quote",
120 "to_do",
121 "toggle",
122 "template",
123 "callout",
124 "synced_block",
125 "table",
126 "column",
127 ),
128 auth=kwargs.get("auth"),
129 )
131 def delete(self, block_id: str, **kwargs: Any) -> SyncAsync[Any]:
132 """Set a [Block object](https://developers.notion.com/reference/block), including page blocks, to `archived: true`.
134 *[🔗 Endpoint documentation](https://developers.notion.com/reference/delete-a-block)*
135 """ # noqa: E501
136 return self.parent.request(
137 path=f"blocks/{block_id}",
138 method="DELETE",
139 auth=kwargs.get("auth"),
140 )
143class DatabasesEndpoint(Endpoint):
144 def retrieve(self, database_id: str, **kwargs: Any) -> SyncAsync[Any]:
145 """Retrieves a [database object](https://developers.notion.com/reference/database) for a provided database ID.
147 *[🔗 Endpoint documentation](https://developers.notion.com/reference/database-retrieve)*
148 """ # noqa: E501
149 return self.parent.request(
150 path=f"databases/{database_id}",
151 method="GET",
152 auth=kwargs.get("auth"),
153 )
155 def update(self, database_id: str, **kwargs: Any) -> SyncAsync[Any]:
156 """Update the title or properties of an existing database.
158 *[🔗 Endpoint documentation](https://developers.notion.com/reference/update-a-database)*
159 """ # noqa: E501
160 return self.parent.request(
161 path=f"databases/{database_id}",
162 method="PATCH",
163 body=pick(
164 kwargs,
165 "parent",
166 "title",
167 "description",
168 "is_inline",
169 "icon",
170 "cover",
171 "in_trash",
172 "is_locked",
173 "show_data_source_title",
174 ),
175 auth=kwargs.get("auth"),
176 )
178 def create(self, **kwargs: Any) -> SyncAsync[Any]:
179 """Create a new database.
181 *[🔗 Endpoint documentation](https://developers.notion.com/reference/create-a-database)*
182 """ # noqa: E501
183 return self.parent.request(
184 path="databases",
185 method="POST",
186 body=pick(
187 kwargs,
188 "parent",
189 "title",
190 "description",
191 "is_inline",
192 "initial_data_source",
193 "database_type",
194 "icon",
195 "cover",
196 "show_data_source_title",
197 ),
198 auth=kwargs.get("auth"),
199 )
202class DataSourcesEndpoint(Endpoint):
203 def retrieve(self, data_source_id: str, **kwargs: Any) -> SyncAsync[Any]:
204 """Retrieve a [data source](https://developers.notion.com/reference/data-source) object for a provided data source ID.
206 *[🔗 Endpoint documentation](https://developers.notion.com/reference/retrieve-a-data-source)*
207 """ # noqa: E501
208 return self.parent.request(
209 path=f"data_sources/{data_source_id}", method="GET", auth=kwargs.get("auth")
210 )
212 def query(self, data_source_id: str, **kwargs: Any) -> SyncAsync[Any]:
213 """Get a list of [Pages](https://developers.notion.com/reference/page) and/or [Data Sources](https://developers.notion.com/reference/data-source) contained in the data source.
215 *[🔗 Endpoint documentation](https://developers.notion.com/reference/query-a-data-source)*
216 """ # noqa: E501
217 return self.parent.request(
218 path=f"data_sources/{data_source_id}/query",
219 method="POST",
220 query=pick(kwargs, "filter_properties"),
221 body=pick(
222 kwargs,
223 "sorts",
224 "filter",
225 "start_cursor",
226 "page_size",
227 "is_archived",
228 "archived",
229 "in_trash",
230 "result_type",
231 ),
232 auth=kwargs.get("auth"),
233 )
235 def create(self, **kwargs: Any) -> SyncAsync[Any]:
236 """Add an additional [data source](https://developers.notion.com/reference/data-source) to an existing [database](https://developers.notion.com/reference/database).
238 *[🔗 Endpoint documentation](https://developers.notion.com/reference/create-a-data-source)*
239 """ # noqa: E501
240 return self.parent.request(
241 path="data_sources",
242 method="POST",
243 body=pick(kwargs, "parent", "properties", "title", "icon"),
244 auth=kwargs.get("auth"),
245 )
247 def update(self, data_source_id: str, **kwargs: Any) -> SyncAsync[Any]:
248 """Updates the [data source](https://developers.notion.com/reference/data-source) object of a specified data source under a database.
250 *[🔗 Endpoint documentation](https://developers.notion.com/reference/update-a-data-source)*
251 """ # noqa: E501
252 return self.parent.request(
253 path=f"data_sources/{data_source_id}",
254 method="PATCH",
255 body=pick(
256 kwargs, "title", "icon", "properties", "in_trash", "archived", "parent"
257 ),
258 auth=kwargs.get("auth"),
259 )
261 def list_templates(self, data_source_id: str, **kwargs: Any) -> SyncAsync[Any]:
262 """List page templates that are available for a data source.
264 *[🔗 Endpoint documentation](https://developers.notion.com/reference/list-data-source-templates)*
265 """ # noqa: E501
266 return self.parent.request(
267 path=f"data_sources/{data_source_id}/templates",
268 method="GET",
269 query=pick(kwargs, "name", "start_cursor", "page_size"),
270 auth=kwargs.get("auth"),
271 )
274class PagesPropertiesEndpoint(Endpoint):
275 def retrieve(self, page_id: str, property_id: str, **kwargs: Any) -> SyncAsync[Any]:
276 """Retrieve a `property_item` object for a given `page_id` and `property_id`.
278 *[🔗 Endpoint documentation](https://developers.notion.com/reference/retrieve-a-page-property)*
279 """ # noqa: E501
280 return self.parent.request(
281 path=f"pages/{page_id}/properties/{property_id}",
282 method="GET",
283 auth=kwargs.get("auth"),
284 query=pick(kwargs, "start_cursor", "page_size"),
285 )
288class PagesEndpoint(Endpoint):
289 def __init__(self, *args: Any, **kwargs: Any) -> None:
290 super().__init__(*args, **kwargs)
291 self.properties = PagesPropertiesEndpoint(*args, **kwargs)
293 def create(self, **kwargs: Any) -> SyncAsync[Any]:
294 """Create a new page in the specified database or as a child of an existing page.
296 *[🔗 Endpoint documentation](https://developers.notion.com/reference/post-page)*
297 """ # noqa: E501
298 return self.parent.request(
299 path="pages",
300 method="POST",
301 query=pick(kwargs, "filter_properties"),
302 body=pick(
303 kwargs,
304 "allow_async",
305 "parent",
306 "properties",
307 "icon",
308 "cover",
309 "content",
310 "children",
311 "markdown",
312 "template",
313 "position",
314 "notifications",
315 ),
316 auth=kwargs.get("auth"),
317 )
319 def retrieve(self, page_id: str, **kwargs: Any) -> SyncAsync[Any]:
320 """Retrieve a [Page object](https://developers.notion.com/reference/page) using the ID specified.
322 *[🔗 Endpoint documentation](https://developers.notion.com/reference/retrieve-a-page)*
323 """ # noqa: E501
324 return self.parent.request(
325 path=f"pages/{page_id}",
326 method="GET",
327 query=pick(kwargs, "filter_properties"),
328 auth=kwargs.get("auth"),
329 )
331 def update(self, page_id: str, **kwargs: Any) -> SyncAsync[Any]:
332 """Update [page property values](https://developers.notion.com/reference/page#property-value-object) for the specified page.
334 *[🔗 Endpoint documentation](https://developers.notion.com/reference/patch-page)*
335 """ # noqa: E501
336 return self.parent.request(
337 path=f"pages/{page_id}",
338 method="PATCH",
339 query=pick(kwargs, "filter_properties"),
340 body=pick(
341 kwargs,
342 "properties",
343 "icon",
344 "cover",
345 "is_locked",
346 "template",
347 "erase_content",
348 "archived",
349 "in_trash",
350 "is_archived",
351 "notifications",
352 ),
353 auth=kwargs.get("auth"),
354 )
356 def retrieve_markdown(self, page_id: str, **kwargs: Any) -> SyncAsync[Any]:
357 """Retrieve a page as markdown.
359 *[🔗 Endpoint documentation](https://developers.notion.com/reference/retrieve-page-markdown)*
360 """ # noqa: E501
361 return self.parent.request(
362 path=f"pages/{page_id}/markdown",
363 method="GET",
364 query=pick(kwargs, "include_transcript"),
365 auth=kwargs.get("auth"),
366 )
368 def update_markdown(self, page_id: str, **kwargs: Any) -> SyncAsync[Any]:
369 """Update a page's content as markdown.
371 *[🔗 Endpoint documentation](https://developers.notion.com/reference/update-page-markdown)*
372 """ # noqa: E501
373 return self.parent.request(
374 path=f"pages/{page_id}/markdown",
375 method="PATCH",
376 body=pick(
377 kwargs,
378 "allow_async",
379 "type",
380 "insert_content",
381 "replace_content_range",
382 "update_content",
383 "replace_content",
384 ),
385 auth=kwargs.get("auth"),
386 )
388 def move(self, page_id: str, **kwargs: Any) -> SyncAsync[Any]:
389 """Use this API to move an existing Notion page to a new parent.
391 *[🔗 Endpoint documentation](https://developers.notion.com/reference/move-page)*
392 """ # noqa: E501
393 return self.parent.request(
394 path=f"pages/{page_id}/move",
395 method="POST",
396 body=pick(kwargs, "parent"),
397 auth=kwargs.get("auth"),
398 )
401class UsersEndpoint(Endpoint):
402 def list(self, **kwargs: Any) -> SyncAsync[Any]:
403 """Return a paginated list of [Users](https://developers.notion.com/reference/user) for the workspace.
405 *[🔗 Endpoint documentation](https://developers.notion.com/reference/get-users)*
406 """ # noqa: E501
407 return self.parent.request(
408 path="users",
409 method="GET",
410 query=pick(kwargs, "start_cursor", "page_size"),
411 auth=kwargs.get("auth"),
412 )
414 def retrieve(self, user_id: str, **kwargs: Any) -> SyncAsync[Any]:
415 """Retrieve a [User](https://developers.notion.com/reference/user) using the ID specified.
417 *[🔗 Endpoint documentation](https://developers.notion.com/reference/get-user)*
418 """ # noqa: E501
419 return self.parent.request(
420 path=f"users/{user_id}", method="GET", auth=kwargs.get("auth")
421 )
423 def me(self, **kwargs: Any) -> SyncAsync[Any]:
424 """Retrieve the bot [User](https://developers.notion.com/reference/user) associated with the API token.
426 *[🔗 Endpoint documentation](https://developers.notion.com/reference/get-self)*
427 """ # noqa: E501
428 return self.parent.request(
429 path="users/me", method="GET", auth=kwargs.get("auth")
430 )
433class ViewsQueriesEndpoint(Endpoint):
434 def create(self, view_id: str, **kwargs: Any) -> SyncAsync[Any]:
435 """Create a view query.
437 *[🔗 Endpoint documentation](https://developers.notion.com/reference/create-view-query)*
438 """ # noqa: E501
439 return self.parent.request(
440 path=f"views/{view_id}/queries",
441 method="POST",
442 body=pick(kwargs, "page_size"),
443 auth=kwargs.get("auth"),
444 )
446 def results(self, view_id: str, query_id: str, **kwargs: Any) -> SyncAsync[Any]:
447 """Get view query results.
449 *[🔗 Endpoint documentation](https://developers.notion.com/reference/get-view-query-results)*
450 """ # noqa: E501
451 return self.parent.request(
452 path=f"views/{view_id}/queries/{query_id}",
453 method="GET",
454 query=pick(kwargs, "start_cursor", "page_size"),
455 auth=kwargs.get("auth"),
456 )
458 def delete(self, view_id: str, query_id: str, **kwargs: Any) -> SyncAsync[Any]:
459 """Delete a view query.
461 *[🔗 Endpoint documentation](https://developers.notion.com/reference/delete-view-query)*
462 """ # noqa: E501
463 return self.parent.request(
464 path=f"views/{view_id}/queries/{query_id}",
465 method="DELETE",
466 auth=kwargs.get("auth"),
467 )
470class ViewsEndpoint(Endpoint):
471 def __init__(self, *args: Any, **kwargs: Any) -> None:
472 super().__init__(*args, **kwargs)
473 self.queries = ViewsQueriesEndpoint(*args, **kwargs)
475 def create(self, **kwargs: Any) -> SyncAsync[Any]:
476 """Create a view.
478 *[🔗 Endpoint documentation](https://developers.notion.com/reference/create-view)*
479 """ # noqa: E501
480 return self.parent.request(
481 path="views",
482 method="POST",
483 body=pick(
484 kwargs,
485 "data_source_id",
486 "name",
487 "type",
488 "database_id",
489 "view_id",
490 "filter",
491 "sorts",
492 "quick_filters",
493 "create_database",
494 "configuration",
495 "position",
496 "placement",
497 ),
498 auth=kwargs.get("auth"),
499 )
501 def retrieve(self, view_id: str, **kwargs: Any) -> SyncAsync[Any]:
502 """Retrieve a view.
504 *[🔗 Endpoint documentation](https://developers.notion.com/reference/retrieve-a-view)*
505 """ # noqa: E501
506 return self.parent.request(
507 path=f"views/{view_id}",
508 method="GET",
509 auth=kwargs.get("auth"),
510 )
512 def update(self, view_id: str, **kwargs: Any) -> SyncAsync[Any]:
513 """Update a view.
515 *[🔗 Endpoint documentation](https://developers.notion.com/reference/update-a-view)*
516 """ # noqa: E501
517 return self.parent.request(
518 path=f"views/{view_id}",
519 method="PATCH",
520 body=pick(
521 kwargs,
522 "name",
523 "filter",
524 "sorts",
525 "quick_filters",
526 "configuration",
527 ),
528 auth=kwargs.get("auth"),
529 )
531 def delete(self, view_id: str, **kwargs: Any) -> SyncAsync[Any]:
532 """Delete a view.
534 *[🔗 Endpoint documentation](https://developers.notion.com/reference/delete-view)*
535 """ # noqa: E501
536 return self.parent.request(
537 path=f"views/{view_id}",
538 method="DELETE",
539 auth=kwargs.get("auth"),
540 )
542 def list(self, **kwargs: Any) -> SyncAsync[Any]:
543 """List views for a database.
545 *[🔗 Endpoint documentation](https://developers.notion.com/reference/list-views)*
546 """ # noqa: E501
547 return self.parent.request(
548 path="views",
549 method="GET",
550 query=pick(
551 kwargs, "database_id", "data_source_id", "start_cursor", "page_size"
552 ),
553 auth=kwargs.get("auth"),
554 )
557class SearchEndpoint(Endpoint):
558 def __call__(self, **kwargs: Any) -> SyncAsync[Any]:
559 """Search all pages and child pages that are shared with the integration.
561 *[🔗 Endpoint documentation](https://developers.notion.com/reference/post-search)*
562 """ # noqa: E501
563 return self.parent.request(
564 path="search",
565 method="POST",
566 query=pick(kwargs, "filter_properties"),
567 body=pick(kwargs, "query", "sort", "filter", "start_cursor", "page_size"),
568 auth=kwargs.get("auth"),
569 )
572class CustomEmojisEndpoint(Endpoint):
573 def list(self, **kwargs: Any) -> SyncAsync[Any]:
574 """List custom emojis.
576 *[🔗 Endpoint documentation](https://developers.notion.com/reference/list-custom-emojis)*
577 """ # noqa: E501
578 return self.parent.request(
579 path="custom_emojis",
580 method="GET",
581 query=pick(kwargs, "start_cursor", "page_size", "name"),
582 auth=kwargs.get("auth"),
583 )
586class CommentsEndpoint(Endpoint):
587 def create(self, **kwargs: Any) -> SyncAsync[Any]:
588 """Create a new comment in the specified page or existing discussion thread.
590 *[🔗 Endpoint documentation](https://developers.notion.com/reference/create-a-comment)*
591 """ # noqa: E501
592 return self.parent.request(
593 path="comments",
594 method="POST",
595 body=pick(
596 kwargs,
597 "attachments",
598 "display_name",
599 "parent",
600 "rich_text",
601 "markdown",
602 "discussion_id",
603 ),
604 auth=kwargs.get("auth"),
605 )
607 def list(self, **kwargs: Any) -> SyncAsync[Any]:
608 """Retrieve a list of un-resolved [Comment objects](https://developers.notion.com/reference/comment-object) from the specified block.
610 *[🔗 Endpoint documentation](https://developers.notion.com/reference/list-comments)*
611 """ # noqa: E501
612 return self.parent.request(
613 path="comments",
614 method="GET",
615 query=pick(kwargs, "block_id", "start_cursor", "page_size"),
616 auth=kwargs.get("auth"),
617 )
619 def retrieve(self, comment_id: str, **kwargs: Any) -> SyncAsync[Any]:
620 """Retrieve a [Comment object](https://developers.notion.com/reference/comment-object) from its `comment_id`.
622 *[🔗 Endpoint documentation](https://developers.notion.com/reference/retrieve-comment)*
623 """ # noqa: E501
624 return self.parent.request(
625 path=f"comments/{comment_id}",
626 method="GET",
627 auth=kwargs.get("auth"),
628 )
630 def update(self, comment_id: str, **kwargs: Any) -> SyncAsync[Any]:
631 """Update a [Comment object](https://developers.notion.com/reference/comment-object) using its `comment_id`.
633 *[🔗 Endpoint documentation](https://developers.notion.com/reference/update-a-comment)*
634 """ # noqa: E501
635 return self.parent.request(
636 path=f"comments/{comment_id}",
637 method="PATCH",
638 body=pick(kwargs, "rich_text", "markdown"),
639 auth=kwargs.get("auth"),
640 )
642 def delete(self, comment_id: str, **kwargs: Any) -> SyncAsync[Any]:
643 """Delete a [Comment object](https://developers.notion.com/reference/comment-object) using its `comment_id`.
645 *[🔗 Endpoint documentation](https://developers.notion.com/reference/delete-a-comment)*
646 """ # noqa: E501
647 return self.parent.request(
648 path=f"comments/{comment_id}",
649 method="DELETE",
650 auth=kwargs.get("auth"),
651 )
654class AsyncTasksEndpoint(Endpoint):
655 def retrieve(self, task_id: str, **kwargs: Any) -> SyncAsync[Any]:
656 """Retrieve the status and result of an async task.
658 *[🔗 Endpoint documentation](https://developers.notion.com/reference/retrieve-async-task)*
659 """ # noqa: E501
660 return self.parent.request(
661 path=f"async_tasks/{task_id}",
662 method="GET",
663 auth=kwargs.get("auth"),
664 )
667class FileUploadsEndpoint(Endpoint):
668 def create(self, **kwargs: Any) -> SyncAsync[Any]:
669 """Create a file upload.
671 *[🔗 Endpoint documentation](https://developers.notion.com/reference/create-a-file-upload)*
672 """ # noqa: E501
673 return self.parent.request(
674 path="file_uploads",
675 method="POST",
676 body=pick(
677 kwargs,
678 "mode",
679 "filename",
680 "content_type",
681 "number_of_parts",
682 "external_url",
683 ),
684 auth=kwargs.get("auth"),
685 )
687 def complete(self, file_upload_id: str, **kwargs: Any) -> SyncAsync[Any]:
688 """Complete the file upload process.
690 *[🔗 Endpoint documentation](https://developers.notion.com/reference/complete-a-file-upload)*
691 """ # noqa: E501
692 return self.parent.request(
693 path=f"file_uploads/{file_upload_id}/complete",
694 method="POST",
695 auth=kwargs.get("auth"),
696 )
698 def retrieve(self, file_upload_id: str, **kwargs: Any) -> SyncAsync[Any]:
699 """Retrieve a file upload object using the ID specified.
701 *[🔗 Endpoint documentation](https://developers.notion.com/reference/retrieve-a-file-upload)*
702 """ # noqa: E501
703 return self.parent.request(
704 path=f"file_uploads/{file_upload_id}",
705 method="GET",
706 auth=kwargs.get("auth"),
707 )
709 def list(self, **kwargs: Any) -> SyncAsync[Any]:
710 """List all file uploads.
712 *[🔗 Endpoint documentation](https://developers.notion.com/reference/list-file-uploads)*
713 """ # noqa: E501
714 return self.parent.request(
715 path="file_uploads",
716 method="GET",
717 query=pick(kwargs, "status", "start_cursor", "page_size"),
718 auth=kwargs.get("auth"),
719 )
721 def send(self, file_upload_id: str, **kwargs: Any) -> SyncAsync[Any]:
722 """Send a file upload
724 *[🔗 Endpoint documentation](https://developers.notion.com/reference/send-a-file-upload)*
725 """ # noqa: E501
726 return self.parent.request(
727 path=f"file_uploads/{file_upload_id}/send",
728 method="POST",
729 form_data=pick(kwargs, "file", "part_number"),
730 auth=kwargs.get("auth"),
731 )
734class OAuthEndpoint(Endpoint):
735 def token(
736 self, client_id: str, client_secret: str, **kwargs: Any
737 ) -> SyncAsync[Any]:
738 """Create an access token that a third-party service can use to authenticate with Notion.
740 *[🔗 Endpoint documentation](https://developers.notion.com/reference/create-a-token)*
741 """ # noqa: E501
742 return self.parent.request(
743 path="oauth/token",
744 method="POST",
745 body=pick(
746 kwargs,
747 "grant_type",
748 "code",
749 "redirect_uri",
750 "external_account",
751 "refresh_token",
752 ),
753 auth={"client_id": client_id, "client_secret": client_secret},
754 )
756 def introspect(
757 self, client_id: str, client_secret: str, **kwargs: Any
758 ) -> SyncAsync[Any]:
759 """Get a token's active status, scope, and issued time.
761 *[🔗 Endpoint documentation](https://developers.notion.com/reference/introspect-token)*
762 """ # noqa: E501
763 return self.parent.request(
764 path="oauth/introspect",
765 method="POST",
766 body=pick(kwargs, "token"),
767 auth={"client_id": client_id, "client_secret": client_secret},
768 )
770 def revoke(
771 self, client_id: str, client_secret: str, **kwargs: Any
772 ) -> SyncAsync[Any]:
773 """Revoke an access token.
775 *[🔗 Endpoint documentation](https://developers.notion.com/reference/revoke-token)*
776 """ # noqa: E501
777 return self.parent.request(
778 path="oauth/revoke",
779 method="POST",
780 body=pick(kwargs, "token"),
781 auth={"client_id": client_id, "client_secret": client_secret},
782 )