> ## 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

> استخدم CometAPI POST /mj/submit/action لتطبيق إجراءات Midjourney — upscale وvariation وreroll وzoom وغير ذلك — على الصور المُولَّدة.

استخدم نقطة النهاية هذه بعد أن تُرجع مهمة Midjourney أزرار الإجراءات. فهي تبدأ مهمة لاحقة جديدة مثل upscale أو variation أو reroll أو zoom أو pan.

## تحتاج إلى قيمتين

* `taskId` من مهمة Midjourney الأصلية أو الأحدث
* `customId` من أحدث مصفوفة `buttons` مُعادة بواسطة [جلب مهمة واحدة](./task-fetching-api/fetch-single-task)

<Warning>
  `customId` غير ثابت. لا تقم أبدًا بترميزه بشكل ثابت. اقرأه دائمًا من أحدث استجابة polling.
</Warning>

## الإجراءات الشائعة

* `U1` إلى `U4`: upscale لصورة واحدة من الشبكة
* `V1` إلى `V4`: إنشاء variations من موضع صورة واحد
* Reroll: إعادة إنشاء الشبكة بالكامل
* Zoom وPan: توسيع التكوين الحالي

## بعد إرسال إجراء

<Steps>
  <Step title="إنشاء المهمة اللاحقة">
    أرسل `taskId` و`customId`، ثم خزّن id المهمة الجديد المُعاد.
  </Step>

  <Step title="الاستعلام عن المهمة الجديدة">
    نفّذ استعلام [جلب مهمة واحدة](./task-fetching-api/fetch-single-task) مرة أخرى حتى يكتمل الإجراء.
  </Step>

  <Step title="التعامل مع الإجراءات الخاصة بـ modal فقط">
    إذا وصلت المهمة الجديدة إلى `MODAL`، فتابع باستخدام [Modal](./modal) لتقديم الإدخال الإضافي.
  </Step>
</Steps>


## OpenAPI

````yaml api/openapi/image/midjourney/post-action.openapi.json POST /mj/submit/action
openapi: 3.1.0
info:
  title: Action API
  version: 1.0.0
  description: >-
    Create a Midjourney follow-up task such as upscale, variation, reroll, zoom,
    or pan using the latest button customId from the fetch response.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /mj/submit/action:
    post:
      summary: Create a Midjourney follow-up action task
      operationId: action
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - customId
                - taskId
              properties:
                customId:
                  type: string
                  description: >-
                    Action id taken from the latest `buttons` array returned by
                    the fetch endpoint.
                taskId:
                  type: string
                  description: Midjourney task id you want to continue from.
                state:
                  type: string
                  description: >-
                    Custom state string. Returned as-is in the task result and
                    webhook callback for your own tracking.
                enableRemix:
                  type: boolean
                  description: >-
                    Whether to force remix mode when the current action supports
                    it.
                chooseSameChannel:
                  type: boolean
                  description: >-
                    Whether to prefer the same provider account used by the
                    current task.
              default:
                customId: MJ::JOB::variation::3::example
                taskId: '1773314942177684'
                enableRemix: false
            examples:
              Upscale U1:
                summary: Upscale the first image (U1)
                value:
                  taskId: <task_id>
                  customId: MJ::JOB::upsample::1::<custom_id_hash>
              Vary Region:
                summary: >-
                  Open the Vary (Region) modal; the response returns code 21 and
                  a task id to use with /mj/submit/modal
                value:
                  taskId: <task_id>
                  customId: MJ::Inpaint::1::<custom_id_hash>::SOLO
      responses:
        '200':
          description: Action task accepted.
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - description
                  - result
                properties:
                  code:
                    type: integer
                    description: >-
                      Submission status code. `1` = submitted successfully
                      (`result` carries the task id). `21` = the action opened a
                      confirmation modal; continue with `/mj/submit/modal` using
                      the returned task id. `4` = parameter error; `description`
                      explains the cause.
                  description:
                    type: string
                  result:
                    type: string
                    description: New Midjourney task id created for the action.
                  properties:
                    type: object
                    properties:
                      numberOfQueues:
                        type: integer
                      discordInstanceId:
                        type: string
                      discordChannelId:
                        type: string
      x-codeSamples:
        - lang: Shell
          label: Default
          source: |
            curl https://api.cometapi.com/mj/submit/action \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                  "taskId": "<task_id>",
                  "customId": "MJ::JOB::upsample::1::<custom_id_hash>"
                }'
        - lang: Python
          label: Default
          source: >
            import os

            import requests


            response = requests.post(
                "https://api.cometapi.com/mj/submit/action",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                        "taskId": "<task_id>",
                        "customId": "MJ::JOB::upsample::1::<custom_id_hash>"
                },
            )


            task = response.json()

            print(task["code"], task.get("result"))  # code 1 means submitted;
            result is the task id
        - lang: JavaScript
          label: Default
          source: >
            const response = await
            fetch("https://api.cometapi.com/mj/submit/action", {
                method: "POST",
                headers: {
                    Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                    "Content-Type": "application/json",
                },
                body: JSON.stringify({
                        "taskId": "<task_id>",
                        "customId": "MJ::JOB::upsample::1::<custom_id_hash>"
                    }),
            });


            const task = await response.json();

            console.log(task.code, task.result); // code 1 means submitted;
            result is the task id
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````