membership_serial_keys_apply
# membership_serial_keys_apply
Issues serial keys for one serial key (COUPON_) plan, 1–200 at once, or withdraws issued keys, as the console serial key screen does. Choose the membership and the plan from memberships_get. Issued keys cannot be deleted, only withdrawn, and a withdrawn key cannot be restored; the preview shows the quantity or the keys first. Only keys still in the ISSUED state can be withdrawn. A sent request is never sent again. 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 |
| --- | --- | --- |
| `membershipMid` | Yes | string; min length 1; max length 512; The membership mid from memberships_get. |
| `subscriptionProductId` | Yes | integer; greater than 0; The serial key (COUPON_) plan of that membership. |
| `action` | Yes | one of: `issue`, `withdraw` (by `kind`) |
| `action.quantity` | Yes | When `action.kind` is `issue`: integer; minimum 1; maximum 200; How many serial keys 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 4096; min items 1; max items 100; Issued serial keys to withdraw. Only keys still in the ISSUED state can be withdrawn; a withdrawn key 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. |