Overview
If you’ve built a chatbot or AI app using Claude Code, you can integrate ChatAds by giving Claude Code the prompt below. It will add a server-side call to the ChatAds API and insert affiliate links into your chat responses.No SDK install needed for basic integration. Claude Code will use the REST API directly, or install the TypeScript or Python SDK if it fits your stack better.
Setup
Step 1: Get Your API Key
- Go to app.getchatads.com/api/keys
- Create an API key (starts with
cak_)
Step 2: Prompt Claude Code
Copy and paste the prompt below into Claude Code. Replacecak_your_api_key with your actual API key.
Claude Code Prompt
Copy this entire prompt and paste it into Claude Code:How It Works
The prompt adds a single step to your chatbot’s response pipeline:- Your chatbot generates a response (via Claude, GPT, etc.)
- That response text is sent to the ChatAds API
- ChatAds identifies product mentions and returns affiliate links
- Matching text in the response is replaced with linked versions
- The final response (with or without links) is shown to the user
Troubleshooting
401 Unauthorized errors
Verify your API key is correct and being sent in thex-api-key header (not Authorization).
No affiliate links appearing
- Test your chat response text in the API Explorer to confirm it returns offers
- Not every message contains product mentions — ChatAds only returns links when it finds relevant products
- Check that the
link_textreplacement is case-sensitive and matching the exact text from the response
API key exposed in client-side code
If Claude Code put the API key in a file that gets shipped to the browser (e.g., a React component, aVITE_ or NEXT_PUBLIC_ env var), ask it:
Response Reference
| Field | Type | Description |
|---|---|---|
data.status | string | "filled" if offers found, "empty" otherwise |
data.returned | number | Number of offers returned |
data.offers[].link_text | string | Text to match in the chat response |
data.offers[].url | string | Affiliate link URL |
data.offers[].product.title | string | Product name |
data.offers[].product.stars | number | Product rating (0-5) |
data.offers[].product.reviews | number | Review count |
Best Practices
Keep keys server-side
The ChatAds API call should happen on the server. Never put your key in client-side code.
Don't block chat responses
If the ChatAds call fails or times out, show the original response. Never let monetization break the chat experience.
Handle empty gracefully
Not every message will have affiliate matches. Always check
data.returned > 0 before modifying the response.Test in API Explorer
Verify your messages return offers in the API Explorer before debugging your integration.