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
import supertokens from "supertokens-node";
import ThirdPartyPasswordless from "supertokens-node/recipe/thirdpartypasswordless";
import Session from "supertokens-node/recipe/session";
import { SupertokensService } from "supertokens-node/recipe/thirdpartypasswordless/smsdelivery"
supertokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
ThirdPartyPasswordless.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/thirdpartypasswordless"
"github.com/supertokens/supertokens-golang/recipe/thirdpartypasswordless/tplmodels"
"github.com/supertokens/supertokens-golang/supertokens"
)
func main() {
supertokens.Init(supertokens.TypeInput{
RecipeList: []supertokens.Recipe{
thirdpartypasswordless.Init(tplmodels.TypeInput{
SmsDelivery: &smsdelivery.TypeInput{
Service: thirdpartypasswordless.MakeSupertokensSMSService("<SMS API KEY GOES HERE>"),
},
}),
},
})
}
from supertokens_python import init, InputAppInfo
from supertokens_python.recipe import thirdpartypasswordless
from supertokens_python.ingredients.smsdelivery.types import SMSDeliveryConfig
init(
app_info=InputAppInfo(
api_domain="...", app_name="...", website_domain="..."),
framework='...',
recipe_list=[
thirdpartypasswordless.init(
sms_delivery=SMSDeliveryConfig(
service=thirdpartypasswordless.SuperTokensSMSService("<SMS API KEY GOES HERE>"))
)
]
)