Method 3) SuperTokens SMS service
Using this method, SuperTokens will send SMSs to your users automatically. Use this method if:
- You are already using our managed service - this is the quickest way to setup SMS sending.
- You want to take advantage of some of the SMS sending optimisations we add over time:
- Reduce SMS cost by picking a local SMS service based on the destination country.
- Fight spam / misuse of SMS.
important
This is a paid service and we charge for every SMS based on the cost we incur. We give new users $10 worth of credits.
#
1) Get the SMS API key- Sign up on supertokens.com
- Create a new development env
- Scroll down and create a new production env (it takes a few minutes to create one)
- Once the production env is created, you can find your SMS API key under the setup section:
#
2) Set the SMS API key in the backend SDK config- NodeJS
- GoLang
- Python
- Other Frameworks
Important
For other backend frameworks, you can follow our guide on how to spin up a separate server configured with the SuperTokens backend SDK to authenticate requests and issue session tokens.
import supertokens from "supertokens-node";
import Passwordless from "supertokens-node/recipe/passwordless";
import Session from "supertokens-node/recipe/session";
import { SupertokensService } from "supertokens-node/recipe/passwordless/smsdelivery"
supertokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
Passwordless.init({
smsDelivery: {
service: new SupertokensService("<SMS API KEY GOES HERE>")
},
}),
Session.init()
]
});
import (
"github.com/supertokens/supertokens-golang/ingredients/smsdelivery"
"github.com/supertokens/supertokens-golang/recipe/passwordless"
"github.com/supertokens/supertokens-golang/recipe/passwordless/plessmodels"
"github.com/supertokens/supertokens-golang/supertokens"
)
func main() {
supertokens.Init(supertokens.TypeInput{
RecipeList: []supertokens.Recipe{
passwordless.Init(plessmodels.TypeInput{
SmsDelivery: &smsdelivery.TypeInput{
Service: passwordless.MakeSupertokensSMSService("<SMS API KEY GOES HERE>"),
},
}),
},
})
}
from supertokens_python import init, InputAppInfo
from supertokens_python.recipe import passwordless
from supertokens_python.ingredients.smsdelivery.types import SMSDeliveryConfig
init(
app_info=InputAppInfo(
api_domain="...", app_name="...", website_domain="..."),
framework='...',
recipe_list=[
passwordless.init(
sms_delivery=SMSDeliveryConfig(
service=passwordless.SuperTokensSMSService("<SMS API KEY GOES HERE>"))
)
]
)