Ecto validation return nested response with put_assoc

And where is the response generated? Repo.insert(bothinsert) would return an invalid changeset in case of an error. So you can flatten out the response where you transform the invalid changeset into this json, I assume?.