AEROSMS

簡単・お手軽・低価格なSMS送信サービス

APIドキュメント

AEROSMS API は REST を基本に構成し、SMS送信やSMS送信ステータスなど、外部のプログラムから AEROSMS の機能を簡単に使用することを可能にしています。
AEROSMS API は、リクエスト、レスポンスおよびエラー含め、すべて、JSON 形式でやりとりを行います。

AEROSMS API は、RAML (RESTful API Modeling Language) をもとに、設計・管理を行っています。
RAMLはRESTful APIを設計するための定義を YAML ベースでまとめた仕様となっているため、プログラム的にAPI設計を簡易に読み出すことができます。

  1. #%RAML 0.8
  2.  
  3. title: AEROSMS API
  4. baseUri: https://aerosms.net/api/{version}
  5. version: v1
  6. mediaType: application/json
  7.  
  8. /message:
  9. /send:
  10. post:
  11. description: "1つの宛先に対して、SMSを送信する"
  12. body:
  13. application/json
  14. schema: sendRequest
  15. example: |
  16. {
  17. "email": "example@aerosms.net"
  18. "apikey": "5b8f2433314f1c04e4fb8821c1a0ad78",
  19. "message": "1宛先送信テストです。",
  20. "label": "○月○日:送信テスト",
  21. "to": [
  22. {
  23. "number": "090-1234-5678",
  24. "tags": [ "customer", "123" ]
  25. }
  26. ]
  27. }
  28. responses:
  29. 200:
  30. body:
  31. application/json:
  32. schema: sendResponse
  33. example: |
  34. {
  35. "id": 101,
  36. "status": "sent",
  37. "message": "1宛先送信テストです。",
  38. "label": "○月○日:送信テスト",
  39. "created_at": "2016-04-01 09:00:00",
  40. "send_at": "2016-04-01 09:00:01",
  41. "sent_at": "2016-04-01 09:00:04",
  42. "duration": "3",
  43. "expires_at": "2016-04-01 09:00:10",
  44. "to": [
  45. {
  46. "id": 201,
  47. "number": "09012345678",
  48. "tags": [ "customer", "123" ]
  49. }
  50. ]
  51. }
  52. 400:
  53. body:
  54. application/json:
  55. schema: !include message.json
  56.  
  57. schemas:
  58.  
  59. - sendRequest: |
  60. {
  61. "description": "SMS送信用データ",
  62. "type": "object",
  63. "properties": {
  64. "email": {
  65. "description": "AEROSMSのログインメールアドレス",
  66. "type": "string",
  67. "required": true
  68. },
  69. "apikey": {
  70. "description": "APIキー",
  71. "type": "string",
  72. "required": true
  73. },
  74. "message": {
  75. "description": "送信するメッセージ",
  76. "type": "string",
  77. "required": true,
  78. "maxLength": 70,
  79. "minLength": 1
  80. },
  81. "label": {
  82. "description": "本SMS送信に関するラベル",
  83. "type": "string",
  84. "required": false,
  85. "maxLength": 255
  86. },
  87. "to": [
  88. {
  89. "number": {
  90. "description": "宛先の携帯番号",
  91. "type": "string",
  92. "required": true,
  93. "pattern": "[090|080|070][\-\d{4}\-\d{4}|\d{8}]"
  94. },
  95. "tags": [
  96. "description": "宛先に設定するタグ文字列",
  97. "type": "string",
  98. "required": false
  99. "maxLength": 255
  100. ],
  101. "register": {
  102. "description": "AEROSMSに宛先を登録するか否か",
  103. "type": "boolean",
  104. "required": false,
  105. "default": true
  106. }
  107. }
  108. ],
  109. "expires": {
  110. "description": "SMS送信期限(秒)、送信期限がきたらステータスはfailedとなる",
  111. "type": "integer",
  112. "minimum": 8,
  113. "maximum": 16,
  114. "required": false,
  115. "default": 10
  116. },
  117. "retry": {
  118. "description": "リトライ回数、ステータスがfailedになった時点でリトライ開始",
  119. "type": "integer",
  120. "minimum": 1,
  121. "maximum": 3,
  122. "required": false,
  123. "default": false
  124. },
  125. "callback": {
  126. "description": "SMS送信結果を受け取るコールバックURL、初回送信およびステータスがsent/failedになった時点でコールバック",
  127. "type": "string",
  128. "required": false,
  129. "pattern": "https?://[\w/:%#\$&\?\(\)~\.=\+\-]+",
  130. "maxLength": 1024
  131. },
  132. "dryrun": {
  133. "description": "SMS送信が正しく実行されるかの検査(実際にはSMS送信されません)",
  134. "type": "boolean",
  135. "required": false,
  136. "default": false
  137. }
  138. }
  139. }
  140. }
  141.  
  142. - sendResponse: |
  143. {
  144. "description": "SMS送信後の返却データ",
  145. "type": "object",
  146. "properties": {
  147. "id": {
  148. "description": "SMS送信時のAEROSMSが管理するID",
  149. "type": "integer"
  150. },
  151. "code": {
  152. "description": "SMS送信時のステータスコード",
  153. "type": "integer",
  154. "enum": [ 200, 400 ]
  155. },
  156. "status": {
  157. "description": "SMS送信時のステータス",
  158. "type": "string",
  159. "enum": [ "pending", "sent", "queued", "failed" ]
  160. },
  161. "message": {
  162. "description": "送信したメッセージ",
  163. "type": "string"
  164. },
  165. "label": {
  166. "description": "本SMS送信に関するラベル",
  167. "type": "string"
  168. },
  169. "created_at": {
  170. "description": "送信受付日時",
  171. "type": "string"
  172. },
  173. "send_at": {
  174. "description": "送信開始日時",
  175. "type": "string"
  176. },
  177. "sent_at": {
  178. "description": "送信完了日時",
  179. "type": "string"
  180. },
  181. "duration": {
  182. "description": "送信所要時間(秒)",
  183. "type": "string"
  184. },
  185. "expires_at": {
  186. "description": "送信期限",
  187. "type": "string"
  188. },
  189. "failed_at": {
  190. "description": "送信失敗日時",
  191. "type": "string"
  192. },
  193. "to": [
  194. {
  195. "id": {
  196. "description": "送信した宛先をAEROSMSが管理するID",
  197. "type": "integer"
  198. },
  199. "number": {
  200. "description": "送信した宛先の携帯番号",
  201. "type": "string",
  202. "pattern": "\d{11}",
  203. },
  204. "tags": [
  205. "description": "送信した宛先に設定したタグ文字列",
  206. "type": "string"
  207. ],
  208. "register": {
  209. "description": "AEROSMSに宛先を登録するか否か",
  210. "type": "boolean"
  211. }
  212. }
  213. ],
  214. "retry": {
  215. "description": "リトライ回数",
  216. "type": "integer"
  217. },
  218. "callback": {
  219. "description": "SMS送信結果を受け取るコールバックURL",
  220. "type": "string"
  221. },
  222. "dryrun": {
  223. "description": "SMS送信が正しく実行されるかの検査(実際にはSMS送信されません)",
  224. "type": "integer"
  225. },
  226. }
  227. }
  228. }

メッセージ

AEROSMS API で返却するメッセージの仕様です。
すべて、JSON 形式で返却されます。
以下は、300 のメッセージが返却された例です。

{"code":300,"message":{"en":"Mobile number is not correct","ja":"\u9001\u4fe1\u5148\u306e\u643a\u5e2f\u756a\u53f7\u304c\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093"}}

  1. 200:
  2. ja: SMS送信に成功しました
  3. en: SMS transmission succeeded
  4.  
  5. 201:
  6. ja: SMS送信のドライランに成功しました
  7. en: SMS transmission succeeded by dryrun
  8.  
  9. 300:
  10. ja: 送信先の携帯番号が正しくありません
  11. en: Mobile number is not correct
  12.  
  13. 301:
  14. ja: 送信メッセージの文字数が上限を超えています
  15. en: The number of characters in the message exceeds the limit
  16.  
  17. 302:
  18. ja: 通数の上限を超えています
  19. en: Exceeded the limit on the number of SMS transmission
  20.  
  21. 400:
  22. ja: SMS送信に失敗しました
  23. en: SMS transmission failed
  24.  
  25. 401:
  26. ja: 認証が必要です
  27. en: Unauthorized
  28.  
  29. 402:
  30. ja: SMS送信がタイムアウトしました
  31. en: SMS transmission has timed out
  32.  
  33. 403:
  34. ja: データベースエラー
  35. en: Database Error
  36.  
  37. 404:
  38. ja: ファイルシステムエラー
  39. en: Filesystem Error
  40.  
  41. 405:
  42. ja: 不明なエラーです
  43. en: Unknown Error
  44.  
  45. 406:
  46. ja: 送信期限までのSMS送信に失敗しました
  47. en: SMS transmission failed until deadline