The page has been translated by Gen AI.

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.

Production EnvironmentRegionPublic URLPrivate URL
For Enterprisekr-west1https://messagehub.service.kr-west1.e.samsungsdscloud.comhttps://messagehub.private.kr-west1.e.samsungsdscloud.com
For Enterprisekr-east1https://messagehub.service.kr-east1.e.samsungsdscloud.comhttps://messagehub.private.kr-east1.e.samsungsdscloud.com
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

Header Description
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.

ChannelAPIExplanation
EmailPOST /v1/emails/{email_id}/sendEmail sending
SMSPOST /v1/phones/{phone_id}/sendPhone Book SMS Sending
PushPOST /v1/push-applications/{application_id}/sendPush 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 nameRequired statustypeExplanation
email_idtruestringOutbound Email Resource ID (32 characters)

Body Parameters

field nameRequired statustypeExplanationConstraints
recipient_addressestruestring[]Recipient email address listMinimum 1, maximum 100. Empty string not allowed.
titletruestringEmail subject
bodytruestringEmail body (HTML/text)Maximum 262,144 bytes

Responses

HTTP CodeDescriptionSchema
204No Content
400Bad Request
401 / 403Unauthorized / Forbidden
404Not Found
413Request Entity Too Large
429Too Many Requests
500Internal Server Error
503Service Unavailable

Errors

HTTP CodeError CodeExplanation
400MissingParameteremail_id, recipient_addresses, title missing
400InvalidParameterValueBody format error, unknown field, empty recipient address, more than 100 recipients
400InvalidParameterCombinationMissing X-Scp-Client-Type header
400AccessDeniedExceptionUnverified sender (unverified_policy=deny), sending resource account mismatch, private endpoint not allowed
401 / 403UnAuthorized / MissingAuthenticationTokenSignature verification failed, no permission
404StatusNotFoundNo outgoing Email resource
413RequestEntityTooLargeRequest body exceeds 294,912 bytes or mail body exceeds 262,144 bytes
429LimitExceededExceptionMonthly sending quota exceeded (Retry-After header included)
500InternalServerErrorInternal error
503ServiceUnavailableTemporary processing unavailable

Example HTTP request

Request Header
"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 nameRequired or nottypeExplanation
phone_idtruestringOutgoing Phone resource ID(32 characters)

Body Parameters

Field nameRequired statustypeExplanationConstraints
recipientstruestring[]Incoming phone number listInternational caller ID usage, minimum 1, maximum 100
texttruestringText message bodyMaximum 90 bytes
Recipient number input format

Recipient numbers follow the ITU-T E.164 format, and the presence or absence of the + prefix distinguishes domestic and international notation.

Input exampleInterpretationcountry codeExplanation
+821012345678International notation (E.164)82Derive the country code from the table using longest prefix match.
+14155552671International notation (NANP)1NANP territories match up to four digits (+1876, etc.)
01012345678domestic (South Korea)82 (default)If there is no +, it is considered a domestic number.
010-1234-5678domestic82- and spaces are removed

Responses

HTTP CodeDescriptionSchema
204No Content
400Bad Request
401 / 403Unauthorized / Forbidden
404Not Found
413Request Entity Too Large
429Too Many Requests
500Internal Server Error
503Service Unavailable

Errors

HTTP CodeError CodeExplanation
400MissingParameterphone_id, recipients missing
400InvalidParameterValueBody format error, unknown field, more than 100 recipients
400InvalidParameterCombinationMissing X-Scp-Client-Type header
400AccessDeniedExceptionUnauthenticated sender, account mismatch of the sending resource, private endpoint not allowed
401 / 403UnAuthorized / MissingAuthenticationTokenSignature verification failed, no permission
404StatusNotFoundOutgoing Phone resource not found
413RequestEntityTooLargeRequest body exceeds limit or text body exceeds 90 bytes
429LimitExceededExceptionMonthly sending quota exceeded (Retry-After header included)
500InternalServerErrorInternal error
503ServiceUnavailableTemporary processing unavailable

Example HTTP request

Request Header
"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 nameRequired or nottypeExplanation
application_idtruestringPush Application resource ID (32 characters)

Body Parameters

Field nameRequired or nottypeExplanationConstraints
datatrueobjectdata-only payloadMaximum 1,024 bytes. The title and body fields are not provided.
tokenstruestring[]Device Token ListMaximum of 100, empty strings are not allowed
priorityfalsestringFCM priority
ttlfalsestringMessage 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 CodeDescriptionSchema
204No Content
400Bad Request
401 / 403Unauthorized / Forbidden
404Not Found
413Request Entity Too Large
429Too Many Requests
500Internal Server Error
503Service Unavailable

Errors

HTTP CodeError CodeExplanation
400MissingParameterapplication_id, data missing, tokens/topic/condition all absent
400InvalidParameterValueBody format error, unknown field, empty token, token count exceeds 100
400InvalidParameterCombinationMissing X-Scp-Client-Type header
400AccessDeniedExceptionResource account mismatch, private endpoint not allowed
401 / 403UnAuthorized / MissingAuthenticationTokenSignature verification failed, no permission
404StatusNotFoundNo Push Application resources
413RequestEntityTooLargeRequest body exceeds limit or data exceeds 1,024 bytes
429LimitExceededExceptionMonthly sending quota exceeded (Retry-After header included)
500InternalServerErrorInternal error
503ServiceUnavailableTemporary processing unavailable

Example HTTP request

Request Header
"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
How-to guides
Release Note