-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsmart-messaging.html.md.erb
308 lines (217 loc) · 9.83 KB
/
smart-messaging.html.md.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
---
title: Swisscom Messaging Api Product
owner: API
---
# Swisscom Messaging API Product: SMS, MFA, Campaigns
## <a id='productpage'></a> Product Page
More infos on our Product page: https://sms.scapp.swisscom.com/
[![img](./img/sms-dashboard.png)](https://sms.scapp.swisscom.com/)
## <a id='digitalmarketplace'></a> Digital Marketplace
Subscribe to the Messaging SMS APIs on the [Swisscom Digital Marketplace](https://digital.swisscom.com).
[![img](./img/dm.png)](https://digital.swisscom.com)
## <a id='sms'></a> SMS
Send SMS and check their status, we provide the product called [Text Messaging](https://digital.swisscom.com/products/text-messaging/info):
[![img](./img/dm-messaging.png)](https://digital.swisscom.com/products/text-messaging/info)
## <a id='tokenvalidation'></a> Token Validation
Validate a phone number with a token as MFA, we provide the product called [Phone Number Validation](https://digital.swisscom.com/products/phone-number-validation/info):
[![img](./img/dm-tokenvalidation.png)](https://digital.swisscom.com/products/phone-number-validation/info)
## <a id='API'></a> API Resources
Below more technical details about the APIs, the most current documentation is on the Product Pages on the Digital Marketplace.
### Sending SMS
```txt
POST /messaging/sms
```
<pre class="terminal">
curl -X POST https://api.swisscom.com/messaging/sms -H 'SCS-Version: 2' -H 'client_id: {YourClientID}' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'SCS-Request-ID: {YourRequestID}' -d '{"to": "{YourPhoneNumber}", "text": "YourMessageText."}'
</pre>
#### Request
##### Headers
* `client_id` required (See [authentication](#authentication))
* `SCS-Version` required (Must be `2`)
* `Content-Type` required (E.g. `application/json`)
* `Accept` required (Must be `application/json`)
* `SCS-Request-ID` optional (Can be used to trace your request to our API. Only relevant if you need support from our team so they know which request to look into.)
##### Body Example (application/json)
```json
{
"to": "+41791234567",
"text": "Greetings from Swisscom!"
}
```
If you need updates about the SMS state (e.g. SMS was received), you can set the `callBackUrl` parameter. You will receive an HTTP `PUT` request to this URL, for any state change of this SMS.
#### Success Responses
##### 201 Response
```txt
no content
```
#### Error Responses
[400](#400), [401](#401), [403](#403), [404](#404), [405](#405), [406](#406), [429](#429), [500](#500), [503](#503)
Most updated error response you can find on the documention on Swisscom Digital Markeplace
### Get status information for an SMS
```txt
GET /messaging/sms/{messageId}
```
<pre class="terminal">
curl https://api.swisscom.com//messaging/sms/{messageId} -H 'SCS-Version: 2' -H 'client_id: {YourClientID}' -H 'Accept: application/json' -H 'SCS-Request-ID: {YourRequestID}'
</pre>
#### Request
##### Headers
* `SCS-Version` required (Must be `2`)
* `client_id` required (See [authentication](#authentication))
* `Accept` required (Defaults to `application/json`)
* `SCS-Request-ID` optional (Can be used to trace your request to our API. Only relevant if you need support from our team so they know which request to look into.)
##### URI Parameters
* `messageId` (MessageId of the SMS. You will receive this in the location header of the initial post to send the sms.)
#### Success Responses
###### 201 Response Example (application/json)
```json
{
"messageId": "0001",
"status": "201",
...
}
```
#### Error Responses
[401](#401), [403](#403), [404](#404), [405](#405), [500](#500), [503](#503)
### Initiate SMS Token Validation process
```txt
POST /messaging/tokenvalidation
```
<pre class="terminal">
curl -X POST https://api.swisscom.com/messaging/tokenvalidation -H 'SCS-Version: 2' -H 'client_id: MyClientID' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'SCS-Request-ID: {YourRequestID}' -d '{"to":"+41791234567", "text":"Take this token: %TOKEN%", "tokenType":"SHORT_NUMERIC", "expireTime":120,"tokenLength":6}'
</pre>
This call will start the SMS Token validation process by sending a validation token to an MSISDN. The validation token is a random string of characters that is sent to the user's mobile phone. After making this call, your application can then verify that the user recieved the validation token by calling the *Validate SMS Token* endpoint.
#### Request
##### Headers
* `SCS-Version` required (Must be `2`)
* `client_id` required (See [authentication](#authentication))
* `Content-Type` required (E.g. `application/json`)
* `Accept` optional (Defaults to `application/json`)
* `SCS-Request-ID` optional (Can be used to trace your request to our API. Only relevant if you need support from our team so they know which request to look into.)
##### Body Example (application/json)
```json
{
"to": "+41791544781",
"text": "Verification code: %TOKEN% \r\n Expires in 60 seconds.",
"tokenType": "SHORT_ALPHANUMERIC",
"expireTime": 60,
"tokenLength": 6
}
```
Use `%TOKEN%` as a placeholder for where the actual token should go.
#### Success Responses
##### 201 Response
```txt
no content
```
#### Error Responses
[400](#400), [401](#401), [403](#403), [404](#404), [405](#405), [406](#406), [429](#429), [500](#500), [503](#503)
### Validate SMS token
```txt
GET /messaging/tokenvalidation/{msisdn}/{token}
```
<pre class="terminal">
curl https://api.swisscom.com/messaging/tokenvalidation/{YourMsisdn}/{YourReceivedToken} -H 'SCS-Version: 2' -H 'client_id: {YourClientID}' -H 'Accept: application/json' -H 'SCS-Request-ID: {YourRequestID}'
</pre>
Validate a token sent to the MSISDN number using the *Send SMS Token* endpoint. This call is made after the *Send SMS Token* call to validate the token sent to the end user via SMS.
#### Request
##### Headers
* `client_id` required (See [authentication](#authentication))
* `SCS-Version` required (Must be `2`)
* `Accept` required (Must be `application/json`)
* `SCS-Request-ID` optional (Can be used to trace your request to our API. Only relevant if you need support from our team so they know which request to look into.)
##### URI Parameters
* `msisdn` required (The token depending phone number. A valid number starts with 0, 00 or + and must contain 7 to 15 digits. Local numbers (prefix 0) are handled with international code +41 by default.)
* `token` required (The token to verify.)
#### Success Responses
##### 200 Response Example (application/json)
```json
{
"validation": "SUCCESS"
}
```
#### Error Responses
[400](#400), [401](#401), [403](#403), [404](#404), [405](#405), [406](#406), [500](#500), [503](#503)
## <a id='error-handling'></a> Error Handling
### Error Response Examples
#### <a id='400'></a> 400 (Bad Request. Invalid request.)
```json
{
"status": "400",
"code": "INVALID_REQUEST",
"message": "The request could not be understood due to malformed syntax. Correct the request syntax and try again.",
"detail": ""
}
```
#### <a id='401'></a> 401 (Unauthorized. No permission to access resource or invalid API key.)
```json
{
"status": "401",
"code": "INVALID_AUTHENTICATION_CREDENTIALS",
"message": "Authentication credentials missing or incorrect. Check that you are using the correct authentication method and that you have permission to the given resource and your app key is approved.",
"detail": ""
}
```
#### <a id='403'></a> 403 (Forbidden. No permission to access requested resource.)
```json
{
"status": "403",
"code": "FORBIDDEN_RESOURCE",
"message": "The server understood the request, but is refusing to fulfill it. Check that you have permission to the given resource.",
"detail": ""
}
```
#### <a id='404'></a> 404 (Not Found. The server has not found a resource matching the Request-URI.)
```json
{
"status": "404",
"code": "INVALID_REQUEST_RESOURCE",
"message": "The requested resource does not exist. Verify that the resource URI is correctly spelled.",
"detail": ""
}
```
#### <a id='405'></a> 405 (Method Not Allowed. The resource is not accessible via the given HTTP method. For example, the client sent a POST request to a resource that only supports GET.)
```json
{
"status": "405",
"code": "INVALID_REQUEST_METHOD",
"message": "The resource is not accessible via the given method. Check the documentation or the Allow header for allowed methods.",
"detail": ""
}
```
#### <a id='406'></a> 406 (Invalid Header Accept. The provided Accept-type is not supported by the resource.)
```json
{
"status": "406",
"code": "INVALID_HEADER_ACCEPT",
"message": "The requested resource is only capable of generating content not acceptable according to the Accept headers sent in the request. Make sure the request has an Accept header with a media type supported by the API. Check the developer portal for supported media types.",
"detail": ""
}
```
#### <a id='429'></a> 429 (Too Many Requests. Quota for this service has been exhausted. Message must contain further details.)
```json
{
"status": "429",
"code": "EXPIRED_QUOTA",
"message": "Your quota for this service has been exhausted. Try again later or contact support at [email protected].",
"detail": ""
}
```
#### <a id='500'></a> 500 (Internal Server Error. The server has run into an unexpected condition.)
```json
{
"status": "500",
"code": "INTERNAL_SERVER_ERROR",
"message": "The server encountered an unexpected condition which prevented it from fulfilling the request. Try again later or contact support at [email protected].",
"detail": ""
}
```
#### <a id='503'></a> 503 (Service Unavailable. The server is currently unable to handle the request due to temporary overloading or maintenance. Typically, back end is unavailable.)
```json
{
"status": "503",
"code": "UNAVAILABLE_SERVICE",
"message": "The server is currently unable to handle the request due to temporary overloading or maintenance. Try again later or contact support at [email protected].",
"detail": ""
}
```