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

# Crear una cuenta

> Creates an account. Send an Idempotency-Key header to make retries safe: repeating the request with the same key returns the originally created account (200) instead of creating a duplicate. An account name is not unique — two accounts can carry the same name, so a repeated name without a key creates a second account.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/accounts
openapi: 3.1.0
info:
  title: Caudal Public API
  version: 1.0.0
  description: >-
    REST API for HORECA distributors to integrate their ERP with Caudal.
    Authenticate with an API key issued from the Caudal dashboard
    (WorkOS-backed). Pass it as 'Authorization: Bearer <key>'. Base URL:
    https://api.caudalflow.com
servers:
  - url: https://api.caudalflow.com
security:
  - bearerAuth: []
tags:
  - name: Pedidos
    description: Leer y crear pedidos.
  - name: Cuentas
    description: Leer y crear las cuentas de los clientes.
  - name: Productos
    description: Leer el catálogo.
paths:
  /v1/accounts:
    post:
      tags:
        - Cuentas
      summary: Crear una cuenta
      description: >-
        Creates an account. Send an Idempotency-Key header to make retries safe:
        repeating the request with the same key returns the originally created
        account (200) instead of creating a duplicate. An account name is not
        unique — two accounts can carry the same name, so a repeated name
        without a key creates a second account.
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAccountRequest'
      responses:
        '200':
          description: >-
            Replay of a previous request with the same Idempotency-Key. The
            original resource comes back and nothing is created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Account'
        '201':
          description: The created resource.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Account'
        '400':
          $ref: '#/components/responses/Error'
          description: The request is malformed (code invalid_request).
        '401':
          $ref: '#/components/responses/Error'
          description: The API key is missing, invalid or not linked to an organization.
        '403':
          $ref: '#/components/responses/Error'
          description: The API key lacks the scope this route requires.
        '409':
          $ref: '#/components/responses/Error'
          description: >-
            The Idempotency-Key already identifies a resource of a different
            type (code idempotency_key_conflict). Send a new key.
        '422':
          $ref: '#/components/responses/Error'
          description: >-
            The subject exercised their right to erasure. Remove them from the
            source system instead of retrying. (code erased_customer)
        '429':
          $ref: '#/components/responses/Error'
          description: >-
            The organization exceeded its rate limit. Retry after the delay in
            Retry-After.
      security:
        - bearerAuth:
            - accounts:write
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      schema:
        type: string
        minLength: 1
        maxLength: 255
      description: >-
        Client-generated unique key (e.g. a UUID), scoped to the organization.
        Retrying a request with the same key returns the original resource with
        status 200 instead of creating a duplicate. One key space serves every
        POST route: a key already used on another route answers 409.
  schemas:
    CreateAccountRequest:
      type: object
      properties:
        name:
          type: string
          minLength: 1
        address:
          anyOf:
            - type: string
            - type: 'null'
        phone:
          anyOf:
            - type: string
            - type: 'null'
      required:
        - name
    Account:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        address:
          anyOf:
            - type: string
            - type: 'null'
        is_active:
          type: boolean
        last_order_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        created_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        channels:
          type: array
          items:
            $ref: '#/components/schemas/ContactChannel'
      required:
        - id
        - name
        - address
        - is_active
        - last_order_at
        - created_at
        - channels
    ContactChannel:
      type: object
      properties:
        type:
          type: string
          enum:
            - phone
            - email
        value:
          type: string
        is_primary:
          type: boolean
        capabilities:
          type: array
          items:
            type: string
            enum:
              - voice
              - whatsapp
              - email
      required:
        - type
        - value
        - is_primary
        - capabilities
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - missing_api_key
                - invalid_api_key
                - insufficient_scope
                - rate_limited
                - not_found
                - invalid_request
                - idempotency_key_conflict
                - internal_error
                - erased_customer
                - order_items_unresolved
            message:
              type: string
          required:
            - code
            - message
      required:
        - error
  responses:
    Error:
      description: Error response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key issued from the Caudal dashboard. Scopes are enforced per route:
        orders:read, orders:write, accounts:read, accounts:write, products:read.

````