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

# Crear cliente

> Registra un cliente en la base de la tienda con al menos un identificador: external_id, tax_id, email o phone. Si alguno ya pertenece a un cliente activo (buscados en ese orden, como en los eventos), ese cliente se devuelve tal como está, con 200, y nada en él cambia. Un cliente nuevo se crea con 201 y dispara el webhook customer.created, con el mismo objeto de la respuesta. Sin consent, el cliente nuevo no tiene opt-in de marketing. No se inicia ningún flow ni se envía ningún mensaje. Envía Idempotency-Key para repetir la solicitud con seguridad. Requiere una clave API con el alcance write.



## OpenAPI

````yaml /openapi.es.json post /v1/customers
openapi: 3.1.0
info:
  title: API de Bevits
  version: 1.0.0
  description: >-
    API pública de Bevits para consultar y gestionar datos de CRM, clientes,
    compras, segmentos, etiquetas, automatizaciones, recetas, campañas,
    plantillas de email, identidad de marca, eventos personalizados y webhooks.
  license:
    name: Proprietary
    identifier: LicenseRef-Proprietary
servers:
  - url: https://api.bevits.com
    description: Producción
security:
  - bearerAuth: []
tags:
  - name: Sistema
    description: Disponibilidad de la API.
  - name: Identidad
    description: Identidad de la organización y de la clave API.
  - name: Clientes
    description: Clientes y sus relaciones.
  - name: Segmentos
    description: Segmentos de clientes.
  - name: Compras
    description: >-
      Compras de las integraciones de tienda y compras creadas por la API por
      quienes venden con su propio sistema.
  - name: Datos del CRM
    description: Etiquetas y definiciones de atributos.
  - name: Automatizaciones
    description: Flows de automatización.
  - name: Campañas
    description: Campañas de email, WhatsApp y SMS.
  - name: Cuenta y marca
    description: Contexto de la cuenta, identidad de marca e imágenes.
  - name: Recetas
    description: Automatizaciones listas creadas a partir de recetas, con deshacer.
  - name: Plantillas de email
    description: Creación e importación de plantillas de email.
  - name: Eventos
    description: Eventos personalizados enviados por la tienda y sus tipos.
  - name: Webhooks
    description: Endpoints que reciben los eventos de la tienda y el registro de entregas.
paths:
  /v1/customers:
    post:
      tags:
        - Clientes
      summary: Crear cliente
      description: >-
        Registra un cliente en la base de la tienda con al menos un
        identificador: external_id, tax_id, email o phone. Si alguno ya
        pertenece a un cliente activo (buscados en ese orden, como en los
        eventos), ese cliente se devuelve tal como está, con 200, y nada en él
        cambia. Un cliente nuevo se crea con 201 y dispara el webhook
        customer.created, con el mismo objeto de la respuesta. Sin consent, el
        cliente nuevo no tiene opt-in de marketing. No se inicia ningún flow ni
        se envía ningún mensaje. Envía Idempotency-Key para repetir la solicitud
        con seguridad. Requiere una clave API con el alcance write.
      operationId: createCustomer
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCustomerRequest'
            example:
              external_id: u_8842
              email: ana@exemplo.com.br
              phone: '+5511988887777'
              name: Ana Souza
              attributes:
                plano: vip
              consent:
                email: true
                whatsapp: true
      responses:
        '200':
          $ref: '#/components/responses/CustomerExisting'
        '201':
          $ref: '#/components/responses/CustomerCreated'
        '400':
          $ref: '#/components/responses/InvalidBody'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/WriteScopeRequired'
        '409':
          $ref: '#/components/responses/IdempotencyConflict'
        '422':
          $ref: '#/components/responses/CustomerValidationError'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
        '503':
          $ref: '#/components/responses/CreateUnavailable'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      description: >-
        Clave única de la operación, de 1 a 255 caracteres (un UUID, por
        ejemplo). Repetir la misma clave con el mismo cuerpo dentro de 24 horas
        devuelve la respuesta original en lugar de ejecutarla de nuevo.
      schema:
        type: string
  schemas:
    CreateCustomerRequest:
      type: object
      additionalProperties: false
      description: >-
        Al menos uno de external_id, tax_id, email o phone. Son los mismos
        campos del customer de un evento.
      properties:
        external_id:
          type: string
          minLength: 1
          maxLength: 255
          description: >-
            El id del cliente en tu sistema. No distingue mayúsculas y
            minúsculas; se quitan los espacios de los extremos.
        tax_id:
          type: string
          maxLength: 32
          description: CPF o CNPJ, con o sin puntuación. Debe ser válido.
        email:
          type: string
          format: email
          maxLength: 256
          description: Se guarda en minúsculas.
        phone:
          type: string
          maxLength: 32
          description: >-
            E.164 (+5511988887777). Sin código de país, se asume el país de la
            tienda.
        name:
          type: string
          minLength: 1
          maxLength: 256
        attributes:
          type: object
          description: >-
            Atributos personalizados por nombre. Un atributo nuevo se crea con
            el tipo inferido. Se ignora cuando el cliente ya existe.
          additionalProperties:
            oneOf:
              - type: string
                maxLength: 256
              - type: number
              - type: boolean
        consent:
          type: object
          additionalProperties: false
          description: >-
            Opt-in de marketing del cliente nuevo. Sin él, el cliente se crea
            sin opt-in.
          properties:
            email:
              type: boolean
            whatsapp:
              type: boolean
    Customer:
      allOf:
        - $ref: '#/components/schemas/CustomerSummary'
        - type: object
          required:
            - tags
            - attributes
          properties:
            external_id:
              type: string
              description: >-
                El id que el sistema de la tienda le dio al cliente (external_id
                de la creación y de los eventos).
            identification:
              type: string
            tags:
              type: array
              items:
                type: object
                required:
                  - id
                  - name
                properties:
                  id:
                    type: string
                    pattern: ^tag_[A-Za-z0-9_-]+$
                  name:
                    type: string
            attributes:
              type: object
              additionalProperties:
                oneOf:
                  - type: string
                  - type: number
                  - type: boolean
                  - type: 'null'
            default_address:
              $ref: '#/components/schemas/Address'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/Error'
    RateLimitErrorResponse:
      allOf:
        - $ref: '#/components/schemas/ErrorResponse'
        - type: object
          required:
            - retry_after
          properties:
            retry_after:
              type: integer
              minimum: 1
              description: Segundos antes de volver a intentarlo.
    CustomerSummary:
      type: object
      required:
        - object
        - id
        - created_at
        - updated_at
        - html_url
      properties:
        object:
          type: string
          const: customer
        id:
          type: string
          pattern: ^cus_[A-Za-z0-9_-]+$
        name:
          type: string
        email:
          type: string
          format: email
        phone:
          type: string
          description: Teléfono con código de país, cuando esté disponible.
        source:
          type: string
        is_subscribed:
          type: boolean
        is_subscribed_to_email:
          type: boolean
        total_spent_in_cents:
          type: integer
        total_orders:
          type: integer
        first_purchase_date:
          type: string
          format: date-time
        last_purchase_date:
          type: string
          format: date-time
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        html_url:
          type: string
          format: uri
    Address:
      type: object
      required:
        - id
        - street
        - number
        - city
        - state
        - country
        - zip_code
      properties:
        id:
          type: string
        street:
          type: string
        number:
          type: string
        city:
          type: string
        state:
          type: string
        country:
          type: string
        zip_code:
          type: string
        neighborhood:
          type: string
        complement:
          type: string
    Error:
      type: object
      required:
        - type
        - message
        - request_id
      properties:
        type:
          type: string
          enum:
            - authentication_error
            - conflict
            - internal_error
            - invalid_request
            - not_found
            - permission_denied
            - rate_limited
            - service_unavailable
            - validation_error
        code:
          type: string
          description: >-
            Motivo estable y legible por máquina dentro de type, como
            invalid_event_name. Presente cuando el error tiene un motivo con
            nombre.
        message:
          type: string
        param:
          type: string
          description: >-
            Ruta completa del campo con problema, como customer.email o
            events[3].name.
        suggestion:
          type: string
          description: Un valor que sería aceptado, cuando existe uno obvio.
        request_id:
          type: string
          pattern: ^req_[a-f0-9]{24}$
  responses:
    CustomerExisting:
      description: >-
        Un cliente activo ya tenía uno de los identificadores enviados. Se
        devuelve tal como está, nada en él cambia y no se envía ningún webhook.
      headers:
        Location:
          $ref: '#/components/headers/Location'
        Idempotent-Replayed:
          $ref: '#/components/headers/IdempotentReplayed'
        ETag:
          $ref: '#/components/headers/ETag'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Customer'
    CustomerCreated:
      description: >-
        Cliente creado. El webhook customer.created lleva este mismo objeto en
        data.customer.
      headers:
        Location:
          $ref: '#/components/headers/Location'
        Idempotent-Replayed:
          $ref: '#/components/headers/IdempotentReplayed'
        ETag:
          $ref: '#/components/headers/ETag'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Customer'
          example:
            object: customer
            id: cus_ckabc123
            name: Ana Souza
            email: ana@exemplo.com.br
            phone: '+5511988887777'
            source: API
            is_subscribed: true
            is_subscribed_to_email: true
            created_at: '2026-11-24T14:03:00.000Z'
            updated_at: '2026-11-24T14:03:00.000Z'
            html_url: https://app.bevits.com/customers/ckabc123
            external_id: u_8842
            tags: []
            attributes:
              plano: vip
    InvalidBody:
      description: >-
        Cuerpo de la solicitud ausente, que no es un objeto JSON, o parámetro de
        ruta inválido.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Clave API ausente, inválida, expirada o revocada.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              type: authentication_error
              message: Invalid API key.
              request_id: req_07f6cdc3c20249d6afcd90b4
    WriteScopeRequired:
      description: La clave API no tiene el alcance write.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              type: permission_denied
              code: missing_scope
              message: This API key does not have the required "write" scope.
              param: scope
              request_id: req_07f6cdc3c20249d6afcd90b4
    IdempotencyConflict:
      description: La Idempotency-Key ya se usó con otro cuerpo de solicitud.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    CustomerValidationError:
      description: >-
        Ningún identificador, un campo desconocido, un email, teléfono o
        CPF/CNPJ inválido, o un atributo con el tipo incorrecto.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              type: validation_error
              code: invalid_phone
              message: >-
                phone is not a valid number. Send it in E.164 (+5511988887777),
                or without a country code for a number in the store's country.
              param: phone
              request_id: req_07f6cdc3c20249d6afcd90b4
    RateLimited:
      description: Límite de solicitudes superado.
      headers:
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
        X-RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/RateLimitRemaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/RateLimitReset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitErrorResponse'
    InternalError:
      description: Error inesperado en el servidor.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    CreateUnavailable:
      description: >-
        La base de datos no pudo confirmar la operación ahora. Repite la misma
        solicitud con la misma Idempotency-Key: se aplica como máximo una vez.
      headers:
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              type: service_unavailable
              code: temporarily_unavailable
              message: >-
                The request could not be confirmed right now. Retry it with the
                same Idempotency-Key: it is applied at most once.
              request_id: req_07f6cdc3c20249d6afcd90b4
  headers:
    Location:
      description: Ruta del recurso creado o encontrado.
      schema:
        type: string
        example: /v1/customers/cus_ckabc123
    IdempotentReplayed:
      description: >-
        Presente con true cuando la respuesta es la que se guardó para esta
        Idempotency-Key en una solicitud anterior.
      schema:
        type: string
        enum:
          - 'true'
    ETag:
      description: Identificador de la versión del contenido para caché condicional.
      schema:
        type: string
        example: '"v1-4ad31f5efb6b8f35"'
    RetryAfter:
      description: Segundos antes de volver a intentarlo.
      schema:
        type: integer
        minimum: 1
    RateLimitLimit:
      description: Límite total de la ventana actual.
      schema:
        type: integer
        example: 600
    RateLimitRemaining:
      description: Solicitudes restantes en la ventana actual.
      schema:
        type: integer
        example: 599
    RateLimitReset:
      description: Instante UTC en que termina la ventana actual.
      schema:
        type: string
        format: date-time
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: bvt_live_...
      description: Clave API creada en la configuración de la organización.

````

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