keitaro-api-skill/SKILL.md

85 lines
2.8 KiB
Markdown

---
name: keitaro-api
description: Interact with Keitaro Admin API v1 to manage campaigns, offers, affiliate networks, domains, landing pages, and more. Use when user asks to create/update/delete Keitaro resources, fetch statistics, or manage tracker configurations. Supports full CRUD operations across all Keitaro resources.
tools: Bash, Read, Write
---
# Keitaro API Skill
This skill provides a comprehensive interface to the Keitaro Admin API v1, enabling management of affiliate marketing infrastructure including campaigns, offers, affiliate networks, domains, landing pages, and third-party integrations.
## Configuration
Specify if Keitaro requests are wrapped w/ cloudflare worker, so instead of:
```bash
curl -H "Api-Key: $KEITARO_API_KEY" \
"https://$KEITARO_DOMAIN/admin_api/v1/affiliate_networks"
```
we should use:
```bash
curl -s -H "x-team-key: $TEAM_KEY}" -H "x-keitaro-instance: $KT_KEY"
"https://{HOSTNAME}/admin_api/v1/affiliate_networks"
```
if not - use requests as provided;
## Notes
- Env variables for scripts should be presented in working folder `.env` file, create one with `cp assets/.env.example ../../.env` if not exists;
- API Documentation Index file: `references/openapi.yaml`.
- The base path for all endpoints is `/admin_api/v1`.
- All POST/PUT requests require `Content-Type: application/json` header
- Dates should be in ISO format (YYYY-MM-DD)
- IDs are integers, not strings
- Some endpoints support pagination with `offset` and `limit` parameters
- Archive/restore endpoints exist for most resources (campaigns, offers, domains, etc.)
- The API supports bulk operations for costs and statistics updates
## Response Codes
- **200/201**: Success
- **400**: Invalid request parameters
- **401**: Missing/invalid API key
- **402**: Account limitation (subscription issue)
- **404**: Resource not found
- **406**: Request state conflict
- **422**: Validation failure
- **500**: Server error
## Usage Examples
When the user asks to:
1. **"Create an affiliate network called MaxBounty"**:
- Use the create affiliate network endpoint
- Return the created network ID
2. **"List all active campaigns"**:
- Use the campaigns list endpoint
- Filter or format the response for active campaigns
3. **"Get statistics for campaign 123 in January"**:
- Use the clicks/log endpoint with proper date range
- Include campaign_id filter
4. **"Clone offer 456 with a new name"**:
- Use the clone offer endpoint
- Pass the new name in the request
## Error Handling
Always check the response status code and provide meaningful error messages:
```bash
response=$(curl -s -w "\n%{http_code}" -H "Api-Key: $KEITARO_API_KEY" "$url")
http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')
if [ "$http_code" -eq 200 ]; then
echo "$body" | jq .
else
echo "Error $http_code: $body"
fi
```