Ruby Example

ⓘ This example is purely and solely for example purposes and is by no mean production ready. If you have written a library based on our API please keep in touch.

Find below an example of using Ruby to subscribe an email address.

require 'net/http'
require 'uri'

# Set variables
uuid = "YOUR_LIST_UUID"
base_url = "https://maitreapp.co/api/v2/lists/#{uuid}/subscribers"
payload = {
 api_token: "YOUR_API_TOKEN",
 hosting_url: "YOUR_HOSTING_URL",
 email: "john.doe@email.com"
}

# Send the request
response = Net::HTTP.post_form(URI(base_url), payload)

# Access data and create your logic
if response["status"] == "ok"
 # Email successful subscribed
else
 # Error
end

Still need help? Contact Us Contact Us