Curl command to push a new subscriber to your sendy
I wanted to figure out how to push a new subscriber to a sendy list from a shell script. Taking a look at the PHP examples it is pretty easy to figure out how to do it with curl. Here's what it would look like:
curl -X "POST" "https://yoursendy.com/subscribe" \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "api_key=123YourAPIKeyFromSettings123" \
--data-urlencode "boolean=true" \
--data-urlencode "silent=true" \
--data-urlencode "name=Joe Bloggs" \
--data-urlencode "email=joe.bloggs+test202007001@gmail.com" \
--data-urlencode "list=ABC123TheListId" \
--data-urlencode "CustomField=Blahblah123"
Replace the api_key and list id with your own. Note a couple of things:
- It needs to be a POST request
- The header needs to be set to "Content-Type: application/x-www-form-urlencoded"
- The key=value pairs go in the "body" of your request because they are mimicking form fields. It doesn't work if you send them as URL params
- The list id you can get from the list of lists in the UI
- If it succeeds it just returns a "1" not some json
This discussion has been closed.