Skip to main content
Glama

create_coupon

Create a discount coupon for a product by providing product ID, coupon code, discount percentage, and optional validity period and affiliate.

Instructions

Create Coupon

Cria um cupom de desconto para um produto.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
product_idYesID do produto
codeYesCódigo do cupom (máximo 25 caracteres)
discountYesPercentual de desconto (entre 0 e 0.99, exclusivo)
start_dateNoData de início de validade (timestamp em milissegundos)
end_dateNoData de fim de validade (timestamp em milissegundos)
affiliateNoID do afiliado
offer_idsNoIDs das ofertas aplicáveis

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Handler function for the 'create_coupon' tool. Sends a POST request to /products/api/v1/product/{product_id}/coupon with coupon details (code, discount, dates, affiliate, offer_ids) and returns the JSON response.
    async def create_coupon(
        product_id: int,
        code: str,
        discount: float,
        start_date: Optional[int] = None,
        end_date: Optional[int] = None,
        affiliate: Optional[int] = None,
        offer_ids: Optional[list[int]] = None,
    ) -> str:
        """Create Coupon
        
        Cria um cupom de desconto para um produto.
        
        Args:
            product_id: ID do produto
            code: Código do cupom (máximo 25 caracteres)
            discount: Percentual de desconto (entre 0 e 0.99, exclusivo)
            start_date: Data de início de validade (timestamp em milissegundos)
            end_date: Data de fim de validade (timestamp em milissegundos)
            affiliate: ID do afiliado
            offer_ids: IDs das ofertas aplicáveis"""
        endpoint = f"/products/api/v1/product/{product_id}/coupon"
        body = {}
        body["code"] = code
        body["discount"] = discount
        if start_date is not None:
            body["start_date"] = start_date
        if end_date is not None:
            body["end_date"] = end_date
        if affiliate is not None:
            body["affiliate"] = affiliate
        if offer_ids is not None:
            body["offer_ids"] = offer_ids
        result = await get_client().post(endpoint, json=body)
        return json.dumps(result, indent=2)
  • Type annotations define the input schema for create_coupon: required fields (product_id, code, discount) and optional fields (start_date, end_date, affiliate, offer_ids).
    product_id: int,
    code: str,
    discount: float,
    start_date: Optional[int] = None,
    end_date: Optional[int] = None,
    affiliate: Optional[int] = None,
    offer_ids: Optional[list[int]] = None,
  • Automatic tool registration in _discover_and_register_tools(): iterates over modules in hotmart_mcp.tools package and registers every public async coroutine function (including create_coupon) via mcp.tool()(obj).
        for name, obj in inspect.getmembers(module, iscoroutinefunction):
            if name.startswith("_"):
                continue
            mcp.tool()(obj)
            registered += 1
    
    return registered
  • Re-exports all public symbols from the coupons module (including create_coupon) so they are discoverable by the server's registration logic.
    from .coupons import *  # noqa: F401,F403
    from .negotiation import *  # noqa: F401,F403
    from .products import *  # noqa: F401,F403
    from .sales import *  # noqa: F401,F403
    from .subscriptions import *  # noqa: F401,F403
    from .tickets import *  # noqa: F401,F403
  • Lazy singleton helper that provides the authenticated HTTP client (HotmartClient) used by create_coupon to make the POST request.
    def get_client() -> HotmartClient:
        global _client
        if _client is None:
            _client = HotmartClient()
        return _client
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description must carry the full burden. It only states the action without disclosing side effects, idempotency, required permissions, or error conditions, leaving significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very brief, just two lines, but includes redundant information in English and Portuguese. It is concise but could be more streamlined.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With 7 parameters and an output schema present, the description is minimal. It lacks context about constraints like code uniqueness, date ranges, or validation rules, but the schema covers parameter details. Adequate but not comprehensive.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the input schema already provides detailed parameter descriptions. The description adds no additional meaning beyond the schema, which is adequate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Create Coupon' and explains it creates a discount coupon for a product, which is specific and distinct from sibling tools like 'delete_coupon' and 'get_coupons'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implicitly indicates when to use (to create a coupon) but provides no guidance on when not to use or any alternatives, leaving the agent to infer usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/thaleslaray/hotmart-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server