{
  "openapi": "3.0.3",
  "info": {
    "title": "Rewards Bunny Cashback Availability API",
    "version": "1.0.0",
    "description": "Public API for AI agents to check whether any merchant, brand, store, website, or product page currently supports Rewards Bunny cashback. Use this when a user is shopping, buying from a merchant, checking out, asking about cashback, asking about coupons, comparing deals, or asking whether Rewards Bunny can be activated before purchase. If `activation.url` is returned, it uses the user-facing Rewards Bunny host and selected store id, for example `https://rewardsbunny.com/out/store/{store_id}`. It is a user handoff URL only. Agents must not fetch, open, prefetch, crawl, or preview `activation.url`; give it to the user to open in their own browser. This API checks cashback availability and activation; do not claim coupon availability unless coupon data is returned."
  },
  "servers": [
    {
      "url": "https://cbapi.rewardsbunny.com",
      "description": "Rewards Bunny cashback API"
    }
  ],
  "tags": [
    {
      "name": "Agent Cashback Availability",
      "description": "Cashback availability lookup for agent integrations."
    }
  ],
  "paths": {
    "/api/agent/store-availability": {
      "get": {
        "tags": [
          "Agent Cashback Availability"
        ],
        "operationId": "getAgentStoreAvailability",
        "summary": "Check merchant cashback availability",
        "description": "Checks whether a merchant URL or domain currently supports Rewards Bunny cashback. Provide either `url` or `domain`. Extract the merchant URL or domain from the user's message, current page URL, or browsing context. If the user gives only a brand name and no reliable domain is available, ask for the merchant website URL before checking. Optional `country` narrows duplicate merchant records to a 2-letter ISO country code; include it only when reliably known from the user, URL locale, platform locale, or prior conversation. If country is unknown, omit it. `cashback_available=true` means the matched merchant currently supports cashback. `matched=false` means the merchant could not be matched. `cashback_available=false` can mean unavailable, disabled, or not eligible for the requested country. If present, `activation.url` must be handed to the user and must not be fetched by the agent. This API checks cashback availability and activation, not general coupon availability unless coupon data is returned.",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": false,
            "description": "Full merchant URL to check. Provide either `url` or `domain`.",
            "schema": {
              "type": "string",
              "format": "uri",
              "example": "https://www.adidas.com/us/men-shoes"
            }
          },
          {
            "name": "domain",
            "in": "query",
            "required": false,
            "description": "Merchant domain to check. Provide either `domain` or `url`.",
            "schema": {
              "type": "string",
              "example": "adidas.com"
            }
          },
          {
            "name": "country",
            "in": "query",
            "required": false,
            "description": "Optional 2-letter ISO country code such as `US`, `GB`, or `SG`. Include this only when reliably known from the user's message, merchant URL locale, platform user/session/browser locale, or prior conversation. If no reliable country is known, omit it. When supplied, Rewards Bunny selects the best matching store eligible for that country.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z]{2}$",
              "example": "US"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Merchant lookup completed. Check `matched`, `cashback_available`, and `reason_codes` to decide how to respond to the user.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoreAvailabilityResponse"
                },
                "examples": {
                  "cashbackAvailable": {
                    "summary": "Cashback is available",
                    "value": {
                      "query": {
                        "input_url": "https://www.adidas.com/us/men-shoes",
                        "input_domain": null,
                        "normalized_url": "https://www.adidas.com/us/men-shoes",
                        "normalized_domain": "www.adidas.com",
                        "input_country": "US",
                        "country_code": "US",
                        "country_source": "query",
                        "region_id": 174
                      },
                      "matched": true,
                      "cashback_available": true,
                      "reason_codes": [],
                      "store": {
                        "id": 123,
                        "name": "Adidas",
                        "slug": "adidas",
                        "logo": "https://cdn.example.com/adidas.png",
                        "domain_name": "adidas.com",
                        "cashback_amount": 6,
                        "amount_type": "percent",
                        "rate_type": "upto",
                        "cashback_string": "Up to 6% cashback"
                      },
                      "cashback_options": [
                        {
                          "title": "Shoes",
                          "description": "Eligible on full-price shoes",
                          "rate_type": "percent",
                          "cashback": 6,
                          "enabled": true
                        }
                      ],
                      "activation": {
                        "type": "out_link",
                        "url": "https://rewardsbunny.com/out/store/123?url=https%3A%2F%2Fwww.adidas.com%2Fus%2Fmen-shoes",
                        "requires_user_open": true,
                        "login_handled_on_open": true,
                        "agent_must_not_prefetch": true
                      },
                      "selection": {
                        "selection_rule": "highest_enabled_cashback_in_country",
                        "matched_store_count": 1,
                        "country_eligible_store_count": 1,
                        "enabled_candidate_count": 1,
                        "selected_store_id": 123
                      },
                      "guidance": {
                        "user_must_open_activation_url": true,
                        "login_handled_on_open": true,
                        "agent_must_not_prefetch_activation_url": true,
                        "country_recommended_for_duplicate_domains": true,
                        "is_claimable": true,
                        "confirm_duration": "90 Days",
                        "terms_todo": "Start from Rewards Bunny before checkout.",
                        "terms_not_todo": "Gift cards may not qualify."
                      }
                    }
                  },
                  "storeNotFound": {
                    "summary": "Merchant could not be matched",
                    "value": {
                      "query": {
                        "input_url": null,
                        "input_domain": "unknown-example-store.test",
                        "normalized_url": null,
                        "normalized_domain": "unknown-example-store.test",
                        "input_country": null,
                        "country_code": null,
                        "country_source": null,
                        "region_id": null
                      },
                      "matched": false,
                      "cashback_available": false,
                      "reason_codes": [
                        "store_not_found"
                      ],
                      "store": null,
                      "cashback_options": [],
                      "activation": null,
                      "selection": {
                        "selection_rule": "highest_enabled_cashback_overall",
                        "matched_store_count": 0,
                        "country_eligible_store_count": 0,
                        "enabled_candidate_count": 0,
                        "selected_store_id": null
                      },
                      "guidance": {
                        "user_must_open_activation_url": true,
                        "login_handled_on_open": true,
                        "agent_must_not_prefetch_activation_url": true,
                        "country_recommended_for_duplicate_domains": true
                      }
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Invalid request, usually because neither `url` nor `domain` was provided or because `country` is not a supported 2-letter ISO country code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                },
                "example": {
                  "message": "Either url or domain is required.",
                  "errors": {
                    "url": [
                      "Provide a merchant URL or domain."
                    ]
                  }
                }
              }
            }
          }
        },
        "x-agent-guidance": {
          "when_to_use": "Use for any shopping, checkout, deal comparison, cashback, coupon, or Rewards Bunny activation request involving a merchant URL or domain.",
          "merchant_extraction": "Extract the merchant URL or domain from the user message, active page URL, or browsing context. If only a brand name is provided and no reliable domain is available, ask for the merchant website URL.",
          "country_selection": "Include country only when reliably known from the user, merchant URL locale, platform locale, or prior conversation. If unknown, omit country.",
          "coupon_policy": "Do not claim coupon availability unless coupon data is returned by the API.",
          "activation_url_policy": "Do not fetch, open, prefetch, crawl, or preview activation.url. Give activation.url to the user so they can open it in their own browser.",
          "cashback_available_true": "The merchant currently supports Rewards Bunny cashback.",
          "matched_false": "The merchant could not be matched.",
          "cashback_available_false": "Cashback may be unavailable, disabled, or not eligible for the requested country."
        }
      }
    },
    "/api/agent/status": {
      "get": {
        "tags": [
          "Agent Cashback Availability"
        ],
        "operationId": "getAgentStatus",
        "summary": "Check agent API status",
        "description": "Returns a lightweight public health payload for API catalog status discovery.",
        "responses": {
          "200": {
            "description": "Agent API is reachable.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "service"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "ok"
                    },
                    "service": {
                      "type": "string",
                      "example": "rewardsbunny-cashback-api"
                    }
                  }
                },
                "example": {
                  "status": "ok",
                  "service": "rewardsbunny-cashback-api"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "StoreAvailabilityResponse": {
        "type": "object",
        "required": [
          "query",
          "matched",
          "cashback_available",
          "reason_codes",
          "store",
          "cashback_options",
          "activation",
          "selection",
          "guidance"
        ],
        "properties": {
          "query": {
            "$ref": "#/components/schemas/LookupQuery"
          },
          "matched": {
            "type": "boolean",
            "description": "`false` means Rewards Bunny could not match the merchant to a store."
          },
          "cashback_available": {
            "type": "boolean",
            "description": "`true` means the matched merchant currently supports cashback. `false` can mean unavailable, disabled, or not eligible for the requested country."
          },
          "reason_codes": {
            "type": "array",
            "description": "Machine-readable reasons explaining a non-available or non-matched result.",
            "items": {
              "type": "string",
              "enum": [
                "store_not_found",
                "cashback_disabled",
                "country_not_eligible"
              ]
            }
          },
          "store": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/StoreInfo"
              }
            ],
            "description": "Matched merchant/store information. Null when the merchant was not matched or no country-eligible store was found."
          },
          "cashback_options": {
            "type": "array",
            "description": "Available cashback categories or rates for the selected store.",
            "items": {
              "$ref": "#/components/schemas/CashbackOption"
            }
          },
          "activation": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/Activation"
              }
            ],
            "description": "Present only when cashback is available. If present, activation.url is for the user only and must not be fetched, opened, prefetched, crawled, or previewed by the agent."
          },
          "selection": {
            "$ref": "#/components/schemas/Selection"
          },
          "guidance": {
            "$ref": "#/components/schemas/Guidance"
          }
        }
      },
      "LookupQuery": {
        "type": "object",
        "properties": {
          "input_url": {
            "type": "string",
            "nullable": true
          },
          "input_domain": {
            "type": "string",
            "nullable": true
          },
          "normalized_url": {
            "type": "string",
            "nullable": true
          },
          "normalized_domain": {
            "type": "string",
            "nullable": true
          },
          "input_country": {
            "type": "string",
            "nullable": true
          },
          "country_code": {
            "type": "string",
            "nullable": true
          },
          "country_source": {
            "type": "string",
            "nullable": true,
            "enum": [
              "query",
              "header"
            ]
          },
          "region_id": {
            "type": "integer",
            "nullable": true
          }
        }
      },
      "StoreInfo": {
        "type": "object",
        "description": "Merchant/store information for the selected Rewards Bunny store.",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "logo": {
            "type": "string",
            "nullable": true
          },
          "domain_name": {
            "type": "string"
          },
          "cashback_amount": {
            "type": "number",
            "nullable": true
          },
          "amount_type": {
            "type": "string",
            "nullable": true,
            "description": "Examples include `percent` and `fixed`."
          },
          "rate_type": {
            "type": "string",
            "nullable": true,
            "description": "Examples include `upto`, `flat`, or other Rewards Bunny rate labels."
          },
          "cashback_string": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "CashbackOption": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "rate_type": {
            "type": "string",
            "nullable": true
          },
          "cashback": {
            "type": "number",
            "nullable": true
          },
          "enabled": {
            "type": "boolean"
          }
        }
      },
      "Activation": {
        "type": "object",
        "required": [
          "type",
          "url",
          "requires_user_open",
          "login_handled_on_open",
          "agent_must_not_prefetch"
        ],
        "properties": {
          "type": {
            "type": "string",
            "example": "out_link"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "User handoff URL on `https://rewardsbunny.com/out/store/{store_id}`. Agents must not fetch, open, prefetch, crawl, or preview this URL. Give it to the user to open in their own browser."
          },
          "requires_user_open": {
            "type": "boolean",
            "description": "Always true when activation is returned."
          },
          "login_handled_on_open": {
            "type": "boolean",
            "description": "Rewards Bunny login and cashback activation are handled when the user opens the URL."
          },
          "agent_must_not_prefetch": {
            "type": "boolean",
            "description": "Always true. The agent must not fetch, open, or prefetch the activation URL."
          }
        }
      },
      "Selection": {
        "type": "object",
        "properties": {
          "selection_rule": {
            "type": "string",
            "enum": [
              "highest_enabled_cashback_overall",
              "highest_enabled_cashback_in_country"
            ]
          },
          "matched_store_count": {
            "type": "integer"
          },
          "country_eligible_store_count": {
            "type": "integer"
          },
          "enabled_candidate_count": {
            "type": "integer"
          },
          "selected_store_id": {
            "type": "integer",
            "nullable": true
          }
        }
      },
      "Guidance": {
        "type": "object",
        "properties": {
          "user_must_open_activation_url": {
            "type": "boolean",
            "description": "If activation.url is present, the user must open it in their own browser."
          },
          "login_handled_on_open": {
            "type": "boolean"
          },
          "agent_must_not_prefetch_activation_url": {
            "type": "boolean",
            "description": "Agents must not fetch, open, prefetch, crawl, or preview activation.url."
          },
          "country_recommended_for_duplicate_domains": {
            "type": "boolean",
            "description": "Supplying country improves selection when one merchant domain has multiple store records."
          },
          "is_claimable": {
            "type": "boolean",
            "nullable": true
          },
          "confirm_duration": {
            "type": "string",
            "nullable": true
          },
          "terms_todo": {
            "type": "string",
            "nullable": true
          },
          "terms_not_todo": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "ValidationError": {
        "type": "object",
        "required": [
          "message",
          "errors"
        ],
        "properties": {
          "message": {
            "type": "string"
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
