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

# Batch Apply Submerchant Markup

> Apply the same markup configuration to many submerchants at once.

# Batch Apply Submerchant Markup

Use this endpoint to apply the same markup configuration to up to 500 submerchants in one request.

Each submerchant is processed on its own. If one of them fails, the others are still saved, and the response reports the result for each submerchant.

<Warning>
  **The configuration is replaced for each submerchant.** Like [Configure Submerchant Markup](/api-reference/markup/submerchant/upsert-submerchant-markup), each listed submerchant keeps only the items sent in `markups`. Any product and payment method you leave out goes back to the global markup.
</Warning>

## Path Parameters

<ParamField path="merchantId" type="integer" required>
  ID of the merchant (parent account). It must be one of the authenticated user's companies.
</ParamField>

## Request Body

<ParamField body="sub_merchant_ids" type="array[integer]" required>
  IDs of the submerchants that will receive the markup. Send between `1` and `500` IDs. Duplicate IDs are ignored.
</ParamField>

<ParamField body="markups" type="array[object]" required>
  Markup configurations to apply. Same fields and rules as the `markups` field of [Configure Submerchant Markup](/api-reference/markup/submerchant/upsert-submerchant-markup).
</ParamField>

## Request Examples

<CodeGroup>
  ```json Batch apply theme={null}
  {
    "sub_merchant_ids": [1234, 1235, 7777],
    "markups": [
      {
        "product": "payin",
        "payment_method": "pix",
        "mode": "percent",
        "amount": 1.4,
        "min_charge_value": 1.0,
        "max_charge_value": 5.0
      },
      {
        "product": "payout",
        "payment_method": "pix",
        "mode": "fixed",
        "amount": 0.8
      }
    ]
  }
  ```

  ```bash cURL theme={null}
  curl -X POST "https://api.sandbox.wepayout.com.br/v2/account/123/submerchants/markups/batch" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "sub_merchant_ids": [1234, 1235],
      "markups": [
        {
          "product": "payin",
          "payment_method": "pix",
          "mode": "fixed",
          "amount": 1.0
        }
      ]
    }'
  ```
</CodeGroup>

## Response

The response is `200 OK` even when some submerchants fail. Check `failed` and `results` to find them.

<ResponseField name="total" type="integer">
  Number of submerchants processed.
</ResponseField>

<ResponseField name="succeeded" type="integer">
  Number of submerchants saved.
</ResponseField>

<ResponseField name="failed" type="integer">
  Number of submerchants that failed.
</ResponseField>

<ResponseField name="results" type="array[object]">
  Result for each submerchant.

  <Expandable title="Result Object">
    <ResponseField name="sub_merchant_id" type="integer">
      Submerchant ID.
    </ResponseField>

    <ResponseField name="status" type="string">
      Values: `success`, `failed`.
    </ResponseField>

    <ResponseField name="error_code" type="string or null">
      Reason for the failure. `null` on success.

      Values:

      * `sub_merchant_not_child`: the ID is not a submerchant of `merchantId`
      * `internal_error`: the markup could not be saved
    </ResponseField>

    <ResponseField name="message" type="string or null">
      Description of the failure. `null` on success.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "total": 3,
    "succeeded": 2,
    "failed": 1,
    "results": [
      {
        "sub_merchant_id": 1234,
        "status": "success",
        "error_code": null,
        "message": null
      },
      {
        "sub_merchant_id": 1235,
        "status": "success",
        "error_code": null,
        "message": null
      },
      {
        "sub_merchant_id": 7777,
        "status": "failed",
        "error_code": "sub_merchant_not_child",
        "message": "The subaccount 7777 does not belong to this account."
      }
    ]
  }
  ```

  ```json 422 Unprocessable Entity theme={null}
  {
    "message": "The given data was invalid.",
    "errors": {
      "sub_merchant_ids": [
        "The batch exceeds the limit of 500 subaccounts."
      ],
      "markups.0.min_charge_value": [
        "Minimum and maximum values are required when the mode is percent."
      ]
    }
  }
  ```

  ```json 500 Internal Server Error theme={null}
  {
    "error": "Failed to apply the markups in batch."
  }
  ```
</ResponseExample>

## Related Resources

<CardGroup cols={2}>
  <Card title="List Submerchant Markups" icon="list" href="/api-reference/markup/submerchant/list-submerchant-markups">
    Find the submerchants to update
  </Card>

  <Card title="Configure Submerchant Markup" icon="pen" href="/api-reference/markup/submerchant/upsert-submerchant-markup">
    Set the markup of a single submerchant
  </Card>
</CardGroup>
