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

# Batch hit

> Used to send realtime events to Xtremepush in batch when events occurs on a backend system, such as "sign_up", "purchase" etc, similar to the `eventHit` methods found in the web and mobile SDKs. This allows users to trigger campaigns/workflows based on events that happen outside of sites or Apps.

## OpenAPI

````json POST /hit/events
{
  "openapi": "3.1.0",
  "info": {
    "title": "external-api",
    "version": "1"
  },
  "servers": [
    {
      "url": "https://api.eu.xtremepush.com/api/external"
    }
  ],
  "paths": {
    "/hit/events": {
      "post": {
        "summary": "Batch hit",
        "description": "Used to send realtime events to Xtremepush in batch when events occurs on a backend system, such as \"sign_up\", \"purchase\" etc, similar to the `eventHit` methods found in the web and mobile SDKs. This allows users to trigger campaigns/workflows based on events that happen outside of sites or Apps.",
        "operationId": "event-batch-hit",
        "deprecated": "false",
        "requestBody": {
          "required": "true",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "apptoken",
                  "events"
                ],
                "properties": {
                  "apptoken": {
                    "type": "string",
                    "description": "Your App token"
                  },
                  "events": {
                    "type": "array",
                    "description": "Array containing the event name (`event`) and the user ID (`user_id`). Other params such as `value`, `user_attributes` and `timestamp` can be included optionally. Review the Hit event endpoint for more details on each specific param.",
                    "items": {
                      "type": "object",
                      "required": [
                        "event",
                        "user_id"
                      ],
                      "properties": {
                        "event": {
                          "type": "string",
                          "description": "Event name"
                        },
                        "user_id": {
                          "type": "string",
                          "description": "Your external user ID. If a user with such user ID doesn't exist it will be automatically created."
                        },
                        "value": {
                          "type": "string",
                          "description": "Can be: string / number, eg. `100`, or key-value object, eg. `{\"product\": \"Some Product\"}`"
                        },
                        "user_attributes": {
                          "type": "string",
                          "format": "json",
                          "description": "Key-value array of user attributes. These attributes will be updated before executing any event-triggered campaign. This is useful when the campaign depends on one of the user attributes, such as email address or first name."
                        },
                        "timestamp": {
                          "type": "string",
                          "format": "date-time",
                          "description": "The timestamp of the event"
                        }
                      }
                    }
                  }
                }
              },
              "examples": {
                "Batch hit events": {
                  "value": {
                    "apptoken": "YOUR_APPTOKEN",
                    "events": [
                      {
                        "event": "purchase",
                        "user_id": "USER_ID_1",
                        "value": "100"
                      },
                      {
                        "event": "sign_up",
                        "user_id": "USER_ID_2"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": "true",
                      "default": "true"
                    },
                    "code": {
                      "type": "integer",
                      "example": "200",
                      "default": "0"
                    }
                  }
                },
                "examples": {
                  "Result": {
                    "value": {
                      "success": "true",
                      "code": "200"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": "false",
                      "default": "true"
                    },
                    "code": {
                      "type": "integer",
                      "example": "400",
                      "default": "0"
                    },
                    "message": {
                      "type": "string",
                      "example": "General error information"
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "text": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "examples": {
                  "Result": {
                    "value": {
                      "success": "false",
                      "code": "400",
                      "message": "General error information",
                      "errors": [
                        {
                          "text": [
                            "Detailed information about the specific error"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "tags": [
          "Event Methods"
        ]
      }
    }
  }
}
````

