bulk_delete_qr_codes
Delete multiple QR codes and their associated scan analytics in one request. Supports up to 50 codes; non-existent IDs are reported as not_found without stopping the batch.
Instructions
Delete multiple QR codes and their scan analytics in a single request (up to 50). Items with non-existent short_id are reported as not_found without failing the whole batch.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| short_ids | Yes | Array of short_id strings to delete. Max 50 per request. |
Implementation Reference
- src/modules/qr/qr.service.ts:508-532 (handler)The actual implementation function that handles bulk deletion. Iterates through shortIds, checks ownership via apiKeyId, deletes matching QR codes, and returns a summary of deleted/not_found items.
export function bulkDeleteQrCodes(shortIds: string[], apiKeyId: number) { let deleted = 0; let notFound = 0; const results: Array<{ short_id: string; status: "deleted" | "not_found" }> = []; for (const shortId of shortIds) { const existing = db .select() .from(qrCodes) .where(and(eq(qrCodes.shortId, shortId), eq(qrCodes.apiKeyId, apiKeyId))) .get(); if (!existing) { notFound++; results.push({ short_id: shortId, status: "not_found" }); continue; } db.delete(qrCodes).where(eq(qrCodes.shortId, shortId)).run(); deleted++; results.push({ short_id: shortId, status: "deleted" }); } return { deleted, not_found: notFound, items: results }; } - src/modules/qr/qr.schemas.ts:438-470 (schema)Route schema definition for bulk delete: validates body requires short_ids array (1-50 items), defines 200 response shape with deleted count, not_found count, and items array.
export const qrBulkDeleteSchema = { body: { type: "object" as const, required: ["short_ids"], properties: { short_ids: { type: "array", minItems: 1, maxItems: 50, description: "Array of short_id strings to delete (max 50).", items: { type: "string" }, }, }, }, response: { 200: { type: "object", properties: { deleted: { type: "integer" }, not_found: { type: "integer" }, items: { type: "array", items: { type: "object", properties: { short_id: { type: "string" }, status: { type: "string", enum: ["deleted", "not_found"] }, }, }, }, }, }, }, - packages/mcp/src/tools.ts:261-273 (registration)MCP tool registration for bulk_delete_qr_codes. Defines input schema (short_ids array, 1-50 items) and handler that calls the HTTP API endpoint DELETE /api/qr/bulk.
bulk_delete_qr_codes: { description: "Delete multiple QR codes and their scan analytics in a single request (up to 50). Items with non-existent short_id are reported as not_found without failing the whole batch.", inputSchema: z.object({ short_ids: z .array(z.string()) .min(1) .max(50) .describe("Array of short_id strings to delete. Max 50 per request."), }), handler: async (input: Record<string, unknown>) => { return apiRequest("/api/qr/bulk", { method: "DELETE", body: input }); }, - src/modules/qr/qr.routes.ts:299-315 (registration)Route registration for DELETE /api/qr/bulk. Validates body with qrBulkDeleteSchema, then delegates to qrService.bulkDeleteQrCodes().
// BULK DELETE QR codes app.delete( "/bulk", { schema: { ...qrBulkDeleteSchema, tags: ["QR Codes"], summary: "Delete multiple QR codes in one request", description: "Delete up to 50 QR codes and their scan analytics in a single request. Items with non-existent short_id are reported as not_found.", }, }, async (request, reply) => { const body = request.body as { short_ids: string[] }; return qrService.bulkDeleteQrCodes(body.short_ids, request.apiKeyId); } );