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

# Simulate Purchase

> Create a simulated purchase of random retailer products on one of your simulated connections, dated now. Emits `purchase.created` to your webhooks, marked `is_simulated`.

[Subtotal Connector tool: simulate\_purchase](/docs/connector/tools.md#simulate_purchase)

Creates a simulated purchase on one of your simulated connections, with random products from the connection's retailer, dated now, and sends `purchase.created` to webhook destinations that [accept simulated events](/docs/event-simulator.md#configure-simulated-events-for-your-webhook-destination). Every call creates a new purchase. Read it with [Get a purchase](/docs/api-reference/purchases/get-purchase.md).

The purchase includes at least one of your brands' products when the retailer sells one. A real, deleted or unknown connection returns `404`, and nothing is created.

Call it with your API key, or with a [Subtotal Connector](/docs/connector/introduction.md) OAuth token that includes `simulator:write`. A token without it receives `403 insufficient_scope`. [Partner app](/docs/partner-apps/introduction.md#fixed-permissions) tokens don't include it.


## OpenAPI

````yaml post /simulated-connections/{connection_id}/purchases
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers: []
security: []
paths:
  /simulated-connections/{connection_id}/purchases:
    post:
      tags:
        - simulator
      summary: Simulate Purchase
      description: >-
        Create a simulated purchase of random retailer products on one of your
        simulated connections, dated now. Emits `purchase.created` to your
        webhooks, marked `is_simulated`.
      operationId: simulate_purchase_simulated_connections__connection_id__purchases_post
      parameters:
        - name: connection_id
          in: path
          required: true
          schema:
            type: string
            title: Connection Id
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Authorization
        - name: x-api-key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Api-Key
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SimulatePurchaseResponse'
        '404':
          description: No simulated connection of yours with this id
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    SimulatePurchaseResponse:
      properties:
        purchase_id:
          type: string
          title: Purchase Id
          description: The simulated purchase, readable like any other purchase
          examples:
            - 01J51S0JYV6N7K1030CV1ZKSCA
      type: object
      required:
        - purchase_id
      title: SimulatePurchaseResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````

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