> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Список задач Midjourney

> POST /mj/task/list-by-condition выводит список задач Midjourney по фильтрам, чтобы получать статус одной или нескольких задач, включая прогресс и результаты.

Используйте этот endpoint, когда вам нужно получить пакет задач Midjourney вместо опроса по одному task id за раз.

## Когда это использовать

* Вы отслеживаете сразу много задач Midjourney
* Вы хотите фильтровать по состоянию задачи, окну отправки или другим условиям на стороне сервера
* Вам нужен дашборд или задача сверки вместо интерактивного опроса одной задачи

## Шаблон запроса

<Steps>
  <Step title="Используйте опрос одной задачи для горячих сценариев">
    Для одной активной задачи предпочтительнее [Fetch Single Task](./fetch-single-task), потому что это проще и быстрее.
  </Step>

  <Step title="Используйте список по условиям для пакетных проверок">
    Отправляйте условия фильтрации через этот endpoint, когда вам нужно проверить несколько задач Midjourney в одном запросе.
  </Step>

  <Step title="Продолжайте работу с важными задачами">
    Когда пакетный результат показывает задачи, требующие более глубокой проверки или продолжения, вернитесь к [Fetch Single Task](./fetch-single-task) и [Action](../action).
  </Step>
</Steps>

<Tip>
  Используйте этот маршрут для задач мониторинга и сверки; для основного интерактивного пути опроса используйте [Fetch Single Task](./fetch-single-task).
</Tip>


## OpenAPI

````yaml api/openapi/image/midjourney/task-fetching-api/post-list-by-condition.openapi.json POST /mj/task/list-by-condition
openapi: 3.1.0
info:
  title: List by Condition API
  version: 1.0.0
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /mj/task/list-by-condition:
    post:
      summary: List by Condition
      operationId: list_by_condition
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - ids
              properties:
                ids:
                  type: array
                  description: >-
                    Array of Midjourney task ids to retrieve. Returns the
                    current status and result for each.
                  items:
                    type: string
                  default:
                    - example
              default:
                ids:
                  - example
            examples:
              Default:
                summary: Fetch several tasks by id
                value:
                  ids:
                    - <task_id>
                    - <task_id>
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    action:
                      type: string
                      description: >-
                        Task type: `IMAGINE`, `UPSCALE`, `VARIATION`,
                        `DESCRIBE`, `BLEND`, `VIDEO`, or another action name.
                    buttons:
                      type: array
                      items:
                        type: object
                        properties:
                          customId:
                            type: string
                          emoji:
                            type: string
                          label:
                            type: string
                          style:
                            type: integer
                          type:
                            type: integer
                      description: >-
                        Action buttons available on the finished task. Send a
                        button's `customId` together with this task's id to
                        `/mj/submit/action` to upscale, vary, zoom, or pan.
                    description:
                      type: string
                      description: Human-readable submission status message.
                    failReason:
                      type: string
                      description: Failure reason when `status` is `FAILURE`.
                    finishTime:
                      type: integer
                      description: Completion time as a Unix timestamp in milliseconds.
                    id:
                      type: string
                      description: Task id.
                    imageUrl:
                      type: string
                      description: >-
                        Stable CometAPI-proxied image link
                        (`https://api.cometapi.com/mj/image/{id}`). Prefer this
                        link; entries in `image_urls` point at provider storage
                        and can expire.
                    progress:
                      type: string
                      description: >-
                        Progress percentage string such as `58%` while the task
                        runs and `100%` when finished.
                    prompt:
                      type: string
                      description: Original prompt as submitted.
                    promptEn:
                      type: string
                      description: >-
                        Prompt after translation to the provider language. For
                        `DESCRIBE` tasks, the extracted prompt suggestions
                        arrive here.
                    properties:
                      type: object
                      properties: {}
                      description: Additional task metadata, such as `finalPrompt`.
                    startTime:
                      type: integer
                      description: >-
                        Processing start time as a Unix timestamp in
                        milliseconds.
                    state:
                      type: string
                      description: >-
                        Custom state string echoed back from the submission for
                        your own tracking.
                    status:
                      type: string
                      description: >-
                        Task lifecycle state: `NOT_START`, `SUBMITTED`,
                        `IN_PROGRESS`, `SUCCESS`, or `FAILURE`.
                    submitTime:
                      type: integer
                      description: Submission time as a Unix timestamp in milliseconds.
      x-codeSamples:
        - lang: Shell
          label: Default
          source: |
            curl https://api.cometapi.com/mj/task/list-by-condition \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                "ids": ["<task_id>", "<task_id>"]
              }'
        - lang: Python
          label: Default
          source: |
            import os
            import requests

            response = requests.post(
                "https://api.cometapi.com/mj/task/list-by-condition",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={"ids": ["<task_id>", "<task_id>"]},
            )

            for task in response.json():
                print(task["id"], task["action"], task["status"], task.get("progress"))
        - lang: JavaScript
          label: Default
          source: >
            const response = await
            fetch("https://api.cometapi.com/mj/task/list-by-condition", {
                method: "POST",
                headers: {
                    Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                    "Content-Type": "application/json",
                },
                body: JSON.stringify({ ids: ["<task_id>", "<task_id>"] }),
            });


            for (const task of await response.json()) {
                console.log(task.id, task.action, task.status, task.progress);
            }
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````