{"__v":0,"_id":"58512c69488ec11900fa3196","category":{"__v":3,"_id":"5515472ac28d6125001b8884","pages":["551924db45b0d80d00152254","55194fec71a8cc210031db15","551e55590a72c50d0085b911"],"project":"54eb50e5615ffc1900305a16","version":"54eb63b859b1172100334fae","sync":{"url":"","isSync":false},"reference":true,"createdAt":"2015-03-27T12:03:54.990Z","from_sync":false,"order":2,"slug":"receive-sms","title":"Receive SMS"},"parentDoc":null,"project":"54eb50e5615ffc1900305a16","user":"54eb4fdedf7add210007b29b","version":{"__v":20,"_id":"54eb63b859b1172100334fae","forked_from":"54eb63a1867e1917009b711d","project":"54eb50e5615ffc1900305a16","createdAt":"2015-02-23T17:30:32.501Z","releaseDate":"2015-02-23T17:30:32.501Z","categories":["54eb63b959b1172100334faf","54eb63b959b1172100334fb0","54eb63b959b1172100334fb1","54eb63b959b1172100334fb2","54ed8dd4ab373e2300f50eae","54ed99b2ab373e2300f50ede","55153a6de68daa2f00cff838","551546edbc466623002afe72","5515472ac28d6125001b8884","55154749c28d6125001b8885","555d9b4106dfec0d00d38ea7","5613e06e433e5735007c7708","5624bbb785a31117001c5403","56669e857cc81e0d00253f8e","568b8d837a42220d00498311","56a632277ef6620d00e2f18a","56d8147c3eb4dd0b00201aac","57a9ce2fac6db30e000d7efd","57a9cf4e944ea60e00dc3f74","58172386715dce0f00da4aa0","582dc59ee1b8692300c0dd03","589b19b4fec2730f0082e040","58b04a023529383900a759b5"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-12-14T11:26:33.662Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":true,"order":8,"body":"This tutorial will help you configure the method of receiving incoming SMS messages. Before configuring Action, you must have [phone number](/docs/phone-number) and [Configuration container](/docs/message-configuration) ready.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/6af562b-sms4.PNG\",\n        \"sms4.PNG\",\n        493,\n        89,\n        \"#dcd4d3\"\n      ]\n    }\n  ]\n}\n[/block]\nWhen setting up Action, you have to choose between two incoming message delivery methods:\n\n* **Http forward method** - allows you to receive messages from your subscribers in real-time\n  * *HTTP POST* - Receive messages via POST request in the request body\n  * *HTTP GET* - Receive messages via GET request as part of the URL query string\n* **Pull method** - allows you to fetch new messages from Infobip server over API at your convenience\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Difference between Forward and Pull methods\",\n  \"body\": \"Learn more about Forward and Pull  methods for receiving messages in [introduction](/docs/receive-sms-introduction#step-3-action-setup).\"\n}\n[/block]\n###Available methods\n* [Create new Action](#create-new-action)\n* [Get Action](#get-action)\n* [Delete Action](#delete-action) \n\n##Action model\n|Property name|Type|Description|\n|-|-|-|\n|actionKey|string|Unique ID of the Action.|\n|type|string|Action model of receiving the message. Must be `HTTP_FORWARD_POST`, `HTTP_FORWARD_GET` or `PULL`|\n|callbackData|string|Data string that will be returned with each received message.|\n|forwardUrl|string|URL to which new messages will be forwarded (if `type` is set to `HTTP_FORWARD_POST` or `HTTP_FORWARD_GET`)|\n[block:api-header]\n{\n  \"type\": \"post\",\n  \"title\": \"Create new Action\"\n}\n[/block]\nThis method will create new Action withing Configuration container.\n```\nhttps://api.infobip.com/sms/1/numbers/{numberKey}/configurations/{configurationKey}/actions\n```\n###Create Pull example\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"POST /sms/1/numbers/78D8394AC5EG0460B4CF0E723FC31B49/configurations/64GD2CA328536A09DD2CA328536A09D8/actions HTTP/1.1\\nHost: api.infobip.com\\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\\nAccept: application/json\\n\\n{\\n\\t\\\"type\\\": \\\"PULL\\\",\\n\\t\\\"callbackData\\\": \\\"you-do-not-call-us-we-call-you-data\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nResponse\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"actionKey\\\": \\\"76BA545050E5623F6BA00D595A23EC28\\\",\\n  \\\"type\\\": \\\"PULL\\\",\\n  \\\"callbackData\\\": \\\"someCallbackData\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nThe success response is represented by an HTTP status code `200 OK`.\n\n###Create HTTP POST forward example\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"POST /sms/1/numbers/78D8394AC5EG0460B4CF0E723FC31B49/configurations/64GD2CA328536A09DD2CA328536A09D8/actions HTTP/1.1\\nHost: api.infobip.com\\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\\nAccept: application/json\\n\\n{\\n\\t\\\"type\\\": \\\"HTTP_FORWARD_POST\\\",\\n\\t\\\"forwardUrl\\\": \\\"http://someurl.com/message\\\",\\n\\t\\\"callbackData\\\": \\\"someCallbackData\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nResponse\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"actionKey\\\": \\\"76BA545050E5623F6BA00D595A23EC28\\\",\\n  \\\"type\\\": \\\"HTTP_FORWARD_POST\\\",\\n  \\\"callbackData\\\": \\\"someCallbackData\\\",\\n  \\\"forwardUrl\\\": \\\"http://someurl.com/message\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nThe success response is represented by an HTTP status code `200 OK`.\n\n###Create HTTP GET forward example\nUse [placeholders](#section-using-placeholders-in-http-forward-get-request) in `forwardUrl` to generate query string with desired message data.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"POST /sms/1/numbers/78D8394AC5EG0460B4CF0E723FC31B49/configurations/64GD2CA328536A09DD2CA328536A09D8/actions HTTP/1.1\\nHost: api.infobip.com\\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\\nAccept: application/json\\n\\n{\\n\\t\\\"type\\\": \\\"HTTP_FORWARD_GET\\\",\\n\\t\\\"forwardUrl\\\": \\\"http://someurl.com/message?sender=%sender%&text=%cleanText%\\\",\\n\\t\\\"callbackData\\\": \\\"someCallbackData\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nResponse\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"actionKey\\\": \\\"76BA545050E5623F6BA00D595A23EC28\\\",\\n  \\\"type\\\": \\\"HTTP_FORWARD_GET\\\",\\n  \\\"callbackData\\\": \\\"someCallbackData\\\",\\n  \\\"forwardUrl\\\": \\\"http://someurl.com/message?sender=%sender%&text=%cleanText%\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nThe success response is represented by an HTTP status code `200 OK`.\n\n####Using placeholders in HTTP Forward GET request\nThis method allows you to pass message data as URL query string parameters. Example:\n\n```\nhttp://someurl.com/message?sender=%sender%&text=%cleanText%\n```\nYou can combine any placeholder from this list to build your query string parameters. Wrap a **placeholder name** with `%` like this `%sender%`.\n\nPalcehodlers\n\n|Placeholder name|Description|\n|-|-|\n|sender|Sender ID|\n|text|Message text|\n|keyword|Configuration container keyword|\n|cleanText|Message text without keyword|\n|receiver|Receiver number|\n|when|Date sent|\n|callbackdata|Callback data|\n[block:api-header]\n{\n  \"type\": \"get\",\n  \"title\": \"Get Action\"\n}\n[/block]\nThis method will return the Action of selected Configuration\n```\nhttps://api.infobip.com/sms/1/numbers/{numberKey}/configurations/{configurationKey}/actions\n```\nRequest example\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"GET /sms/1/numbers/78D8394AC5EG0460B4CF0E723FC31B49/configurations/64GD2CA328536A09DD2CA328536A09D8/actions HTTP/1.1\\nHost: api.infobip.com\\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\\nAccept: application/json\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nResponse\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"actions\\\": [\\n    {\\n      \\\"actionKey\\\": \\\"76BA545050E5623F6BA00D595A23EC28\\\",\\n      \\\"type\\\": \\\"PULL\\\",\\n      \\\"callbackData\\\": \\\"you-do-not-call-us-we-call-you-data\\\"\\n    }\\n  ]\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nThe success response is represented by an HTTP status code `200 OK`.\n\n[block:api-header]\n{\n  \"type\": \"delete\",\n  \"title\": \"Delete Action\"\n}\n[/block]\nThis method will delete Action of selected Configuration\n```\nhttps://api.infobip.com/sms/1/numbers/{numberKey}/configurations/{configurationKey}/actions/{actionKey}\n```\nRequest example\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"DELETE /sms/1/numbers/78D8394AC5EG0460B4CF0E723FC31B49/configurations/64GD2CA328536A09DD2CA328536A09D8/actions/76BA545050E5623F6BA00D595A23EC28 HTTP/1.1\\nHost: api.infobip.com\\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\\nAccept: application/json\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nThe success response is represented by an HTTP status code `204 No Content`. There is no response body.","excerpt":"Actions allow you to configure incoming messages delivery method.","slug":"action","type":"basic","title":"Action"}

Action

Actions allow you to configure incoming messages delivery method.

This tutorial will help you configure the method of receiving incoming SMS messages. Before configuring Action, you must have [phone number](/docs/phone-number) and [Configuration container](/docs/message-configuration) ready. [block:image] { "images": [ { "image": [ "https://files.readme.io/6af562b-sms4.PNG", "sms4.PNG", 493, 89, "#dcd4d3" ] } ] } [/block] When setting up Action, you have to choose between two incoming message delivery methods: * **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 Infobip server over API at your convenience [block:callout] { "type": "info", "title": "Difference between Forward and Pull methods", "body": "Learn more about Forward and Pull methods for receiving messages in [introduction](/docs/receive-sms-introduction#step-3-action-setup)." } [/block] ###Available methods * [Create new Action](#create-new-action) * [Get Action](#get-action) * [Delete Action](#delete-action) ##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`)| [block:api-header] { "type": "post", "title": "Create new Action" } [/block] This method will create new Action withing Configuration container. ``` https://api.infobip.com/sms/1/numbers/{numberKey}/configurations/{configurationKey}/actions ``` ###Create Pull example [block:code] { "codes": [ { "code": "POST /sms/1/numbers/78D8394AC5EG0460B4CF0E723FC31B49/configurations/64GD2CA328536A09DD2CA328536A09D8/actions HTTP/1.1\nHost: api.infobip.com\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\nAccept: application/json\n\n{\n\t\"type\": \"PULL\",\n\t\"callbackData\": \"you-do-not-call-us-we-call-you-data\"\n}", "language": "json" } ] } [/block] Response [block:code] { "codes": [ { "code": "{\n \"actionKey\": \"76BA545050E5623F6BA00D595A23EC28\",\n \"type\": \"PULL\",\n \"callbackData\": \"someCallbackData\"\n}", "language": "json" } ] } [/block] The success response is represented by an HTTP status code `200 OK`. ###Create HTTP POST forward example [block:code] { "codes": [ { "code": "POST /sms/1/numbers/78D8394AC5EG0460B4CF0E723FC31B49/configurations/64GD2CA328536A09DD2CA328536A09D8/actions HTTP/1.1\nHost: api.infobip.com\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\nAccept: application/json\n\n{\n\t\"type\": \"HTTP_FORWARD_POST\",\n\t\"forwardUrl\": \"http://someurl.com/message\",\n\t\"callbackData\": \"someCallbackData\"\n}", "language": "json" } ] } [/block] Response [block:code] { "codes": [ { "code": "{\n \"actionKey\": \"76BA545050E5623F6BA00D595A23EC28\",\n \"type\": \"HTTP_FORWARD_POST\",\n \"callbackData\": \"someCallbackData\",\n \"forwardUrl\": \"http://someurl.com/message\"\n}", "language": "json" } ] } [/block] The success response is represented by an HTTP status code `200 OK`. ###Create HTTP GET forward example Use [placeholders](#section-using-placeholders-in-http-forward-get-request) in `forwardUrl` to generate query string with desired message data. [block:code] { "codes": [ { "code": "POST /sms/1/numbers/78D8394AC5EG0460B4CF0E723FC31B49/configurations/64GD2CA328536A09DD2CA328536A09D8/actions HTTP/1.1\nHost: api.infobip.com\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\nAccept: application/json\n\n{\n\t\"type\": \"HTTP_FORWARD_GET\",\n\t\"forwardUrl\": \"http://someurl.com/message?sender=%sender%&text=%cleanText%\",\n\t\"callbackData\": \"someCallbackData\"\n}", "language": "json" } ] } [/block] Response [block:code] { "codes": [ { "code": "{\n \"actionKey\": \"76BA545050E5623F6BA00D595A23EC28\",\n \"type\": \"HTTP_FORWARD_GET\",\n \"callbackData\": \"someCallbackData\",\n \"forwardUrl\": \"http://someurl.com/message?sender=%sender%&text=%cleanText%\"\n}", "language": "json" } ] } [/block] The success response is represented by an 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 placeholder from this list to build your query string parameters. Wrap a **placeholder name** with `%` like this `%sender%`. Palcehodlers |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| [block:api-header] { "type": "get", "title": "Get Action" } [/block] This method will return the Action of selected Configuration ``` https://api.infobip.com/sms/1/numbers/{numberKey}/configurations/{configurationKey}/actions ``` Request example [block:code] { "codes": [ { "code": "GET /sms/1/numbers/78D8394AC5EG0460B4CF0E723FC31B49/configurations/64GD2CA328536A09DD2CA328536A09D8/actions HTTP/1.1\nHost: api.infobip.com\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\nAccept: application/json", "language": "json" } ] } [/block] Response [block:code] { "codes": [ { "code": "{\n \"actions\": [\n {\n \"actionKey\": \"76BA545050E5623F6BA00D595A23EC28\",\n \"type\": \"PULL\",\n \"callbackData\": \"you-do-not-call-us-we-call-you-data\"\n }\n ]\n}", "language": "json" } ] } [/block] The success response is represented by an HTTP status code `200 OK`. [block:api-header] { "type": "delete", "title": "Delete Action" } [/block] This method will delete Action of selected Configuration ``` https://api.infobip.com/sms/1/numbers/{numberKey}/configurations/{configurationKey}/actions/{actionKey} ``` Request example [block:code] { "codes": [ { "code": "DELETE /sms/1/numbers/78D8394AC5EG0460B4CF0E723FC31B49/configurations/64GD2CA328536A09DD2CA328536A09D8/actions/76BA545050E5623F6BA00D595A23EC28 HTTP/1.1\nHost: api.infobip.com\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\nAccept: application/json", "language": "json" } ] } [/block] The success response is represented by an HTTP status code `204 No Content`. There is no response body.