Pages API

Pages are rich content associated with Courses and Groups in Canvas. The Pages API allows you to create, retrieve, update, and delete ages.

A Page object looks like:

{
  // the unique locator for the page
  url: "my-page-title",

  // the title of the page
  title: "My Page Title",

  // the creation date for the page
  created_at: "2012-08-06T16:46:33-06:00",

  // the date the page was last updated
  updated_at: "2012-08-08T14:25:20-06:00",

  // whether this page is hidden from students
  // (note: students will never see this true; pages hidden from them will be omitted from results)
  hide_from_students: false,

  // roles allowed to edit the page; comma-separated list comprising a combination of
  // 'teachers', 'students', and/or 'public'
  // if not supplied, course defaults are used
  editing_roles: "teachers,students",

  // the User who last edited the page
  // (this may not be present if the page was imported from another system)
  last_edited_by: { 
    id: 133,
    display_name: "Rey del Pueblo",
    avatar_image_url: "https://canvas.example.com/images/thumbnails/bm90aGluZyBoZXJl",
    html_url: "https://canvas.example.com/courses/789/users/133"
  },

  // the page content, in HTML
  // (present when requesting a single page; omitted when listing pages)
  body: "<p>Page Content</p>",

  // whether the page is published
  published: true,

  // whether this page is the front page for the wiki
  front_page: false,

  // Whether or not this is locked for the user.
  locked_for_user: false,

  // (Optional) Information for the user about the lock. Present when locked_for_user is true.
  lock_info: {
    // Asset string for the object causing the lock
    asset_string: "wiki_page_1",

    // (Optional) Context module causing the lock.
    context_module: { ... }
  },

  // (Optional) An explanation of why this is locked for the user. Present when locked_for_user is true.
  lock_explanation: "This discussion is locked until September 1 at 12:00am"
}
  

List pages WikiPagesApiController#index

GET /api/v1/courses/:course_id/pages

GET /api/v1/groups/:group_id/pages

List the wiki pages associated with a course or group

Request Parameters:

  • sort
    optional

    Sort results by this field: one of 'title', 'created_at', or 'updated_at'

  • order
    optional

    The sorting order: 'asc' (default) or 'desc'

  • search_term

    (optional) The partial title of the pages to match and return.

Example Request:

curl -H 'Authorization: Bearer <token>' \ 
     https://<canvas>/api/v1/courses/123/pages?sort=title&order=asc
Returns a list of Pages

Show page WikiPagesApiController#show

GET /api/v1/courses/:course_id/pages/:url

GET /api/v1/groups/:group_id/pages/:url

GET /api/v1/courses/:course_id/front_page

GET /api/v1/groups/:group_id/front_page

Retrieve the content of a wiki page

Request Parameters:

  • url

    the unique identifier for a page.

Example Request:

curl -H 'Authorization: Bearer <token>' \ 
     https://<canvas>/api/v1/courses/123/pages/my-page-url

curl -H 'Authorization: Bearer <token>' \
     https://<canvas>/api/v1/courses/123/front_page
Returns a Page

Create page WikiPagesApiController#create

POST /api/v1/courses/:course_id/pages

POST /api/v1/groups/:group_id/pages

Create a new wiki page

Request Parameters:

  • wiki_page[title]

    the title for the new page.

  • wiki_page[body]

    the content for the new page.

  • wiki_page[hide_from_students]
    boolean

    whether the page should be hidden from students.

  • wiki_page[notify_of_update]
    boolean

    whether participants should be notified when this page changes.

  • wiki_page[published]
    optional
    boolean

    whether the page is published (true) or draft state (false).

  • wiki_page[front_page]
    optional
    boolean

    set an unhidden page as the front page (if true)

Example Request:

curl -X POST -H 'Authorization: Bearer <token>' \ 
https://<canvas>/api/v1/courses/123/pages?wiki_page[title]=New+page&wiki_page[body]=New+body+text
Returns a Page

Update page WikiPagesApiController#update

PUT /api/v1/courses/:course_id/pages/:url

PUT /api/v1/groups/:group_id/pages/:url

PUT /api/v1/courses/:course_id/front_page

PUT /api/v1/groups/:group_id/front_page

Update the title or contents of a wiki page

Request Parameters:

  • url

    the unique identifier for a page.

  • wiki_page[title]
    optional

    the new title for the page.

    NOTE: changing a page's title will change its url. The updated url will be returned in the result.

  • wiki_page[body]
    optional

    the new content for the page.

  • wiki_page[hide_from_students]
    optional

    boolean; whether the page should be hidden from students.

  • wiki_page[notify_of_update]
    optional
    boolean

    notify participants that the wiki page has been changed.

  • wiki_page[published]
    optional
    boolean

    whether the page is published (true) or draft state (false)

  • wiki_page[front_page]
    optional
    boolean

    set an unhidden page as the front page (if true), or un-set it (if false)

Example Request:

curl -X PUT -H 'Authorization: Bearer <token>' \ 
https://<canvas>/api/v1/courses/123/pages/the-page-url?wiki_page[body]=Updated+body+text

curl -X PUT -H 'Authorization: Bearer <token>' \
https://<canvas>/api/v1/courses/123/front_page?wiki_page[body]=Updated+body+text
Returns a Page

Delete page WikiPagesApiController#destroy

DELETE /api/v1/courses/:course_id/pages/:url

DELETE /api/v1/groups/:group_id/pages/:url

DELETE /api/v1/courses/:course_id/front_page

DELETE /api/v1/groups/:group_id/front_page

Delete a wiki page

Request Parameters:

  • url

    the unique identifier for a page.

Example Request:

curl -X DELETE -H 'Authorization: Bearer <token>' \ 
https://<canvas>/api/v1/courses/123/pages/the-page-url

curl -X DELETE -H 'Authorization: Bearer <token>' \
https://<canvas>/api/v1/courses/123/front_page
Returns a Page