Cloud Outbound Mailer Overview
-
Print
-
PDF
Cloud Outbound Mailer Overview
-
Print
-
PDF
Summary
The Cloud Outbound Mailer API is provided in RESTful form. It is done through the HTTP method GET/POST/DELETE method call.
With this API, you can configure and manage address books, make a request to send emails and check results, and view logs of sending emails.
Common settings
Cloud Outbound Mailer API URL
GET/POST/DELETE
https://mail.apigw.ntruss.com/api/v1
Request headers
Header | Description |
---|---|
x-ncp-apigw-timestamp | This is the time elapsed since January 1, 1970 00:00:00 UTC in milliseconds. If the time differs from that of the API Gateway server by 5 minutes or more, then the request is considered invalid. x-ncp-apigw-timestamp:{Timestamp} |
x-ncp-iam-access-key | This is the Access Key ID value issued by the Naver Cloud Platform portal.x-ncp-iam-access-key:{Account Access Key} |
x-ncp-apigw-signature-v2 | This is the signature encrypted Access Key ID value and Secret Key.x-ncp-apigw-signature-v2:{API Gateway Signature} |
x-ncp-lang | A value to handle API response value in multiple languages. (Example of input values: ko-KR, en-US, and zh-CN / Default: en-US)x-ncp-lang:{language code} |
Authentication header
The Cloud Outbound Mailer API is provided via Naver Cloud Platform’s API Gateway, which requires you to get two authentication keys (Access Key ID and Secret Key).
For more information, refer to Naver Cloud Platform API Guide.
- Create authentication key
- Go to My Page > Manage Account > Manage Authentication Key on the Naver Cloud Platform portal, and then click Create a new API authentication key to create an Access Key ID and Secret Key
- You can use your existing Access Key ID and Secret Key.
Request example
curl -i -s -X POST \
-H "Content-Type:application/json" \
-H "x-ncp-apigw-timestamp:1521787414578" \
-H "x-ncp-iam-access-key:6uxz1nKkcYwUjWRG5Q1V7NsW0i5jErlu2NjBXXgy" \
-H "x-ncp-apigw-signature-v2:iJFK773KH0WwQ79PasqJ+ZGixtpDQ/abS57WGQdld2M=" \
"https://mail.apigw.ntruss.com/api/v1/mails"\
-d '{"senderAddress":"no_reply@company.com","title":"Hello, ${customer_name}. ","body":"Your grade has been changed from ${BEFORE_GRADE} to ${AFTER_GRADE}.","recipients":[{"address":"hongildong@naver_.com","name":"Gildong Hong","type":"R","parameters":{"customer_name":"Gildong Hong","BEFORE_GRADE":"SILVER","AFTER_GRADE":"GOLD"}},{"address":"chulsoo@daum_.net","name":null,"type":"R","parameters":{"customer_name":"Cheolsu","BEFORE_GRADE":"BRONZE","AFTER_GRADE":"SILVER"}}],"individual":true,"advertising":false}'
-
Create a signature (Add a new line with
\n
.)- Create a StringToSign appropriate for your request, encrypt it with your secret key and the HMACSHA256 algorithm, and encode it with Base64.
- This value is used as
x-ncp-apigw-signature-v2
.
-
Sample code
public String makeSignature() {
String space = " "; // Space
String newLine = "\n"; // Line break
String method = "POST"; // HTTP method
String url = "/api/v1/mails"; // Full URL under "/" (including query strings), excluding the domain
String timestamp = "{timestamp}"; // Current timestamp (epoch, millisecond)
String accessKey = "{accessKey}"; // access key id (from portal or Sub Account)
String secretKey = "{secretKey}"; // secret key (from portal or Sub Account)
String message = new StringBuilder()
.append(method)
.append(space)
.append(url)
.append(newLine)
.append(timestamp)
.append(newLine)
.append(accessKey)
.toString();
SecretKeySpec signingKey = new SecretKeySpec(secretKey.getBytes("UTF-8"), "HmacSHA256");
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(signingKey);
byte[] rawHmac = mac.doFinal(message.getBytes("UTF-8"));
String encodeBase64String = Base64.encodeBase64String(rawHmac);
return encodeBase64String;
}
function makeSignature() {
$space = " "; // Space
$newLine = "\n"; // Line break
$method = "POST"; // HTTP method
$uri= "/api/v1/mails"; // Full URL under "/" (including query strings), excluding the domain
$timestamp = "{timestamp}"; // Current timestamp (epoch, millisecond)
$accessKey = "{accessKey}"; // access key id (from portal or Sub Account)
$secretKey = "{secretKey}"; // secret key (from portal or Sub Account)
$hmac = $method.$space.$uri.$newLine.$timestamp.$newLine.$accessKey;
$signautue = base64_encode(hash_hmac('sha256', $hmac, $secretKey,true));
return $signautue;
}
Common response
Returned as HTTP status code in the response body.
HTTP Status Code | Return code | Description |
---|---|---|
200 | - | Success for usual requests |
201 | - | Resource successfully created |
400 | 77101 | Error in login information |
400 | 77102 | BAD_REQUEST |
400 | 77103 | Resource not found |
403 | 77201 | No permission |
403 | 77202 | No request to subscribe the email product |
405 | 77001 | METHOD_NOT_ALLOWED |
415 | 77002 | UNSUPPORTED_MEDIA_TYPE |
500 | 77301 | Default project not found |
500 | 77302 | Error in working with external system API |
500 | 77303 | Other INTERNAL_SERVER_ERROR |
Operations
Send emails
Manage recipient groups
- createAddressBook
- getAddressBook
- deleteAddressBook
- deleteAddress
- deleteRecipientGroup
- deleteRecipientGroupRelation
- deleteRecipientGroupRelationEmpty
Manage template
- createCategory
- createTemplate
- createTemplateExportRequest
- deleteCategory
- deleteTemplate
- exportTemplate
- getTemplate
- getTemplateExportRequestList
- getTemplateStructure
- importTemplate
- updateCategory
- updateTemplate
- updateTemplateLocationOrName
- restoreTemplate
Manage project config
Manage send block list and unsubscribers
Manage file
Was this article helpful?