Avalara Developer Network Developer blog

Renaming Transactions

You’re building your integration using the AvaTax REST API. The way your application works; you only have access to a temporary invoice number and at the end of all the processing your system assigns a permanent invoice number. Given this; how can you keep the final values assigned by your application in sync with AvaTax?

Renaming a Transaction

Let’s review an example…First; we call CreateTransaction and we can let AvaTax assign a unique “code” for us which we will capture and remember from the AvaTax response. Notice we also set the “commit” flag to “false” in this request because once we commit the document, we will not be able to change the transaction code.

    "companyCode": "DEFAULT",
    "type": "SalesInvoice",
    "commit": "false",
    "customerCode": "TOI",
    "date": "2017-10-09",
    "lines": [{
        "number": "Line 1",
        "quantity": 10,
        "amount": 1000,
        "taxCode": "PC040100",
        "description": "Baseball Cap",
        "addresses": {
            "ShipFrom": {
                "line1": "2790 NE Strand Rd",
                "city": "Bremerton",
                "region": "WA",
                "country": "US",
                "postalCode": "98311"
            "ShipTo": {
                "line1": "26772 Calle Maria",
                "city": "Capistrano Beach",
                "region": "CA",
                "country": "US",
                "postalCode": "92624"

Next; using ChangeTransactionCode, we will match what our application has assigned to the record.

    "newCode": "Invoice-3025"

Now we can easily cross-reference posted transactions in our Application with recorded transactions in AvaTax.

Handling Errors

There are a few types of errors you might get back when calling the ChangeTransactionCode API:

  • Did you remember to put the correct original code in the request? If not, you will get a EnitityNotFoundError.
  • Is your transaction committed in AvaTax? If so, you will get a DocStatusError.
  • If you do not provide a value for the newCode, you will get a ValueRequiredError.

Remember to use the CommitTransaction API to finalize the renamed transaction in AvaTax. Also; if the transaction your trying to change is “locked” you will not be able to change the transaction code.

-Mark Withers Partner Launch Team

Back to posts