Surge is the easiest SMS API for developers. We write all of our code in Elixir, and we're proud to maintain a first party client for Elixir.
Add surge to your list of dependencies in mix.exs:
defdepsdo[{:surge_api,"~> 0.2.0"}]endThen run:
mix deps.getConfigure your Surge API credentials in your application configuration:
# config/config.exsconfig:surge_api,api_key: System.get_env("SURGE_API_KEY"),base_url: System.get_env("SURGE_API_URL","https://api.surge.app")The SDK will automatically use your configured API key:
# Send a message{:ok,message}=Surge.Messages.create(account.id,%{from: "+15551234567",to: "+15559876543",body: "Hello from Surge!"})You can create a client to use specific credentials, base URL, or other options:
client=Surge.Client.new("sk_test_your_api_key")# Use the client for API calls{:ok,account}=Surge.Accounts.create(client,%{name: "Test Account"})All API calls return either {:ok, result} or {:error, error}:
caseSurge.Messages.create("acct_123",params)do{:ok,message}->IO.puts("Message sent: #{message.id}"){:error,%Surge.Error{}=error}->IO.puts("Error: #{error.message}")IO.puts("Error type: #{error.type}")IO.puts("Error details: #{inspect(error.detail)}")endYou can pass custom options to the underlying HTTP client:
client=Surge.Client.new("api_key",req_options: [timeout: 30_000,retry: :transient])For testing or using a different Surge environment:
client=Surge.Client.new("api_key",base_url: "https://staging.surge.app")Generate the documentation locally:
mix docs
open doc/index.html- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This SDK is distributed under the MIT license. See LICENSE for more information.
For questions and support:
- Email: support@surge.app
- Documentation: https://docs.surge.app
- API Status: https://status.surge.app