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

# Create Onboarding

> Two bodies, both under `maihue-onboarding:create`:

- **Drip** (the `register-migration` body): creates or updates the
  customer (`type_dni`, `country`, `language` and `sex` accept a uuid
  or a code; a company's legal representative carries `dni` and
  `type_dni`), then opens the onboarding of the business unit
  `maihue_<type>`. Answers `201` when the account was created and
  `200` when it was updated; `onboarding` describes the new
  onboarding. When the business unit already has an open
  onboarding, the customer stays provisioned and `onboarding` is that
  open one with `already_open: true` (no `409`). A customer without a
  recipient keeps `onboarding.document_id: null` and
  `reason: no-eligible-recipient`.
- **Operator**: `{ account, type }` opens an onboarding for an
  existing account and answers `201` with its detail.

Never sends an email: call `POST /maihue/onboarding/{document_id}/invite`.

The drip body is the one external systems such as Odoo send; see the
[Odoo onboarding integration guide](/integrations/odoo-onboarding).




## OpenAPI

````yaml POST /maihue/onboarding
openapi: 3.0.1
info:
  title: Maihue Onboarding API
  description: |
    Onboardings of Maihue customers (maihue/onboarding). An onboarding asks
    one recipient (the primary user of a person account, or the legal
    representative of a company) to finish the steps of its type for one
    account and business unit: consent, identity, payment method and
    password for `customer_activation`.

    - An account may have several onboardings, but only **one open per
      business unit**: a second operator create answers
      `409 onboarding-already-open` with the open one in
      `error.metadata.onboarding`, and a drip create answers the open one
      with `onboarding.already_open: true` (the customer stays
      provisioned). A terminal status (`completed`, `expired`, `cancelled`)
      frees the slot.
    - Creating never sends anything. Inviting sends the invitation email
      through the notification core (gateway `horizon-maihue-onboarding`,
      `external_id` `<onboarding>:invitation:<n>`) and links it to the
      onboarding.
    - Statuses: `created` → `invited` → `in_progress` (magic link consumed or
      first step done) → `completed`; any open status → `expired` (hourly
      cron, when the type sets an expiry) or `cancelled`.
    - Only `CHL_RUT` accounts onboard.

    Callers authenticate with a user JWT or an API key (`x-api-key`, ADR
    0105); the key that created an onboarding is recorded on it
    (`api_key`, `created_origin: api_key`).
  version: '2026-10-21'
servers:
  - description: Production
    url: https://api.bbrands.io/api/v3
  - description: Certification
    url: https://certification.api.bbrands.io/api/v3
  - description: Development
    url: https://development.api.bbrands.io/api/v3
security:
  - bearerAuth: []
  - apiKeyAuth: []
tags:
  - name: Maihue Onboarding
    description: Create, list, invite and cancel onboardings.
paths:
  /maihue/onboarding:
    post:
      tags:
        - Maihue Onboarding
      summary: Create an onboarding
      description: >
        Two bodies, both under `maihue-onboarding:create`:


        - **Drip** (the `register-migration` body): creates or updates the
          customer (`type_dni`, `country`, `language` and `sex` accept a uuid
          or a code; a company's legal representative carries `dni` and
          `type_dni`), then opens the onboarding of the business unit
          `maihue_<type>`. Answers `201` when the account was created and
          `200` when it was updated; `onboarding` describes the new
          onboarding. When the business unit already has an open
          onboarding, the customer stays provisioned and `onboarding` is that
          open one with `already_open: true` (no `409`). A customer without a
          recipient keeps `onboarding.document_id: null` and
          `reason: no-eligible-recipient`.
        - **Operator**: `{ account, type }` opens an onboarding for an
          existing account and answers `201` with its detail.

        Never sends an email: call `POST
        /maihue/onboarding/{document_id}/invite`.


        The drip body is the one external systems such as Odoo send; see the

        [Odoo onboarding integration guide](/integrations/odoo-onboarding).
      operationId: maihueOnboardingCreate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/MaihueOnboardingDripBody'
                - $ref: '#/components/schemas/MaihueOnboardingAccountBody'
            examples:
              dripHome:
                summary: Drip, person account (home)
                value:
                  country: CL
                  dni: 12345678-5
                  external_id: res.partner:84213
                  name: Juan Andrés Pérez Soto
                  type: home
                  type_dni: CHL_RUT
                  users:
                    - email: juan.perez@example.com
                      firstname: Juan Andrés
                      language: ES
                      lastname: Pérez Soto
                      role: primary_user
                      sex: MALE
              dripCompany:
                summary: Drip, company account (business)
                value:
                  commercial_activity: Software development
                  country: CL
                  dni: 76543210-3
                  external_id: res.partner:91007
                  name: TechCorp Solutions SpA
                  name_fantasy: TechCorp
                  tier: premium
                  type: business
                  type_dni: CHL_RUT
                  users:
                    - dni: 11111111-1
                      email: maria.gonzalez@techcorp.example
                      firstname: María
                      language: ES
                      lastname: González
                      role: legal_representative
                      sex: FEMALE
                      type_dni: CHL_RUT
                    - email: pagos@techcorp.example
                      firstname: Luis
                      language: ES
                      lastname: Martínez
                      role: billing_contact
              operator:
                summary: Operator, existing account
                value:
                  account: 8f3b1c2e-0d4a-4f2b-9c1e-6a7b8c9d0e1f
                  type: home
      responses:
        '200':
          description: Drip customer updated and onboarding opened
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/MaihueOnboardingDripResult'
                  message:
                    type: string
                  meta:
                    $ref: '#/components/schemas/Meta'
        '201':
          description: Created (drip result or onboarding detail)
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    oneOf:
                      - $ref: '#/components/schemas/MaihueOnboardingDripResult'
                      - $ref: '#/components/schemas/MaihueOnboardingDetail'
                  message:
                    type: string
                  meta:
                    $ref: '#/components/schemas/Meta'
              examples:
                dripHome:
                  summary: Drip, new person account
                  value:
                    data:
                      account: e1d2c3b4-a596-4765-8321-0987fedcba87
                      business_units:
                        - business_unit: 5b8c1d2e-3f4a-4b6c-8d7e-9f0a1b2c3d4e
                          created: true
                          internal: maihue_home
                      created: true
                      onboarding:
                        already_open: false
                        business_unit: maihue_home
                        document_id: 3c9e7a10-2b4d-4f6a-8c1e-5d7f9a0b2c4e
                        eligible: true
                        pending: true
                        reason: null
                        status: created
                    message: Created
                    meta:
                      correlation: 29146752-ef3a-4569-b397-ff2144412c4a
                      status: 201
                      timestamp: '2026-11-03T15:30:45Z'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/TooManyRequests'
components:
  schemas:
    MaihueOnboardingDripBody:
      type: object
      description: |
        The `POST /auth/register/migration` body; catalog fields accept a
        uuid or a code, so the caller needs no per-environment ids. The
        account is matched by `dni + type + type_dni`: sending the same
        customer again updates it (`200`) instead of duplicating it.
      required:
        - dni
        - type_dni
        - country
        - name
        - type
        - users
      properties:
        dni:
          type: string
          maxLength: 50
          description: >-
            Chilean RUT of the account, with check digit (`12345678-5`; dots are
            accepted).
          example: 12345678-5
        type_dni:
          type: string
          description: |
            `CHL_RUT` or its uuid. Only `CHL_RUT` onboards; `CHL_PASSPORT`
            answers `422 type-dni-not-supported`.
          example: CHL_RUT
        country:
          type: string
          description: ISO 3166-1 alpha-2 code (`CL`) or the country uuid.
          example: CL
        name:
          type: string
          minLength: 1
          maxLength: 250
          description: Full name of the person or legal name of the company.
        name_fantasy:
          type: string
          maxLength: 250
          description: Trade name. Required when `type` is `horeca` or `business`.
        commercial_activity:
          type: string
          maxLength: 250
          description: Required when `type` is `horeca` or `business`.
        external_id:
          type: string
          maxLength: 255
          description: |
            Identifier of the customer in the source system (e.g. the Odoo
            `res.partner` id). Stored as is; when omitted on an update the
            account keeps its current value.
        gloss:
          type: string
          maxLength: 150
          description: Free note about the origin of the account.
        tier:
          type: string
          enum:
            - free
            - premium
            - enterprise
          default: free
        type:
          type: string
          enum:
            - home
            - horeca
            - business
          description: |
            Business unit of the onboarding (`maihue_<type>`). `home` makes a
            person account; `horeca` and `business` make a company account.
        users:
          type: array
          minItems: 1
          description: |
            Logins of the account, created without a password (the customer
            sets it in the onboarding). The onboarding recipient is the
            `primary_user` of a person account or the `legal_representative`
            of a company; without one, `onboarding.document_id` is `null`
            with `reason: no-eligible-recipient`.
          items:
            type: object
            required:
              - email
              - firstname
              - lastname
              - language
            properties:
              email:
                type: string
                format: email
                maxLength: 256
                description: Stored lowercased; it is the login of the user.
              firstname:
                type: string
                minLength: 1
                maxLength: 250
              lastname:
                type: string
                minLength: 1
                maxLength: 250
              language:
                type: string
                description: |
                  Language code (`ES`, `EN`, `FR`, `IT`, `PT`; case
                  insensitive) or uuid. An unknown code answers `404`. See
                  `GET /general/language?fields=name,internal`.
                example: ES
              sex:
                type: string
                description: |
                  `MALE`, `FEMALE` (case insensitive) or uuid. Optional; an
                  unknown value is stored as empty instead of failing.
                example: FEMALE
              role:
                type: string
                enum:
                  - legal_representative
                  - billing_contact
                  - service_contact
                  - key_contact
                  - administrator
                  - primary_user
                default: primary_user
              dni:
                type: string
                maxLength: 50
                description: >-
                  RUT of the person. Required for the `legal_representative` of
                  a company.
              type_dni:
                type: string
                description: >-
                  `CHL_RUT` or its uuid. Required for the `legal_representative`
                  of a company.
    MaihueOnboardingAccountBody:
      type: object
      required:
        - account
        - type
      additionalProperties: false
      properties:
        account:
          type: string
          format: uuid
        type:
          type: string
          enum:
            - home
            - horeca
            - business
        recipient_user:
          type: string
          format: uuid
          description: >-
            Must hold the recipient role of the account; the oldest one by
            default.
        onboarding_type:
          type: string
          default: customer_activation
    MaihueOnboardingDripResult:
      type: object
      properties:
        account:
          type: string
          format: uuid
          nullable: true
        created:
          type: boolean
          description: >-
            `true` when the account was created (`201`), `false` when it was
            updated (`200`).
        business_units:
          type: array
          description: Subscription of the account to the business unit of `type`.
          items:
            type: object
            properties:
              business_unit:
                type: string
                format: uuid
              created:
                type: boolean
              internal:
                type: string
                nullable: true
                example: maihue_home
        members:
          type: array
          description: |
            Company accounts only: per login, the person account behind it
            and its membership in the company. `person` is `existing`,
            `created` (from the login's document), `document` (another
            account holds that document) or `pending` (no document; `member`
            is `null`).
          items:
            type: object
            properties:
              email:
                type: string
                format: email
              member:
                type: string
                format: uuid
                nullable: true
              person:
                type: string
                enum:
                  - existing
                  - created
                  - document
                  - pending
        onboarding:
          type: object
          properties:
            already_open:
              type: boolean
              description: |
                The business unit already had an open onboarding:
                `document_id` is that one and nothing new was opened.
            document_id:
              type: string
              format: uuid
              nullable: true
            business_unit:
              type: string
              example: maihue_home
            status:
              type: string
              nullable: true
            eligible:
              type: boolean
              description: Whether an invite can send now.
            pending:
              type: boolean
            reason:
              type: string
              nullable: true
              enum:
                - flag-off
                - no-eligible-recipient
                - onboarding-not-pending
                - null
    Meta:
      type: object
      properties:
        correlation:
          type: string
          description: Request correlation id; quote it when reporting an issue.
        status:
          type: integer
        timestamp:
          type: string
          format: date-time
        version:
          type: string
          nullable: true
    MaihueOnboardingDetail:
      allOf:
        - $ref: '#/components/schemas/MaihueOnboarding'
        - type: object
          properties:
            required:
              type: boolean
              description: Some step is still missing.
            steps:
              type: array
              items:
                $ref: '#/components/schemas/MaihueOnboardingStep'
            payment_method_detail:
              type: object
              nullable: true
              properties:
                document_id:
                  type: string
                  format: uuid
                alias:
                  type: string
                  nullable: true
                status:
                  type: string
                  nullable: true
                type:
                  type: string
                  nullable: true
    MaihueOnboarding:
      type: object
      properties:
        document_id:
          type: string
          format: uuid
        account:
          type: object
          properties:
            document_id:
              type: string
              format: uuid
            dni:
              type: string
              nullable: true
            name:
              type: string
              nullable: true
            type:
              type: string
              nullable: true
        business_unit:
          $ref: '#/components/schemas/CatalogRef'
        type:
          $ref: '#/components/schemas/CatalogRef'
        status:
          allOf:
            - $ref: '#/components/schemas/CatalogRef'
            - type: object
              properties:
                is_terminal:
                  type: boolean
        recipient_user:
          type: object
          properties:
            document_id:
              type: string
              format: uuid
            email:
              type: string
              nullable: true
            name:
              type: string
              nullable: true
        payment_method:
          type: string
          format: uuid
          nullable: true
          description: Method the customer confirmed in this onboarding.
        payment_method_confirmed_at:
          type: string
          format: date-time
          nullable: true
        invited_at:
          type: string
          format: date-time
          nullable: true
        activated_at:
          type: string
          format: date-time
          nullable: true
        completed_at:
          type: string
          format: date-time
          nullable: true
        expires_at:
          type: string
          format: date-time
          nullable: true
        cancelled_at:
          type: string
          format: date-time
          nullable: true
        cancel_reason:
          type: string
          nullable: true
        closed_at:
          type: string
          format: date-time
          nullable: true
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
          format: uuid
          nullable: true
        created_origin:
          type: string
          enum:
            - api_key
            - system
            - user
        api_key:
          type: string
          format: uuid
          nullable: true
    MaihueOnboardingStep:
      type: object
      properties:
        step:
          type: string
          enum:
            - consent
            - identity
            - payment_method
            - password
        scope:
          type: string
          enum:
            - user
            - account
            - onboarding
          description: >-
            `user` and `account` steps are shared by every open onboarding of
            that user or account; `onboarding` steps belong to one.
        status:
          type: string
          enum:
            - pending
            - completed
            - skipped
        position:
          type: integer
        required:
          type: boolean
        completed_at:
          type: string
          format: date-time
          nullable: true
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code.
            errors:
              type: array
              items: {}
              description: |
                Details. The onboarding reasons (`account-not-found`,
                `onboarding-already-open`, `onboarding-closed`,
                `type-dni-not-supported`, `no-eligible-recipient`,
                `recipient-not-linked`, `invitation-not-enqueued`) and the
                validation messages are listed here.
            message:
              type: string
            metadata:
              type: object
              additionalProperties: true
        meta:
          $ref: '#/components/schemas/Meta'
    CatalogRef:
      type: object
      nullable: true
      properties:
        document_id:
          type: string
          format: uuid
        internal:
          type: string
        name:
          type: string
  responses:
    BadRequest:
      description: Validation error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Missing, invalid, revoked or expired credentials
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: The caller lacks the permission, or `portal-customer-onboarding` is off
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: '`onboarding-not-found`, `account-not-found` or a missing catalog value'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Conflict:
      description: >-
        `onboarding-already-open` (operator create, with `metadata.onboarding`)
        or `onboarding-closed`
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unprocessable:
      description: >-
        `type-dni-not-supported`, `no-eligible-recipient` or
        `recipient-not-linked`
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    TooManyRequests:
      description: |
        Rate limit of the API key exceeded: a sliding window of
        `rate_limit_per_minute` requests per key (600 when the key sets
        none). Wait `Retry-After` seconds; `X-RateLimit-*` carry the budget.
      headers:
        Retry-After:
          description: Seconds until the window frees a request.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: A `secret` API key, `hzk_<env>_<prefix>_<secret>`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.