# Create, update or delete products in bulk

Creates, updates or deletes products in bulk. Works with Meta Ads.

```http
POST https://api.pozy.ai/v1/ads/catalogs/{catalogId}/products/batch
```

- Area: Ads / Product Catalogs
- Auth: Authorization: Bearer pz_live_...

## Path parameters

- `catalogId` (string, required)

## Request body

Content type: `application/json`

- `accountId`, string, required
- `catalogAccountId`, string
- `requests`, array of object, required: At least 1 item. Up to 5000 items
  - `method`, string, required: One of `CREATE`, `UPDATE`, `DELETE`
  - `product`, object, required
    - `retailerId`, string, required: Up to 100 characters
    - `name`, string: Up to 200 characters
    - `description`, string: Up to 9999 characters
    - `url`, string (URL)
    - `imageUrl`, string (URL)
    - `additionalImageUrls`, array of string (URL): Up to 20 items
    - `price`, number
    - `currency`, string
    - `salePrice`, number
    - `salePriceStartDate`, string
    - `salePriceEndDate`, string
    - `availability`, string: One of `in stock`, `out of stock`, `preorder`, `available for order`, `discontinued`, `pending`
    - `condition`, string: One of `new`, `refurbished`, `used`
    - `brand`, string: Up to 100 characters
    - `category`, string: Up to 250 characters
    - `googleProductCategory`, string: Up to 250 characters
    - `productType`, string: Up to 750 characters
    - `gtin`, string: Up to 50 characters
    - `mpn`, string: Up to 100 characters
    - `inventory`, integer: At least 0
    - `visibility`, string: One of `published`, `staging`
    - `color`, string: Up to 200 characters
    - `size`, string: Up to 200 characters
    - `gender`, string: One of `female`, `male`, `unisex`
    - `material`, string: Up to 200 characters
    - `pattern`, string: Up to 100 characters
    - `customLabel0`, string: Up to 100 characters
    - `customLabel1`, string: Up to 100 characters
    - `customLabel2`, string: Up to 100 characters
    - `customLabel3`, string: Up to 100 characters
    - `customLabel4`, string: Up to 100 characters

## Example request

```bash
curl -X POST "https://api.pozy.ai/v1/ads/catalogs/6f2f2ffcf4ace3659342c4c2/products/batch" \
  -H "Authorization: Bearer $POZY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "accountId": "696e0b682d0a31188e7a2ba9",
  "requests": [
    {
      "method": "CREATE",
      "product": {
        "retailerId": "62ed28b157a658d89f9173aa"
      }
    }
  ]
}'
```

```ts
const res = await fetch("https://api.pozy.ai/v1/ads/catalogs/6f2f2ffcf4ace3659342c4c2/products/batch", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.POZY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    accountId: "696e0b682d0a31188e7a2ba9",
    requests: [
      {
        method: "CREATE",
        product: {
          retailerId: "62ed28b157a658d89f9173aa"
        }
      }
    ]
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(data?.error ?? `Request failed with status ${res.status}`);
console.log(data);
```

```python
import os
import requests

resp = requests.post(
    "https://api.pozy.ai/v1/ads/catalogs/6f2f2ffcf4ace3659342c4c2/products/batch",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    json={
        "accountId": "696e0b682d0a31188e7a2ba9",
        "requests": [
            {
                "method": "CREATE",
                "product": {
                    "retailerId": "62ed28b157a658d89f9173aa",
                },
            },
        ],
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 202

- `handles`, array of string
- `statusUrl`, string

```json
{
  "handles": [
    "acme"
  ],
  "statusUrl": "https://pozy.ai/media/example-1.jpg"
}
```
