Store Hugs Developers

Reviews

Shoppers' product reviews: moderate them, reply in the shop's name, or delete them.

Reach them through $admin->reviews. Reading needs the reviews:read scope, changing them reviews:write. Reviews need a plan with reviews (403 plan_required).

List reviews

$admin->reviews->list(array $query = []): array

One page of the shop's reviews, newest first, or oldest change first with updatedSince. Read the next page with meta.nextCursor as cursor. Scope: reviews:read.

Parameters

Parameter Type
$query array The query fields below, by name.

Query fields

ParameterTypeDescription
statusany
ratingintegerAt least 1. At most 5.
productIdinteger
limitintegerAt least 1. At most 100. Default 50.
cursorstringmeta.nextCursor (or the cursor in links.next) of the previous page. At most 1000 characters.
updatedSincestring (date-time)Records changed at or after this time (ISO 8601, any offset or Z), oldest change first, for incremental sync.

Returns

An array with data (a list of AdminReview), links and meta:

FieldTypeDescription
linksobject
links.firstnull
links.lastnull
links.prevstring (uri) or null
links.nextstring (uri) or null
metaobject
meta.pathstring (uri)
meta.perPageinteger
meta.nextCursorstring or null
meta.prevCursorstring or null
dataarray of AdminReview
data[].idinteger
data[].productIdinteger or null
data[].customerIdinteger or null
data[].orderIdinteger or null
data[].ratingintegerAt least 1. At most 5.
data[].titlestring or null
data[].bodystring or null
data[].authorNamestring or null
data[].verifiedBuyerboolean
data[].localestring or null
data[].statusstringOne of pending_approval, published, rejected, flagged.
data[].replyobject or null
data[].reply.bodystring
data[].reply.updatedAtstring (date-time) or null
data[].publishedAtstring (date-time) or null
data[].createdAtstring (date-time) or null
data[].updatedAtstring (date-time) or null

Errors

StatusWhen
401invalid_api_key: no active Admin key in Authorization: Bearer.
403admin_key_in_browser (an Origin header was sent), ip_not_allowed, plan_required(the shop's plan lacks the Integration API, or the feature the endpoint needs), orinsufficient_scope.
422Validation errors ({ message, errors }), or an idempotency refusal(idempotency_key_reused, idempotency_key_invalid).
429Rate limited.

Example

$page = $admin->reviews->list(['rating' => 1, 'productId' => 12]);

Iterate over every review

$admin->reviews->all(array $query = []): Generator

Every review matching the query, one at a time, fetching the next page as you read. It takes the same query as list, without cursor. Scope: reviews:read.

Returns

A generator of AdminReview arrays, each:

FieldTypeDescription
[].idinteger
[].productIdinteger or null
[].customerIdinteger or null
[].orderIdinteger or null
[].ratingintegerAt least 1. At most 5.
[].titlestring or null
[].bodystring or null
[].authorNamestring or null
[].verifiedBuyerboolean
[].localestring or null
[].statusstringOne of pending_approval, published, rejected, flagged.
[].replyobject or null
[].reply.bodystring
[].reply.updatedAtstring (date-time) or null
[].publishedAtstring (date-time) or null
[].createdAtstring (date-time) or null
[].updatedAtstring (date-time) or null

Example

foreach ($admin->reviews->all(['status' => 'pending_approval']) as $review) {
    $admin->reviews->setStatus($review['id'], 'published');
    $admin->reviews->reply($review['id'], 'Thank you for your review!');
}

Get a review

$admin->reviews->get(int $id): array

One review by its id, with the shop's reply. Scope: reviews:read.

Parameters

Parameter Type
$id int The review's id.

Returns

An AdminReview:

FieldTypeDescription
idinteger
productIdinteger or null
customerIdinteger or null
orderIdinteger or null
ratingintegerAt least 1. At most 5.
titlestring or null
bodystring or null
authorNamestring or null
verifiedBuyerboolean
localestring or null
statusstringOne of pending_approval, published, rejected, flagged.
replyobject or null
reply.bodystring
reply.updatedAtstring (date-time) or null
publishedAtstring (date-time) or null
createdAtstring (date-time) or null
updatedAtstring (date-time) or null

Errors

StatusWhen
401invalid_api_key: no active Admin key in Authorization: Bearer.
403admin_key_in_browser (an Origin header was sent), ip_not_allowed, plan_required(the shop's plan lacks the Integration API, or the feature the endpoint needs), orinsufficient_scope.
404not_found: the shop has no such record.
429Rate limited.

Moderate a review

$admin->reviews->setStatus(int $id, string $status, string|false|null $idempotencyKey = null): array

Publishes, rejects, flags or holds a review; the product's rating follows. Scope: reviews:write.

Parameters

Parameter Type
$id int The review's id.
$status string pending_approval, published, rejected or flagged.
$idempotencyKey string|false|null Your own Idempotency-Key, or false for none. One is made for you when null.

Returns

The moderated AdminReview:

FieldTypeDescription
idinteger
productIdinteger or null
customerIdinteger or null
orderIdinteger or null
ratingintegerAt least 1. At most 5.
titlestring or null
bodystring or null
authorNamestring or null
verifiedBuyerboolean
localestring or null
statusstringOne of pending_approval, published, rejected, flagged.
replyobject or null
reply.bodystring
reply.updatedAtstring (date-time) or null
publishedAtstring (date-time) or null
createdAtstring (date-time) or null
updatedAtstring (date-time) or null

Errors

StatusWhen
401invalid_api_key: no active Admin key in Authorization: Bearer.
403admin_key_in_browser (an Origin header was sent), ip_not_allowed, plan_required(the shop's plan lacks the Integration API, or the feature the endpoint needs), orinsufficient_scope.
404not_found: the shop has no such record.
409idempotency_in_progress: a request with this Idempotency-Key is still running. Retry with the same key after Retry-After seconds; the first answer is then replayed.
422Validation errors ({ message, errors }), or an idempotency refusal(idempotency_key_reused, idempotency_key_invalid).
429Rate limited.

Example

$admin->reviews->setStatus(41, 'rejected');

Reply to a review

$admin->reviews->reply(int $id, string $body, string|false|null $idempotencyKey = null): array

Writes or rewrites the shop's public reply. It also touches the review's updatedAt. Scope: reviews:write.

Parameters

Parameter Type
$id int The review's id.
$body string The reply, at most the platform's review body length.
$idempotencyKey string|false|null Your own Idempotency-Key, or false for none. One is made for you when null.

Returns

The AdminReview, with its reply:

FieldTypeDescription
idinteger
productIdinteger or null
customerIdinteger or null
orderIdinteger or null
ratingintegerAt least 1. At most 5.
titlestring or null
bodystring or null
authorNamestring or null
verifiedBuyerboolean
localestring or null
statusstringOne of pending_approval, published, rejected, flagged.
replyobject or null
reply.bodystring
reply.updatedAtstring (date-time) or null
publishedAtstring (date-time) or null
createdAtstring (date-time) or null
updatedAtstring (date-time) or null

Errors

StatusWhen
401invalid_api_key: no active Admin key in Authorization: Bearer.
403admin_key_in_browser (an Origin header was sent), ip_not_allowed, plan_required(the shop's plan lacks the Integration API, or the feature the endpoint needs), orinsufficient_scope.
404not_found: the shop has no such record.
409idempotency_in_progress: a request with this Idempotency-Key is still running. Retry with the same key after Retry-After seconds; the first answer is then replayed.
422Validation errors ({ message, errors }), or an idempotency refusal(idempotency_key_reused, idempotency_key_invalid).
429Rate limited.

Example

$admin->reviews->reply(41, 'Sorry to hear that. We have sent you a replacement.');

Delete the shop's reply

$admin->reviews->deleteReply(int $id): array

Removes the shop's reply and answers with the review. Scope: reviews:write.

Parameters

Parameter Type
$id int The review's id.

Returns

The AdminReview, without a reply:

FieldTypeDescription
idinteger
productIdinteger or null
customerIdinteger or null
orderIdinteger or null
ratingintegerAt least 1. At most 5.
titlestring or null
bodystring or null
authorNamestring or null
verifiedBuyerboolean
localestring or null
statusstringOne of pending_approval, published, rejected, flagged.
replyobject or null
reply.bodystring
reply.updatedAtstring (date-time) or null
publishedAtstring (date-time) or null
createdAtstring (date-time) or null
updatedAtstring (date-time) or null

Errors

StatusWhen
401invalid_api_key: no active Admin key in Authorization: Bearer.
403admin_key_in_browser (an Origin header was sent), ip_not_allowed, plan_required(the shop's plan lacks the Integration API, or the feature the endpoint needs), orinsufficient_scope.
404not_found: the shop has no such record.
409idempotency_in_progress: a request with this Idempotency-Key is still running. Retry with the same key after Retry-After seconds; the first answer is then replayed.
422Validation errors ({ message, errors }), or an idempotency refusal(idempotency_key_reused, idempotency_key_invalid).
429Rate limited.

Delete a review

$admin->reviews->delete(int $id): void

Deletes the review for good, with its reply. Scope: reviews:write.

Parameters

Parameter Type
$id int The review's id.

Returns

Nothing.

Errors

StatusWhen
401invalid_api_key: no active Admin key in Authorization: Bearer.
403admin_key_in_browser (an Origin header was sent), ip_not_allowed, plan_required(the shop's plan lacks the Integration API, or the feature the endpoint needs), orinsufficient_scope.
404not_found: the shop has no such record.
409idempotency_in_progress: a request with this Idempotency-Key is still running. Retry with the same key after Retry-After seconds; the first answer is then replayed.
422Validation errors ({ message, errors }), or an idempotency refusal(idempotency_key_reused, idempotency_key_invalid).
429Rate limited.