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

# Create Sub-account

> Creates a sub-account with its own balance, fully independent from the main account balance.

**Required permission:** `SUBACCOUNT:WRITE` or `FULL_ACCESS`

<Note>
  **The `reference` is immutable.** It is the identifier you send in the `X-Sub-Account` header to operate on the sub-account, and the value that arrives in the `subAccount` field of webhooks — choose it carefully, because it cannot be changed after creation.

  Format: `^[a-z0-9][a-z0-9_-]{1,31}$` — 2 to 32 characters, only lowercase letters, digits, `-` and `_`, starting with a lowercase letter or a digit. The `reference` must be unique within the account: reusing an existing one returns `409 SUB_ACCOUNT_REFERENCE_TAKEN`.

  The sub-account starts with its own balance, at zero and fully independent from the main account balance. See [Sub-accounts](/en#sub-accounts) for the behavior of the `X-Sub-Account` header and the full error table.
</Note>


## OpenAPI

````yaml openapi.en.json POST /sub-accounts
openapi: 3.0.0
info:
  title: pague.dev API
  description: pague.dev Payment API documentation
  version: '1.0'
  contact: {}
servers:
  - url: https://api-gateway.pague.dev/v2
security: []
paths:
  /sub-accounts:
    post:
      tags:
        - External API - Sub-accounts (Subcontas)
      summary: Create a sub-account
      description: >-
        Creates a sub-account with its own balance, fully independent from the
        main account balance.


        **Required permission:** `SUBACCOUNT:WRITE` or `FULL_ACCESS`
      operationId: ExternalSubAccountsController_createSubAccount
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSubAccountInput'
      responses:
        '201':
          description: Sub-account created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateSubAccountOutput'
        '400':
          description: Bad Request - Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestErrorResponse'
        '401':
          description: Unauthorized - Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedErrorResponse'
        '403':
          description: Forbidden - Permission denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenErrorResponse'
        '409':
          description: >-
            Conflict - `reference` already used in this account
            (`SUB_ACCOUNT_REFERENCE_TAKEN`) or sub-account limit reached
            (`SUB_ACCOUNT_QUOTA_EXCEEDED`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConflictErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    CreateSubAccountInput:
      type: object
      properties:
        reference:
          type: string
          description: >-
            Sub-account identifier defined by you. Unique within the account and
            immutable after creation. `principal` is a reserved word for the
            main account and cannot be used: it returns `400
            SUB_ACCOUNT_INVALID_REFERENCE`.
          pattern: ^[a-z0-9][a-z0-9_-]{1,31}$
          example: loja-centro
        name:
          type: string
          description: Sub-account display name
          maxLength: 255
          example: Loja Centro
      required:
        - reference
        - name
    CreateSubAccountOutput:
      type: object
      properties:
        id:
          type: string
          description: Sub-account ID
          format: uuid
        reference:
          type: string
          description: Sub-account reference
          example: loja-centro
        name:
          type: string
          description: Sub-account name
          example: Loja Centro
        status:
          type: string
          description: Sub-account status
          example: approved
        createdAt:
          type: string
          description: Creation date
          format: date-time
      required:
        - id
        - reference
        - name
        - status
        - createdAt
    BadRequestErrorResponse:
      type: object
      properties:
        statusCode:
          type: number
          example: 400
        error:
          type: string
          example: BadRequest
        message:
          type: string
          example: name must be longer than or equal to 2 characters
        details:
          type: object
        timestamp:
          type: string
          example: '2025-12-15T22:00:00.000Z'
        traceId:
          type: string
      required:
        - statusCode
        - error
        - message
        - timestamp
    UnauthorizedErrorResponse:
      type: object
      properties:
        statusCode:
          type: number
          example: 401
        error:
          type: string
          example: Unauthorized
        message:
          type: string
          example: Authentication token is required
        details:
          type: object
        timestamp:
          type: string
          example: '2025-12-15T22:00:00.000Z'
        traceId:
          type: string
      required:
        - statusCode
        - error
        - message
        - timestamp
    ForbiddenErrorResponse:
      type: object
      properties:
        statusCode:
          type: number
          example: 403
        error:
          type: string
          example: Forbidden
        message:
          type: string
          example: You do not have permission to access this resource
        details:
          type: object
        timestamp:
          type: string
          example: '2025-12-15T22:00:00.000Z'
        traceId:
          type: string
      required:
        - statusCode
        - error
        - message
        - timestamp
    ConflictErrorResponse:
      type: object
      properties:
        statusCode:
          type: number
          example: 409
        error:
          type: string
          example: Conflict
        message:
          type: string
          example: Resource with name 'Example' already exists
        details:
          type: object
          example:
            resource: Example
            field: name
            value: Example
        timestamp:
          type: string
          example: '2025-12-15T22:00:00.000Z'
        traceId:
          type: string
      required:
        - statusCode
        - error
        - message
        - timestamp
    InternalServerErrorResponse:
      type: object
      properties:
        statusCode:
          type: number
          example: 500
        error:
          type: string
          example: InternalError
        message:
          type: string
          example: An unexpected error occurred
        details:
          type: object
        timestamp:
          type: string
          example: '2025-12-15T22:00:00.000Z'
        traceId:
          type: string
          example: 2771463d58840c8e116dc6dda1e1e5d0
      required:
        - statusCode
        - error
        - message
        - timestamp
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Access token obtained from POST /auth (client_id + client_secret). Valid
        for 300 seconds.

````