Shrink Certificate API
Shortens the service period of a certificate order by cancelling not-yet-expired renewal orders in whole years. The fee is refunded to the workspace balance.
Shrink only applies to renewal orders; it does not shorten the base service period of the initial purchase, and it does not reissue or revoke an already issued certificate.
Only some products support Shrink; please ask support for the exact list. Calls for unsupported products return The current certificate does not support shrinking.
Endpoint
POST /api/v1/certificate/shrink
Host:
...
Full URL
/api/v1/certificate/shrink
Request
Content-Type: application/json
{
"service_id": "o91bZ", // Certificate ID, required, the `service_id` returned when the order was created
"shrink_years": 1 // Number of years to shrink, optional, an integer from 1-5, defaults to 1 year if omitted
}
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| service_id | string | Yes | - | Certificate ID, the service_id returned by the Create Certificate Order API |
| shrink_years | integer | No | 1 | Number of years to shrink, an integer from 1-5 |
Refund Rules
- Cancellation starts from the most recent paid renewal order and proceeds backwards.
- When an entire renewal order is cancelled, the full amount actually paid for that order is refunded.
- When only part of the years in an order are cancelled, the amount actually paid is refunded in proportion to the cancelled years, and the renewal order's term is changed to the remaining years.
- The refund goes back to the workspace balance in the currency originally used to pay the order, and a refund record with the remark
SHRINK#<service_id>is generated. - The refund amount is calculated from the amount actually paid for the renewal order, which was affected by discounts at renewal time and may differ from the current selling price.
As long as there are renewal orders that can be cancelled, repeated calls will keep shrinking and keep refunding. Do not retry directly after a timeout; first use the Query Certificate API to confirm whether the service period has already been shortened.
Response
- response
- errors
HTTP/1.1 200 OK
Content-Type: application/json
{
"success": true,
"data": {
"service_id": "o91bZ", // Same certificate ID as passed in the request
"order_id": "ord_xxxxx", // Order ID on the CA side, provide it when contacting after-sales support
"old_validity_years": 3, // Order service years before the shrink
"new_validity_years": 2, // Order service years after the shrink
"new_expiration_date": "2027-01-01" // Service period expiration date after the shrink
}
}
new_expiration_dateDepending on the product, the format may be YYYY-MM-DD or YYYY-MM-DD HH:mm:ss. If the CA detail query fails, this field is null; in that case, refer to the service period expiration date returned by the Query Certificate API.
HTTP/1.1 422 Unprocessable Content
Content-Type: application/json
{
"success": false,
"message": "No renewal orders available to cancel"
}
Error Codes
| HTTP Status Code | message | Meaning and Suggested Action |
|---|---|---|
| 400 | Error message returned by the CA, or Failed to shrink | Submission to the CA failed; troubleshoot based on the message content; contact support if there is no useful information |
| 404 | The certificate is not found, or has been cancelled or refunded | The certificate does not exist, has been cancelled or refunded, or does not belong to the workspace of the current API key |
| 422 | The current certificate does not support shrinking | The certificate's product does not support Shrink, or the certificate cannot be operated on right now (manually locked, being submitted, being refunded, order cancelled, or missing CA order ID) |
| 422 | No renewal orders available to cancel | There are no paid renewal orders (never extended, or all renewal orders have been cancelled), so there are no years to shorten |
| 422 | Cannot shrink by 1 year, insufficient renewal orders | shrink_years exceeds the total years of paid renewal orders; reduce the number of years and retry |
| 422 | Cannot shrink by 1 year, renewal order terms do not match | The remaining years after the shrink cannot form complete order periods; reduce the number of years and retry |
| 422 | A shrink is being processed, please try again later | The previous shrink for the same certificate has not finished processing; retry later |
| 422 | Parameter validation message | The certificate ID service_id was not provided, or shrink_years is not between 1-5; the response also includes errors details |
errors DetailsWhen parameter validation fails (422), in addition to message, an errors field is returned indicating which parameter is invalid:
{
"success": false,
"message": "The shrink years must not be greater than 5.",
"errors": {
"shrink_years": ["The shrink years must not be greater than 5."]
}
}
Prerequisites
Before calling, make sure all of the following conditions are met; otherwise the request will be rejected:
- The certificate's product supports Shrink (ask support for the exact list)
- The order exists and has not been cancelled, and the certificate is not manually locked, being submitted, or being refunded
- The certificate has been submitted to the CA and has a valid CA order ID
- There are paid renewal orders
shrink_yearsdoes not exceed the total years of paid renewal orders- The remaining years after the shrink form a whole-year period of 1-5 years
To buy back the years that were shrunk, use the Extend Certificate API, charged at the current selling price.