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

# Retrieve Sub-accounts

> Retrieves all sub-accounts associated with the parent account.
The response is paginated with a default limit of 1000 sub-accounts per page and an offset of 0.




## OpenAPI

````yaml /email-api/api-reference/openapi.yaml get /sub-account
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:
    get:
      tags:
        - Sub-accounts
      summary: Retrieve Sub-accounts
      description: >
        Retrieves all sub-accounts associated with the parent account.

        The response is paginated with a default limit of 1000 sub-accounts per
        page and an offset of 0.
      parameters:
        - in: query
          name: limit
          required: false
          schema:
            default: 1000
            description: The maximum number of sub-accounts to return. The default is 1000.
            maximum: 1000
            minimum: 1
            type: integer
        - in: query
          name: offset
          required: false
          schema:
            default: 0
            description: >-
              The number of sub-accounts to skip before returning results. The
              default is 0.
            minimum: 0
            type: integer
        - in: header
          name: X-Api-Key
          required: true
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/SubAccountDetails'
                maxItems: 1000
                type: array
          description: >-
            Successfully retrieved all sub-accounts associated with the parent
            account.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Bad Request. The limit and/or offset query parameter are invalid.
        '500':
          description: An unexpected internal error occurred.
      x-codeSamples:
        - label: Node.js
          lang: javascript
          source: >-
            import { MailChannels } from "mailchannels-sdk";


            const { PARENT_API_KEY } = process.env;

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


            const mailchannels = new MailChannels(PARENT_API_KEY);


            const { data, error } = await mailchannels.subAccounts.list();


            if (error) {
              console.error("List sub-accounts failed:", error);
              process.exit(1);
            }

            console.log(data);
        - label: Python
          lang: python
          source: |-
            import os
            import sys

            import mailchannels

            parent_api_key = os.environ.get("PARENT_API_KEY")
            if not parent_api_key:
                sys.exit("Set PARENT_API_KEY (a parent-account API key) before running")

            mailchannels.api_key = parent_api_key

            # Retrieve all sub-accounts for the parent account.
            response = mailchannels.SubAccounts.list()

            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");


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


            $response = $client->subAccounts->list();


            print_r($response->toArray());
components:
  schemas:
    SubAccountDetails:
      properties:
        company_name:
          type: string
        enabled:
          type: boolean
        handle:
          type: string
      required:
        - handle
        - enabled
      type: object
    ErrorResponse:
      properties:
        errors:
          description: >
            This is an array error objects that provide machine and human
            readable descriptions of the errors.
          items:
            type: string
          type: array
      type: object

````