Skip to main content

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.

Supported Products

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
}
ParameterTypeRequiredDefaultDescription
service_idstringYes-Certificate ID, the service_id returned by the Create Certificate Order API
shrink_yearsintegerNo1Number 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.
This API Is Not Idempotent

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​

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
}
}
Format of new_expiration_date

Depending 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.

Error Codes​

HTTP Status CodemessageMeaning and Suggested Action
400Error message returned by the CA, or Failed to shrinkSubmission to the CA failed; troubleshoot based on the message content; contact support if there is no useful information
404The certificate is not found, or has been cancelled or refundedThe certificate does not exist, has been cancelled or refunded, or does not belong to the workspace of the current API key
422The current certificate does not support shrinkingThe 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)
422No renewal orders available to cancelThere are no paid renewal orders (never extended, or all renewal orders have been cancelled), so there are no years to shorten
422Cannot shrink by 1 year, insufficient renewal ordersshrink_years exceeds the total years of paid renewal orders; reduce the number of years and retry
422Cannot shrink by 1 year, renewal order terms do not matchThe remaining years after the shrink cannot form complete order periods; reduce the number of years and retry
422A shrink is being processed, please try again laterThe previous shrink for the same certificate has not finished processing; retry later
422Parameter validation messageThe certificate ID service_id was not provided, or shrink_years is not between 1-5; the response also includes errors details
422 Responses Include errors Details

When 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:

  1. The certificate's product supports Shrink (ask support for the exact list)
  2. The order exists and has not been cancelled, and the certificate is not manually locked, being submitted, or being refunded
  3. The certificate has been submitted to the CA and has a valid CA order ID
  4. There are paid renewal orders
  5. shrink_years does not exceed the total years of paid renewal orders
  6. 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.