Showing results for 
Search instead for 
Did you mean: 

Create a Sandbox Course via Web Application/API?

Jump to solution

Hi Canvas gurus,

I've got a bit of a dreamscape project that I'm looking to build and am wondering if anyone has done anything similar or is able to help me think through how to best develop it. What I'm wanting to build is a webpage on our university's site that would allow a faculty member to create a sandbox course on their own as opposed to emailing our team to do it for them. 

The simplest way to achieve this would be to enable faculty to create courses within Canvas, however, I'd like to make a more controlled process that automatically adds the course to the correct subaccount, and also has a prefix appended to the reference ID.

So here's the ideal solution: a webpage where a faculty member signs in, they click a "Create Sandbox Course" button that asks what they'd like the name of the course to be, and then that course gets created and with them enrolled as the instructor. Any ideas of how to achieve this or is this too simplistic in the reality of what needs to happen?

I appreciate any and all recommendations.

- Michael

1 Solution

Accepted Solutions

Hi Michael,

I'd be happy to help you get setup.

Check out the README for more details ccsd-canvas/workrooms at master · robert-carroll/ccsd-canvas · GitHub 

Specifically, skipping over the Implementation & Deployment section, which is part of our SIS Import and is there as a more complete solution.

And get right to Configuration

cfg: {
     // the ID of the subaccount where all workrooms should be put
     wkrm_acct_id: 123456,
     // the ID of the term that all workrooms should be created with (Forever)
     term_id: 1234,
     // the roles allowed to create a workroom
     roles: ['teacher']

The wkrm_acct_id is the account id of a sub account within your instance, this basically makes a 'folder' for all your user created workrooms to go into, so they don't clutter your other spaces. Create the sub account in the root of your instance, or anywhere you like... this is what our Root Sub Accounts look like.

Workrooms is in our root, but at the bottom alphabetically.

The term_id of the Forever Term, I believe each instance has one, you'll just have to identify what yours is. The Live API can help here: > Enrollment Terms > List Enrollment Terms

I've created a Github Gist for you, which has all the utility functions and the workroom code setup inline for you. All you'd have to do is set those 2 values and append it to your current theme-able JavaScript file. gist example for canvas workrooms · GitHub 

Once that works for you on your test instance, I'd recommend compressing the file down for production with something like or

From the README, the Additional Considerations and workroom.enroll() options can be addressed later.

View solution in original post

54 Replies
Learner II

Your ideal solution is pretty much enough of a description for someone to do this with the API.  Its very straightforward and I think only two API calls.

You might want other features like having the webpage show their current sandbox course(s) and/or only allowing a certain number.  And maybe letting them choose some settings etc.  But these are all just extras.

Limiting the number of courses that are able to be created would be a great addition to this. I could see faculty getting trigger happy with it Smiley Happy

I had actually been curious about this since you posted the trigger happy comment. I had even started a Canvas Data view to collect Workrooms and Enrollments. I was reminded of that today... and finished my stats.

40,400+ employees

9,905 have logged in this school year

51,123 workrooms where course_state is claimed or available

2,338 users have created a course with the Workroom Button

465 of those users have created 2 or more workrooms, mostly by our course designers and folks in curriculum development

170 users have created more than 1 workroom in a day

      30 of them did so on more than 1 occasion (between 2 in a day and 6 in a day)

   171 created 2

     28 created 3

       9 created 4

       1 created 5

       7 created 6

       3 created 7

       1 created 10

That's less than 2% of active employees (9,905) that have pressed the button multiple times in a day.

Maybe next week I'll check on activity in those workrooms.

Now I can back up my statement that providing this button won't make faculty click happy.

We also purge unused courses before Fall Term.


We do this directly in Canvas with a bit of JavaScript. Every employee has a Workroom generated during SIS Import, and we also allow employees to create a new one on the /courses page. It's a great way to increase adoption, when teachers don't have to depend on their SIS Course to learn the ropes.



We feed the API with some user info and place them all in a Workrooms Sub Account. We used to limit the number of workrooms they could create to 1 per day by seeding today's date, but now we seed the timestamp, or they can name it, as you see above. Staff don't typically get carried away, they either create 1 additional Workroom at a time or they want to create 8 today and start playing around with all their courses.

We also do a cleanup in summer and purge any unused courses throughout the instance with the API and Unused Courses Report, so if they create them and never get around to using them it's not much of a problem. For 40,000 employees. :smileycool:

If you're interested, I can work on sharing this later today, although probably best to say next week. I'm currently tinkering with another idea I want to get out the door.

Edit: ccsd-canvas/workrooms at master · robert-carroll/ccsd-canvas · GitHub 

This seems like it'd work perfectly for what I'm looking to do. Does it rely on having any permissions being set? For instance the permission that allows instructors to create classes? Because we have that option off. If we could do this as an exception to that rule and only allow them to create a sandbox course, or workroom in your instance, then perfect! 

If you're willing to share I'd be EXTREMELY grateful Smiley Happy

Hi Michael,

I'm working on making this available. The code that makes this work was written by a previous dev here, this is my first time reviewing it, and I want to evaluate it before passing it around. I'm finding there a specific issue I recently noticed working on another project within this solution.

Specifically, that retrieving the sis user id from the API /api/v1/users/self isn't possible unless the user is an ADMIN... which if I find is true, is unfortunate and also a waste of code. Not sure if this changed since it was originally written. I don't want to share anything that requires more documentation or maintenance than necessary, so I ask for a little patience while I work this out.

Thank You

EDIT: Found the answer... Users - Canvas LMS REST API Documentation 


SIS ID for the user's account. To set this parameter, the caller must be able to manage SIS permissions.


The thread Retrieving Own SIS ID from Users API Call As Teacher, addresses the issue with a solution, formulated by  @aleonard , who has since left our department Smiley Sad via promotion. :smileygrin:

I will be posting soon, with some refactored code for ease of 'configuration' and some explanation for deployment suggestions.

Thanks again, so much for this  @carrollrw ‌! No real rush on it. I'm just appreciative you're willing to share.


Hi Michael,

I believe this should work for you, details in the readme.

ccsd-canvas/workrooms at master · robert-carroll/ccsd-canvas · GitHub

edit: Please let me know if you have any questions.

Community Team
Community Team

 @michael_mcgarry ‌, I saw two developers demonstrate a micro LTI for this at InstructureCon 2016's Hack Night. While I've never used this myself, I think it suits your purposes: It places a button on instructors' dashboard that allows them to create a new course, automatically enrolls them in that course, and populates the sub-account of your choice with that course. Here's the link to their page on GitHub: GitHub - CUOnline/sandbox: LTI tool that generates sandbox courses in Canvas