Skip to main content

Archive Product Draft Variant

Archive a variant on a product's unpublished overlay. Buyers still see the live product.

draft_version is required. There is no /unarchive.

A variant that already exists live stays fetchable afterwards: Get Product Draft Variant returns 200 with status: archived. A variant created only on the overlay — not yet published — is removed from the overlay; a later GET returns 404, and a second archive of that id also returns 404.

Get Product Draft Variants omits archived variants in both cases. Repeating the call on an already-archived live overlay variant is a no-op (returns 200, draft_version unchanged).

To charge a different amount, archive this variant and create a draft variant — see Immutable price fields.

Archiving also clears the variant's upsells in both directions: the ones it offered, and the entries on sibling variants that offered it. Both stop appearing on draft reads straight away, and publishing removes them from the live product.

Request

POST /products/{productId}/draft/variants/{id}/archive

Path Parameters

ParameterTypeRequiredDescription
productIdstringYesProduct UUID
idstringYesProduct variant UUID

Request Body

ParameterTypeRequiredDescription
draft_versionintegerYesCurrent overlay version from Get Product Draft. Minimum 1. A mismatch returns 409.

Example Request

curl -X POST "https://cart.easy.tools/api/v1/products/0632bef5-c308-42cd-9cba-89a7a4f722bb/draft/variants/d91c65aa-b221-4aa4-b626-cf0d8a198749/archive" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"draft_version": 15
}'

Response

Success Response (200)

Returns the archived overlay variant plus the new draft_version and a fresh product preview_url. See Draft preview.

{
"id": "d91c65aa-b221-4aa4-b626-cf0d8a198749",
"status": "archived",
"type": "one_time",
"recurring_options": null,
"name": "250g Package",
"amount": 1999,
"currency": "usd",
"checkout_url": "https://cart.easy.tools/checkout/premium-coffee?plan=price_123",
"draft_version": 16,
"preview_url": "https://cart.easy.tools/checkout-preview/0632bef5-c308-42cd-9cba-89a7a4f722bb?expires=1749384000&signature=abc123"
}

The response contains the full variant plus draft_version and preview_url. See Get Product Variant for the complete list of variant fields; the example above is abbreviated.

An overlay-only variant that is removed from the overlay still returns 200 with status: archived on this call. A later Get Product Draft Variant for that id returns 404.

Response Fields

Shared variant fields are listed on Get Product Variant. This write adds:

FieldTypeNullableDescription
draft_versionintegerNoNew overlay version after this write. Unchanged when the overlay variant was already archived. Send it on the next draft write.
preview_urlstringNoTemporary signed checkout preview of the product. Always reminted. Expires after about one hour. See Draft preview.

Error Responses

Bad Request (400)

Returned when the product UUID or the variant UUID is malformed.

{
"message": "Invalid product ID"
}
{
"message": "Invalid variant ID"
}

Not Found (404)

Two cases share this status, told apart by the message. The product UUID does not exist, belongs to another store, or points at an archived product:

{
"message": "Product with ID 0632bef5-c308-42cd-9cba-89a7a4f722bb not found"
}

Or the product resolves but the variant is not on its overlay — including a second archive of an overlay-only variant that was already removed:

{
"message": "Product variant with ID 5272bfcf-4e92-458d-b513-80ca474a16e4 not found"
}

Conflict Error (409 — Stale Draft Version)

Returned when draft_version does not match the current overlay version. GET the draft and retry with the current draft_version.

{
"message": "The draft was edited elsewhere. GET the draft and retry with the current draft_version."
}

Validation Error (422 Unprocessable Entity)

Returned when draft_version is missing.

{
"message": "The given data was invalid.",
"errors": {
"draft_version": [
"The draft version field is required."
]
}
}