[POST] Modify subscription activity (cancel / resume subscription) (AR/PMR)
Request Description
POST /v1/subscription/modify_activity
The request allows you to change the activity of a subscription, i.e. cancel it or resume it after cancellation.
NOTE: The request affects only one subscription of one individual customer.
The subscription activity is a separate attribute. It is not a subscription status:
- As long as a subscription is active, it is renewable. When active, the subscription can have the following statuses: active or not_paid.
- When deactivating subscriptions, they become cancelled (subscription status changes to cancelled). You can deactivate active subscriptions. This action is available for AR and PRM subscriptions.
- When activating subscriptions, they resume after cancellation (subscription status returns to active or not_paid). You can activate deactivated subscriptions. In addition, these subscriptions must meet the resumption requirements. This action is available for AR subscriptions only.
More details on:
- AR subscription cancellation (same for PMR)
- AR subscription resumption
Connection Data
- Endpoint URL:
- Production environment: https://api.ecommerce.noventiq.com/v1/subscription/modify_activity
- Test environment: https://api.ecommerce.noventiq.com.demonqweb.com/v1/subscription/modify_activity
- Request Method: POST
- Format: JSON
- Authorization: token-based
- Format:
Bearer [token]
- Where [token] is substituted by the token value obtained through the authentication API.
Format: NN_MM, where NN is an identifier of the order that initiates subscriptions (parent order).
You can get it from:
- Webhook (subscription.id)
- Orders API request response
Value options:
- true - subscription is activated. If a subscription has the cancelled status and meets the resumption conditions, the subscription gets resumed in case of successful request processing.
- false - subscription is deactivated. If a subscription has the active status, or it is payment pending (not paid), the subscription gets cancelled in case of successful request processing.
Value options:
- true - mailing is suppressed. In case of successful request processing subscription cancellation / resumption emails are not sent.
- false - mailing is not suppressed. In case of successful request processing subscription cancellation / resumption emails are sent (if enabled).
Request Example
Using all the parameters
{
"id": "111111_22222",
"activity": false,
"suppress_customer_notification": true
}
Cancelling a subscription (cancellation emails are sent to customers)
{
"id": "111111_22222",
"activity": false
}
Cancelling a subscription while using notification mailing suppression
{
"id": "111111_22222",
"activity": false,
"suppress_customer_notification": true
}
Resuming a subscription (resumption emails are sent to customers)
{
"id": "111111_22222",
"activity": true
}
Response Description
In response to the request, you receive the server response code corresponding to the processing result. Depending on the code, the response body may contain additional parameters.
Successful Response
If processing is successful, the following will return in response server response code: HTTP/1.1 200 ОК.
Request processing is considered successful only if corresponding actions are executed with subscriptions:
- The following is transferred in the request: "activity": false - The processing is successful if a subscription gets cancelled as the result of this processing (if the subscription was cancelled earlier, an error returns in response to the request).
- The following is transferred in the request: "activity": true - The processing is successful if a subscription gets resumed as the result of this processing (if the subscription is active at the time of the request transfer, or it is payment pending, an error returns in response to the request).
Error Response
If an error occurs while processing the request, you receive a server response code corresponding to the result of processing.
Depending on the code, the response body may contain additional parameters.
HTTP Server Response Error Code
HTTP code | Description |
HTTP/1.1 400 Bad Request | The request is not valid (error in parameters; necessary data is not transferred, etc.). An additional error code (one or more) will be transferred in the response bodу. |
HTTP/1.1 401 Unauthorized | Unsuccessful authorization. An additional error code (one or more) will be transferred in the response bodу. |
HTTP/1.1 404 Not found | Invalid request URL or no subscription having the identifier transferred is found. If no subscription is found, an additional additional error code will return in the response body. |
HTTP/1.1 500 Request Error | Internal Server Error. Please try again later or contact support. |
Additional Error Codes for HTTP 400
Error | Message | Description |
If at least one error from the list below is found, then it returns in response to a request, other errors are not validated. | ||
110 | JSON is not valid. | The request cannot be processed. Request field structure is not valid. Check the fields in the request body against the JSON format. |
111 | Invalid data format (Content-type). | The request cannot be processed. Invalid request header. Content-type must be equal to application/json. |
7000 | No access to subscription management. Please contact technical support. | During processing, we could not identify your account setting unambiguously. Please contact support team. |
If at least one error from the list below is found, then request validation is not interrupted. Several errors may return in response. | ||
7010 | Invalid field value: [parametr name]. | The request is not valid, e.g., the required parameter is not filled out, the parameter name is incorrect, the parameter value does not match with the data type provided, or the value format is incorrect. Moreover, the error will return if null is transferred in the parameter, and this value option is not set as valid in the parameter description. |
7210 | Impossible to cancel the subscription. The subscription was cancelled earlier. | The subscription cannot be cancelled because it has already been cancelled (subscription status is cancelled). The subscription requires no cancellation. |
7220 | Impossible to restore the subscription. The subscription is still active. | The subscription cannot be resumed because it is currently active (subscription status is active), or it is pending payment (subscription status is not_paid). The subscription requires no resumption (restoration). |
7230 | Impossible to restore the subscription. No restoration option is available for this subscription. | The AR subscription cannot be resumed (restored) because the resumption conditions are not met. This action is available for AR subscriptions only. |
7900 | Failed to execute the action with the subscription. Please contact Technical Support. |
Failed to execute the action with the subscription. Please contact Technical Support. |
Additional Error Codes for HTTP 401
The errors are the same for all the APIs that use token authorization.
Additional Error Codes for HTTP 404
Error | Message | Description |
If at least one error from the list below is found, then it returns in response to a request, other errors are not validated. | ||
7400 | Subscription not found. | No subscription with the identifier transferred is found, or you do not have the rights to get the data. |
Example of Error Response
{
"errors": [{
"error": 7210,
"message": "Impossible to cancel the subscription. The subscription was cancelled earlier."
}
]
}