> ## 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.

# Create purchase

> Records an order from your own system, for organizations without a store integration. external_id is the order's ID in your system: if a purchase with it already exists, it is returned as is, with 200, and no webhook is sent. A new purchase is created with 201 and triggers the purchase.created webhook, with the same object as the response. The customer is matched as in events (id, external_id, tax_id, email, phone) and created when none matches; a matched customer is not changed. Only paid purchases (the default) count as sales: home, Sales screen, campaign and flow revenue, recovered carts, RFM and customer totals. No flow is started and no message is sent: for automations, also send the order event (order_placed, payment_confirmed) to POST /v1/events. Send an Idempotency-Key to retry the request safely. Requires a live API key (bvt_live_) with the write scope. The sale events sent to POST /v1/events (order_placed, payment_confirmed, charge_paid…) become purchases too, on the same external_id (the order's order_id, or charge:<charge_id> for a subscription charge): a sale reported both ways counts once. Refused with 409 sales_source_conflict when the organization has a connected store, which is the source of its sales, and with 422 test_customer_not_supported when the customer's e-mail is on a domain reserved for testing (example.com, .test).



## OpenAPI

````yaml /openapi.en.json post /v1/purchases
openapi: 3.1.0
info:
  title: Bevits API
  version: 1.0.0
  description: >-
    Bevits public API for querying and managing CRM data, customers, purchases,
    segments, tags, automations, recipes, campaigns, email templates, brand kit,
    custom events, and webhooks.
  license:
    name: Proprietary
    identifier: LicenseRef-Proprietary
servers:
  - url: https://api.bevits.com
    description: Production
security:
  - bearerAuth: []
tags:
  - name: System
    description: API availability.
  - name: Identity
    description: Organization and API key identity.
  - name: Customers
    description: Customers and their relationships.
  - name: Segments
    description: Customer segments.
  - name: Purchases
    description: >-
      Purchases from store integrations and purchases created through the API by
      organizations that sell through their own system.
  - name: CRM data
    description: Tags and attribute definitions.
  - name: Automations
    description: Automation flows.
  - name: Campaigns
    description: Email, WhatsApp, and SMS campaigns.
  - name: Account and brand
    description: Account context, brand kit, and images.
  - name: Recipes
    description: Ready-made automations created from recipes, with undo.
  - name: Email templates
    description: Creating and importing email templates.
  - name: Events
    description: Custom events sent by the store and their types.
  - name: Webhooks
    description: Endpoints that receive the store's events, and the delivery log.
paths:
  /v1/purchases:
    post:
      tags:
        - Purchases
      summary: Create purchase
      description: >-
        Records an order from your own system, for organizations without a store
        integration. external_id is the order's ID in your system: if a purchase
        with it already exists, it is returned as is, with 200, and no webhook
        is sent. A new purchase is created with 201 and triggers the
        purchase.created webhook, with the same object as the response. The
        customer is matched as in events (id, external_id, tax_id, email, phone)
        and created when none matches; a matched customer is not changed. Only
        paid purchases (the default) count as sales: home, Sales screen,
        campaign and flow revenue, recovered carts, RFM and customer totals. No
        flow is started and no message is sent: for automations, also send the
        order event (order_placed, payment_confirmed) to POST /v1/events. Send
        an Idempotency-Key to retry the request safely. Requires a live API key
        (bvt_live_) with the write scope. The sale events sent to POST
        /v1/events (order_placed, payment_confirmed, charge_paid…) become
        purchases too, on the same external_id (the order's order_id, or
        charge:<charge_id> for a subscription charge): a sale reported both ways
        counts once. Refused with 409 sales_source_conflict when the
        organization has a connected store, which is the source of its sales,
        and with 422 test_customer_not_supported when the customer's e-mail is
        on a domain reserved for testing (example.com, .test).
      operationId: createPurchase
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePurchaseRequest'
            example:
              external_id: ord_77120
              order_number: '10293'
              customer:
                external_id: u_8842
                email: ana@exemplo.com.br
                phone: '+5511988887777'
                name: Ana Souza
              currency: BRL
              total_amount_in_cents: 18990
              subtotal_amount_in_cents: 17990
              shipping_cost_customer_in_cents: 1000
              payment_status: paid
              created_at: '2026-11-24T11:00:00-03:00'
              utm_source: instagram
      responses:
        '200':
          $ref: '#/components/responses/PurchaseExisting'
        '201':
          $ref: '#/components/responses/PurchaseCreated'
        '400':
          $ref: '#/components/responses/InvalidBody'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/PurchaseWriteForbidden'
        '404':
          $ref: '#/components/responses/EventCustomerNotFound'
        '409':
          $ref: '#/components/responses/PurchaseCreateConflict'
        '422':
          $ref: '#/components/responses/PurchaseValidationError'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
        '503':
          $ref: '#/components/responses/CreateUnavailable'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      description: >-
        Unique key for the operation, 1 to 255 characters (a UUID, for example).
        Repeating the same key with the same body within 24 hours returns the
        original response instead of running it again.
      schema:
        type: string
  schemas:
    CreatePurchaseRequest:
      type: object
      additionalProperties: false
      description: >-
        An order from your own system. Amounts are in cents, in the currency of
        currency.
      required:
        - external_id
        - customer
        - currency
        - total_amount_in_cents
      properties:
        external_id:
          type: string
          minLength: 1
          maxLength: 191
          description: >-
            The order's unique ID in your system. Creating a purchase with an
            external_id that already exists returns that purchase unchanged,
            with 200.
        customer:
          $ref: '#/components/schemas/EventCustomerInput'
          description: >-
            Who bought, with the identifiers of the events API, matched in this
            order: id, external_id, tax_id, email, phone. If none matches, a new
            customer is created; a matched customer is not changed.
        currency:
          type: string
          pattern: ^[A-Za-z]{3}$
          description: ISO 4217 currency of every amount, such as BRL.
        total_amount_in_cents:
          type: integer
          minimum: 0
          maximum: 2000000000
          description: What the customer paid, shipping included, in cents.
        subtotal_amount_in_cents:
          type: integer
          minimum: 0
          maximum: 2000000000
          description: 'Products only, in cents. Default: total_amount_in_cents.'
        discount_in_cents:
          type: integer
          minimum: 0
          maximum: 2000000000
          description: Order discount, in cents.
        shipping_cost_customer_in_cents:
          type: integer
          minimum: 0
          maximum: 2000000000
          description: Shipping paid by the customer, in cents.
        payment_status:
          type: string
          enum:
            - pending
            - authorized
            - paid
            - refunded
            - voided
          default: paid
          description: >-
            Only paid purchases count as sales (home, Sales, revenue, RFM).
            refunded and voided take a paid purchase out of them.
        status:
          type: string
          enum:
            - open
            - closed
            - cancelled
          default: open
          description: The order's status in your system.
        shipping_status:
          type: string
          enum:
            - unfulfilled
            - fulfilled
            - shipped
            - delivered
        order_number:
          type: string
          minLength: 1
          maxLength: 191
          description: The order number the customer sees, such as 1042.
        created_at:
          type: string
          format: date-time
          description: >-
            When the order was placed (ISO 8601 with offset). Default: now. It
            is the sale date in every report; more than 1 hour in the future
            responds 422 created_at_in_future, and before 2000-01-01, 422
            created_at_too_old.
        utm_source:
          type: string
          minLength: 1
          maxLength: 512
        utm_medium:
          type: string
          minLength: 1
          maxLength: 512
        utm_campaign:
          type: string
          minLength: 1
          maxLength: 512
        utm_content:
          type: string
          minLength: 1
          maxLength: 512
        utm_term:
          type: string
          minLength: 1
          maxLength: 512
    EventCustomerInput:
      type: object
      description: >-
        Who it happened to. Send at least one identifier: id, external_id,
        tax_id, email, or phone.
      additionalProperties: false
      anyOf:
        - required:
            - id
        - required:
            - external_id
        - required:
            - tax_id
        - required:
            - email
        - required:
            - phone
      properties:
        id:
          type: string
          pattern: ^cus_[A-Za-z0-9_-]+$
          description: >-
            Bevits customer ID. An ID that does not exist returns 404 and no
            other identifier is tried.
        external_id:
          type: string
          minLength: 1
          maxLength: 255
          description: >-
            The customer's ID in your system. Letter case is ignored; leading
            and trailing spaces are removed.
        tax_id:
          type: string
          minLength: 1
          maxLength: 32
          description: Valid CPF or CNPJ (Brazilian tax IDs), with or without punctuation.
        email:
          type: string
          format: email
          maxLength: 256
          description: Customer's email, matched in lowercase.
        phone:
          type: string
          minLength: 3
          maxLength: 32
          description: >-
            Phone in E.164, such as +5511988887777. Without a country code, the
            store's country is assumed.
        name:
          type: string
          minLength: 1
          maxLength: 256
          description: Customer's name.
        attributes:
          type: object
          description: >-
            Customer attributes to set. Only the keys sent change; new
            attributes are created with the inferred type.
          additionalProperties:
            oneOf:
              - type: string
                maxLength: 256
              - type: number
              - type: boolean
        consent:
          type: object
          description: >-
            Marketing opt-in, read only when the event creates the customer.
            Without it, the customer is created without marketing opt-in.
          additionalProperties: false
          properties:
            email:
              type: boolean
            whatsapp:
              type: boolean
    Purchase:
      type: object
      required:
        - object
        - id
        - customer_id
        - purchase_value_in_cents
        - created_at
        - updated_at
      properties:
        object:
          type: string
          const: purchase
        id:
          type: string
          pattern: ^pur_[A-Za-z0-9_-]+$
        customer_id:
          type: string
          pattern: ^cus_[A-Za-z0-9_-]+$
        external_id:
          type: string
          description: >-
            The order's ID in the system it came from: the store, or your own
            system for purchases created through the API.
        order_id_on_integration_platform:
          type: string
        order_number:
          type: string
        platform:
          type: string
        status:
          type: string
        payment_status:
          type: string
        shipping_status:
          type: string
        currency:
          type: string
          example: BRL
        purchase_value_in_cents:
          type: integer
        subtotal_amount_in_cents:
          type: integer
        total_amount_in_cents:
          type: integer
        discount_in_cents:
          type: integer
        shipping_cost_customer_in_cents:
          type: integer
        coupons:
          type: array
          items:
            $ref: '#/components/schemas/Coupon'
        attributed_flow_ids:
          deprecated: true
          description: >-
            Deprecated legacy field retained for compatibility. When present,
            always returns an empty array; execution attribution is unavailable
            in this field.
          type: array
          items:
            type: string
            pattern: ^flw_[A-Za-z0-9_-]+$
        utm_source:
          type: string
        utm_medium:
          type: string
        utm_campaign:
          type: string
        utm_content:
          type: string
        utm_term:
          type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    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: Seconds before retrying.
    Coupon:
      type: object
      required:
        - id
        - code
        - value
        - type
      properties:
        id:
          type: string
        code:
          type: string
        value:
          type: number
        type:
          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: >-
            Stable, machine-readable reason within type, such as
            invalid_event_name. Present when the error has a named reason.
        message:
          type: string
        param:
          type: string
          description: >-
            Full path of the offending field, such as customer.email or
            events[3].name.
        suggestion:
          type: string
          description: A value that would be accepted, when there is an obvious one.
        request_id:
          type: string
          pattern: ^req_[a-f0-9]{24}$
  responses:
    PurchaseExisting:
      description: >-
        A purchase with this external_id already exists. It is returned as is,
        nothing in it changes and no webhook is sent.
      headers:
        Location:
          $ref: '#/components/headers/Location'
        Idempotent-Replayed:
          $ref: '#/components/headers/IdempotentReplayed'
        ETag:
          $ref: '#/components/headers/ETag'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Purchase'
    PurchaseCreated:
      description: >-
        Purchase created. The purchase.created webhook carries this same object
        in data.purchase.
      headers:
        Location:
          $ref: '#/components/headers/Location'
        Idempotent-Replayed:
          $ref: '#/components/headers/IdempotentReplayed'
        ETag:
          $ref: '#/components/headers/ETag'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Purchase'
          example:
            object: purchase
            id: pur_ckabc123
            customer_id: cus_ckabc123
            external_id: ord_77120
            order_id_on_integration_platform: ord_77120
            order_number: '10293'
            platform: api
            status: open
            payment_status: paid
            currency: BRL
            purchase_value_in_cents: 17990
            subtotal_amount_in_cents: 17990
            total_amount_in_cents: 18990
            shipping_cost_customer_in_cents: 1000
            coupons: []
            created_at: '2026-11-24T14:00:00.000Z'
            updated_at: '2026-11-24T14:00:01.000Z'
    InvalidBody:
      description: >-
        Missing request body, a body that is not a JSON object, or an invalid
        route parameter.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Missing, invalid, expired, or revoked API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              type: authentication_error
              message: Invalid API key.
              request_id: req_07f6cdc3c20249d6afcd90b4
    PurchaseWriteForbidden:
      description: >-
        The API key does not have the write scope, or it is a test key
        (bvt_test_): purchases have no test mode, because they would count as
        real sales.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              type: permission_denied
              code: test_mode_not_supported
              message: >-
                Purchases can't be written with a test key: they would count as
                real sales. Use a live key (bvt_live_…).
              request_id: req_07f6cdc3c20249d6afcd90b4
    EventCustomerNotFound:
      description: >-
        customer.id does not match any active customer. The other identifiers
        are not tried.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              type: not_found
              code: customer_not_found
              message: >-
                No customer has this id. Remove customer.id to match by the
                other identifiers.
              param: customer.id
              request_id: req_07f6cdc3c20249d6afcd90b4
    PurchaseCreateConflict:
      description: >-
        The organization has a connected store, which is the source of its
        sales, and does not record purchases through the API
        (sales_source_conflict): each sale would count twice. Or the
        Idempotency-Key was already used with a different request body.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              type: conflict
              code: sales_source_conflict
              message: >-
                This organization's sales come from its connected store.
                Purchases can't also be written through the API, or each sale
                would count twice.
              request_id: req_07f6cdc3c20249d6afcd90b4
    PurchaseValidationError:
      description: >-
        Missing required field, unknown field, invalid amount or currency,
        customer without an identifier, customer with an e-mail on a domain
        reserved for testing (test_customer_not_supported), created_at more than
        1 hour in the future (created_at_in_future) or before 2000-01-01
        (created_at_too_old) or, on an update, no field to change.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              type: validation_error
              code: created_at_in_future
              message: >-
                created_at is in the future. Send when the order was placed, or
                omit it for now.
              param: created_at
              request_id: req_07f6cdc3c20249d6afcd90b4
    RateLimited:
      description: Request limit exceeded.
      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: Unexpected server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    CreateUnavailable:
      description: >-
        The database could not confirm the operation right now. Retry the same
        request with the same Idempotency-Key: it is applied at most once.
      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: Path of the resource created or found.
      schema:
        type: string
        example: /v1/customers/cus_ckabc123
    IdempotentReplayed:
      description: >-
        Present with true when the response is the one saved for this
        Idempotency-Key by an earlier request.
      schema:
        type: string
        enum:
          - 'true'
    ETag:
      description: Content version identifier for conditional caching.
      schema:
        type: string
        example: '"v1-4ad31f5efb6b8f35"'
    RetryAfter:
      description: Seconds before retrying.
      schema:
        type: integer
        minimum: 1
    RateLimitLimit:
      description: Total limit for the current window.
      schema:
        type: integer
        example: 600
    RateLimitRemaining:
      description: Requests remaining in the current window.
      schema:
        type: integer
        example: 599
    RateLimitReset:
      description: UTC instant when the current window ends.
      schema:
        type: string
        format: date-time
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: bvt_live_...
      description: API key created in the organization settings.

````

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