Send a Command to a Sim.

POST /v1/Commands

Machine-to-machine commands sent to/from devices

Send a Command to a Sim.

application/x-www-form-urlencoded

Body

  • Command string Required

    The message body of the Command. Can be plain text in text mode or a Base64 encoded byte string in binary mode.

  • Sim string

    The sid or unique_name of the SIM to send the Command to.

  • CallbackMethod string(http-method)

    The HTTP method we use to call callback_url. Can be: POST or GET, and the default is POST.

    Values are GET or POST.

  • CallbackUrl string(uri)

    The URL we call using the callback_url when the Command has finished sending, whether the command was delivered or it failed.

  • CommandMode string

    The mode used to send the SMS message. Can be: text or binary. The default SMS mode is text.

    Values are text or binary.

  • IncludeSid string

    Whether to include the SID of the command in the message body. Can be: none, start, or end, and the default behavior is none. When sending a Command to a SIM in text mode, we can automatically include the SID of the Command in the message body, which could be used to ensure that the device does not process the same Command more than once. A value of start will prepend the message with the Command SID, and end will append it to the end, separating the Command SID from the message body with a space. The length of the Command SID is included in the 160 character limit so the SMS body must be 128 characters or less before the Command SID is included.

  • DeliveryReceiptRequested boolean

    Whether to request delivery receipt from the recipient. For Commands that request delivery receipt, the Command state transitions to 'delivered' once the server has received a delivery receipt from the device. The default value is true.

Responses

  • 201 application/json

    Created

    Hide headers attributes Show headers attributes
    • Access-Control-Allow-Origin string

      Specify the origin(s) allowed to access the resource

    • Access-Control-Allow-Methods string

      Specify the HTTP methods allowed when accessing the resource

    • Access-Control-Allow-Headers string

      Specify the headers allowed when accessing the resource

    • Access-Control-Allow-Credentials boolean

      Indicates whether the browser should include credentials

    • Access-Control-Expose-Headers string

      Headers exposed to the client

    Hide response attributes Show response attributes object
    • sid string | null

      The unique string that we created to identify the Command resource.

      Minimum length is 34, maximum length is 34. Format should match the following pattern: ^DC[0-9a-fA-F]{32}$.

    • account_sid string | null

      The SID of the Account that created the Command resource.

      Minimum length is 34, maximum length is 34. Format should match the following pattern: ^AC[0-9a-fA-F]{32}$.

    • sim_sid string | null

      The SID of the Sim resource that the Command was sent to or from.

      Minimum length is 34, maximum length is 34. Format should match the following pattern: ^DE[0-9a-fA-F]{32}$.

    • command string | null

      The message being sent to or from the SIM. For text mode messages, this can be up to 160 characters. For binary mode messages, this is a series of up to 140 bytes of data encoded using base64.

    • command_mode string

      The mode used to send the SMS message. Can be: text or binary. The default SMS mode is text.

      Values are text or binary.

    • transport string

      The type of transport used. Can be: sms or ip.

      Values are sms or ip.

    • delivery_receipt_requested boolean | null

      Whether to request a delivery receipt.

    • status string

      The status of the Command. Can be: queued, sent, delivered, received, or failed. See Status Values for a description of each state.

      Values are queued, sent, delivered, received, or failed.

    • direction string

      The direction of the Command. Can be to_sim or from_sim. The value of to_sim is synonymous with the term mobile terminated, and from_sim is synonymous with the term mobile originated.

      Values are from_sim or to_sim.

    • date_created string(date-time) | null

      The date and time in GMT when the resource was created specified in ISO 8601 format.

    • date_updated string(date-time) | null

      The date and time in GMT when the resource was last updated specified in ISO 8601 format.

    • url string(uri) | null

      The absolute URL of the resource.

POST /v1/Commands
curl \
 --request POST 'https://wireless.twilio.com/v1/Commands' \
 --user "username:password" \
 --header "Content-Type: application/x-www-form-urlencoded" \
 --data 'Sim=sim&Command=command&IncludeSid=include_sid&CallbackUrl=http%3A%2F%2Fwww.example.com&CommandMode=text&CallbackMethod=callback_method'
Request examples
{"Sim"=>"sim", "Command"=>"command", "IncludeSid"=>"include_sid", "CallbackUrl"=>"http://www.example.com", "CommandMode"=>"text", "CallbackMethod"=>"callback_method"}
{"Sim"=>"sim", "Command"=>"command", "IncludeSid"=>"include_sid", "CallbackUrl"=>"http://www.example.com", "CommandMode"=>"binary", "CallbackMethod"=>"callback_method", "DeliveryReceiptRequested"=>true}
Response examples (201)
{
  "sid": "DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "url": "https://wireless.twilio.com/v1/Commands/DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "status": "queued",
  "command": "command",
  "sim_sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "direction": "from_sim",
  "transport": "sms",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "command_mode": "text",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "delivery_receipt_requested": true
}
{
  "sid": "DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "url": "https://wireless.twilio.com/v1/Commands/DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "status": "queued",
  "command": "command",
  "sim_sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "direction": "to_sim",
  "transport": "ip",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "command_mode": "binary",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "delivery_receipt_requested": true
}