Skip to main content

Connect Product

Link an existing Easycart product to a course. This does not create an Easycart product. product_id is that product's UUID. Omitted or null variant_ids links every current and future variant. A non-empty list restricts the link to those variants. The change is live immediately, including on a published course, and this call does not publish. On a published course, connecting the first product makes a free course paid. See Paywall.

Request​

POST /players/{id}/products

Path Parameters​

ParameterTypeRequiredDescription
idstringYesCourse UUID. See Identifiers.

Request Body​

Do not send draft_version.

ParameterTypeRequiredDescription
product_idstringYesEasycart product UUID
variant_idsarray|nullNoEasycart variant UUIDs of that product, at most 100. Omit or send null to link every variant. [] is 422.

Example Request​

curl -X POST "https://app.easy.tools/api/v1/players/8f3c1a62-d047-4e89-9b25-1c6a4d8e0f71/products" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"product_id": "2f1c0a2e-7b3d-4e1a-9c55-0a1b2c3d4e5f",
"variant_ids": ["9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d"]
}'

Response​

Success Response (201)​

{
"data": {
"product_id": "2f1c0a2e-7b3d-4e1a-9c55-0a1b2c3d4e5f",
"product_name": "Course",
"variant_ids": ["9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d"],
"missing": false
}
}

Response Fields​

See Product Link Object. The response has no preview_url, draft_version, or draft_updated_at. Omitted or null variant_ids comes back as variant_ids null.

Error Responses​

Not Found Error (404)​

See Identifiers.

{
"error": {
"code": "RESOURCE_NOT_FOUND",
"message": "Resource not found"
}
}

Conflict Error (409)​

The product is already linked. Change its variants with Update Product Link.

{
"error": {
"code": "DUPLICATE_RESOURCE",
"message": "This product is already linked. Change variants with PATCH."
}
}

Validation Error (422 Unprocessable Entity)​

[] is 422. A product_id that is not a UUID, or a product UUID that Easycart does not resolve, is 422. A variant UUID that is unknown, or that belongs to a different product, is 422. A workspace that is not connected to an Easycart store is 422. Nothing is saved.

{
"error": {
"code": "VALIDATION_ERROR",
"message": "The given data was invalid",
"details": {
"variant_ids": ["variant_ids must not be empty. Send null to link every variant"]
}
}
}

An unknown product UUID uses the same status and message, with details.product_id set to product_id is not a product in this workspace. A variant that is missing or that belongs to another product uses details.variant_ids set to variant_ids is not a price of this product. A value that is not a UUID uses product_id must be a UUID or variant_ids must be a UUID. More than 100 variants uses variant_ids must contain no more than 100 elements.

Bad Gateway Error (502)​

Easycart answered, but not with a result the API can use. Nothing is saved.

{
"error": {
"code": "UPSTREAM_ERROR",
"message": "EasyCart rejected the request"
}
}

Service Unavailable Error (503)​

Easycart is unreachable or failing. Nothing is saved. Retry later.

{
"error": {
"code": "SERVICE_UNAVAILABLE",
"message": "EasyCart is unavailable"
}
}

Authentication, permission, and rate-limit errors are described in Authorization.