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

# Set Sub-account Limit

> Sets the limit for the specified sub-account.
The minimum allowed sends is 0.




## OpenAPI

````yaml /email-api/api-reference/openapi.yaml put /sub-account/{handle}/limit
openapi: 3.0.0
info:
  contact:
    email: support@mailchannels.com
    name: MailChannels Corporation
  description: >
    This is the API reference for Email API. Here, you'll find more detailed
    information on every endpoint, including parameters, response formats, and
    error codes.
  title: Email API
  version: 1.4.0
servers:
  - url: https://api.mailchannels.net/tx/v1
security: []
tags:
  - name: Send
  - name: DKIM
  - name: Metrics
  - name: Sub-accounts
  - name: Suppression
  - name: Webhooks
  - name: Usage
  - name: Custom Tracking
paths:
  /sub-account/{handle}/limit:
    put:
      tags:
        - Sub-accounts
      summary: Set Sub-account Limit
      description: |
        Sets the limit for the specified sub-account.
        The minimum allowed sends is 0.
      parameters:
        - description: Handle of the sub-account to set limit for.
          in: path
          name: handle
          required: true
          schema:
            type: string
        - in: header
          name: X-Api-Key
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LimitInput'
        description: The value the sub-account limit to set.
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LimitUpdateResult'
          description: The limit was successfully updated for the specified sub-account.
        '400':
          description: |
            Missing or invalid limit value.
        '404':
          description: The specified sub-account does not exist.
        '500':
          description: An unexpected internal error occurred.
      x-codeSamples:
        - label: Node.js
          lang: javascript
          source: >-
            import { MailChannels } from "mailchannels-sdk";


            const { PARENT_API_KEY, SUB_ACCOUNT_HANDLE, SEND_LIMIT } =
            process.env;

            if (!PARENT_API_KEY) throw new Error("Set PARENT_API_KEY (a
            parent-account API key) before running");

            if (!SUB_ACCOUNT_HANDLE) throw new Error("Set SUB_ACCOUNT_HANDLE
            (the sub-account to set a limit on)");

            if (!SEND_LIMIT) throw new Error("Set SEND_LIMIT (maximum sends per
            billing period, integer >= 0)");


            const mailchannels = new MailChannels(PARENT_API_KEY);


            const { success, error } = await
            mailchannels.subAccounts.setLimit(SUB_ACCOUNT_HANDLE, {
              sends: Number(SEND_LIMIT),
            });


            if (!success) {
              console.error("Set sub-account limit failed:", error);
              process.exit(1);
            }

            console.log({ success });
        - label: Python
          lang: python
          source: >-
            import os

            import sys


            import mailchannels


            parent_api_key = os.environ.get("PARENT_API_KEY")

            handle = os.environ.get("SUB_ACCOUNT_HANDLE")

            send_limit = os.environ.get("SEND_LIMIT")

            if not parent_api_key:
                sys.exit("Set PARENT_API_KEY (a parent-account API key) before running")
            if not handle:
                sys.exit("Set SUB_ACCOUNT_HANDLE (the sub-account to set a limit on)")
            if not send_limit:
                sys.exit("Set SEND_LIMIT (maximum sends per billing period, integer >= 0)")

            mailchannels.api_key = parent_api_key


            response = mailchannels.SubAccounts.Limits.set(handle,
            sends=int(send_limit))


            print(response)
        - label: PHP
          lang: php
          source: >-
            <?php


            require_once __DIR__ . '/vendor/autoload.php';


            use MailChannels\Client;


            $parent_api_key     = getenv('PARENT_API_KEY') or exit("Error:
            PARENT_API_KEY is not set\n");

            $sub_account_handle = getenv('SUB_ACCOUNT_HANDLE') or exit("Error:
            SUB_ACCOUNT_HANDLE is not set\n");

            $send_limit         = getenv('SEND_LIMIT') or exit("Error:
            SEND_LIMIT is not set\n");


            $client = new Client(apiKey: $parent_api_key);


            $response = $client->subAccounts->limits->set($sub_account_handle,
            sends: (int) $send_limit);


            print_r($response->toArray());
components:
  schemas:
    LimitInput:
      properties:
        sends:
          minimum: 0
          type: integer
      required:
        - sends
      type: object
    LimitUpdateResult:
      properties:
        limit:
          $ref: '#/components/schemas/Limit'
      type: object
    Limit:
      properties:
        sends:
          type: integer
      required:
        - sends
      type: object

````