POSTing split transactions

Do you have an example of creating a new transaction that is split? I've tried several things through the API, but nothing seems to work. Is this supported? If not, do you have a timeline for it? If it is supported, can we have an example json that works? Thanks!

57replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Split transactions are now supported!  You can specify a "subtransactions" array when creating or updating a transaction like this:

    curl -H "Authorization: Bearer $API_ACCESS_TOKEN" https://api.youneedabudget.com/v1/budgets/last-used/transactions -H "Content-Type: application/json" -X POST --data-binary @- << EOF
    {
       "transaction":{
          "account_id":"00d17281-a898-4bac-a3e4-0cbcb947c6e7",
          "date":"2020-02-18",
          "amount":-200000,
          "memo":"This is a split",
          "subtransactions":[
             {
                "amount":-100000,
                "payee_name":"Split payee",
                "category_id":"99e33804-e58f-4121-9930-ba013c8bb4c3",
                "memo":"Split 1"
             },
             {
                "amount":-100000,
                "payee_id":"f7d7779a-0084-4023-91fd-7de2a80f9105",
                "category_id":"3b9dcabc-ca09-4c7f-a26e-cb823209194d",
                "memo":"Split 2"
             }
          ]
       }
    }
    EOF

    See the API Endpoint Documentation for more details.

    The client libraries have not been updated to support splits yet, but will be in the near future.

    Like 5
      • Alfred
      • firnnauriel
      • 6 mths ago
      • 1
      • Reported - view

      Brady Fantastic news! I'll test it sometime this week. Thanks for the work.

      Like 1
    • Brady Cool. But I‘m not able to create a transaction with a transfer as a subtransaction. I tried with payee_name and payee_id. But the subtransaction has no payee in the end.

      Can you give a hint, or is there a bug?

      Like
    • Pink Yearling Per the docs, transfer payees are not allowed for splits.

      Like
  • Nice! Thanks Brady!

    Like 1
  • So excited for this! Thank you! 

    Like 1
  • Integrated split transactions into my grocery store receipt processor and it's working great. Thanks again!

    Like 2
  • Hi Brady, nice to see this feature!
    But there is a problem - why subtransactions cannot be specified for an imported transaction?
    I'm heavily relying on this field to backtrack created transactions.

    Like
  • Gold Wrench - There is a technical design reason we don't support that, currently.  One thing you could do is create a regular non-imported transaction (no import_id) as a split and then create a secondary imported transaction that will match (same account_id, amount, and date) to that first transaction.  The net result would be a single, split transaction with a matched, non-visible imported transaction counterpart.  This is effectively how things work when not using the API.

    Like
      • Gold Wrench
      • Gold_Wrench.11
      • 6 mths ago
      • Reported - view

      Brady thank you, will try it out!

      Like
    • Brady I'm trying to add a split to an already existing imported transaction. As far as I understood I just need to create a new transaction with the same account_id, amount and date as the imported transaction.

      This is the request I'm sending (where transaction is the already existing transaction, that has a import_id)

      {
          "account_id": transaction["account_id"],
          "date": transaction["date"],
          "amount": transaction["amount"],
          "payee_id": transaction["payee_id"],
          "memo": "split", # same as old transaction, but doesn't seem to matter
          "cleared": "cleared",
          "approved": True,
          "subtransactions": [
              {
                  "amount": amount2,
                  "category_id": splitCategoryId,
              },
              {
                  "amount": amount1,
                  "category_id": transaction["category_id"],
              }
          ]
      }

      The transaction is created correctly, the transactions are not merged and I end up with 2 transactions.

      Is there anything I'm doing wrong?

      Like
    • Slate Gray Sloth 

      It sounds like you are trying to create another transaction that will be matched to the original imported transaction.  Matching is only done for new import transactions.  When a new import transaction is created for the first time, matching is performed and if there is a non-imported transaction (user entered, import_id = null) that matches it (date, amount) they will be matched.  You cannot match a new non-imported transaction to a previously imported transaction.  Also, you cannot split an imported transaction.  They are, by design, not allowed to be splits.      

      You could create a non-import transaction with the splits before the imported transaction gets created which would cause matching to take place and the non-imported split would remain.

      Like
    • Brady Thank you for your reply.

      Since matching only occurs when an imported transaction is created, I'd need to create a second imported transaction based on the origin one.

      If I do that the original transaction remains and I end up with a duplicate (the original imported transaction without split and a new transaction with split).

      It also seems that there is no way to delete a transaction via the API.

      To summarize: There is no way to add a split to an existing imported transaction or create a new transaction with a split and delete the original imported transaction?

      Like
    • Slate Gray Sloth Correct - I don't think the API currently supports what you are trying to achieve here.  One stop-gap here could be to update the original imported transaction amount to $0 (with a memo) to clear out its effect on the budget.  This is obviously not ideal but could work for your particular workflow.

      Like
    • Brady What I wish to achieve (and I believe this is true for others), is to automatically apportion income transactions between "To Be Budgeted" and "Tax Year XXXX->YYYY"

      The reason I want to be able to do this with a split transaction is that I'd be able to tell whether any given transaction has been processed for tax accrual. As it is, I use the API to read and subtotal the correct tax amount per month so that I can manually verify.

      As I understand it, we cannot split an imported transaction and if we were to do so via the Web UI, we'd effectively been creating a new transaction that's been "matched".

      Your suggested solution of pre-creating a transaction to be automatically matched with an imported transaction is impractical as it requires prior knowledge of the transaction.

      Do you think it would be worth us putting in a feature request to be able to match transactions over the API?

      Using the API to find an unmatched / unsplit imported transaction, create a new split transaction and match it to the pristine one would achieve the goal I think myself and others are after?

      Like
    • Tomato Deer  - Yes, submitting a feature request would be the way to go here.  When using a YNAB client (e.g. web) and you split a transaction that was imported we actually do change that imported transaction to a split.  The API doesn't support this, though and there is a specific technical reason for not supporting it.  But, it's feasible to implement this ability to do so so a feature request to "Allow an imported transaction to be split" would be appropriate.  Thanks!

      Like
    • Brady Thank you for the suggestion, I've submitted a feature request to allow the API to split imported transactions.

      Like
    • Tomato Deer A quick update here.  We have implemented this.  An imported transaction may now be a split.

      Like 1
  • Hi there, I noticed that " Updating subtransactions on an existing split transaction is not supported." Is this something that is being added/planned on being added? It would be very helpful for my app to be able to change the payee of an existing split transaction  to a transfer payee. For now I have a workaround but it results in a second transaction being made which is less optimal.

    Like
    • Tan Camera I can pass that on as a feature request- right now it's not in our immediate plans, but I can definitely add your voice that you'd like to see that. 

      Like
      • Tan Camera
      • Tan_Camera.15
      • 1 mth ago
      • Reported - view

      Chrissy Thank you! 

      Like
Like17 Follow
  • 17 Likes
  • 1 mth agoLast active
  • 57Replies
  • 1633Views
  • 34 Following