Overview
The Cloud Outbound Mailer API is provided in the RESTful format. It is done through the HTTP method GET/POST/DELETE method call.
You can configure and manage your address book via the API, request email delivery, check request results, and view delivery history.
Common settings
Cloud Outbound Mailer API Endpoint
| Region | Endpoint |
|---|---|
| Korea (KR) | https://mail.apigw.ntruss.com/api/v1 |
| Singapore (SGN) | https://mail.apigw.ntruss.com/api/v1-sgn/ |
| Japan (JPN) | https://mail.apigw.ntruss.com/api/v1-jpn/ |
Request headers
| Header name | Description |
|---|---|
| x-ncp-apigw-timestamp | It indicates the time elapsed since January 1, 1970 00:00:00 UTC in milliseconds, and request is considered invalid if the timestamp differs from the current time by more than 5 minutes.x-ncp-apigw-timestamp:{Timestamp} |
| x-ncp-iam-access-key | Access key ID value issued from the NAVER Cloud Platform portalx-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 APIs are provided through the NAVER Cloud Platform API Gateway. To use APIs registered with the API Gateway, you must obtain two authentication keys (access key ID and secret key).
For more information, see NAVER Cloud Platform API guide.
- Create authentication key.
- Create access key ID and secret key by referring to Ncloud API.
- If you have an access key ID and secret key, use them.
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":"Chulsoo","BEFORE_GRADE":"BRONZE","AFTER_GRADE":"SILVER"}}],"individual":true,"advertising":false}'
-
Create a signature (add a new line with
\n)- Create StringToSign matching the request, encrypt using SecretKey with HmacSHA256 algorithm, and encode using 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.getEncoder().encodeToString(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 responses
It is returned as an HTTP status code and delivered as body information.
| HTTP Status Code | Return code | Description |
|---|---|---|
| 200 | - | General request made successfully |
| 201 | - | Response code related to the success of resource creation |
| 400 | 77101 | Error in login information |
| 400 | 77102 | BAD_REQUEST |
| 400 | 77103 | Resource not found |
| 403 | 77201 | Unauthorized |
| 403 | 77202 | No subscription |
| 405 | 77001 | METHOD_NOT_ALLOWED |
| 415 | 77002 | UNSUPPORTED_MEDIA_TYPE |
| 500 | 77301 | Default project does not exist |
| 500 | 77302 | External system API integration error |
| 500 | 77303 | Other internal server error |
Operations
Send Email
- createMailRequest
- getMail
- getMailList
- getMailRequestList
- getMailRequestStatus
- createFile
- getFile
- deleteFile
Template management
- createTemplate
- createTemplateExportRequest
- getTemplate
- getTemplateExportRequestList
- getTemplateStructure
- updateTemplate
- exportTemplate
- importTemplate
- deleteTemplate
- restoreTemplate
- createCategory
- deleteCategory
Manage recipient groups
- createAddressBook
- getAddressBook
- deleteAddressBook
- deleteAddress
- deleteRecipientGroup
- deleteRecipientGroupRelation
- deleteRecipientGroupRelationEmpty