Action
Actions allow you to configure the incoming messages delivery method.
This documentation will help you configure the method for receiving incoming SMS messages and Voice services. Before configuring an Action, you must have a phone number and a Configuration container ready.
When setting up an Action for SMS you need to choose between two methods for incoming message delivery:
- Http forward method - allows you to receive messages from your subscribers in real-time
- HTTP POST - Receive messages via POST request in the request body
- HTTP GET - Receive messages via GET request as part of the URL query string
- Pull method - allows you to fetch new messages from the Infobip server over API at your convenience
Difference between Forward and Pull methods
Learn more about Forward and Pull methods for receiving messages in the introduction.
Available methods
Action model
Property name | Type | Description |
---|---|---|
actionKey | string | Unique ID of the Action. |
type | string | Action model of receiving the message. Must be HTTP_FORWARD_POST , HTTP_FORWARD_GET or PULL . |
callbackData | string | Data string that will be returned with each received message. |
forwardUrl | string | URL to which new messages will be forwarded (if type is set to HTTP_FORWARD_POST or HTTP_FORWARD_GET ). |
Create new Action
This method will create a new Action within the Configuration container.
https://api.infobip.com/numbers/1/numbers/{numberKey}/configurations/{configurationKey}/actions
Create Pull example
POST /numbers/1/numbers/78D8394AC5EG0460B4CF0E723FC31B49/configurations/64GD2CA328536A09DD2CA328536A09D8/actions HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Accept: application/json
{
"type": "PULL",
"callbackData": "you-do-not-call-us-we-call-you-data"
}
Response:
{
"actionKey": "76BA545050E5623F6BA00D595A23EC28",
"type": "PULL",
"callbackData": "someCallbackData"
}
Successful response is represented by the HTTP status code 200 OK
.
Create HTTP POST forward example
POST /numbers/1/numbers/78D8394AC5EG0460B4CF0E723FC31B49/configurations/64GD2CA328536A09DD2CA328536A09D8/actions HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Accept: application/json
{
"type": "HTTP_FORWARD_POST",
"forwardUrl": "http://someurl.com/message",
"callbackData": "someCallbackData"
}
Response:
{
"actionKey": "76BA545050E5623F6BA00D595A23EC28",
"type": "HTTP_FORWARD_POST",
"callbackData": "someCallbackData",
"forwardUrl": "http://someurl.com/message"
}
Successful response is represented by the HTTP status code 200 OK
.
Create HTTP GET forward example
Use placeholders in forwardUrl
to generate a query string with desired message data.
POST /numbers/1/numbers/78D8394AC5EG0460B4CF0E723FC31B49/configurations/64GD2CA328536A09DD2CA328536A09D8/actions HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Accept: application/json
{
"type": "HTTP_FORWARD_GET",
"forwardUrl": "http://someurl.com/message?sender=%sender%&text=%cleanText%",
"callbackData": "someCallbackData"
}
Response:
{
"actionKey": "76BA545050E5623F6BA00D595A23EC28",
"type": "HTTP_FORWARD_GET",
"callbackData": "someCallbackData",
"forwardUrl": "http://someurl.com/message?sender=%sender%&text=%cleanText%"
}
Successful response is represented by the HTTP status code 200 OK
.
Using placeholders in HTTP Forward GET request
This method allows you to pass message data as URL query string parameters. Example:
http://someurl.com/message?sender=%sender%&text=%cleanText%
You can combine any placeholders from this list to build your query string parameters. Wrap a placeholder name with %
like this %sender%
.
Placeholders:
Placeholder name | Description |
---|---|
sender | Sender ID. |
text | Message text. |
keyword | Configuration container keyword. |
cleanText | Message text without keyword. |
receiver | Receiver number. |
when | Date sent. |
callbackdata | Callback data. |
Get Action
This method will return the Action of the selected Configuration:
https://api.infobip.com/numbers/1/numbers/{numberKey}/configurations/{configurationKey}/actions
Request example:
GET /numbers/1/numbers/78D8394AC5EG0460B4CF0E723FC31B49/configurations/64GD2CA328536A09DD2CA328536A09D8/actions HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Accept: application/json
Response:
{
"actions": [
{
"actionKey": "76BA545050E5623F6BA00D595A23EC28",
"type": "PULL",
"callbackData": "you-do-not-call-us-we-call-you-data"
}
]
}
Successful response is represented by the HTTP status code 200 OK
.
Delete Action
This method will delete an Action of the selected Configuration:
https://api.infobip.com/numbers/1/numbers/{numberKey}/configurations/{configurationKey}/actions/{actionKey}
Request example:
DELETE /numbers/1/numbers/78D8394AC5EG0460B4CF0E723FC31B49/configurations/64GD2CA328536A09DD2CA328536A09D8/actions/76BA545050E5623F6BA00D595A23EC28 HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Accept: application/json
Successful response is represented by the HTTP status code 204 No Content
. There is no response body.