Skip to content

Commit 51617ae

Browse files
vvillait88claude
andcommitted
docs(readme): add verify_webhook_signature section + .status alias note
Mirrors core/docs/integrations/python.mdx additions so README readers see the helper alongside the existing AgentScore API methods. Also documents the AgentScoreError.status property aliasing .status_code for polyglot codebase parity with node-sdk. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e82f1fb commit 51617ae

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,24 @@ client.associate_wallet(
9191
)
9292
```
9393

94+
### Verify webhook signatures
95+
96+
For merchants who receive HMAC-signed webhooks (Stripe-pattern `t=<unix>,v1=<hex>` header):
97+
98+
```python
99+
from agentscore import verify_webhook_signature
100+
101+
result = verify_webhook_signature(
102+
payload=raw_request_body, # raw bytes — capture before any JSON parse
103+
signature_header=request.headers.get("X-AgentScore-Signature", ""),
104+
secret=os.environ["AGENTSCORE_WEBHOOK_SECRET"],
105+
)
106+
if not result.valid:
107+
return {"error": result.reason}, 400
108+
```
109+
110+
`reason` distinguishes transient (`timestamp_too_old`, `timestamp_in_future`) from permanent (`signature_mismatch`, `no_signatures`, `malformed_header`) failures. Default tolerance 300s; pass `tolerance_seconds=0` to skip timestamp checking. Uses `hmac.compare_digest` for constant-time comparison.
111+
94112
### Async
95113

96114
All methods have async variants prefixed with `a`:
@@ -129,6 +147,8 @@ with AgentScore(api_key="as_live_...") as client:
129147
| `timeout` | `10.0` | Request timeout (seconds)|
130148
| `user_agent` | `None` | Prepended to the default `User-Agent` as `"{user_agent} (agentscore-py/{version})"`. Use to attribute API calls to your app. |
131149

150+
`AgentScoreError.status` is a property aliasing `.status_code` so polyglot codebases can use the same attribute name regardless of which SDK raised the error.
151+
132152
## Error Handling
133153

134154
```python

0 commit comments

Comments
 (0)