# 9 - External IDs

Up to this point we have been getting the status of a transaction using the transaction ID returned by the API call used to start the transaction.

But... what happens if there is a network failure during that initial call? There is no way to know if the transaction started or not, and no way to know the transaction ID so we can get the result of the transaction.

To get around this potential scenario, we allow the client to specify their own unique ID, called an externalId. This is a string up to 32 characters that must be unique. If the client tries to start another transaction with the same externalId an error will bre returned.

# Starting a transaction with an externalId

In MONDAT, start the null transaction with an external ID by providing it in the metadata:

{
  "metadata": {
    "reply": "shortpoll",
    "externalID": "abc123"
  },
  "data": {}
}
1
2
3
4
5
6
7

This should complete as expected. If you then press the Run Test button a second time you will get an error message.

{
  "code": "Internal",
  "message": "Error: CANNOT CREATE A DUPLICATE TRANSACTION"
}
1
2
3
4

# Getting the status using an externalId

We get the status of a transaction using an externalId in much the same way as with using a transaction ID.

In Postman, try the following URLs:

http://localhost:33370/datp/1.0/tx/statusByExternalId/abc123        (defaults to shortpoll) http://localhost:33370/datp/1.0/tx/statusByExternalId/abc123&reply=longpoll

# Next...

In the next section we look at how to call a DATP transaction from a client application.

Deployed on Github Pages.
Last updated: 2023-05-17, 15:37:23 UTC