Create new subscriber
Creates a new subscriber, providing basic information, fields and groups.
Endpoint
Section titled “Endpoint”HTTP method: POST
https://api.sender.net/v2/subscribers
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
email | string required | The value must be a valid email address. |
firstname | string | Subscriber firstname |
lastname | string | Subscriber lastname |
groups | array | Provide the new groups assigned to the subscriber, by inserting the group id separated by commas for more than one. |
fields | array | Provide an array formed by key - field name, value - field value. |
phone | string | Phone number must include the country code: +370 or 00370 follow by a valid phone number |
trigger_automation | boolean | This property by default its true. You ca send it as false if you want not to activate an automation. |
Request Examples
Section titled “Request Examples”const url = new URL("https://api.sender.net/v2/subscribers");
let headers = { "Authorization": "Bearer [your-token]", "Content-Type": "application/json", "Accept": "application/json",};
let bodyContent = { "firstname": "Sender", "lastname": "Support", "groups": ["eZVD4w", "b2vAR1"], "fields": {"{$test_text}":"Documentation example","{$test_num}": 8}, "phone": "+370XXXXXXXX", "trigger_automation": false};
fetch(url, { method: "POST", headers, body: JSON.stringify(bodyContent)}).then(response => response.json()).then(data => console.log(data)).catch(error => console.error('Error:', error));$client = new \GuzzleHttp\Client();
$json = [ "firstname" => "Sender", "lastname" => "Support", "groups" => ["eZVD4w", "b2vAR1"], "fields" => ['{$test_text}' =>"Documentation example",'{$test_num}' => 8], "phone" => "+370XXXXXXXX", "trigger_automation" => false];
$response = $client->post( 'https://api.sender.net/v2/subscribers', [ 'headers' => [ 'Authorization' => 'Bearer [your-token]', 'Content-Type' => 'application/json', 'Accept' => 'application/json', ], 'json' => $json ]);
$body = $response->getBody()->getContents();$data = json_decode($body, true);print_r($data);import requestsimport json
url = "https://api.sender.net/v2/subscribers"
headers = { "Authorization": "Bearer [your-token]", "Content-Type": "application/json", "Accept": "application/json",}
payload = { "firstname": "Sender", "lastname": "Support", "groups": ["eZVD4w", "b2vAR1"], "fields": {"{$test_text}":"Documentation example","{$test_num}": 8}, "phone": "+370XXXXXXXX", "trigger_automation": false}
response = requests.request('POST', url, headers=headers, json=payload)
print(response.json())curl -X POST \"https://api.sender.net/v2/subscribers" \-H "Authorization: Bearer [your-token]" \-H "Content-Type: application/json" \-H "Accept: application/json" \-d '{"email":"[email protected]","firstname":"Sender","lastname":"Support","groups":["eZVD4w", "b2vAR1"],"fields":{"{$test_text}":"Documentation example","{$test_num}": 8},"phone":"+370XXXXXXXX","trigger_automation":false}'Response
Section titled “Response”{ "success": true, "message": [], "data": { "id": "o2lk68Y", "firstname": "Sender", "lastname": "Support", "phone": "+370XXXXXXXX", "phone_country": { "phone_code": 370, "country_code": "LT" }, "created": "2021-04-08 11:06:34", "location": null, "status": { "email": "active", "temail": "active" }, "ip_address": null, "subscriber_tags": [ { "id": "eZVD4w", "title": "Test group" }, { "id": "b2vAR1", "title": "My Renamed Group" } ], "columns": [ { "id": "bDqoKd", "title": "test num", "type": "number", "default": true, "value": 1 }, { "id": "avAlVe", "title": "First name", "type": "text", "default": true, "value": "Support" }, { "id": "dwBVJb", "title": "Last name", "type": "text", "default": true, "value": "Sender" } ], "sms_campaign": { "sent_count": 0, "clicked_count": 0, "delivered_count": 0, "failed_count": 0, "unsubscribed_at": null, "unsubscribed": 0 }, "email_campaign": { "sent_count": 4, "opened_count": 0, "clicked_count": 0, "unsubscribed": 0, "bounced": 0, "spam_reported": 0 } }}