createMailRequest
- Print
- PDF
createMailRequest
- Print
- PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
Available in Classic and VPC
Request an email to be sent, specifying the recipient, sender, mail content, etc. The mailing operation is processed asynchronously.Note
- You can send up to 100,000 recipients at a time, and it is processed in batches of 30 by default. However, you can send more than 100,000 recipients when you enter the recipient group combination sending condition (
recipientGroupFilter
). - You can specify up to 30 recipients for Cc and Bcc.
- Email bodies are allowed to be up to 500 KB.
- The default sending limit is 1,000,000 per month, but you can request an increase through Support.
- The sending request limit is calculated based on the number of email recipients. A send request for 100 recipients is considered 100 send requests.
Request
The following describes the request format for the endpoint. The request format is as follows:
Method | URI |
---|---|
POST | /mails |
Request headers
For headers common to Cloud Outbound Mailer APIs, see Cloud Outbound Mailer request headers.
Request body
The following describes the request body.
Field | Type | Required | Description |
---|---|---|---|
senderAddress | String | Conditional | Sender's email address
|
senderName | String | Optional | Sender's name (byte)
|
templateSid | Integer | Optional | SID of the template you want to use to create the email
|
title | String | Conditional | Email subject (byte)
|
body | String | Conditional | Email body (KB)
|
individual | Boolean | Optional | Whether to send generally or by individual
|
confirmAndSend | Boolean | Optional | Whether to send after confirmation
|
advertising | Boolean | Optional | Whether it is advertising email
|
parameters | Object | Optional | Substitution parameter
|
referencesHeader | String | Optional | References header
|
reservationUtc | Long | Optional | Reserved delivery date and time
|
reservationDateTime | String | Optional | Reserved delivery date and time (yyyy-MM-dd HH:mm)
|
attachFileIds | List<String> | Optional | ID list of attachments
|
recipients | List<RecipientForRequest> | Conditional | Recipient list
|
recipientGroupFilter | RecipientGroupFilter | Optional | Recipient group combination filter |
useBasicUnsubscribeMsg | Boolean | Optional | Whether to use unsubscribe messages in advertising email
|
unsubscribeMessage | String | Conditional | Custom unsubscribe message text
|
Request example
The following is a sample request.
Create without template
The following is a sample request for writing your own email content without using a template.
curl --location --request POST 'https://mail.apigw.ntruss.com/api/v1/mails'
--header 'x-ncp-apigw-timestamp: {Timestamp}'
--header 'x-ncp-iam-access-key: {Access Key}'
--header 'x-ncp-apigw-signature-v2: {API Gateway Signature}'
--header 'Content-Type: application/json'
--data-raw '{"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 with template
The following is a sample request for writing your own email content using a template.
curl --location --request POST 'https://mail.apigw.ntruss.com/api/v1/mails'
--header 'x-ncp-apigw-timestamp: {Timestamp}'
--header 'x-ncp-iam-access-key: {Access Key}'
--header 'x-ncp-apigw-signature-v2: {API Gateway Signature}'
--header 'Content-Type: application/json'
--data-raw '{"templateSid" : 1,"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}'
Response
The following describes the response format.
Response body
The following describes the response body.
Field | Type | Required | Description |
---|---|---|---|
requestId | String | Required | Email delivery request ID to distinguish each request
|
count | Integer | Required | Number of mailing requests |
Response status codes
The following describes the response status codes.
HTTP status code | Code | Description |
---|---|---|
201 | - | Request succeeded |
400 | - | Authentication failed, invalid request |
400 | 77101 | Error in login information |
400 | 77102 | Request error |
400 | 77103 | Requested resource does not exist |
403 | 77201 | No permissions to the requested resource |
403 | 77202 | Call from a user who hasn't subscribed to the email service |
405 | 77001 | Unsupported method type |
415 | 77002 | Unsupported media type |
500 | - | Server error |
500 | 77301 | Default project does not exist |
500 | 77302 | External system API integration error |
500 | 77303 | Other internal server error |
Response example
The following is a sample response.
{
"requestId":"20181203000000000201",
"count":10000
}
Was this article helpful?