Programmatically set env file? Per-student setup


Each of our students has their own set of credentials.

I’d like them to run and see code in Glitch, and then have the opportunity to remix it themselves.

Option 1 can be done now:

  1. Glitch project looks for the student’s credentials in either env variables or query parameters.
  2. My site runs the Glitch URL with the query parameters set for the student’s credentials.
  3. If the student wants to remix, they login/create account, remix, then set up an env file with their own credentials.

Works but step 3 is a bit involved.

Option 2 or better would be preferred:

  1. My site somehow (Glitch API?) creates an anonymous remix of the project and sets the env file to the student’s credentials.
  2. The student views the example as an anonymous Glitch user.
  3. If the student wants to remix, they simply save the project for themselves.


A goal is for the students to not need a Glitch account unless they want to remix.


You can populate env var values on remix from a URL, so if on your side you can add the credentials to the URL, then Option 2 should work - see


Excellent – so my project offers the remix button to the student (including the student’s credentials) rather than the student clicking the generic Remix button on your site.

Many thanks,


Or the process starts with a Remix from my site? Does a remix work for a then anonymous user?


Wherever you’re able to set the student’s credentials from. Yes, you don’t need to be logged-in to remix.


If you’re going to remix programmatically, it’s better to POST to<project-name>/remix. You can send a JSON body like:

  env: {
    var1: "value1",
    var2: "value2"

It will return

    domain: project.domain,
    inviteToken: project.invite_token,
    joinLink: joinLink

Set env when remixing from API

Thanks Tom.

Do I then use the joinLink to open the new remix for the anonymous or logged in user?

Any immediate need for the id, domain, or inviteToken?

Also, when using the remix url with env settings via the url – eg “!/remix/project-name?ACCESS_TOKEN=eyJ0eXAiOid2c2e&USER_FULLNAME=Larry%20Kluger&

I noticed a possible bug: The USER_FULLNAME line in the created env file is


This results in an error since the env file should be

USER_FULLNAME="Larry Kluger"

Thanks again for your help and time.


You would give the joinLink to the user who is going to own the new project - anyone using that link becomes a member of the project. You might want to use the domain for something - that’s the name of the new project.

I think you can probably add the quotes to the URL (either directly or maybe URL encoded), and they will be added to .env. If not, let me know and we’ll fix that.


I tried the API call, but received a response body of Error remixing project. I tried twice.

Response header date: “Wed, 26 Sep 2018 18:15:11 GMT”
Response status: 200. (Not expected since the request didn’t succeed.)

request body:

    "env": {
        "ACCESS_TOKEN": "eyJ0eXAiOiJNVCIsImFsZyI6IlJTMjU2xxxxxxxx...xxxx",
        "ACCOUNT_ID": "b124a74b-faa8-46f7-a55e-9xxxxxxxx",
        "USER_FULLNAME": "Larry Kluger",
        "USER_EMAIL": ""


Using " around the environment variables sent via query parameters worked.


You may want to update your page