# Update product availability

> POST /api/v0/products/availability: change only whether products can be bought, with the request, a working curl, responses, errors and limits.

`POST /api/v0/products/availability` changes `available` on products Releva already has, and nothing else.

## When to use it

Use it only if it makes your integration simpler. Availability changes far more often than the rest of a product, and this call lets you send just `{ id, available }` instead of the whole product. Everything it does can also be done with [Create or update products](https://releva.ai/documentation/reference/catalog/create-or-update-products/), which is the only way to change a price, a name or any other field.

A change of availability is recorded as an in-stock or out-of-stock catalog event, the same as through a full update, so back-in-stock and out-of-stock [catalog triggers](https://releva.ai/documentation/learn/catalog-triggers/how-catalog-triggers-work/) fire either way.

## Authentication

Send your shop’s **Secret Key** as a bearer token: `authorization: Bearer $RELEVA_SECRET_KEY`. Find it under **Settings › Shop & Integration** ([Find your Access Token and Secret Key](https://releva.ai/documentation/guides/shop-settings/find-your-api-keys/)). The error messages are in [Catalog API: Authentication](https://releva.ai/documentation/reference/catalog/overview/#authentication).

## Request

`POST https://releva.ai/api/v0/products/availability` with `content-type: application/json`.

| Field                  | Type    | Required | Notes                                                                                                                |
| ---------------------- | ------- | -------- | -------------------------------------------------------------------------------------------------------------------- |
| `products`             | array   | yes      | At least one entry.                                                                                                  |
| `products[].id`        | string  | yes      | The stored product id, as sent to `POST /products`, including the locale and market suffix if your catalog uses one. |
| `products[].available` | boolean | yes      | `true` when the product can be bought.                                                                               |

No other key is allowed on an entry.

```plaintext
curl -X POST 'https://releva.ai/api/v0/products/availability' \
  -H "authorization: Bearer $RELEVA_SECRET_KEY" \
  -H 'content-type: application/json' \
  -d '{
    "products": [
      { "id": "DEMO-1001", "available": true },
      { "id": "DEMO-1002", "available": false }
    ]
  }'
```

What changes:

* Only `available` changes. Price, stock quantity, custom fields and everything else stay as they are.
* A product stored with a single variant has that variant’s `available` changed too. Products with several variants keep their variants as they are: to change the availability of one variant, send the product with its full `variants` array to [Create or update products](https://releva.ai/documentation/reference/catalog/create-or-update-products/).
* An `id` that is not in the catalog is skipped. The call never creates a product.

## Response

`202 Accepted` with the body `{}`. The change is queued and usually visible within seconds.

## Errors

Errors have one shape, `{ "message": "..." }`.

| Status | When                            | Message                                                                                      |
| ------ | ------------------------------- | -------------------------------------------------------------------------------------------- |
| `400`  | Authentication failed           | See [Catalog API: Authentication](https://releva.ai/documentation/reference/catalog/overview/#authentication) |
| `400`  | Extra key `listPrice`           | `The object 'products[0]' contains forbidden keys: 'listPrice'.`                             |
| `400`  | Missing `available`             | `The 'products[0].available' field is required.`                                             |
| `400`  | `available: "false"` (a string) | `The 'products[0].available' field must be a boolean.`                                       |
| `402`  | Your shop is disabled           | `Domain is disabled. Please reach out to support@releva.ai to enable it.`                    |
| `413`  | Body larger than 800 KB         | `request entity too large`                                                                   |
| `500`  | Unexpected error; retry later   | `An internal error occurred.`                                                                |

## Limits

* Body size: 800 KB per request.
* Rate limits: none.

## Next steps

* [Create or update products](https://releva.ai/documentation/reference/catalog/create-or-update-products/): Send the complete product when anything other than availability changes.
* [How catalog triggers work](https://releva.ai/documentation/learn/catalog-triggers/how-catalog-triggers-work/): See how back-in-stock and out-of-stock changes start messages.
* [Catalog API overview](https://releva.ai/documentation/reference/catalog/overview/): Read the authentication, request format and error rules shared by all catalog calls.