PrestaShop Bridge V1
PrestaShop Bridge V1 is a secure operational contract for AI agents and Python handlers that need to interact with a PrestaShop 9 store through a stable interface. It standardizes OAuth2 authentication, HMAC request signing, rate limiting, asynchronous writes, idempotency, and durable job polling.
Operating model
- - Reads are synchronous.
- Writes are asynchronous.
- Redis is used only for Messenger transport and temporary HTTP idempotency cache.
- MySQL is the source of truth for job status, business idempotency, and failed jobs.
- A
202 Accepted response means only that a job was accepted for processing. It never means business success.
Capabilities
get_product
- - method: INLINECODE1
- endpoint: INLINECODE2
- sync: INLINECODE3
- scope: INLINECODE4
- params:
-
id integer, required
get_order
- - method: INLINECODE7
- endpoint: INLINECODE8
- sync: INLINECODE9
- scope: INLINECODE10
- params:
-
id integer, required
getjobstatus
- - method: INLINECODE13
- endpoint: INLINECODE14
- sync: INLINECODE15
- scope: INLINECODE16
- note: job status is read from MySQL, not from Redis
- success: INLINECODE17
update_product
- - method: INLINECODE18
- endpoint: INLINECODE19
- sync: INLINECODE20
- scope: INLINECODE21
- idempotency:
X-Request-ID required - payload:
-
product_id
-
updates.price_ht
-
updates.stock_delta
-
updates.seo
-
options.skip_reindex
import_products
- - method: INLINECODE29
- endpoint: INLINECODE30
- sync: INLINECODE31
- scope: INLINECODE32
- idempotency: request id required and stable INLINECODE33
- payload:
-
batch_id
-
items
-
options
- maximum
50 items
- maximum payload size
10MB
updateorderstatus
- - method: INLINECODE40
- endpoint: INLINECODE41
- sync: INLINECODE42
- scope: INLINECODE43
- idempotency:
X-Request-ID required - payload:
-
order_id
-
new_status
-
notify_customer
-
tracking_number
Security
Required headers on protected routes
- - INLINECODE50
- INLINECODE51
- INLINECODE52
- INLINECODE53
- INLINECODE54
- INLINECODE55
Compression
- - gzip recommended above
1024 bytes - gzip required above
32768 bytes
OAuth2
- - flow: INLINECODE58
- token endpoint: INLINECODE59
- JWT algorithm: INLINECODE60
- TTL: INLINECODE61
- scopes:
-
bridge:read
- INLINECODE63
HMAC
String to sign:
INLINECODE64
Exact example:
- - method: INLINECODE65
- uri: INLINECODE66
- timestamp: INLINECODE67
- request id: INLINECODE68
- body sha256: INLINECODE69
- signature: INLINECODE70
Response handling
- -
200 OK: synchronous read success or completed idempotent replay. - INLINECODE72 : job accepted only. Always poll
/v1/jobs/{jobId}. - INLINECODE74 : schema validation failed.
- INLINECODE75 : JWT missing, invalid, or expired.
- INLINECODE76 : invalid HMAC, invalid timestamp window, or insufficient scope.
- INLINECODE77 : idempotency conflict or known failed replay.
- INLINECODE78 : valid JSON but impossible business transition.
- INLINECODE79 : wait for
Retry-After. - INLINECODE81 : unexpected server failure.
- INLINECODE82 : service degraded or Redis unavailable.
Absolute refusal rules
- - Never report business success immediately after a
202. - Never modify TTC price directly. Only HT price may be changed.
- Never delete a product that has associated orders.
- Never access the database or filesystem directly.
- Never send payloads larger than
10MB. - Never perform heavy writes synchronously.
- Never reuse an
X-Request-ID for a different business intention within 24 hours.
Pre-deployment checks
- - Verify JWT issuance and validation with RS256 only.
- Verify the exact HMAC example in
examples.http. - Verify schema validation for all request bodies.
- Verify Redis-backed idempotency replay behavior.
- Verify MySQL-backed job polling after Redis restart.
- Verify idempotent handlers under at-least-once delivery.
PrestaShop Bridge V1
PrestaShop Bridge V1 是一个安全运营合约,适用于需要通过稳定接口与 PrestaShop 9 商店交互的 AI 代理和 Python 处理器。它标准化了 OAuth2 认证、HMAC 请求签名、速率限制、异步写入、幂等性和持久化任务轮询。
运营模式
- - 读取操作为同步。
- 写入操作为异步。
- Redis 仅用于 Messenger 传输和临时 HTTP 幂等性缓存。
- MySQL 是任务状态、业务幂等性和失败任务的真实数据源。
- 202 Accepted 响应仅表示任务已被接受处理,绝不代表业务成功。
功能
get_product
- - 方法:GET
- 端点:/v1/products/{id}
- 同步:true
- 范围:bridge:read
- 参数:
- id 整数,必填
get_order
- - 方法:GET
- 端点:/v1/orders/{id}
- 同步:true
- 范围:bridge:read
- 参数:
- id 整数,必填
getjobstatus
- - 方法:GET
- 端点:/v1/jobs/{jobId}
- 同步:true
- 范围:bridge:read
- 注意:任务状态从 MySQL 读取,而非 Redis
- 成功:200
update_product
- - 方法:POST
- 端点:/v1/jobs/products/update
- 同步:false
- 范围:bridge:write
- 幂等性:需要 X-Request-ID
- 负载:
- product_id
- updates.price_ht
- updates.stock_delta
- updates.seo
- options.skip_reindex
import_products
- - 方法:POST
- 端点:/v1/jobs/products/import
- 同步:false
- 范围:bridge:write
- 幂等性:需要请求 ID 和稳定的 batch_id
- 负载:
- batch_id
- items
- options
- 最多 50 个项目
- 最大负载大小 10MB
updateorderstatus
- - 方法:POST
- 端点:/v1/jobs/orders/status
- 同步:false
- 范围:bridge:write
- 幂等性:需要 X-Request-ID
- 负载:
- order_id
- new_status
- notify_customer
- tracking_number
安全
受保护路由所需的请求头
- - Authorization: Bearer {jwtrs256token}
- X-Request-ID: {uuidv4}
- X-Timestamp: {unixseconds}
- X-Signature: {hmacsha256hex}
- Content-Type: application/json
- Accept: application/json
压缩
- - 超过 1024 字节建议使用 gzip
- 超过 32768 字节必须使用 gzip
OAuth2
- - 流程:client_credentials
- 令牌端点:/oauth/token
- JWT 算法:RS256
- TTL:3600
- 范围:
- bridge:read
- bridge:write
HMAC
待签名字符串:
METHOD + \n + URI + \n + TIMESTAMP + \n + REQUESTID + \n + BODYSHA256
精确示例:
- - 方法:POST
- URI:/v1/jobs/products/update
- 时间戳:1710950400
- 请求 ID:f47ac10b-58cc-4372-a567-0e02b2c3d479
- 正文 SHA256:37abd647733fbd18a3f11fb5a082fe59c62719d9fe833aec96b28ccea36b70ba
- 签名:448e251d1c71078b07a10baf4094fd2686bcebef97761c4729a921f71798554c
响应处理
- - 200 OK:同步读取成功或已完成幂等重放。
- 202 Accepted:仅任务被接受。始终轮询 /v1/jobs/{jobId}。
- 400 Bad Request:模式验证失败。
- 401 Unauthorized:JWT 缺失、无效或已过期。
- 403 Forbidden:HMAC 无效、时间戳窗口无效或范围不足。
- 409 Conflict:幂等性冲突或已知失败重放。
- 422 Unprocessable Entity:JSON 有效但业务转换不可行。
- 429 Too Many Requests:等待 Retry-After。
- 500 Internal Server Error:意外的服务器故障。
- 503 Service Unavailable:服务降级或 Redis 不可用。
绝对禁止规则
- - 绝不在 202 响应后立即报告业务成功。
- 绝不直接修改含税价格。仅可修改不含税价格。
- 绝不删除有关联订单的产品。
- 绝不直接访问数据库或文件系统。
- 绝不发送大于 10MB 的负载。
- 绝不同步执行大量写入操作。
- 绝不在 24 小时内为不同的业务意图重复使用 X-Request-ID。
部署前检查
- - 仅使用 RS256 验证 JWT 签发和验证。
- 验证 examples.http 中的精确 HMAC 示例。
- 验证所有请求体的模式验证。
- 验证基于 Redis 的幂等性重放行为。
- 验证 Redis 重启后基于 MySQL 的任务轮询。
- 验证至少一次投递下的幂等处理器。