To do a cancellation via our API, you can use the cancel a subscription API call.
The parameter end_of_term can be used to specify if the subscription should be canceled immediately or on next renewal.
By default, this is set as "false". So if you don't specify the end_of_term parameter, the subscription will be canceled immediately. Passing this as "true" will move the subscription to Non-Renewing state which means the customer will not be charged anymore and the subscription will be automatically canceled on renewal.
More information here.