Capital asset json format

I’m making a script using python to upload expenses based on extracted receipt information. The script uploads each receipt as either a capital asset or expense. However, I haven’t been able to upload capital assets yet.

So my question is,: what’s the correct format to upload capital assets through the API? Is it supposed to be the same as an expense but with a capital asset category or something entirely different? It seems like the documentation might have some outdated information.

I was able to upload regular expenses fairly easily but I just can’t get capital assets right. Can anyone help me figure this out please?

Can’t you just give it a category in the assets & stock list? It’s possible you can’t but that’s how it works on the web…

I tried that, below is what I am using for testing. Using any other category works fine and the expense uploads to my account.

However, whenever I set the category link to the Capital Asset Purchase one it doesn’t upload and gives error 422 {‘errors’: [{‘message’: “category can’t be blank”}]}. Is there something I might be missing?

{
  "expense": {
    "user": "[my user link]",
    "dated_on": "2024-12-30",
    "description": "Description",
    "gross_value": -5.99,
    "category": "https://api.freeagent.com/v2/categories/602",
    "asset_life_years": 5,
    "sales_tax_value": -1.0,
    "ec_status": "UK/Non-EC",
    "attachment": {
      "data": "[encrypted file data]",
      "file_name": "Name.pdf",
      "description": "Receipt Name",
      "content_type": "application/x-pdf"
    }
  }
}

After some tinkering I have found a solution, turns out that the links to each capital asset category have an index at the end that corresponds to the order they appear in the UI. Not sure how to get these from the API so I hardcoded them in my script for now.

"Computer Equipment Purchase": "https://api.freeagent.com/v2/categories/602-1",
"Fixtures and Fittings Purchase": "https://api.freeagent.com/v2/categories/602-2",
"Motor Vehicle Purchase": "https://api.freeagent.com/v2/categories/602-3",
"Other Capital Asset Purchase": "https://api.freeagent.com/v2/categories/602-4",
"Land and Property Purchase": "https://api.freeagent.com/v2/categories/602-5"