Settling Transactions
Learn to use the AvaTax API to commit or settle a tax transaction.
We'll cover the following...
Committing and verifying transactions is essential in separating approximate estimates from final sales. Doing this allows us to report to the taxation authorities only the sales that we make. This helps our company during tax audits.
Committing a transaction
We use the {{BASE_URL}}/companies/{{companyCode}}/transactions/{{transactionCode}}/commit
endpoint to commit existing uncommitted transactions. The complete endpoint URL for committing a transaction is as follows:
https://sandbox-rest.avatax.com/api/v2/companies/{{companyCode}}/transactions/{{transactionCode}}/commit
Some of the request parameters for the URL above are as follows:
Request Parameters
Name | Type | Parameter Type | Category | Description |
| string | Path | Required | This parameter specifies the company code of the company associated with the transaction. |
| string | Path | Required | This parameter specifies the transaction's unique code, allowing us to reference the transaction to adjust it quickly. |
| string | Query | Optional | This parameter specifies any objects we want the API to add in the API response to our request. |
| string | Query | Optional | This parameter specifies the company code of the company associated with the transaction. The default value of this parameter is |
| boolean | Body | Optional | This parameter specifies whether to commit the referenced transaction. |
Let’s see how to make an API call to void an existing transaction. Click the “Run” button to execute the code.
# Account ID and License Keyaccount_id = "{{ACCOUNT_ID}}"license_key = "{{LICENSE_KEY}}"# Transaction and Company Codestransaction_code = create_transaction(account_id, license_key)company_code = "{{COMPANY_CODE}}"# Endpoint URLendpoint_url = f"https://sandbox-rest.avatax.com/api/v2/companies/{company_code}/transactions/{transaction_code}/commit"# Creating a basic auth token using account ID and license keyauth_token = requests.auth.HTTPBasicAuth(account_id, license_key)# Define query parameters hereparameters = {"$documentType": "SalesInvoice",}# Define body parameters heredata_obj = {"commit": True}# Making a POST request to the AvaTax APIresponse = requests.post(url=endpoint_url, auth=auth_token,params=parameters, json=data_obj)# Printing responseprint_response(response)
Here's an explanation for the code widget ...