DKIM Overview
SocketLabs will sign outbound messages where the From address domain matches the domain of one of your DKIM entries.
To create a new DKIM entry, please provide the domain, selector, and private key. We will attempt to validate the private key that you provide against the public key for your domain and selector. If we are unable to validate the public key, an error message will be returned.
You can create your own private and public keys to use with this endpoint. If you would prefer to have SocketLabs generate the key pairs for you, we provide a Generate endpoint that will generate a public/private key pair for your provided domain and selector combination.
Options
DKIM entries can be set up by having SocketLabs generate a private and public key pair or by providing SocketLabs directly with the public/private key pair. The private key must exist on the domain you are setting up in order for it to pass validation.
Endpoint
https://api.socketlabs.com/v2/subaccount/:subaccountId/dkim
Path Variables
- subaccountId (number, required)
Generate a DKIM Key for a Subaccount
Attributes
Property Name | Data Type | Details |
domain | string | Domain or subdomain you want to set up for your DKIM entry |
selector | string | Selector for the DKIM record |
Example Request
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://api.socketlabs.com/v2/subaccount/12345/dkim/generate?domain=example.com&selector=dkim1");
request.Headers.Add("Authorization", "Bearer <token>");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Example Response
{
"data": {
"dnsHostName": "dkim1._domainkey.example.com",
"domain": "example.com",
"selector": "dkim1",
"dnsRecord": "\"v=DKIM1; k=rsa; p=abcdefghijklmnop1234567890",
"publicKey": "abcdefghijklmnop1234567890",
"privateKey": "abcdefghijklmnop1234567890"
}
}
Providing SocketLabs directly with a DKIM key pair
If the privateKey is not provided, we will generate a new public/private key pair for you. Otherwise, we will attempt to validate your private key against the public key for your domain.
Attributes
- domain (string) Domain or subdomain you want to set up for your DKIM entry
- privateKey (string)
- selector (string)
Example Request
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.socketlabs.com/v2/subaccount/12345/dkim");
request.Headers.Add("Authorization", "Bearer <token>");
var content = new StringContent("{\n \"domain\": \"example.com\",\n \"selector\": \"dkim\",\n \"privateKey\": \"abcdefghijklmnop1234567890\"\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Example Response
{
"data": {
"domain": "example.com",
"selector": "dkim",
"truncatedPrivateKey": "abcdefghijklmnop1234567890",
"recordType": "TXT",
"createdOn": "1964-07-03T01:28:32.192Z",
"updatedOn": "1958-04-15T17:44:52.185Z"
}
}
With the basics in place, you’ll move on to connecting your account to engagement tracking. This reporting will give you insight into how recipients are interacting with your mail.