For an LTI assignment, you will be using the Outcomes Service to post grades back to the gradebook, not the API.
You should receive two variables on the launch request of your assignment:
- lis_outcome_service_url - this is the callback to Canvas to post the grade for the assignment
- lis_result_sourcedid - this is the reference to the specific cell in the gradebook representing the exact assignment and exact student associated with the grade you are posting.
To quote the IMS document:
"The TP may retain thelis_outcome_service_url and lis_result_sourcedid from a launch and then call the service long after the user's session has ended."
The intention of these two variables is to allow the student to complete the assignment and leave, if the assignment requires additional processing by the Tool Provider, the Tool Provider is able to post the grade once the processing is complete.
Take a look at the IMS doc, see if this helps:
Learning Tools Interoperability v1.1 Implementation Guide - LTI Basic Outcomes Service