View Source Stytch
An Elixir API client for Stytch
installation
Installation
The package can be installed by adding stytch
to your list of
dependencies in mix.exs
:
def deps do
[
{:stytch, "~> 0.1.0"}
]
end
configuration
Configuration
To make API calls you need to configure your Stytch project_id
and secret
.
If you set the STYTCH_PROJECT_ID
and STYTCH_SECRET
environment variables
then they will be used.
You can also override the configuration in your application config:
config :stytch,
project_id: "my-project-id",
secret: "my-secret"
The default endpoint for API requests is https://test.stytch.com/v1 and in
prod environments is https://api.stytch.com/v1 but these can be
overridden by the STYTCH_ENDPOINT
environment variable or :endpoint
config option.
documentation
Documentation
The package docs can be found at https://hexdocs.pm/stytch.
The full Stytch API documentation can be found at https://stytch.com/docs/api.
examples
Examples
These examples use sandbox values provided by Stytch so will return a valid response but won't actually send anything.
magic-links
Magic Links
Stytch.send_magic_link("sandbox@stytch.com")
Stytch.authenticate_with_magic_link("DOYoip3rvIMMW5lgItikFK-Ak1CfMsgjuiCyI7uuU94=")
one-time-passcodes-otp
One-time Passcodes (OTP)
Stytch.send_otp_by_sms("+10000000000")
sessions
Sessions
Stytch.authenticate_session("WJtR5BCy38Szd5AfoDpf0iqFKEt4EE5JhjlWUY7l3FtY")
time-based-one-time-passcodes-totp
Time-based one-time passcodes (TOTP)
Stytch.create_totp("user-test-e3795c81-f849-4167-bfda-e4a6e9c280fd")