> For the complete documentation index, see [llms.txt](https://docs.payments.thalescloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payments.thalescloud.io/transit-classic/api-reference/outgoing-api-to-tes/device-gateway-api.md).

# Device Gateway API

[TES-OUT-v1-device-gateway.yaml](https://openapi.gitbook.com/o/fwy1mtbRONGA2YDKDBr0/spec/TES-OUT-v1-device-gateway.yaml)

## Request to provide the next list of commands to be executed on a device

> This method is used by TSH to request the pending commands to be executed on a device.\</br> It is used for reading/updating the content of a device (e.g. topup).\</br> The TES has to return the list of commands that needs to be executed on the device after checking the previous commands responses.\</br>

```json
{"openapi":"3.1.1","info":{"title":"Gemalto TSH Device Gateway API - TSH to TES","version":"1.0.20"},"servers":[{"url":"/tes/devicegtwapi/1/0"}],"paths":{"/getCardCommands":{"post":{"summary":"Request to provide the next list of commands to be executed on a device","description":"This method is used by TSH to request the pending commands to be executed on a device.</br> It is used for reading/updating the content of a device (e.g. topup).</br> The TES has to return the list of commands that needs to be executed on the device after checking the previous commands responses.</br>","operationId":"getCardCommands","parameters":[{"$ref":"#/components/parameters/actorHeader"}],"responses":{"200":{"description":"getCardCommands response payload","content":{"application/json":{"schema":{"$ref":"#/components/schemas/getCardCommandsRes"}}}},"500":{"description":"Internal Server Error"}},"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/getCardCommandsReq"}}},"description":"getCardCommands request payload","required":true}}}},"components":{"parameters":{"actorHeader":{"schema":{"type":"string","maxLength":32},"description":"HTTP header identifying the actor initiating the request.","in":"header","name":"x-actor-id","required":true}},"schemas":{"getCardCommandsRes":{"type":"object","required":["responseHeader"],"properties":{"responseHeader":{"$ref":"#/components/schemas/responseHeader"},"commands":{"$ref":"#/components/schemas/commands"}}},"responseHeader":{"type":"object","required":["responseId","sessionId","statusCode"],"properties":{"responseId":{"$ref":"#/components/schemas/responseId"},"sessionId":{"$ref":"#/components/schemas/sessionId"},"generationDateTime":{"$ref":"#/components/schemas/generationDateTime"},"statusCode":{"$ref":"#/components/schemas/statusCode"},"statusMessage":{"$ref":"#/components/schemas/statusMessage"}}},"responseId":{"description":"Unique response identifier","maxLength":48,"minLength":1,"type":"string"},"sessionId":{"description":"Unique session identifier used to trace the calls across systems during a use case.","maxLength":48,"minLength":1,"type":"string"},"generationDateTime":{"description":"Date time representing when the request or response has been generated.<br/>RFC3339 format.<br/> Examples:<li>\"2018-12-24T17:32:28Z\"<li>\"2019-10-02T10:00:00-05:00\"","type":"string","format":"date-time"},"statusCode":{"type":"number","description":"Status code to the request\n|Status code | Description|\n|-------|-------|\n|0|OK|\n|111|Missing mandatory parameter|\n|112|Bad parameter format|\n|113|Unknown issuer|\n|117|Unknown device|\n|118|Unknown session|\n|119|Unknown virtual card|\n|159|Card is blacklisted|\n|160|Card is deleted|\n|162|Card has unsufficient balance|\n|163|Card product not eligible|\n|167|Card is already provisioned|\n|172|Invalid card, unsupported system code|\n|173|Invalid card, unsupported service|\n|177|Invalid card, invalid area data|\n|178|Invalid card, card status is in-station|\n|191|Card is expired|\n|192|Reader mode attempt exceeded allowed threshold|\n|221|Device or wallet server not accessible|\n|231|Device unexpected error|\n|232|Device out of memory error|\n|321|Operation already on-going for this device|\n|322|Time to live of the operation expired|\n|323|Operation incomplete|      \n|911|Operation failed|\n|921|Unexpected server error|\n"},"statusMessage":{"type":"string","description":"Textual status message"},"commands":{"type":"array","maxItems":200,"description":"List of commands to be executed on the device.","items":{"type":"object","properties":{"id":{"type":"string","description":"ID of the command","maxLength":64,"minLength":1},"name":{"type":"string","description":"Descriptive name of the command","maxLength":100,"minLength":1},"value":{"type":"string","description":"Hex encoded string command value","maxLength":512,"minLength":1}}}},"getCardCommandsReq":{"type":"object","required":["requestHeader","issuerId","cardId","deviceId"],"properties":{"requestHeader":{"$ref":"#/components/schemas/requestHeader"},"issuerId":{"$ref":"#/components/schemas/issuerId"},"cardId":{"$ref":"#/components/schemas/cardId"},"purchaseId":{"maxLength":64,"minLength":1,"type":"string","description":"The Purchase Identifier. Unique for each purchase.<br/> It is provided when the call is related to topup initiated from wallet."},"deviceId":{"$ref":"#/components/schemas/deviceId"},"operation":{"$ref":"#/components/schemas/operation"},"responses":{"$ref":"#/components/schemas/responses"},"responseTimeMs":{"$ref":"#/components/schemas/responseTimeMs"},"statusCode":{"$ref":"#/components/schemas/statusCode"},"statusMessage":{"$ref":"#/components/schemas/statusMessage"}}},"requestHeader":{"type":"object","required":["requestId","sessionId"],"properties":{"requestId":{"$ref":"#/components/schemas/requestId"},"sessionId":{"$ref":"#/components/schemas/sessionId"},"generationDateTime":{"$ref":"#/components/schemas/generationDateTime"}}},"requestId":{"description":"Unique request identifier","maxLength":48,"minLength":1,"type":"string"},"issuerId":{"maxLength":16,"minLength":1,"type":"string","description":"The Card Issuer Identifier. Unique for each card issuer."},"cardId":{"maxLength":48,"minLength":1,"type":"string","description":"The Card Identifier. Unique for each card."},"deviceId":{"maxLength":48,"minLength":1,"type":"string","description":"The Device Identifier. Unique for each device."},"operation":{"type":"string","description":"The operation for which the commands are requested","enum":["READ_BALANCE","UPDATE_BALANCE","UPDATE_CONFIG","UPDATE_PLAN","ERASE_CARD","PARK_CARD","BLOCK_AND_READ_CARD"]},"responses":{"type":"array","maxItems":200,"description":"List of the responses executed on the device.","items":{"type":"object","properties":{"id":{"type":"string","description":"ID of the command that has been executed.</br> Extracted from the original message.","maxLength":64,"minLength":1},"name":{"type":"string","description":"Descriptive name of the command that has been executed.</br> Extracted from the original message and appended with \"_RESP\"","maxLength":100,"minLength":1},"value":{"type":"string","description":"Hex encoded string command response","maxLength":512,"minLength":1}}}},"responseTimeMs":{"type":"number","format":"double","description":"Total time of all executed commands listed in responses array in milliseconds."}}}}
```

## Request to provide the next list of commands to be executed on a device for parking a card

> This method is used by TSH to request the pending commands to be executed on a device.\</br> It is used for parking a card (meaning reading the current balance of a card for storing it on server side).\</br> The TES has to return the list of commands that needs to be executed on the device after checking the previous commands responses.\</br> Once the card has been parked on TES side, the TES has to return the card balance to TSH on last response.

```json
{"openapi":"3.1.1","info":{"title":"Gemalto TSH Device Gateway API - TSH to TES","version":"1.0.20"},"servers":[{"url":"/tes/devicegtwapi/1/0"}],"paths":{"/getParkCardCommands":{"post":{"summary":"Request to provide the next list of commands to be executed on a device for parking a card","description":"This method is used by TSH to request the pending commands to be executed on a device.</br> It is used for parking a card (meaning reading the current balance of a card for storing it on server side).</br> The TES has to return the list of commands that needs to be executed on the device after checking the previous commands responses.</br> Once the card has been parked on TES side, the TES has to return the card balance to TSH on last response.","operationId":"getParkCardCommands","parameters":[{"$ref":"#/components/parameters/actorHeader"}],"responses":{"200":{"description":"getParkCardCommands response payload","content":{"application/json":{"schema":{"$ref":"#/components/schemas/getParkCardCommandsRes"}}}},"500":{"description":"Internal Server Error"}},"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/getParkCardCommandsReq"}}},"description":"getParkCardCommands request payload","required":true}}}},"components":{"parameters":{"actorHeader":{"schema":{"type":"string","maxLength":32},"description":"HTTP header identifying the actor initiating the request.","in":"header","name":"x-actor-id","required":true}},"schemas":{"getParkCardCommandsRes":{"type":"object","required":["responseHeader"],"properties":{"responseHeader":{"$ref":"#/components/schemas/responseHeader"},"commands":{"$ref":"#/components/schemas/commands"},"cardData":{"$ref":"#/components/schemas/cardData"}}},"responseHeader":{"type":"object","required":["responseId","sessionId","statusCode"],"properties":{"responseId":{"$ref":"#/components/schemas/responseId"},"sessionId":{"$ref":"#/components/schemas/sessionId"},"generationDateTime":{"$ref":"#/components/schemas/generationDateTime"},"statusCode":{"$ref":"#/components/schemas/statusCode"},"statusMessage":{"$ref":"#/components/schemas/statusMessage"}}},"responseId":{"description":"Unique response identifier","maxLength":48,"minLength":1,"type":"string"},"sessionId":{"description":"Unique session identifier used to trace the calls across systems during a use case.","maxLength":48,"minLength":1,"type":"string"},"generationDateTime":{"description":"Date time representing when the request or response has been generated.<br/>RFC3339 format.<br/> Examples:<li>\"2018-12-24T17:32:28Z\"<li>\"2019-10-02T10:00:00-05:00\"","type":"string","format":"date-time"},"statusCode":{"type":"number","description":"Status code to the request\n|Status code | Description|\n|-------|-------|\n|0|OK|\n|111|Missing mandatory parameter|\n|112|Bad parameter format|\n|113|Unknown issuer|\n|117|Unknown device|\n|118|Unknown session|\n|119|Unknown virtual card|\n|159|Card is blacklisted|\n|160|Card is deleted|\n|162|Card has unsufficient balance|\n|163|Card product not eligible|\n|167|Card is already provisioned|\n|172|Invalid card, unsupported system code|\n|173|Invalid card, unsupported service|\n|177|Invalid card, invalid area data|\n|178|Invalid card, card status is in-station|\n|191|Card is expired|\n|192|Reader mode attempt exceeded allowed threshold|\n|221|Device or wallet server not accessible|\n|231|Device unexpected error|\n|232|Device out of memory error|\n|321|Operation already on-going for this device|\n|322|Time to live of the operation expired|\n|323|Operation incomplete|      \n|911|Operation failed|\n|921|Unexpected server error|\n"},"statusMessage":{"type":"string","description":"Textual status message"},"commands":{"type":"array","maxItems":200,"description":"List of commands to be executed on the device.","items":{"type":"object","properties":{"id":{"type":"string","description":"ID of the command","maxLength":64,"minLength":1},"name":{"type":"string","description":"Descriptive name of the command","maxLength":100,"minLength":1},"value":{"type":"string","description":"Hex encoded string command value","maxLength":512,"minLength":1}}}},"cardData":{"type":"object","properties":{"balanceAmount":{"$ref":"#/components/schemas/balanceAmount"}}},"balanceAmount":{"type":"number","format":"double","description":"The current balance amount of the card"},"getParkCardCommandsReq":{"type":"object","required":["requestHeader","issuerId","cardId","deviceId"],"properties":{"requestHeader":{"$ref":"#/components/schemas/requestHeader"},"issuerId":{"$ref":"#/components/schemas/issuerId"},"cardId":{"$ref":"#/components/schemas/cardId"},"deviceId":{"$ref":"#/components/schemas/deviceId"},"operation":{"$ref":"#/components/schemas/operation"},"responses":{"$ref":"#/components/schemas/responses"},"responseTimeMs":{"$ref":"#/components/schemas/responseTimeMs"},"statusCode":{"$ref":"#/components/schemas/statusCode"},"statusMessage":{"$ref":"#/components/schemas/statusMessage"}}},"requestHeader":{"type":"object","required":["requestId","sessionId"],"properties":{"requestId":{"$ref":"#/components/schemas/requestId"},"sessionId":{"$ref":"#/components/schemas/sessionId"},"generationDateTime":{"$ref":"#/components/schemas/generationDateTime"}}},"requestId":{"description":"Unique request identifier","maxLength":48,"minLength":1,"type":"string"},"issuerId":{"maxLength":16,"minLength":1,"type":"string","description":"The Card Issuer Identifier. Unique for each card issuer."},"cardId":{"maxLength":48,"minLength":1,"type":"string","description":"The Card Identifier. Unique for each card."},"deviceId":{"maxLength":48,"minLength":1,"type":"string","description":"The Device Identifier. Unique for each device."},"operation":{"type":"string","description":"The operation for which the commands are requested","enum":["READ_BALANCE","UPDATE_BALANCE","UPDATE_CONFIG","UPDATE_PLAN","ERASE_CARD","PARK_CARD","BLOCK_AND_READ_CARD"]},"responses":{"type":"array","maxItems":200,"description":"List of the responses executed on the device.","items":{"type":"object","properties":{"id":{"type":"string","description":"ID of the command that has been executed.</br> Extracted from the original message.","maxLength":64,"minLength":1},"name":{"type":"string","description":"Descriptive name of the command that has been executed.</br> Extracted from the original message and appended with \"_RESP\"","maxLength":100,"minLength":1},"value":{"type":"string","description":"Hex encoded string command response","maxLength":512,"minLength":1}}}},"responseTimeMs":{"type":"number","format":"double","description":"Total time of all executed commands listed in responses array in milliseconds."}}}}
```

## Request to provide the next list of reader mode commands to be executed on a device

> This method is used by TSH to request the pending reader mode commands to be executed on a device.\</br> It is used for reading/updating the content of an external device.\</br> The TES has to return the list of commands that needs to be executed on the device after checking the previous commands responses.\</br> Once the card has been ingested on TES side, the TES has to create a new card account and return the card balance and card account identifier to TSH on last response.

````json
{"openapi":"3.1.1","info":{"title":"Gemalto TSH Device Gateway API - TSH to TES","version":"1.0.20"},"servers":[{"url":"/tes/devicegtwapi/1/0"}],"paths":{"/getReaderModeCommands":{"post":{"summary":"Request to provide the next list of reader mode commands to be executed on a device","description":"This method is used by TSH to request the pending reader mode commands to be executed on a device.</br> It is used for reading/updating the content of an external device.</br> The TES has to return the list of commands that needs to be executed on the device after checking the previous commands responses.</br> Once the card has been ingested on TES side, the TES has to create a new card account and return the card balance and card account identifier to TSH on last response.","operationId":"getReaderModeCommands","parameters":[{"$ref":"#/components/parameters/actorHeader"}],"responses":{"200":{"description":"getReaderModeCommands response payload","content":{"application/json":{"schema":{"$ref":"#/components/schemas/getReaderModeCommandsRes"}}}},"500":{"description":"Internal Server Error"}},"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/getReaderModeCommandsReq"}}},"description":"getReaderModeCommands request payload","required":true}}}},"components":{"parameters":{"actorHeader":{"schema":{"type":"string","maxLength":32},"description":"HTTP header identifying the actor initiating the request.","in":"header","name":"x-actor-id","required":true}},"schemas":{"getReaderModeCommandsRes":{"type":"object","required":["responseHeader"],"properties":{"responseHeader":{"$ref":"#/components/schemas/responseHeader"},"commands":{"$ref":"#/components/schemas/commands"},"cardAccountId":{"$ref":"#/components/schemas/cardAccountId"},"cardData":{"$ref":"#/components/schemas/cardData"}}},"responseHeader":{"type":"object","required":["responseId","sessionId","statusCode"],"properties":{"responseId":{"$ref":"#/components/schemas/responseId"},"sessionId":{"$ref":"#/components/schemas/sessionId"},"generationDateTime":{"$ref":"#/components/schemas/generationDateTime"},"statusCode":{"$ref":"#/components/schemas/statusCode"},"statusMessage":{"$ref":"#/components/schemas/statusMessage"}}},"responseId":{"description":"Unique response identifier","maxLength":48,"minLength":1,"type":"string"},"sessionId":{"description":"Unique session identifier used to trace the calls across systems during a use case.","maxLength":48,"minLength":1,"type":"string"},"generationDateTime":{"description":"Date time representing when the request or response has been generated.<br/>RFC3339 format.<br/> Examples:<li>\"2018-12-24T17:32:28Z\"<li>\"2019-10-02T10:00:00-05:00\"","type":"string","format":"date-time"},"statusCode":{"type":"number","description":"Status code to the request\n|Status code | Description|\n|-------|-------|\n|0|OK|\n|111|Missing mandatory parameter|\n|112|Bad parameter format|\n|113|Unknown issuer|\n|117|Unknown device|\n|118|Unknown session|\n|119|Unknown virtual card|\n|159|Card is blacklisted|\n|160|Card is deleted|\n|162|Card has unsufficient balance|\n|163|Card product not eligible|\n|167|Card is already provisioned|\n|172|Invalid card, unsupported system code|\n|173|Invalid card, unsupported service|\n|177|Invalid card, invalid area data|\n|178|Invalid card, card status is in-station|\n|191|Card is expired|\n|192|Reader mode attempt exceeded allowed threshold|\n|221|Device or wallet server not accessible|\n|231|Device unexpected error|\n|232|Device out of memory error|\n|321|Operation already on-going for this device|\n|322|Time to live of the operation expired|\n|323|Operation incomplete|      \n|911|Operation failed|\n|921|Unexpected server error|\n"},"statusMessage":{"type":"string","description":"Textual status message"},"commands":{"type":"array","maxItems":200,"description":"List of commands to be executed on the device.","items":{"type":"object","properties":{"id":{"type":"string","description":"ID of the command","maxLength":64,"minLength":1},"name":{"type":"string","description":"Descriptive name of the command","maxLength":100,"minLength":1},"value":{"type":"string","description":"Hex encoded string command value","maxLength":512,"minLength":1}}}},"cardAccountId":{"maxLength":48,"minLength":1,"type":"string","description":"The Card Account Identifier. Unique for each card account."},"cardData":{"type":"object","properties":{"balanceAmount":{"$ref":"#/components/schemas/balanceAmount"}}},"balanceAmount":{"type":"number","format":"double","description":"The current balance amount of the card"},"getReaderModeCommandsReq":{"type":"object","required":["requestHeader","issuerId","deviceId"],"properties":{"requestHeader":{"$ref":"#/components/schemas/requestHeader"},"issuerId":{"$ref":"#/components/schemas/issuerId"},"deviceId":{"$ref":"#/components/schemas/deviceId"},"operation":{"$ref":"#/components/schemas/operation"},"responses":{"$ref":"#/components/schemas/responses"},"responseTimeMs":{"$ref":"#/components/schemas/responseTimeMs"},"cardContents":{"$ref":"#/components/schemas/cardContents"},"statusCode":{"$ref":"#/components/schemas/statusCode"},"statusMessage":{"$ref":"#/components/schemas/statusMessage"}}},"requestHeader":{"type":"object","required":["requestId","sessionId"],"properties":{"requestId":{"$ref":"#/components/schemas/requestId"},"sessionId":{"$ref":"#/components/schemas/sessionId"},"generationDateTime":{"$ref":"#/components/schemas/generationDateTime"}}},"requestId":{"description":"Unique request identifier","maxLength":48,"minLength":1,"type":"string"},"issuerId":{"maxLength":16,"minLength":1,"type":"string","description":"The Card Issuer Identifier. Unique for each card issuer."},"deviceId":{"maxLength":48,"minLength":1,"type":"string","description":"The Device Identifier. Unique for each device."},"operation":{"type":"string","description":"The operation for which the commands are requested","enum":["READ_BALANCE","UPDATE_BALANCE","UPDATE_CONFIG","UPDATE_PLAN","ERASE_CARD","PARK_CARD","BLOCK_AND_READ_CARD"]},"responses":{"type":"array","maxItems":200,"description":"List of the responses executed on the device.","items":{"type":"object","properties":{"id":{"type":"string","description":"ID of the command that has been executed.</br> Extracted from the original message.","maxLength":64,"minLength":1},"name":{"type":"string","description":"Descriptive name of the command that has been executed.</br> Extracted from the original message and appended with \"_RESP\"","maxLength":100,"minLength":1},"value":{"type":"string","description":"Hex encoded string command response","maxLength":512,"minLength":1}}}},"responseTimeMs":{"type":"number","format":"double","description":"Total time of all executed commands listed in responses array in milliseconds."},"cardContents":{"type":"object","description":"This object gives a description of the external SE.</br> For FeliCa, the following can be provided:\n```\n\"cardContents\": {\n\t\"cardServiceId\" : \"Test Service\",\n\t\"systemCode\" : \"FE00\",\n\t\"idm\" : \"1122334455667788\",\n\t\"pmm\" : \"0000000000000000\",\n\t\"areaCodeList\" : [\n\t\t{\n\t\t\t\"areaCode\" : \"0100\",\n\t\t\t\"keyVersion\" : \"6745\"\n\t\t},\n\t\t{\n\t\t\t\"areaCode\" : \"1000\",\n\t\t\t\"keyVersion\" : \"4567\"\n\t\t}\n\t]\n}\n```"}}}}
````


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.payments.thalescloud.io/transit-classic/api-reference/outgoing-api-to-tes/device-gateway-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
