# IPCommand Resource

IP Commands enable you to exchange IP/UDP messages between your cloud and your devices connected with Super SIM.

```html
https://supersim.api.korewireless.com/v1/IpCommands
```

You can use IP Commands to send server-initiated IP messages from your cloud to your devices. The private IP addresses assigned to Super SIMs are behind the cellular networks' NAT/firewalls and you cannot reach them over IP without your device first initiating the connection or maintaining a persistent connection. IP Commands allow you to reach your devices over IP, by forwarding a UDP message to a port on your device and going around the networks' NAT/firewalls.

{% hint style="success" %}
IP Commands can be used as an alternative to using VPN to reach a device from outside the cellular network.
{% endhint %}

You can also send a UDP message from your device to a dedicated KORE IP address that will treat the message as an IP Command from the SIM, the payload of which will be forwarded to your cloud via a webhook.

To use IP Commands, you must have data enabled on the [Fleet resource](https://docs.korewireless.com/en-us/api/products/supersim/fleet-resource) your Super SIM is assigned to, and the [Sim resource](https://docs.korewireless.com/en-us/api/products/supersim/sim-resource) representing your Super SIM must be [Active or Ready](https://docs.korewireless.com/en-us/supersim/how-to/how-to-determine-a-super-sims-status).

{% hint style="info" %}
If you'd like to try IP Commands out straight away, check out our [Get Started](https://docs.korewireless.com/en-us/supersim/get-started/get-started-with-super-sim-ip-commands-and-the-raspberry-pi) guide. Or read on for the full API documentation.
{% endhint %}

***

## IP Commands to SIM (Mobile Terminated) <a href="#ip-commands-to-sim-mobile-terminated" id="ip-commands-to-sim-mobile-terminated"></a>

IP Commands are sent by making a `POST` request to the IP Commands API. The created IP Command resource's status will initially be `queued`. The IP Command will be sent to the device asynchronously on an existing data connection. If the device is attached, we will attempt to send the UDP message to your device and the IP Command resource's status will be updated to `sent`. If the device is not attached, the IP Command will not be sent and its status will be marked as `failed`. An error code will be indicated on the resource.

Learn more about:

* [Asynchronous operations](https://docs.korewireless.com/en-us/api/products/supersim#asynchronous-resources)
* [Sending an IP Command](#send-an-ip-command)
* [IP Command Callbacks](#sms-command-resource-status-callbacks)

{% hint style="info" %}
If the device is sleeping ([3GPP `IDLE` mode](https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1180)), IP Commands can still be delivered to the device. There are three scenarios here:

1. Regular LTE devices — When the IP message reaches the visited network to which your device is attached to, the visited network will page your device. When your device responds to the page, it will receive the IP Command.
2. Cat-M1 devices without eDRX — IP Commands sent to Cat-M1 devices which do not have [eDRX mode](https://docs.korewireless.com/en-us/supersim/cellular-module-knowledgebase#low-power-optimization-for-cellular-modules) enabled are treated like regular LTE devices. Your device will get paged and the IP message is delivered when your device responds to the page.
3. Cat-M1 devices that use eDRX sleep mode — HLCOM (High Latency Communication) is a network feature that allows a Cat-M1 device sleeping in eDRX mode to avoid being paged for IP messages. Instead the IP message is buffered in the visited network and delivered when the device comes out of the sleep cycle. HLCOM is not available on all cellular networks. If HLCOM is not enabled and the device is sleeping in eDRX mode, then the IP message is dropped in the visited network and will not be delivered to your device.
   {% endhint %}

***

## IP Commands from SIM (Mobile Originated) <a href="#ip-commands-from-sim-mobile-originated" id="ip-commands-from-sim-mobile-originated"></a>

You can receive IP Commands from the device by configuring a webhook on your Super SIM's [Fleet resource](https://docs.korewireless.com/en-us/api/products/supersim/fleet-resource). A special destination address, `100.64.0.1`, has been exposed by KORE to receive IP packets. Any IP message sent to this address by your device will be treated as an IP Command and the content will be delivered to your Fleet resource's `ip_commands_url`.

To receive a Command (Mobile Originated) from a SIM, you should create or update an existing [Fleet instance](https://docs.korewireless.com/en-us/api/products/supersim/fleet-resource) and provide an `ip_commands_url` property and, optionally, an `ip_commands_method` property.

When a your device sends an IP message to the special IP address `100.64.0.1`, an IP Command resource will be created and your `ip_commands_url` will be invoked. The created IP Command resource's status will always be `received`.&#x20;

Learn more about the contents of the [IP Command callbacks](#sms-command-resource-status-callbacks) below.

***

## API Authorization <a href="#api-authorization" id="api-authorization"></a>

Before you can make requests to this resource, you must have a valid bearer token. Review our API [authorization guide](https://docs.korewireless.com/en-us/developers/api-management/auth) to learn how to generate a token. Here's a curl example on how to define your access token in a header:

{% code overflow="wrap" %}

```bash
curl -L "https://supersim.api.korewireless.com/v1/Sims" -H "Authorization: Bearer <YOUR_ACCESS_TOKEN>" 
```

{% endcode %}

{% hint style="warning" %}
The examples below do not show the required `Authorization` header due to a bug. We're working on fixing that. In the meantime, be sure to include that in all of your requests.
{% endhint %}

***

## Send an IP Command

## POST /v1/IpCommands

> Send an IP Command to a Super SIM.

```json
{"openapi":"3.0.1","info":{"title":"KORE - Supersim","version":"1.0.0"},"tags":[{"name":"SupersimV1IpCommand"}],"servers":[{"url":"https://supersim.api.korewireless.com"}],"security":[{"OAuth":[]}],"components":{"securitySchemes":{"OAuth":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.korewireless.com/api-services/v1/auth/token","scopes":{}}}}},"schemas":{"supersim.v1.ip_command":{"type":"object","properties":{"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^HG[0-9a-fA-F]{32}$","nullable":true,"description":"The unique string that we created to identify the IP Command resource."},"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Account](https://docs.korewireless.com/en-us/v/api/global-resources/iam/account) that created the IP Command resource."},"sim_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^HS[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Super SIM](https://docs.korewireless.com/en-us/v/api/products/supersim/sim-resource) that this IP Command was sent to or from."},"sim_iccid":{"type":"string","nullable":true,"description":"The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) of the [Super SIM](https://docs.korewireless.com/en-us/v/api/products/supersim/sim-resource) that this IP Command was sent to or from."},"status":{"$ref":"#/components/schemas/ip_command_enum_status"},"direction":{"$ref":"#/components/schemas/ip_command_enum_direction"},"device_ip":{"type":"string","nullable":true,"description":"The IP address of the device that the IP Command was sent to or received from. For an IP Command sent to a Super SIM, `device_ip` starts out as `null`, and once the IP Command is “sent”, the `device_ip` will be filled out. An IP Command sent from a Super SIM have its `device_ip` always set."},"device_port":{"type":"integer","default":0,"nullable":true,"description":"For an IP Command sent to a Super SIM, it would be the destination port of the IP message. For an IP Command sent from a Super SIM, it would be the source port of the IP message."},"payload_type":{"$ref":"#/components/schemas/ip_command_enum_payload_type"},"payload":{"type":"string","nullable":true,"description":"The payload that is carried in the IP/UDP message. The payload can be encoded in either text or binary format. For text payload, UTF-8 encoding must be used.\n\nFor an IP Command sent to a Super SIM, the payload is appended to the IP/UDP message “as is”. The payload should not exceed 1300 bytes.\n\nFor an IP Command sent from a Super SIM, the payload from the received IP/UDP message is extracted and sent in binary encoding. For an IP Command sent from a Super SIM, the payload should not exceed 1300 bytes. If it is larger than 1300 bytes, there might be fragmentation on the upstream and the message may appear truncated."},"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."},"date_updated":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."},"url":{"type":"string","format":"uri","nullable":true,"description":"The absolute URL of the IP Command resource."}}},"ip_command_enum_status":{"type":"string","nullable":true,"description":"The delivery status of the IP Command. This is one of the following: “queued”, “sent”, “failed” or “received”.","enum":["queued","sent","received","failed"]},"ip_command_enum_direction":{"type":"string","nullable":true,"description":"Either `to_sim` or `from_sim`. Indicates whether the IP Command resource was sent from or to the Super SIM.","enum":["to_sim","from_sim"]},"ip_command_enum_payload_type":{"type":"string","nullable":true,"description":"Indicates how the payload is encoded. Either “text” or “binary”. For an IP Command sent to a Super SIM, `payload_type` is configurable. For an IP Command sent from a Super SIM, `payload_type` is always “binary”.","enum":["text","binary"]}}},"paths":{"/v1/IpCommands":{"post":{"description":"Send an IP Command to a Super SIM.","tags":["SupersimV1IpCommand"],"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/supersim.v1.ip_command"}}},"headers":{"Access-Control-Allow-Origin":{"description":"Specify the origin(s) allowed to access the resource","schema":{"type":"string"}},"Access-Control-Allow-Methods":{"description":"Specify the HTTP methods allowed when accessing the resource","schema":{"type":"string"}},"Access-Control-Allow-Headers":{"description":"Specify the headers allowed when accessing the resource","schema":{"type":"string"}},"Access-Control-Allow-Credentials":{"description":"Indicates whether the browser should include credentials","schema":{"type":"boolean"}},"Access-Control-Expose-Headers":{"description":"Headers exposed to the client","schema":{"type":"string"}}},"description":"Created"}},"operationId":"CreateIpCommand","requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"type":"object","title":"CreateIpCommandRequest","properties":{"Sim":{"type":"string","description":"The `sid` or `unique_name` of the [Super SIM](https://docs.korewireless.com/en-us/v/api/products/supersim/sim-resource) to send the IP Command to."},"Payload":{"type":"string","description":"The data that will be sent to the device. The payload cannot exceed 1300 bytes. If the PayloadType is set to text, the payload is encoded in UTF-8. If PayloadType is set to binary, the payload is encoded in Base64."},"DevicePort":{"type":"integer","description":"The device port to which the IP Command will be sent."},"PayloadType":{"$ref":"#/components/schemas/ip_command_enum_payload_type"},"CallbackUrl":{"type":"string","format":"uri","description":"The URL we should call using the `callback_method` after we have sent the IP Command."},"CallbackMethod":{"type":"string","format":"http-method","enum":["GET","POST"],"description":"The HTTP method we should use to call `callback_url`. Can be `GET` or `POST`, and the default is `POST`."}},"required":["Sim","Payload","DevicePort"]}}}}}}}}
```

***

## Fetch an IP Command

## GET /v1/IpCommands/{Sid}

> Fetch IP Command instance from your account.

```json
{"openapi":"3.0.1","info":{"title":"KORE - Supersim","version":"1.0.0"},"tags":[{"name":"SupersimV1IpCommand"}],"servers":[{"url":"https://supersim.api.korewireless.com"}],"security":[{"OAuth":[]}],"components":{"securitySchemes":{"OAuth":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.korewireless.com/api-services/v1/auth/token","scopes":{}}}}},"schemas":{"supersim.v1.ip_command":{"type":"object","properties":{"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^HG[0-9a-fA-F]{32}$","nullable":true,"description":"The unique string that we created to identify the IP Command resource."},"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Account](https://docs.korewireless.com/en-us/v/api/global-resources/iam/account) that created the IP Command resource."},"sim_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^HS[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Super SIM](https://docs.korewireless.com/en-us/v/api/products/supersim/sim-resource) that this IP Command was sent to or from."},"sim_iccid":{"type":"string","nullable":true,"description":"The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) of the [Super SIM](https://docs.korewireless.com/en-us/v/api/products/supersim/sim-resource) that this IP Command was sent to or from."},"status":{"$ref":"#/components/schemas/ip_command_enum_status"},"direction":{"$ref":"#/components/schemas/ip_command_enum_direction"},"device_ip":{"type":"string","nullable":true,"description":"The IP address of the device that the IP Command was sent to or received from. For an IP Command sent to a Super SIM, `device_ip` starts out as `null`, and once the IP Command is “sent”, the `device_ip` will be filled out. An IP Command sent from a Super SIM have its `device_ip` always set."},"device_port":{"type":"integer","default":0,"nullable":true,"description":"For an IP Command sent to a Super SIM, it would be the destination port of the IP message. For an IP Command sent from a Super SIM, it would be the source port of the IP message."},"payload_type":{"$ref":"#/components/schemas/ip_command_enum_payload_type"},"payload":{"type":"string","nullable":true,"description":"The payload that is carried in the IP/UDP message. The payload can be encoded in either text or binary format. For text payload, UTF-8 encoding must be used.\n\nFor an IP Command sent to a Super SIM, the payload is appended to the IP/UDP message “as is”. The payload should not exceed 1300 bytes.\n\nFor an IP Command sent from a Super SIM, the payload from the received IP/UDP message is extracted and sent in binary encoding. For an IP Command sent from a Super SIM, the payload should not exceed 1300 bytes. If it is larger than 1300 bytes, there might be fragmentation on the upstream and the message may appear truncated."},"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."},"date_updated":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."},"url":{"type":"string","format":"uri","nullable":true,"description":"The absolute URL of the IP Command resource."}}},"ip_command_enum_status":{"type":"string","nullable":true,"description":"The delivery status of the IP Command. This is one of the following: “queued”, “sent”, “failed” or “received”.","enum":["queued","sent","received","failed"]},"ip_command_enum_direction":{"type":"string","nullable":true,"description":"Either `to_sim` or `from_sim`. Indicates whether the IP Command resource was sent from or to the Super SIM.","enum":["to_sim","from_sim"]},"ip_command_enum_payload_type":{"type":"string","nullable":true,"description":"Indicates how the payload is encoded. Either “text” or “binary”. For an IP Command sent to a Super SIM, `payload_type` is configurable. For an IP Command sent from a Super SIM, `payload_type` is always “binary”.","enum":["text","binary"]}}},"paths":{"/v1/IpCommands/{Sid}":{"get":{"description":"Fetch IP Command instance from your account.","tags":["SupersimV1IpCommand"],"parameters":[{"name":"Sid","in":"path","description":"The SID of the IP Command resource to fetch.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^HG[0-9a-fA-F]{32}$"},"required":true}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/supersim.v1.ip_command"}}},"headers":{"Access-Control-Allow-Origin":{"description":"Specify the origin(s) allowed to access the resource","schema":{"type":"string"}},"Access-Control-Allow-Methods":{"description":"Specify the HTTP methods allowed when accessing the resource","schema":{"type":"string"}},"Access-Control-Allow-Headers":{"description":"Specify the headers allowed when accessing the resource","schema":{"type":"string"}},"Access-Control-Allow-Credentials":{"description":"Indicates whether the browser should include credentials","schema":{"type":"boolean"}},"Access-Control-Expose-Headers":{"description":"Headers exposed to the client","schema":{"type":"string"}}},"description":"OK"}},"operationId":"FetchIpCommand"}}}}
```

***

## List Your IP Commands

## GET /v1/IpCommands

> Retrieve a list of IP Commands from your account.

```json
{"openapi":"3.0.1","info":{"title":"KORE - Supersim","version":"1.0.0"},"tags":[{"name":"SupersimV1IpCommand"}],"servers":[{"url":"https://supersim.api.korewireless.com"}],"security":[{"OAuth":[]}],"components":{"securitySchemes":{"OAuth":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.korewireless.com/api-services/v1/auth/token","scopes":{}}}}},"schemas":{"ip_command_enum_status":{"type":"string","nullable":true,"description":"The delivery status of the IP Command. This is one of the following: “queued”, “sent”, “failed” or “received”.","enum":["queued","sent","received","failed"]},"ip_command_enum_direction":{"type":"string","nullable":true,"description":"Either `to_sim` or `from_sim`. Indicates whether the IP Command resource was sent from or to the Super SIM.","enum":["to_sim","from_sim"]},"supersim.v1.ip_command":{"type":"object","properties":{"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^HG[0-9a-fA-F]{32}$","nullable":true,"description":"The unique string that we created to identify the IP Command resource."},"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Account](https://docs.korewireless.com/en-us/v/api/global-resources/iam/account) that created the IP Command resource."},"sim_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^HS[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Super SIM](https://docs.korewireless.com/en-us/v/api/products/supersim/sim-resource) that this IP Command was sent to or from."},"sim_iccid":{"type":"string","nullable":true,"description":"The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) of the [Super SIM](https://docs.korewireless.com/en-us/v/api/products/supersim/sim-resource) that this IP Command was sent to or from."},"status":{"$ref":"#/components/schemas/ip_command_enum_status"},"direction":{"$ref":"#/components/schemas/ip_command_enum_direction"},"device_ip":{"type":"string","nullable":true,"description":"The IP address of the device that the IP Command was sent to or received from. For an IP Command sent to a Super SIM, `device_ip` starts out as `null`, and once the IP Command is “sent”, the `device_ip` will be filled out. An IP Command sent from a Super SIM have its `device_ip` always set."},"device_port":{"type":"integer","default":0,"nullable":true,"description":"For an IP Command sent to a Super SIM, it would be the destination port of the IP message. For an IP Command sent from a Super SIM, it would be the source port of the IP message."},"payload_type":{"$ref":"#/components/schemas/ip_command_enum_payload_type"},"payload":{"type":"string","nullable":true,"description":"The payload that is carried in the IP/UDP message. The payload can be encoded in either text or binary format. For text payload, UTF-8 encoding must be used.\n\nFor an IP Command sent to a Super SIM, the payload is appended to the IP/UDP message “as is”. The payload should not exceed 1300 bytes.\n\nFor an IP Command sent from a Super SIM, the payload from the received IP/UDP message is extracted and sent in binary encoding. For an IP Command sent from a Super SIM, the payload should not exceed 1300 bytes. If it is larger than 1300 bytes, there might be fragmentation on the upstream and the message may appear truncated."},"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."},"date_updated":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."},"url":{"type":"string","format":"uri","nullable":true,"description":"The absolute URL of the IP Command resource."}}},"ip_command_enum_payload_type":{"type":"string","nullable":true,"description":"Indicates how the payload is encoded. Either “text” or “binary”. For an IP Command sent to a Super SIM, `payload_type` is configurable. For an IP Command sent from a Super SIM, `payload_type` is always “binary”.","enum":["text","binary"]}}},"paths":{"/v1/IpCommands":{"get":{"description":"Retrieve a list of IP Commands from your account.","tags":["SupersimV1IpCommand"],"parameters":[{"name":"Sim","in":"query","description":"The SID or unique name of the Sim resource that IP Command was sent to or from.","schema":{"type":"string"}},{"name":"SimIccid","in":"query","description":"The ICCID of the Sim resource that IP Command was sent to or from.","schema":{"type":"string"}},{"name":"Status","in":"query","description":"The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://docs.korewireless.com/en-us/v/api/products/supersim/ipcommand-resource#status-values) for a description of each.","schema":{"$ref":"#/components/schemas/ip_command_enum_status"}},{"name":"Direction","in":"query","description":"The direction of the IP 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`.","schema":{"$ref":"#/components/schemas/ip_command_enum_direction"}},{"name":"PageSize","in":"query","description":"How many resources to return in each list page. The default is 50, and the maximum is 100.","schema":{"type":"integer","minimum":1,"maximum":100}},{"name":"Page","in":"query","description":"The page index. This value is simply for client state.","schema":{"type":"integer","minimum":0}},{"name":"PageToken","in":"query","description":"The page token. This is provided by the API.","schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"type":"object","properties":{"ip_commands":{"type":"array","items":{"$ref":"#/components/schemas/supersim.v1.ip_command"}},"meta":{"properties":{"first_page_url":{"format":"uri","type":"string"},"key":{"type":"string"},"next_page_url":{"format":"uri","nullable":true,"type":"string"},"page":{"type":"integer"},"page_size":{"type":"integer"},"previous_page_url":{"format":"uri","nullable":true,"type":"string"},"url":{"format":"uri","type":"string"}},"type":"object"}},"title":"ListIpCommandResponse"}}},"headers":{"Access-Control-Allow-Origin":{"description":"Specify the origin(s) allowed to access the resource","schema":{"type":"string"}},"Access-Control-Allow-Methods":{"description":"Specify the HTTP methods allowed when accessing the resource","schema":{"type":"string"}},"Access-Control-Allow-Headers":{"description":"Specify the headers allowed when accessing the resource","schema":{"type":"string"}},"Access-Control-Allow-Credentials":{"description":"Indicates whether the browser should include credentials","schema":{"type":"boolean"}},"Access-Control-Expose-Headers":{"description":"Headers exposed to the client","schema":{"type":"string"}}},"description":"OK"}},"operationId":"ListIpCommand"}}}}
```

***

## Status Values <a href="#sms-command-resource-status-callbacks" id="sms-command-resource-status-callbacks"></a>

The table below describes the available status values of an IP Command resource. When the API is called to send an IP message to your device, the returned IP Command resource's `status` will be `queued`. The status property will be updated to `sent` when an IP message is sent to the visited cellular network to which your device is connected. If at any point this process fails, and the IP Command is not deliverable, the status property will be updated to `failed` and an error code will be indicated on the resource.

An IP Command resource will have one of the following statuses:

| `queued`   | The IP Command was accepted and is queued in our service waiting to be sent. |
| ---------- | ---------------------------------------------------------------------------- |
| `sent`     | The IP Command was sent to the SIM in the form of an IP message.             |
| `received` | The IP Command was received from the SIM.                                    |
| `failed`   | The IP Command could not be sent.                                            |

## IP Command Resource Callbacks <a href="#sms-command-resource-status-callbacks" id="sms-command-resource-status-callbacks"></a>

You can receive callbacks when:

1. An IP Command resource representing an IP Command to be sent [to your device](#ip-commands-to-sim-mobile-terminated) advances through its statuses. The callback is sent to the URL included in your API request.
2. An IP Command is [received from your device](#ip-commands-from-sim-mobile-originated) and a corresponding IP Command resource is created. The callback is sent to the `ip_commands_callback_url` defined on the Fleet to which the SIM is assigned.

You can see an example below of a request to send an IP Command to a device, the response to that request, and the callback sent after the IP Command was sent.

{% tabs %}
{% tab title="Request" %}

```bash
curl -L -X POST "https://supersim.api.korewireless.com/v1/IpCommands" \
--header "Authorization: Bearer <YOUR_AUTH_TOKEN>" \
--data-urlencode "Payload={\"enable\":\"True\", \"reset\":\"False\",\"when\":\"Immediate\"}" \
--data-urlencode "Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
--data-urlencode "DevicePort=3030" \
--data-urlencode "CallbackUrl=<YOUR_CALLBACK_URL>" \
--data-urlencode "CallbackMethod=GET"
```

{% endtab %}

{% tab title="Response" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong><strong>    "account_sid":"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
</strong>    "sid":"HCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "sim_sid":"HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "sim_iccid":"89nnnnnnnnnnnnnnnnnn",
    "date_created":"2024-10-24T20:39:13.474616Z",
    "date_updated":"2024-10-24T20:39:13.474616Z",
    "device_port":3030,
    "payload":"{\"command\":\"wake up\",\"timestamp\":\"2024-03-08-14-02-49}\"",
    "payload_type":"text",
    "status":"queued",
    "device_ip":null,
    "error_code":null,
    "direction":"to_sim",   
    "url":"https://supersim.api.korewireless.com/v1/IpCommands/HGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
</code></pre>

{% endtab %}

{% tab title="Callback" %}

<pre><code>Status sent
<strong>ApiVersion v1
</strong>SimUniqueName Parking-Meter-Lot-Area-001
Payload {"enable":"True", "reset":"False","when":"Immediate"}
SimSid HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
CommandSid HGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Direction to_sim
AccountSid ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
SimIccid 89nnnnnnnnnnnnnnnnnn
PayloadType text
</code></pre>

{% endtab %}
{% endtabs %}

The request sent to the callback URL contains the following properties:

| `AccountSid`    | The SID of the Account that the SMS Command resource belongs to. For example: `ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`                                                                                           |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `CommandSid`    | The unique string that we created to identify the SMS Command resource. For example: `HGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`                                                                                    |
| `SimSid`        | The receiving Super SIM's SID. For example: `HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`                                                                                                                             |
| `SimUniqueName` | <p>The receiving Super SIM's <code>UniqueName</code>. For example:<br><code>Parking-Meter-Lot-Area-001</code></p>                                                                                            |
| `Payload`       | <p>The body of the SMS Command message. This value can be up to 160 characters of text. Binary mode is not supported. For example:<br><code>{"enable":"True", "reset":"False","When":"Immediate"}</code></p> |
| `PayloadType`   | `text` mode by default. Binary mode is not supported.                                                                                                                                                        |
| `Direction`     | Indicates whether the Command is MT or MO. It has two possible values: `to_sim` or `from_sim`.                                                                                                               |
| `Status`        | The delivery status of the SMS Command.                                                                                                                                                                      |
| `ErrorCode`     | The error code (if any) associated with a failed SMS Command. Unless the status is `failed`, `ErrorCode` will not be present.                                                                                |
| `ErrorMessage`  | A description of the error (if any) associated with a failed SMS Command. Unless the status is `failed`, `ErrorMessage` will not be present.                                                                 |

## Error Scenarios

### Synchronous Errors

The following scenarios will return a synchronous 4xx error:

* **Unknown SIM** — The SIM SID or Unique Name given to the API does not belong to the requesting account.
* **Invalid SIM State** — The SIM to which the IP Command would be sent is neither `active` nor `ready`.
* **Payload Too Big** — The decoded payload is too large to send in a single UDP request. The maximum size is 1300 bytes. This will produce an HTTP error 400.

### Asynchronous Errors <a href="#asynchronous-errors" id="asynchronous-errors"></a>

The following scenarios will result in the IP Command initially being accepted and an IP Command resource created, but they will ultimately fail. A `failed` status callback will be sent to your `callback_url` if one was provided in your create request:

* **Device Not Attached** — The device was not attached to a cellular network when the IP Command was dequeued. The Command was not sent to the device.

***

## Retention Period <a href="#retention-period" id="retention-period"></a>

IP Commands are retained for 30 days from the time they are created. IP Commands older than 30 days will no longer be readable from this resource.
