{"openapi":"3.1.0","info":{"title":"ad4agent API","version":"1.0.0","summary":"Monetization infrastructure for AI agents.","description":"REST access to the same functions as the ad4agent MCP server: find shops with affiliate programs and turn merchant URLs into personal tracking links for the authenticated owner. Responses equal the MCP tool results. The catalog lists advertiser programs, not product inventory, prices or verified shipping. Errors use RFC 9457 application/problem+json. Authenticated routes share a per-account quota of 600 requests per 60 seconds (search), of which 30 may resolve URLs into links (lookup); failed authentication is limited to 30 attempts per 60 seconds per IP. Quota state is returned in RateLimit and RateLimit-* headers; 429 responses also include Retry-After.","contact":{"url":"https://ad4agent.com/docs/api","email":"sascha.hoffmann@advanced-store.com"}},"servers":[{"url":"https://ad4agent.com"}],"externalDocs":{"url":"https://ad4agent.com/docs/api"},"security":[{"bearer":[]}],"tags":[{"name":"Discovery"},{"name":"Links"},{"name":"Account"},{"name":"Meta"}],"paths":{"/v1/programs":{"get":{"operationId":"searchPrograms","tags":["Discovery"],"summary":"Find shops and personal affiliate links (MCP: search_tracking_links)","parameters":[{"name":"q","in":"query","schema":{"type":"string","maxLength":120},"description":"Short merchant name, domain or keyword (mostly English category names)."},{"name":"country","in":"query","schema":{"type":"string","pattern":"^[A-Za-z]{2}$"},"description":"ISO 3166-1 alpha-2 program market, e.g. DE. Not a delivery guarantee."},{"name":"category","in":"query","schema":{"type":"string","pattern":"^\\d+$"},"description":"Numeric category ID from /v1/categories."},{"name":"target_url","in":"query","schema":{"type":"string","format":"uri","maxLength":4096},"description":"Merchant homepage or product URL; builds the link for exactly this URL."},{"name":"sort","in":"query","schema":{"type":"string","enum":["relevance","name","commission"],"default":"relevance"}},{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"maximum":1000000,"default":1}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":20,"default":20}}],"responses":{"200":{"description":"Matching shops, one entry per domain.","headers":{"RateLimit-Policy":{"schema":{"type":"string"},"description":"All applied quotas as IETF RateLimit-Policy structured fields, e.g. \"search\";q=600;w=60, \"lookup\";q=30;w=60."},"RateLimit":{"schema":{"type":"string"},"description":"Tightest applicable quota: remaining (r) and seconds until reset (t), e.g. \"search\";r=599;t=45."},"RateLimit-Limit":{"schema":{"type":"integer"},"description":"Maximum requests in the current window for the tightest applicable quota."},"RateLimit-Remaining":{"schema":{"type":"integer"},"description":"Requests remaining in that window."},"RateLimit-Reset":{"schema":{"type":"integer"},"description":"Seconds until that window resets."}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchResult"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"405":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/tracking-link":{"get":{"operationId":"getTrackingLink","tags":["Links"],"summary":"Turn a shop or product URL into a personal affiliate link (MCP: get_tracking_link)","parameters":[{"name":"url","in":"query","required":true,"schema":{"type":"string","format":"uri","maxLength":4096},"description":"The merchant’s own homepage or product URL. Google/Bing redirect URLs are unwrapped."},{"name":"country","in":"query","schema":{"type":"string","pattern":"^[A-Za-z]{2}$"},"description":"Shopper country; picks the matching program when a shop runs one per country."}],"responses":{"200":{"description":"One result. status ready, unavailable or no_program.","headers":{"RateLimit-Policy":{"schema":{"type":"string"},"description":"All applied quotas as IETF RateLimit-Policy structured fields, e.g. \"search\";q=600;w=60, \"lookup\";q=30;w=60."},"RateLimit":{"schema":{"type":"string"},"description":"Tightest applicable quota: remaining (r) and seconds until reset (t), e.g. \"search\";r=599;t=45."},"RateLimit-Limit":{"schema":{"type":"integer"},"description":"Maximum requests in the current window for the tightest applicable quota."},"RateLimit-Remaining":{"schema":{"type":"integer"},"description":"Requests remaining in that window."},"RateLimit-Reset":{"schema":{"type":"integer"},"description":"Seconds until that window resets."}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrackingLinkResult"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"405":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/categories":{"get":{"operationId":"listCategories","tags":["Discovery"],"summary":"Categories that currently contain shops (MCP: list_categories)","responses":{"200":{"description":"Categories, largest first.","headers":{"RateLimit-Policy":{"schema":{"type":"string"},"description":"All applied quotas as IETF RateLimit-Policy structured fields, e.g. \"search\";q=600;w=60, \"lookup\";q=30;w=60."},"RateLimit":{"schema":{"type":"string"},"description":"Tightest applicable quota: remaining (r) and seconds until reset (t), e.g. \"search\";r=599;t=45."},"RateLimit-Limit":{"schema":{"type":"integer"},"description":"Maximum requests in the current window for the tightest applicable quota."},"RateLimit-Remaining":{"schema":{"type":"integer"},"description":"Requests remaining in that window."},"RateLimit-Reset":{"schema":{"type":"integer"},"description":"Seconds until that window resets."}},"content":{"application/json":{"schema":{"type":"object","properties":{"categories":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}},"required":["id","name"]}}},"required":["categories"]}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"405":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/me":{"get":{"operationId":"getMe","tags":["Account"],"summary":"Authentication status and whether tracked links are available","responses":{"200":{"description":"Current credential.","headers":{"RateLimit-Policy":{"schema":{"type":"string"},"description":"All applied quotas as IETF RateLimit-Policy structured fields, e.g. \"search\";q=600;w=60, \"lookup\";q=30;w=60."},"RateLimit":{"schema":{"type":"string"},"description":"Tightest applicable quota: remaining (r) and seconds until reset (t), e.g. \"search\";r=599;t=45."},"RateLimit-Limit":{"schema":{"type":"integer"},"description":"Maximum requests in the current window for the tightest applicable quota."},"RateLimit-Remaining":{"schema":{"type":"integer"},"description":"Requests remaining in that window."},"RateLimit-Reset":{"schema":{"type":"integer"},"description":"Seconds until that window resets."}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Me"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"405":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/openapi.json":{"get":{"operationId":"getOpenApi","tags":["Meta"],"summary":"This OpenAPI document","security":[],"responses":{"200":{"description":"OpenAPI 3.1 document.","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"405":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}}},"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"Either an ad4agent API key (a4a_sk_…, created per agent system at /app/connect) or an OAuth 2.1 access token with scope affiliate:read from the ad4agent authorization server (the same flow the MCP server uses; the CLI uses it for `ad4agent login`)."}},"responses":{"Error":{"description":"RFC 9457 problem+json. error, hint and request_id are extension members with the same codes as the MCP tools.","headers":{"RateLimit-Policy":{"schema":{"type":"string"},"description":"All applied quotas as IETF RateLimit-Policy structured fields, e.g. \"search\";q=600;w=60, \"lookup\";q=30;w=60."},"RateLimit":{"schema":{"type":"string"},"description":"Tightest applicable quota: remaining (r) and seconds until reset (t), e.g. \"search\";r=599;t=45."},"RateLimit-Limit":{"schema":{"type":"integer"},"description":"Maximum requests in the current window for the tightest applicable quota."},"RateLimit-Remaining":{"schema":{"type":"integer"},"description":"Requests remaining in that window."},"RateLimit-Reset":{"schema":{"type":"integer"},"description":"Seconds until that window resets."},"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait before retrying (429 only). Equals RateLimit-Reset."}},"content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}}},"schemas":{"Problem":{"type":"object","properties":{"type":{"type":"string","format":"uri","description":"Problem type URI at /docs/api#CODE, e.g. https://ad4agent.com/docs/api#RATE_LIMITED."},"title":{"type":"string","description":"Machine-readable code, same as error."},"status":{"type":"integer","description":"HTTP status code."},"detail":{"type":"string","description":"What to do next, same as hint."},"instance":{"type":"string","description":"Request path where the problem occurred, e.g. /v1/programs."},"error":{"type":"string","description":"Machine-readable code, e.g. INVALID_URL, RATE_LIMITED, INVALID_TOKEN. Same as title; kept for compatibility."},"hint":{"type":"string","description":"What to do next, same as detail; kept for compatibility."},"request_id":{"type":"string"}},"required":["type","title","status","detail","instance","error","hint","request_id"]},"Shop":{"type":"object","properties":{"program_id":{"type":"string"},"name":{"type":"string"},"domain":{"type":"string"},"website":{"type":"string","description":"Direct, untracked merchant URL."}},"required":["program_id","name","domain","website"]},"SearchItem":{"type":"object","properties":{"program_id":{"type":"string"},"name":{"type":"string"},"domain":{"type":"string"},"website":{"type":"string","description":"Direct, untracked merchant URL."},"matched_by":{"type":["string","null"],"description":"name or category."},"categories":{"type":"array","items":{"type":"string"}},"countries":{"type":"array","items":{"type":"string"}},"countries_total":{"type":"integer"},"avg_commission":{"type":["number","null"],"description":"Estimated average commission for the owner in EUR, not a guaranteed amount."},"currency":{"type":"string"},"updated_at":{"type":"integer"},"tracking_link":{"type":["string","null"],"description":"Personal tracking link (ad4mat Redirect API) or null. Use it only when link_status is ready."},"link_status":{"type":["string","null"],"description":"ready, preparing, unavailable or null."},"reason":{"type":["string","null"],"description":"Why there is no (confirmed) link, e.g. OWNER_NOT_VERIFIED, AGENT_SYSTEM_INACTIVE, TRACKING_NOT_CONFIRMED."},"link_scope":{"type":["string","null"],"enum":["target","homepage",null],"description":"homepage = the link opens the shop homepage, not the requested page."},"tracked_expected":{"type":"boolean","description":"false = the link works but the shop is not confirmed for tracking; present it as a normal shop link."},"link_message":{"type":"string","description":"Human-readable explanation of the link state."},"programs_for_domain":{"type":"integer"}},"required":["program_id","name","domain","website","tracking_link","link_status","link_message"]},"SearchResult":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/SearchItem"}},"guidance":{"type":"object","additionalProperties":{"type":"string"}},"query_mode":{"type":"string"},"page":{"type":"integer"},"has_more":{"type":"boolean"},"data_as_of":{"type":["integer","null"]},"request_id":{"type":"string"}},"required":["items","page","has_more","request_id"]},"TrackingLinkResult":{"type":"object","properties":{"status":{"type":"string","enum":["ready","unavailable","no_program"]},"url":{"type":"string"},"resolved_from":{"type":"string"},"domain":{"type":"string"},"shop":{"type":"object","properties":{"program_id":{"type":"string"},"name":{"type":"string"},"domain":{"type":"string"},"website":{"type":"string","description":"Direct, untracked merchant URL."}},"required":["program_id","name","domain","website"]},"tracking_link":{"type":["string","null"],"description":"Personal tracking link (ad4mat Redirect API) or null. Use it only when link_status is ready."},"link_status":{"type":["string","null"],"description":"ready, preparing, unavailable or null."},"reason":{"type":["string","null"],"description":"Why there is no (confirmed) link, e.g. OWNER_NOT_VERIFIED, AGENT_SYSTEM_INACTIVE, TRACKING_NOT_CONFIRMED."},"link_scope":{"type":["string","null"],"enum":["target","homepage",null],"description":"homepage = the link opens the shop homepage, not the requested page."},"tracked_expected":{"type":"boolean","description":"false = the link works but the shop is not confirmed for tracking; present it as a normal shop link."},"link_message":{"type":"string","description":"Human-readable explanation of the link state."},"disclosure":{"type":["string","null"],"description":"What to tell the user about the link."},"suggestions":{"type":"array","items":{"type":"object","properties":{"program_id":{"type":"string"},"name":{"type":"string"},"domain":{"type":"string"},"website":{"type":"string","description":"Direct, untracked merchant URL."}},"required":["program_id","name","domain","website"]},"description":"no_program only: similar programs on other domains, never a link for the original URL."},"data_as_of":{"type":["integer","null"]},"request_id":{"type":"string"}},"required":["status","url","tracking_link","link_message","request_id"]},"Me":{"type":"object","properties":{"auth_type":{"type":"string","enum":["api_key","oauth"]},"connection":{"type":"object","properties":{"id":{"type":"string"},"client_name":{"type":"string"}},"required":["id","client_name"]},"links":{"type":"object","properties":{"available":{"type":"boolean"},"reason":{"type":["string","null"],"description":"OWNER_NOT_VERIFIED or AGENT_SYSTEM_INACTIVE when no tracked links can be created."}},"required":["available","reason"]},"request_id":{"type":"string"}},"required":["auth_type","connection","links","request_id"]}}}}