---
updatedAt: 2025-09-18T00:30:52.000Z
agentTools:
  projectIndex: https://developers.alby.com/llms.txt
---

# Create Purchase Event

Tracks a purchase event. Returns the created event if successful.

The Create Purchase Event API records a completed purchase transaction. It requires a `brand_id` in the path and an `order_id` in the request body, along with optional fields like `user_id`, `order_total`,  and `product_ids`.

*Rate limits:*\
Steady: `1000/hr`

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "analytics",
    "description": "Analytics API. Used to track events and purchases in order to obtain insights about Alby's performance on your store. Although this is functionally an optional API, it is paramount to have it integrated in order to have a complete view of your store's performance and enable Alby to better support you.\n## Alby Apps API\nThe following APIs are available:\n\n* ### [Apps](https://api.alby.com/apps/docs)\n    Display and interact with the apps that are enabled for your store.\n\n\n* ### [Analytics](https://api.alby.com/analytics/docs)\n    Track and analyze the performance of Alby for your store.\n\n",
    "version": "0.1"
  },
  "servers": [
    {
      "url": "https://api.alby.com/analytics"
    }
  ],
  "paths": {
    "/v1/brands/{brand_id}/purchase": {
      "post": {
        "tags": [
          "purchase"
        ],
        "summary": "Create Purchase Event",
        "description": "Tracks a purchase event. Returns the created event if successful.",
        "operationId": "create_purchase_event_v1_brands__brand_id__purchase_post",
        "parameters": [
          {
            "name": "brand_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Brand ID. UUID v4 format.",
              "title": "Brand Id"
            },
            "description": "Brand ID. UUID v4 format."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PurchaseInput-Input"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PurchaseInput-Output"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "PurchaseInput-Input": {
        "properties": {
          "user_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "User Id",
            "description": "A unique identifier of the User."
          },
          "order_id": {
            "type": "string",
            "title": "Order Id",
            "description": "A unique identifier of the order."
          },
          "order_total": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Order Total",
            "description": "The total amount of the order."
          },
          "email_address": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email Address",
            "description": "The email address of the user."
          },
          "product_ids": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Product Ids",
            "description": "A list of product identifiers."
          }
        },
        "type": "object",
        "required": [
          "order_id"
        ],
        "title": "PurchaseInput",
        "description": "Purchase event containing information on the user, order, and products.\nUsed along with track events to track conversion."
      },
      "PurchaseInput-Output": {
        "properties": {
          "user_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "User Id",
            "description": "A unique identifier of the User."
          },
          "order_id": {
            "type": "string",
            "title": "Order Id",
            "description": "A unique identifier of the order."
          },
          "order_total": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Order Total",
            "description": "The total amount of the order."
          },
          "email_address": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email Address",
            "description": "The email address of the user."
          },
          "product_ids": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Product Ids",
            "description": "A list of product identifiers."
          }
        },
        "type": "object",
        "required": [
          "order_id"
        ],
        "title": "PurchaseInput",
        "description": "Purchase event containing information on the user, order, and products.\nUsed along with track events to track conversion."
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      }
    },
    "securitySchemes": {
      "AlbyAccessToken": {
        "type": "http",
        "description": "Access token generated by calling the auth server with your Alby API credentials (clientId and clientSecret)",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "security": [
    {
      "AlbyAccessToken": []
    }
  ],
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  }
}
```