# POST /v1/favorites Save a listing for a consumer. | Access | | | --- | --- | | Keys | publishable or secret | | Plan | every plan | | Environment | live and sandbox | | Acts for | one consumer | | While the account is suspended | refused | | During a data stop | works | ## Headers | Name | Description | | --- | --- | | `X-Client-Token` | With a publishable key: **required.** A token your server minted for the consumer with [`POST /v1/client-tokens`](create-client-token.md). | | `X-Client-Id` | With a secret key: **required.** Your own opaque ID for the consumer. | | `Idempotency-Key` | A new random value for this action, such as a UUID. A repeat with the same value and the same request gets the first answer again, and nothing is saved twice ([idempotency](../../concepts/idempotency.md)). | ## Body | Field | Type | Description | | --- | --- | --- | | `listingKey` | string | The key of a listing this environment serves. | ```json { "listingKey": "805454359664" } ``` ## Answers ### 200: The consumer had saved this listing before: the same favorite, never a second one The answer is `{ data, meta }`; `meta` holds `requestId` and `environment`. `data` is a [Favorite](../objects.md#favorite). ### 201: Saved The answer is `{ data, meta }`; `meta` holds `requestId` and `environment`. `data` is a [Favorite](../objects.md#favorite). ## Errors | Status | Codes | | --- | --- | | 400 | [`client_id_must_be_opaque`](../../errors/client_id_must_be_opaque.md), [`validation_failed`](../../errors/validation_failed.md) | | 401 | [`client_token_account_mismatch`](../../errors/client_token_account_mismatch.md), [`client_token_expired`](../../errors/client_token_expired.md), [`client_token_invalid`](../../errors/client_token_invalid.md), [`client_token_required`](../../errors/client_token_required.md), [`invalid_api_key`](../../errors/invalid_api_key.md), [`key_revoked`](../../errors/key_revoked.md), [`missing_api_key`](../../errors/missing_api_key.md) | | 403 | [`account_pending`](../../errors/account_pending.md), [`account_suspended`](../../errors/account_suspended.md), [`origin_not_allowed`](../../errors/origin_not_allowed.md), [`secret_key_in_browser`](../../errors/secret_key_in_browser.md) | | 404 | [`listing_not_found`](../../errors/listing_not_found.md) | | 409 | [`idempotency_conflict`](../../errors/idempotency_conflict.md) | | 429 | [`rate_limited`](../../errors/rate_limited.md) | | 500 | [`internal_error`](../../errors/internal_error.md), [`temporarily_unavailable`](../../errors/temporarily_unavailable.md) | Every error has the same body, and says how to fix it ([responses and errors](../../concepts/responses-and-errors.md)). ## More Request `{ "listingKey": "805454359664" }`. Response `201` with the new favorite; posting a listing the consumer already saved returns the same record with `200`, never a duplicate. Refused with `403 account_suspended` while suspended. Writes for one consumer are applied one at a time: a `POST` that overlaps a delete of the same favorite or of the consumer still answers `200` or `201`, and the delete takes effect right after it. A write waits at most about a second for an earlier write of the same consumer; past that, or in the rare case that the write keeps losing a race with changes made outside the API, it answers `500 temporarily_unavailable` with `Retry-After`, and nothing is saved. The same cap applies to `DELETE /v1/favorites/{id}` and `DELETE /v1/clients/{clientId}`. `Idempotency-Key` is accepted: a retry with the same key and body gets the first answer again (its status included) with `Idempotency-Replayed: true`, and saves nothing. See [idempotency](../../concepts/idempotency.md). _This page is made from the route's own declaration by `npm run openapi`. To change it, change the declaration or its explanation, never this file._