Create Custom Events

Changed on

The Custom Events API allows you to record user events. Custom events can represent any action users take in your application, such as completing a purchase, viewing content, or achieving milestones.

post/apps/{app_id}/custom_events

Request

  • Base URL
    https://api.onesignal.com
  • URL
    https://api.onesignal.com/apps/{app_id}/custom_events
  • Auth
    none required

Path parameters

app_idstring required

Your OneSignal App ID in UUID v4 format. See Keys & IDs.

Headers

Authorizationstring required

Your app API key with prefix Key . See Keys & IDs.

Request body

Response

Accepted. Events that could not be processed are listed in errors. Other events in the same request were processed. An empty errors array, or a response with no body, means every event was accepted. An individual event fails when its user identifier does not match a OneSignal user (not found), when name is empty (empty event name), when name is longer than 512 bytes (event name too long), or when the app is at its limit of 1,000 unique event names (too many event names).

Example response

{
  "errors": [
    {
      "event_user_id": "abc123",
      "error": {
        "code": "not found",
        "title": "failed to find a onesignal_id for user_id abc123"
      }
    }
  ]
}

Changes

    • breaking

      the header request parameter Authorization became required

    • breaking

      the response property // became nullable for the status