Deploy API on your server 💻
To deploy our API on your server you only need to create a .env
file and fill it with your secret phrase to allow for token autentification. This file should be located in the root folder. You can also set request limits in that file.
NOTES before you begin
⚠️ Latest version of API migrated to Prisma, so to connect to the database, only the database_url parameter is needed.
⚠️ Since migration to Prisma, POSTGRESQL is no longer the only database that works. However provider needs to be replaced in prisma.schema file.
⚠️ Make sure to also test every form before deploying to ensure everything is configured correctly.
.env file
The example file should look like this:
RATE_LIMIT_TTL_SEC=60
RATE_LIMIT_REQ_COUNT_PUBLIC=20
RATE_LIMIT_REQ_COUNT_AUTH=100
JWT_SECRET_KEY=YourSecretPhrase
RECAPTCHA_SECRET_KEY=YourRecaptchaSecretKey
PORT=YourHTTPServerPort
DATABASE_URL="yourDbUrl"
EMAIL_ADDRESS_SENDER=sender@gmail.com
EMAIL_ADDRESS_RECIPIENT_ARR=admin1@gmail.com,admin2@gmail.com
EMAIL_CLIENT_ID=YourClientId
EMAIL_CLIENT_SECRET=YourClientSecret
EMAIL_REDIRECT_URI=YourRedirectUri
EMAIL_REFRESH_TOKEN=YourClientRefreshToken
MIXPANEL_PROJECT_TOKEN=YourMixPanelToken
SENTRY_DSN=YourSentryToken
What each line in the file means (every line must be configured otherwise API won't start):
RATE_LIMIT_TTL_SEC
: Line specifies how much time is allowed to pass before the request counter is reset.RATE_LIMIT_REQ_COUNT_PUBLIC
: Line specifies users without token authentification and how many requests they are allowed to do per specified time.RATE_LIMIT_REQ_COUNT_AUTH
: Line specifies users with token authentification and how many requests they are allowed to do per specified time.JWT_SECRET_KEY
: Key, that has to be set before the server is launched. Secret from which all tokens are hash-derived.RECAPTCHA_SECRET_KEY
: Secret key for your ReCaptcha. A guide on how it can be obtained can be found here. Make sure to select reCAPTCHA v3 when generating new key.PORT
: Specifies the port on which the API server will be running. This parameter is optional and if now added API will default to port 3001.DATABASE_URL
: Specifies your database connection url. More info on how to create it here.EMAIL_ADDRESS_SENDER
: Specifies the email address that will send responses to filled forms.EMAIL_ADDRESS_RECIPIENT_ARR
: Specifies the email address that will receive responses from filled forms. There can be multiple emails set and you can observe in the example above how to insert them.EMAIL_CLIENT_ID
: These are required for nodemailer find out more in this tutorial.EMAIL_CLIENT_SECRET
: These are required for nodemailer find out more in this tutorial.EMAIL_REDIRECT_URI
: These are required for nodemailer find out more in this tutorial.EMAIL_REFRESH_TOKEN
: These are required for nodemailer find out more in this tutorial.MIXPANEL_PROJECT_TOKEN
: This token is for statistics that track requests (Not saving amounts and wallet addresses to keep the privacy of users intact). This parameter is optional.SENTRY_DSN
: This token is for sentry - statistics tool that tracks errors produced by API to create easier debugging for developers. This parameter is optional.
If you have configured everything correctly, you should receive emails similar to the one showcased below. These should be received at the email addresses you specified in the EMAIL_ADDRESS_RECIPIENT_ARR
configuration line.

Based on the UserID received in the email can edit the maximum request amount for a specific API key. NOTE: Database overrides maximum request count. If the value is left on null
, the user can generate a default of 100 requests per minute just like before, as a Captcha-verified user.

Setting up Sentry
Recently, LightSpell introduced the Sentry error tracking service implementation. This guide covers how to use it.
- First step is to register at this website.
- Create a new project to get the DSN token for the .env file used by LightSpell

- Monitor your issues through the dashboard. If you receive any unhandled issues, you should be notified by email also
How to trigger Sentry test error
Open your REST API client, client we use is Insomnia.
Paste in the following details and input the following link to test out Sentry: http://localhost:3001/v3/sentry-test
LightSpell has integrated this test for you so you can test out error 500 in localhost mode. Once you paste the link into the browser, Sentry should notify you about a new error 500. It should look like this in your project:
You can see that the exact line where the error was triggered is shown, and you can even try to ask AI for help with resolving the task for you.
This confirms that the sentry is working correctly.