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

# Create Subaccount

> Creates a new Subaccount.




## OpenAPI

````yaml api-reference/openapi.yaml post /subaccounts
openapi: 3.1.0
info:
  title: CNaught Carbon Credits API Documentation
  contact:
    email: support@cnaught.com
    name: CNaught
    url: https://cnaught.com/
  version: v1
  description: |
    Carbon Credits API Documentation
  termsOfService: https://cnaught.com/terms
  license:
    name: MIT
    url: https://spdx.org/licenses/MIT.html
servers:
  - url: https://api.cnaught.com/v1
    description: CNaught API
security:
  - ApiKey: []
tags:
  - name: Orders
    description: Endpoints for placing orders and retrieving information about orders
  - name: Quotes
    description: Endpoints for obtaining price quotes for orders
  - name: Climate Impact
    description: >-
      Endpoints for retrieving climate impact data and hosted public impact page
      configuration
  - name: Subaccounts
    description: Endpoints for creating and retrieving information about subaccounts
paths:
  /subaccounts:
    post:
      tags:
        - Subaccounts
      summary: Create Subaccount
      description: |
        Creates a new Subaccount.
      operationId: CreateSubaccount
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        description: Subaccount Parameters
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubaccountParams'
            examples:
              Example:
                value:
                  name: Marketing Department
                  email: jane.doe@example.com
                  default_portfolio_id: mHvNvWbq
      responses:
        '201':
          description: Subaccount Details
          headers:
            Location:
              schema:
                type: string
                description: URL for retrieving details about the subaccount
                examples:
                  - https://api.cnaught.com/v1/subaccounts/5nubL0NS
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Subaccount'
              examples:
                New Subaccount:
                  value:
                    id: 5nubL0NS
                    name: Marketing Department
                    email: jane.doe@example.com
                    default_portfolio_id: mHvNvWbq
                    logo_url: >-
                      https://customer-assets.cnaught.com/VChGzdcf/4b1cdc0f-fb47-4251-ab52-b0566369723b/logo
        '400':
          description: Invalid default portfolio ID
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/BadRequestProblemDetails'
              example:
                errors:
                  default_portfolio_id:
                    - Portfolio 'eGy2vWbq' does not exist
                type: https://api.cnaught.com/v1/errors/invalid-parameters
                title: Your request parameters didn't validate
                status: 400
        '401':
          $ref: '#/components/responses/Unauthorized'
        '409':
          $ref: '#/components/responses/IdempotencyConflict'
        '422':
          $ref: '#/components/responses/IdempotencyUnprocessableEntity'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      description: >
        If present, a unique identifier that allows you to retry a request
        multiple times while only performing the action once.

        See [Idempotency](/api/#idempotency) for more info.
      schema:
        type: string
  schemas:
    SubaccountParams:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          description: Name for the subaccount
          maxLength: 512
        email:
          type:
            - string
            - 'null'
          description: Optional email associated with the subaccount
          examples:
            - jane.doe@example.com
        default_portfolio_id:
          type:
            - string
            - 'null'
          description: >
            Optional ID of the default portfolio to use for fulfilling orders
            placed for this subaccount. If not specified,

            the parent account's default portfolio will be the default portfolio
            for the subaccount.
          examples:
            - a23bF6
        logo_url:
          type:
            - string
            - 'null'
          description: >
            Optional URL for a logo to use for this subaccount. The URL must be
            public. 

            The logo will be downloaded to CNaught's hosting when creating the
            account. 

            If not specified, the subaccount will not have a logo.
    Subaccount:
      type: object
      properties:
        id:
          type: string
          description: Identifier that can be used to retrieve the subaccount details
          examples:
            - 5nubL0NS
        created_on:
          type: string
          description: Timestamp of when the subaccount was created (in UTC)
        name:
          type: string
          description: Name of the subaccount
          maxLength: 512
        email:
          type:
            - string
            - 'null'
          description: Optional email associated with the subaccount.
          examples:
            - jane.doe@example.com
        default_portfolio_id:
          type:
            - string
            - 'null'
          description: >
            Optional ID of the default portfolio used to fulfilling orders
            placed for this subaccount. If not specified,

            the parent account's default portfolio is the default portfolio for
            the subaccount.
          examples:
            - a23bF6
        logo_url:
          type:
            - string
            - 'null'
          description: >
            Optional URL for the logo used for this subaccount, if any. This URL
            is for the logo as stored on CNaught's hosting.
    BadRequestProblemDetails:
      allOf:
        - $ref: '#/components/schemas/BaseProblemDetails'
        - type: object
          properties:
            errors:
              description: >-
                Invalid properties object where each property is the key, mapped
                to a list of reasons why the property is invalid
              type:
                - object
                - 'null'
              additionalProperties:
                type: array
                items:
                  type: string
    BaseProblemDetails:
      type: object
      description: Problem details object returned on errors
      properties:
        title:
          type: string
          description: Short, human-readable summary of the problem
        details:
          type: string
          description: Longer, human-readable description of the problem
        type:
          type: string
          description: URI that identifies the problem type
        status:
          type: integer
          description: HTTP status code of the error
  responses:
    Unauthorized:
      description: Request Unauthorized
      content:
        application/problem+json:
          schema:
            properties:
              title:
                type: string
                description: Short, human-readable summary of the problem type
              status:
                type: integer
                description: HTTP status code of the error
          example:
            title: Authorization has been denied for this request
            status: 401
    IdempotencyConflict:
      description: Concurrent Requests with Same Idempotency Key
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/BaseProblemDetails'
          example:
            type: https://api.cnaught.com/v1/errors/idempotency-concurrent-requests
            title: Concurrent request in flight with same idempotency key
            status: 409
    IdempotencyUnprocessableEntity:
      description: Mismatched Requests with Same Idempotency Key
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/BaseProblemDetails'
          example:
            type: https://api.cnaught.com/v1/errors/idempotency-changed-payload
            title: >-
              Previous request submitted with same idempotency key had different
              payload
            status: 422
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer

````