---
title: "Generate Batch Async"
method: POST
path: "/api/messages/generate-batch-async"
tags: ["Messages"]
---

# Generate Batch Async

`POST /api/messages/generate-batch-async`

## Request

- Base URL: `https://api.soeru.biz` (the document declares no server; this is the origin it was published from)
- URL: `https://api.soeru.biz/api/messages/generate-batch-async`
- Auth: none declared. Required headers: `authorization`

バルク生成の背景ジョブ化 (2026-06-11, migration 107)。

旧: 4 件ずつの同期チャンクがフロント timeout (60s) / プロキシ (~100s) と競争し、
10 通で必ずタイムアウト → 自動リカバリが処理中の注文を再生成 (二重課金の温床)。
新: 即座に job_id を返し、生成は spawn_background_task でサーバー側続行。
フロントは /generation-jobs/{id} をポーリング。HTTP が長持ちしない =
タイムアウト概念ごと消える。離脱安全。

- per-shop 実行中ガード: 直近 10 分以内に更新された running ジョブがあれば
  それを返す (resumed=true) — 二重発火を構造的に防止
- generation_jobs テーブル未適用環境では 503 → フロントは従来チャンクへ fallback

## Headers

- `x-shop-id` string, nullable: Optional shop ID
- `authorization` string, required: Bearer <token>

## Request body

- BatchGenerateRequest
  - `orders` GenerateRequest[], required
    - `order_id` string, required
    - `customer_name` string
    - `customer_email` string, nullable
    - `item_names` string[]
    - `total_price` integer
    - `is_gift` boolean
    - `delivery_context` string, nullable
    - `repeat_count` integer, nullable
    - `is_repeat` boolean, nullable
    - `mode` string
  - `restore_only` boolean

## Response `200`

Successful Response

- unknown

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/soeru/apis/soeru-api.md) · [All operations](https://skmtc.dev/soeru/apis/soeru-api/llms.txt) · [OpenAPI document](https://skmtc.dev/soeru/apis/soeru-api/revisions/63f8d371abed?raw)
