Message API reference
Overview
Message Hub provided by Samsung Cloud Platform can send messages through Email, SMS, and Mobile Application Push Notification channels.
This guide provides an explanation of the Message Hub message transmission API and how to invoke it.
Reference
- Before calling the message sending API, you must first add the resources (Email, phone number, Push Application) to be used for sending in the Console and complete authentication. * Refer to the Message Hub How-to guides for how to add resources.
- The monthly outbound count for each channel is limited to 10,000 SMS, 100,000 Email, and 1,000,000 Push. * To increase the outbound limit count, please proceed through Support Center > Service Request.
Message Hub Call Procedure
The Message Hub API URL must be adjusted based on the operating environment and region, and is categorized as a Public URL or Private URL depending on the call scope. Please check the operating environment and Region information in the table below.
Reference
- Public URL: Used when calling the Message Hub from the internet segment.
- Private URL: Used when calling the Message Hub via a Private Endpoint from resources inside the VPC. * If a Private Endpoint call is not allowed, a 400 AccessDeniedException error occurs.
- The call examples in this guide are based on the Public URL. * When calling from the Private segment, you only need to change the URL to the Private URL, while the request headers and body remain the same.
Calling the API
AUTH PARAMS
X-Scp-Access-Key : 삼성 클라우드 플랫폼 포털에서 발급받은 Access Key
X-Scp-Signature : 호출 API 요청을 Access Key와 매핑되는 Access Secret Key로 암호화한 서명. HMAC 암호화 알고리즘은 HmacSHA256 사용
X-Scp-Timestamp : 1970년 1월 1일 00:00:00 협정 세계시(UTC)부터의 경과 시간을 밀리초(Millisecond)로 정의합니다.
X-Scp-Client-Type : Userapi 고정(대소문자 구분)
Content-Type : application/json 명시
Reference
The message sending API requires all five headers above. If the X-Scp-Client-Type header is missing, a 400 InvalidParameterCombination error occurs.
Create Signature
- To call Message Hub via the message sending API, you must authenticate using the “authentication key” in authentication-key mode from a valid allowed IP address.
- Generate the string to be signed from the request, encrypt it with the HmacSHA256 algorithm using the Access and Secret keys, and then encode it in Base64.
- Use this value as X-Scp-Signature.
- The generated signature is valid for 15 minutes.
Signature generation Sample Code (Java)
public static String makeHmacSignature(String method,
String url,
String timestamp,
String accessKey,
String accessSecretKey,
String clientType) {
String body = method + url + timestamp + accessKey + clientType;
String encodeBase64Str;
try {
byte[] message = body.getBytes("UTF-8");
byte[] secretKey = accessSecretKey.getBytes("UTF-8");
Mac mac = Mac.getInstance("HmacSHA256");
SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey, "HmacSHA256");
mac.init(secretKeySpec);
byte[] hmacSha256 = mac.doFinal(message);
encodeBase64Str = Base64.getEncoder().encodeToString(hmacSha256);
} catch (Exception e) {
throw new RuntimeException("Failed to calculate hmac-sha256", e);
}
return encodeBase64Str;
}
Signature Generation Sample Code (JavaScript)
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/hmac-sha256.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/components/enc-base64-min.js"></script>
<script type="text/javascript">
function makeSignature() {
var method = "POST"; // Method
var url = "{url}"; // url (예: /v1/emails/{email_id}/send)
var timestamp = Date.now(); // timestamp
var accessKey = "{accessKey}"; // access key
var secretKey = "{secretKey}"; // secret key
var clientType = "Userapi"; // client type
url = encodeURI(url); // 한글, 특수 문자 처리
var message = method + url + timestamp + accessKey + clientType;
var hash = CryptoJS.HmacSHA256(message, secretKey);
return CryptoJS.enc.Base64.stringify(hash);
}
</script>
Message Hub API call example
Curl
curl -i -X POST
-H "X-Scp-Access-Key:2sd2gg=2agbdSD26svcD"
-H "X-Scp-Signature:fsfsdf235f9U35sdgf35Xsf/qgsdgsdg326=sfsdr23rsef="
-H "X-Scp-Timestamp:1605290625682"
-H "X-Scp-Client-Type:Userapi"
-H "Content-Type:application/json"
--data '{"recipient_addresses": ["someone@example.com"], "title": "notification title", "body": "notification body"}'
'https://messagehub.service.kr-west1.e.samsungsdscloud.com/v1/emails/33ff0000a8a345d78cdf163673f3da11/send'
Python
import requests
url = "https://messagehub.service.kr-west1.e.samsungsdscloud.com/v1/emails/33ff0000a8a345d78cdf163673f3da11/send"
payload = {
'recipient_addresses': ['someone@example.com'],
'title': 'notification title',
'body': 'notification body'
}
headers = {
'X-Scp-Access-Key': '2sd2gg=2agbdSD26svcD',
'X-Scp-Signature': 'fsfsdf235f9U35sdgf35Xsf/qgsdgsdg326=sfsdr23rsef=',
'X-Scp-Timestamp': '1605290625682',
'X-Scp-Client-Type': 'Userapi',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, json=payload)
if response.status_code == 204:
return None
else:
raise Exception(f"Failed to POST API: {response.status_code}, {response.text}")
Java
String apiUrl = "https://messagehub.service.kr-west1.e.samsungsdscloud.com/v1/emails/33ff0000a8a345d78cdf163673f3da11/send";
String accessKey = "2sd2gg=2agbdSD26svcD";
String signature = "fsfsdf235f9U35sdgf35Xsf/qgsdgsdg326=sfsdr23rsef=";
String timestamp = "1605290625682";
String clientType = "Userapi";
String requestBody = "{\"recipient_addresses\":[\"someone@example.com\"],\"title\":\"notification title\",\"body\":\"notification body\"}";
public static void sendMessage(String apiUrl, String requestBody) throws IOException {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost postRequest = new HttpPost(apiUrl);
postRequest.addHeader("X-Scp-Access-Key", accessKey);
postRequest.addHeader("X-Scp-Signature", signature);
postRequest.addHeader("X-Scp-Timestamp", timestamp);
postRequest.addHeader("X-Scp-Client-Type", clientType);
postRequest.addHeader("Content-Type", "application/json");
postRequest.setEntity(new StringEntity(requestBody, "UTF-8"));
HttpResponse response = httpClient.execute(postRequest);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode == 204) {
httpClient.close();
} else {
String responseBody = EntityUtils.toString(response.getEntity());
httpClient.close();
throw new RuntimeException("Failed to Request: " + statusCode + ", " + responseBody);
}
}
Message Hub Message API
Message Hub provides the following message-sending APIs per channel.
| Channel | API | Explanation |
|---|
| Email | POST /v1/emails/{email_id}/send | Email sending |
| SMS | POST /v1/phones/{phone_id}/send | Phone Book SMS Sending |
| Push | POST /v1/push-applications/{application_id}/send | Push Application Sending (FCM HTTP v1) |
Reference
All message-sending APIs return a 204 No Content with no response body upon success. The total size of the request body cannot exceed 294,912 bytes.
Email sending
POST https://messagehub.service.kr-west1.e.samsungsdscloud.com/v1/emails/{email_id}/send
Description
Send an email to the recipient using the registered outbound Email resource.
Path Parameters
| field name | Required status | type | Explanation |
|---|
| email_id | true | string | Outbound Email Resource ID (32 characters) |
Body Parameters
| field name | Required status | type | Explanation | Constraints |
|---|
| recipient_addresses | true | string[] | Recipient email address list | Minimum 1, maximum 100. Empty string not allowed. |
| title | true | string | Email subject | |
| body | true | string | Email body (HTML/text) | Maximum 262,144 bytes |
Responses
| HTTP Code | Description | Schema |
|---|
| 204 | No Content | |
| 400 | Bad Request | |
| 401 / 403 | Unauthorized / Forbidden | |
| 404 | Not Found | |
| 413 | Request Entity Too Large | |
| 429 | Too Many Requests | |
| 500 | Internal Server Error | |
| 503 | Service Unavailable | |
Errors
| HTTP Code | Error Code | Explanation |
|---|
| 400 | MissingParameter | email_id, recipient_addresses, title missing |
| 400 | InvalidParameterValue | Body format error, unknown field, empty recipient address, more than 100 recipients |
| 400 | InvalidParameterCombination | Missing X-Scp-Client-Type header |
| 400 | AccessDeniedException | Unverified sender (unverified_policy=deny), sending resource account mismatch, private endpoint not allowed |
| 401 / 403 | UnAuthorized / MissingAuthenticationToken | Signature verification failed, no permission |
| 404 | StatusNotFound | No outgoing Email resource |
| 413 | RequestEntityTooLarge | Request body exceeds 294,912 bytes or mail body exceeds 262,144 bytes |
| 429 | LimitExceededException | Monthly sending quota exceeded (Retry-After header included) |
| 500 | InternalServerError | Internal error |
| 503 | ServiceUnavailable | Temporary processing unavailable |
Example HTTP request
"X-Scp-Access-Key:2sd2gg=2agbdSD26svcD",
"X-Scp-Signature:fsfsdf235f9U35sdgf35Xsf/qgsdgsdg326=sfsdr23rsef=",
"X-Scp-Timestamp:1605290625682",
"X-Scp-Client-Type:Userapi",
"Content-Type:application/json"
Request Body
{
"recipient_addresses": ["someone@example.com"],
"title": "notification title",
"body": "notification body"
}
Example HTTP response
204 Response
Phone Book SMS Sending
POST https://messagehub.service.kr-west1.e.samsungsdscloud.com/v1/phones/{phone_id}/send
Description
Send an SMS to the recipient’s phone number using the registered outbound Phone resource.
Path Parameters
| Field name | Required or not | type | Explanation |
|---|
| phone_id | true | string | Outgoing Phone resource ID(32 characters) |
Body Parameters
| Field name | Required status | type | Explanation | Constraints |
|---|
| recipients | true | string[] | Incoming phone number list | International caller ID usage, minimum 1, maximum 100 |
| text | true | string | Text message body | Maximum 90 bytes |
Recipient numbers follow the ITU-T E.164 format, and the presence or absence of the + prefix distinguishes domestic and international notation.
| Input example | Interpretation | country code | Explanation |
|---|
| +821012345678 | International notation (E.164) | 82 | Derive the country code from the table using longest prefix match. |
| +14155552671 | International notation (NANP) | 1 | NANP territories match up to four digits (+1876, etc.) |
| 01012345678 | domestic (South Korea) | 82 (default) | If there is no +, it is considered a domestic number. |
| 010-1234-5678 | domestic | 82 | - and spaces are removed |
Responses
| HTTP Code | Description | Schema |
|---|
| 204 | No Content | |
| 400 | Bad Request | |
| 401 / 403 | Unauthorized / Forbidden | |
| 404 | Not Found | |
| 413 | Request Entity Too Large | |
| 429 | Too Many Requests | |
| 500 | Internal Server Error | |
| 503 | Service Unavailable | |
Errors
| HTTP Code | Error Code | Explanation |
|---|
| 400 | MissingParameter | phone_id, recipients missing |
| 400 | InvalidParameterValue | Body format error, unknown field, more than 100 recipients |
| 400 | InvalidParameterCombination | Missing X-Scp-Client-Type header |
| 400 | AccessDeniedException | Unauthenticated sender, account mismatch of the sending resource, private endpoint not allowed |
| 401 / 403 | UnAuthorized / MissingAuthenticationToken | Signature verification failed, no permission |
| 404 | StatusNotFound | Outgoing Phone resource not found |
| 413 | RequestEntityTooLarge | Request body exceeds limit or text body exceeds 90 bytes |
| 429 | LimitExceededException | Monthly sending quota exceeded (Retry-After header included) |
| 500 | InternalServerError | Internal error |
| 503 | ServiceUnavailable | Temporary processing unavailable |
Example HTTP request
"X-Scp-Access-Key:2sd2gg=2agbdSD26svcD",
"X-Scp-Signature:fsfsdf235f9U35sdgf35Xsf/qgsdgsdg326=sfsdr23rsef=",
"X-Scp-Timestamp:1605290625682",
"X-Scp-Client-Type:Userapi",
"Content-Type:application/json"
Request Body
{
"recipients": ["01012345678", "+14155552671"],
"text": "sms text"
}
Example HTTP response
204 Response
Push Application Sending
POST https://messagehub.service.kr-west1.e.samsungsdscloud.com/v1/push-applications/{application_id}/send
Description
Send a Push message based on FCM HTTP v1 using the registered Push Application resource and a device token.
Path Parameters
| Field name | Required or not | type | Explanation |
|---|
| application_id | true | string | Push Application resource ID (32 characters) |
Body Parameters
| Field name | Required or not | type | Explanation | Constraints |
|---|
| data | true | object | data-only payload | Maximum 1,024 bytes. The title and body fields are not provided. |
| tokens | true | string[] | Device Token List | Maximum of 100, empty strings are not allowed |
| priority | false | string | FCM priority | |
| ttl | false | string | Message TTL | |
Reference
Push messages are sent only with data-only payloads. The notification title and body should be placed in the data payload and delivered, and the device application must display them directly on the screen.
Responses
| HTTP Code | Description | Schema |
|---|
| 204 | No Content | |
| 400 | Bad Request | |
| 401 / 403 | Unauthorized / Forbidden | |
| 404 | Not Found | |
| 413 | Request Entity Too Large | |
| 429 | Too Many Requests | |
| 500 | Internal Server Error | |
| 503 | Service Unavailable | |
Errors
| HTTP Code | Error Code | Explanation |
|---|
| 400 | MissingParameter | application_id, data missing, tokens/topic/condition all absent |
| 400 | InvalidParameterValue | Body format error, unknown field, empty token, token count exceeds 100 |
| 400 | InvalidParameterCombination | Missing X-Scp-Client-Type header |
| 400 | AccessDeniedException | Resource account mismatch, private endpoint not allowed |
| 401 / 403 | UnAuthorized / MissingAuthenticationToken | Signature verification failed, no permission |
| 404 | StatusNotFound | No Push Application resources |
| 413 | RequestEntityTooLarge | Request body exceeds limit or data exceeds 1,024 bytes |
| 429 | LimitExceededException | Monthly sending quota exceeded (Retry-After header included) |
| 500 | InternalServerError | Internal error |
| 503 | ServiceUnavailable | Temporary processing unavailable |
Example HTTP request
"X-Scp-Access-Key:2sd2gg=2agbdSD26svcD",
"X-Scp-Signature:fsfsdf235f9U35sdgf35Xsf/qgsdgsdg326=sfsdr23rsef=",
"X-Scp-Timestamp:1605290625682",
"X-Scp-Client-Type:Userapi",
"Content-Type:application/json"
Request Body
{
"tokens": ["fcm-device-token-1"],
"data": {
"key1": "value1",
"key2": "value2"
},
"priority": "high",
"ttl": "3600s"
}
Example HTTP response
204 Response