coupon_issue_apply
# coupon_issue_apply
Issues coupons from one coupon (1–200 at once) or withdraws issued coupons, as the console coupon screen does. Choose the coupon by targetId (cotid) from discounts_get. Issued coupons cannot be deleted and a withdrawn coupon cannot be restored. Called without confirmToken it previews and returns a confirmToken; repeating the same input with it executes once. Ask the user again before executing; this cannot be undone. When the preview has requiresReconfirmation, execute only with irreversibleConfirmed: true after the person confirms again.
## Inputs
| Field | Required here | Contract |
| --- | --- | --- |
| `targetId` | Yes | string; pattern `^[A-Za-z0-9_-]{1,128}$`; The coupon (cotid) from discounts_get with family coupon-template. |
| `action` | Yes | one of: `issue`, `withdraw` (by `kind`) |
| `action.quantity` | Yes | When `action.kind` is `issue`: integer; minimum 1; maximum 200; How many coupons to issue at once: 1–200, as the console allows. |
| `action.codes` | Yes | When `action.kind` is `withdraw`: array; items: string; min length 1; max length 200; min items 1; max items 100; Issued coupon codes to withdraw. USED, WITHDRAWN and EXPIRED coupons cannot be withdrawn; a withdrawn coupon cannot be used again. |
| `confirmToken` | No | string; pattern `^ct[a-f\d]{32}$`; The confirmToken from this tool's preview result. Omit it to preview; repeat the same input with it to execute. |
| `irreversibleConfirmed` | No | `true`; true only after the person confirmed again, when the preview has requiresReconfirmation: the action cannot be undone. |