Send Text Sms From Subscriber
This part of the SMS API enables a third party to send out text SMSes on behalf of an authorized subscriber.
This required that the API key holder has the authorization to send on behalf of that subscriber, which is
set in the from_subscriber
field.
Field | Description |
---|---|
from_subscriber |
The E.164 number with '+' of the subscriber. |
The destination number can be set to international or short numbers. Which numbers is allowed is based on a matrix of rights for the product and subscriber, so you must check for rejected messages based on it's content.
Field | Content | Description |
---|---|---|
to_address |
+number | An international number in E.164 format with a '+'. |
to_address |
number | A short format or network specific number in the national format. Numbers resolving to international must be entered as international. |
Note that using this API may incur costs or quota uses to the subscriber.
Any such cost will be based on the number of fragments sent. See the response
num_fragments
field for details.
Fragmentation And Encoding
Fragmentation and message encoding is handled the same way as for messages to subscriber.
Limitations
There are also some other restrictions to this API.
- This API cannot send a message from the subscriber that are blocked by subscription policies or quotas, i.e. messages that the subscriber is not allowed to send from the handset itself.
- This API will not send messages larger than 2000 characters. Note that unicode characters outside of the BMP plane counts as 2 characters each, and number of emoji characters and the newer CJK characters are in this group. Worst case this is 35 fragments for a single message.
- This API does not guarantee that the message is successfully delivered.
Prerequisites
Required Scope
sms.text.send_from_subscriber
is required to use the API function.
Code Dependencies
<dependency>
<groupId>com.wgtwo.api.v1.grpc</groupId>
<artifactId>sms</artifactId>
<version>1.10.1</version>
</dependency>
Code
If targeting production, you would need to add authentication to the sample code.
#!/usr/bin/env bash
grpcurl \
-d '
{
"content": "My text message",
"fromSubscriber": "+47xxxxxxxx",
"toAddress": "+47yyyyyyyy"
}
' \
sandbox.api.shamrock.wgtwo.com:443 \
wgtwo.sms.v1.SmsService/SendTextFromSubscriber
package com.example.sms
import com.wgtwo.api.v1.sms.SmsProto.SendTextFromSubscriberRequest
import com.wgtwo.api.v1.sms.SmsServiceGrpc
import io.grpc.ManagedChannelBuilder
fun main() {
val channel = ManagedChannelBuilder.forAddress("sandbox.api.shamrock.wgtwo.com", 443).build()
val stub = SmsServiceGrpc.newBlockingStub(channel)
val request = SendTextFromSubscriberRequest.newBuilder().apply {
fromSubscriber = "+4799900111"
toAddress = "+4799900112"
content = "Hello, World!"
}.build()
println("Request:
$request")
val response = stub.sendTextFromSubscriber(request)
println("Response:
$response")
}
Example Results
{
"messageId": "6a75356e-6191-11ec-b47d-7382e9b102b6",
"status": "SEND_STATUS_OK",
"numFragments": 1
}
message_id: "6a75356e-6191-11ec-b47d-7382e9b102b6"
status: SEND_STATUS_OK
num_fragments: 1