insumer_validate_code
Validate INSR-XXXXX discount codes during checkout by confirming validity, discount percent, and expiry. Returns valid or invalid status with a reason. No authentication required.
Instructions
Validate an INSR-XXXXX discount code. For merchant backends during ACP/UCP checkout to confirm code validity, discount percent, and expiry. Returns valid/invalid status with reason. No authentication required, no credits consumed. Does not expose wallet or token data.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Discount code in INSR-XXXXX format |
Implementation Reference
- src/index.ts:750-763 (registration)Tool registration for 'insumer_validate_code' using server.tool() — defines name, description, schema, and handler.
server.tool( "insumer_validate_code", "Validate an INSR-XXXXX discount code. For merchant backends during ACP/UCP checkout to confirm code validity, discount percent, and expiry. Returns valid/invalid status with reason. No authentication required, no credits consumed. Does not expose wallet or token data.", { code: z.string().regex(/^INSR-[A-Z0-9]{5}$/).describe("Discount code in INSR-XXXXX format"), }, async (args) => { const res = await fetch(`${API_BASE}/codes/${encodeURIComponent(args.code)}`); const data = await res.json(); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], }; } ); - src/index.ts:753-755 (schema)Input schema for the tool: a single required 'code' parameter validated with regex /^INSR-[A-Z0-9]{5}$/ matching the INSR-XXXXX format.
{ code: z.string().regex(/^INSR-[A-Z0-9]{5}$/).describe("Discount code in INSR-XXXXX format"), }, - src/index.ts:756-762 (handler)Handler function: fetches code validation from API_BASE/codes/{code} endpoint without API key auth, returns the response as JSON text.
async (args) => { const res = await fetch(`${API_BASE}/codes/${encodeURIComponent(args.code)}`); const data = await res.json(); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], }; }