SMTP

The SocketLabs API can be used for getting and updating SMTP credentials for a subaccount

Endpoint

https://api.socketlabs.com/v2/subaccount/:subaccountId/credentials/smtp

Path Variables

  • subaccountId (number, required)

Get SMTP Credentials for a Subaccount

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://api.socketlabs.com/v2/subaccount/12345/credentials/smtp");
request.Headers.Add("Authorization", "Bearer <token>");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

Example Response

{
    "data": {
        "username": "server12345",
        "password": "abcdefghijklmnopqrstuvwxyz",
        "gateway": "smtp-cx.socketlabs.com"
    }
}

Update SMTP Password for the Subaccount

Example Request

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Put, "https://api.socketlabs.com/v2/subaccount/12345/credentials/smtp");
request.Headers.Add("Authorization", "Bearer <token>");
var content = new StringContent("{\n  \"password\": \"ad minim ut\"\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

Example Response

{
    "data": {
        "username": "server12345",
        "password": "abcdefghijklmnopqrstuvwxyz",
        "gateway": "smtp-cx.socketlabs.com"
    }
}

Now that you've sent mail, let's review Account Level Event Webhooks

Other Resources