Prompt
product catalog api pagination webhooks
Latest observation
Oct 28, 2026
OpenAI APIWeb search: off
Here’s a practical blueprint for a Product Catalog API with pagination and webhooks.
Core resources
- Products
- Categories
- Inventory/Variants (optional)
- Webhooks subscriptions
1) Product catalog API
List products
GET /products
Query params
limit— number of items per pagecursor— opaque pagination cursorsort— e.g.created_at,updated_at,nameorder—ascordesccategory_id— filter by categoryq— search textupdated_since— incremental sync support
Example
GET /products?limit=20&cursor=eyJpZCI6MTIzfQ==
Response
{
"data": [
{
"id": "prod_001",
"sku": "SHOE-001",
"name": "Running Shoe",
"description": "Lightweight running shoe",
"price": 89.99,
"currency": "USD",
"category_id": "cat_10",
"stock": 42,
"created_at": "2026-10-28T10:00:00Z",
"updated_at": "2026-10-28T10:00:00Z"
}
],
"pagination": {
"limit": 20,
"next_cursor": "eyJpZCI6MTQ0fQ==",
"has_more": true
}
}
Get a single product
GET /products/{product_id}
Create product
POST /products
{
"sku": "SHOE-001",
"name": "Running Shoe",
"description": "Lightweight running shoe",
"price": 89.99,
"currency": "USD",
"category_id": "cat_10",
"stock": 42
}
Update product
PATCH /products/{product_id}
Delete product
DELETE /products/{product_id}
2) Pagination strategy
Recommended: cursor-based pagination
Cursor pagination is best for catalogs because it’s stable under inserts/deletes.
Pattern
- Client requests the first page:
GET /products?limit=20 - API returns
next_cursor - Client requests next page using that cursor:
GET /products?limit=20&cursor=...
Why use it
- Better than offset for large catalogs
- Avoids duplicates/missing records when data changes
- Good for syncing and infinite scroll
Alternative: offset pagination
GET /products?limit=20&offset=40
Use only if simplicity matters more than consistency.
3) Webhooks
Webhooks notify consumers when catalog data changes.
Supported events
product.createdproduct.updatedproduct.deletedcategory.createdcategory.updatedcategory.deletedinventory.updated
Subscribe to webhooks
POST /webhooks/subscriptions
{
"url": "https://example.com/webhooks/catalog",
"events": ["product.created", "product.updated", "product.deleted"],
"secret": "shared-signing-secret"
}
Response
{
"id": "wh_123",
"url": "https://example.com/webhooks/catalog",
"events": ["product.created", "product.updated", "product.deleted"],
"status": "active"
}
Webhook payload example
{
"id": "evt_001",
"type": "product.updated",
"created_at": "2026-10-28T10:05:00Z",
"data": {
"id": "prod_001",
"sku": "SHOE-001",
"name": "Running Shoe",
"price": 84.99,
"currency": "USD",
"updated_at": "2026-10-28T10:05:00Z"
}
}
4) Webhook delivery best practices
- Sign payloads with HMAC (e.g.
X-Signature) - Include event ID for idempotency
- Retry on failures with exponential backoff
- Return
2xxquickly; process asynchronously - Allow consumers to replay events
- Store delivery logs/status
Headers
X-Webhook-Id: wh_123
X-Event-Id: evt_001
X-Signature: sha256=...
X-Event-Type: product.updated
5) Example event handling flow
- Admin updates a product
- API saves change
- API emits
product.updated - Webhook dispatcher queues delivery
- Consumer verifies signature
- Consumer processes event and returns
200 OK
6) Useful endpoints
GET /productsGET /products/{id}POST /productsPATCH /products/{id}DELETE /products/{id}GET /categoriesPOST /webhooks/subscriptionsGET /webhooks/subscriptionsDELETE /webhooks/subscriptions/{id}GET /webhooks/deliveries?subscription_id=...
If you want, I can turn this into:
- an OpenAPI spec,
- a database schema, or
- a Node/Express or FastAPI implementation.