Create pages in the default Office 365 notebook (in Preview)

Hi all! Yan and Diane here. Yan recently added Office 365 support for creating pages in the default notebook and creating pages in named sections in the default notebook. Saving to the default notebook makes creating OneNote pages quick and easy, and your users can choose to move them later.

The calls work just like the consumer APIs (which you can try out here). You simply send POST requests to the pages endpoint:

POST https://www.onenote.com/api/beta/me/notes/pages

    Creates a page in the default section of the user's default notebook.

POST https://www.onenote.com/api/beta/me/notes/pages?sectionName=SomeSectionName

    Creates a page in the specified section of the user's default notebook.

Remember the following rules when using the sectionName parameter:

  • Only top-level sections can be created or referenced (not sections within section groups).
  • If a section with the specified name doesn't exist in the default notebook, the API creates it.
  • Section names are case-insensitive for matching, but case is preserved when sections are created. So "My New Section" will display like that, but "my new section" would also match on subsequent posts.
  • These characters are not allowed for section names: ? * \ / : < > | & # " % ~
  • Section names must be URL-encoded. For example, spaces must be %20.

If the page creates successfully, the API responds with a 201 HTTP status code and a JSON representation of the new page. The response includes:

  • The links property in the body which contains links that open the page in the desktop client or in OneNote Online.
  • The URL to the new page resource in both the Location header and the self property in the body.

Typically, the default notebook is named something along these lines: {first-name} @ Work, {first-name} @ {tenant-name} , or My Notebook @ Work. On OneDrive for Business, these notebooks are found in the Documents library, either at the root or in the Notebooks folder. If the default notebook or section doesn't exist, the API creates a new one. Default notebooks created by the API are named {first-name} @ Work , and default sections are named Quick Notes.

Note: Currently, creating pages in the default notebook is not supported for SharePoint site-hosted notebooks.

Let us know what you think! Post your comments here, or get in touch via UserVoice or @onenotedev!