Bank transaction not found

Hi. I’m trying to Create a bank transaction explanation and upload a PDF.

If the root element is “bank_transaction_explanation” I get an error “Bank transaction not found for this company” (I have verified the transaction and can request it via API so that’s not the problem).

If I change it to “bank_transaction_explanations”, I get a dated_on error (“dated_on is not valid”). I have tried using our original transaction date, the date returned from the transaction lookup, and removing the element altogether, but to no avail.

Thanks, Nik

Hi Nik :wave:

I’m Brad from the Banking team at FreeAgent.

Sorry to hear that you are having trouble creating an explanation via our https://api.freeagent.com/v2/bank_transaction_explanations API endpoint.

You can create an explanation with a payload like this:

{
  "bank_transaction_explanation": {
    "bank_transaction": "https://api.freeagent.com/v2/bank_transactions/123456",
    "dated_on": "2025-01-17",
    "gross_value": "-250.00",
    "description": "Supplies",
  }
}

I’ve had a look at our logs and can you double check that you are sending us the correct value for bank_transaction, specifically the number after the last / (i.e. 123456 in my example above). I can see a few failing requests that are using a ID of a bank transaction that doesn’t exist.

Hi Brad. Thanks for the response. I’m getting successful response searching for that transaction ID, so it must exist.

I’m finding unexplained transactions, grabbing the transaction ID, searching for it, confirming it exists, then trying to explain it.

But without the “s”, I consistently get the error “Bank transaction not found for this company”

Does this payload look OK?

{
“bank_transaction_explanation”: {
“bank_transaction”: “https://api.freeagent.com/v2/bank_transactions/1737010204”,
“bank_account”: “https://api.freeagent.com/v2/bank_accounts/1535961”,
“dated_on”: “2025-01-15”,
“gross_value”: “-271.96”
}

Hi Nik :wave:

That payload looks good but it is missing a closing } at the end of it. The root element is singular so using bank_transaction_explanation is correct (rather than bank_transaction_explanations).

I’ve just checked and I can confirm that bank transaction https://api.freeagent.com/v2/bank_transactions/1737010204 does not exist within FreeAgent and this is why you are getting the Bank transaction not found for this company error.

Would you be able to share where you are retrieving this value from? The easiest way to get it would be by calling our https://api.freeagent.com/v2/bank_transactions endpoint and getting the value from the url parameter for each bank transaction.

Oh. Sounds like my mistake - I assumed that transactionId was the transaction ID I needed. I’ve just tried again using the URL and seem to be getting somewhere.

I’m now left with
Response: {“errors”:[{“message”:“category can’t be blank”}]} (Status Code: 422)

So hopefully if I can work out what category needs to be I might be in business.

Thanks

PS - I’m assuming transaction_id is a timestamp or something, but it doesn’t half confuse things when you’re looking for a transaction ID and it’s in the URL, and the transaction_id field isn’t actually the transaction you’re after

Yep, you should be able to provide a category attribute in the payload. We have documentation on the available categories here and you’ll want to use the url too. For example:

{
  "bank_transaction_explanation": {
    "bank_transaction": "https://api.freeagent.com/v2/bank_transactions/123456",
    "dated_on": "2025-01-17",
    "gross_value": "-250.00",
    "description": "Supplies",
    "category": "https://api.freeagent.com/v2/categories/103" # This is for the 'Materials' category.
  }
}

Sorry for the confusion here. The transaction_id is provided to us by your bank if you have a bank feed enabled or API app if the transaction was created via our API, but when using the API to retrieve the transaction or create explanations, you’ll want to use the url instead.


Give us a shout on here if you run into any other issues using our API. Thanks for using FreeAgent!

Thank you - I have tested this successfully now and can upload an attachment. Have a great weekend

1 Like