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

# Capture an event

> Record an event to track user actions or system behavior.



## OpenAPI

````yaml api-reference/openapi.json post /capture
openapi: 3.1.0
info:
  title: SeerStack API
  description: >-
    The SeerStack API allows you to send events, identify users, and track user
    behavior in your applications.
  version: 1.0.0
  contact:
    name: SeerStack Support
    url: https://seerstack.com
servers:
  - url: https://api.seerstack.com
    description: Production API
security:
  - bearerAuth: []
tags:
  - name: Events
    description: Track user actions and system events
  - name: Users
    description: Manage user identities and attributes
paths:
  /capture:
    post:
      tags:
        - Events
      summary: Capture an event
      description: Record an event to track user actions or system behavior.
      operationId: captureEvent
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventRequest'
            examples:
              basic:
                summary: Basic event
                value:
                  name: page.view
              with_user:
                summary: Event with user ID
                value:
                  name: button.clicked
                  user_id: user_123
              full:
                summary: Full event with data
                value:
                  name: invoice.paid
                  user_id: user_123
                  timestamp: '2025-01-04T12:00:00Z'
                  data:
                    invoice_id: inv_993
                    amount: 2000
                    currency: usd
      responses:
        '200':
          description: Event captured successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessResponse'
              example:
                success: true
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: Missing or invalid API key
      x-codeSamples:
        - lang: typescript
          label: TypeScript SDK
          source: |-
            import Seerstack from 'seerstack';

            const client = new Seerstack({
              apiKey: process.env['SEERSTACK_API_KEY'],
            });

            const response = await client.events.capture({
              name: 'invoice.paid',
              user_id: 'user_123',
              data: {
                invoice_id: 'inv_993',
                amount: 2000,
                currency: 'usd'
              }
            });

            console.log(response.success);
        - lang: ruby
          label: Ruby SDK
          source: |-
            require "seerstack"

            seerstack = Seerstack::Client.new(
              api_key: ENV["SEERSTACK_API_KEY"]
            )

            response = seerstack.events.capture(
              name: "invoice.paid",
              user_id: "user_123",
              data: {
                invoice_id: "inv_993",
                amount: 2000,
                currency: "usd"
              }
            )

            puts(response.success)
        - lang: bash
          label: cURL
          source: |-
            curl -X POST https://api.seerstack.com/capture \
              -H "Authorization: Bearer $SEERSTACK_API_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                "name": "invoice.paid",
                "user_id": "user_123",
                "data": {
                  "invoice_id": "inv_993",
                  "amount": 2000,
                  "currency": "usd"
                }
              }'
components:
  schemas:
    EventRequest:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          description: >-
            The name of the event. We recommend using `noun.verb` syntax (e.g.,
            `invoice.paid`, `user.signup`).
          example: invoice.paid
        user_id:
          type: string
          description: >-
            The external user ID associated with this event. Use your database's
            primary key.
          example: user_123
        timestamp:
          type: string
          format: date-time
          description: >-
            ISO 8601 timestamp for when the event occurred. Defaults to the
            current time if not provided.
          example: '2025-01-04T12:00:00Z'
        data:
          type: object
          additionalProperties: true
          description: >-
            Additional data to include with the event. Can contain any
            JSON-serializable values.
          example:
            invoice_id: inv_993
            amount: 2000
            currency: usd
    SuccessResponse:
      type: object
      required:
        - success
      properties:
        success:
          type: boolean
          description: Indicates whether the operation was successful.
          example: true
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: A human-readable error message.
          example: Missing or invalid API key
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Use your SeerStack API key as a Bearer token. You can find your API key
        in the SeerStack Dashboard under Settings > Developer.

````

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