

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Analytics",
    "description": "# Overview\nThe Unity Analytics Collect API allows you to submit events related to your game for analysis.\n\nUnity offers support for Analytics within the Unity Editor version 2019.4 and above.  This is done through our SDK package (see the Useful Links section below).  Using the SDK provides you with some benefits like automatic batching of events and automatic retries of event submissions which fail due to network issues. If you use the SDK to send events, you do not need to use this API.\n\nIn some cases you may not be able to use the SDK, for example:\n- Sending events from a game server\n- Sending events from a non-Unity game\n\nIn these cases you can use this API.\n\nYou can send either Standard Events or Custom Events, which are configured per environment. To see a list of Event types (Standard or Custom) or to define new Custom event types, you can use the Event Manager.\n\nIn the request body, specify a JSON document corresponding to the event type.\n\nTo verify whether the event has been processed by our service, check the Event Browser to see events coming in from your game.\n\nFor requests originating in China, to comply with China's Personal Information Protection Law (PIPL) you are required to set headers to indicate whether the user has consented to have their personal information processed. Requests made from China which do not have these headers set will result in no data being recorded by Unity Analytics.\n\n# Useful Links\n- [SDK Documentation](https://docs.unity.com/analytics/AnalyticsSDKGuide.html)\n- [Event Manager Documentation](https://docs.unity.com/analytics/EventManager.html)\n- [Event Browser Documentation](https://docs.unity.com/analytics/EventBrowser.html)\n- [PIPL Consent Documentation](https://docs.unity.com/analytics/SendingPIPLConsent.html)\n",
    "version": "2.8.0"
  },
  "servers": [
    {
      "url": "https://collect.analytics.unity3d.com"
    }
  ],
  "paths": {
    "/api/analytics/collect/v1/projects/{projectId}/environments/{environmentName}": {
      "post": {
        "summary": "Submit event(s)",
        "operationId": "submitEvent",
        "tags": [
          "Analytics"
        ],
        "description": "You may submit either a single event or a list of events to this endpoint. When possible, sending a list of events is preferable due to efficiencies in connection pooling. Keep the POST length below 5MB; anything above might be rejected.\n",
        "parameters": [
          {
            "in": "path",
            "name": "projectId",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID for Unity project"
          },
          {
            "in": "path",
            "name": "environmentName",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Name of an environment. To get the Environment name, go to the project Dashboard > Projects > Project Settings > Environments."
          },
          {
            "in": "header",
            "name": "PIPL_CONSENT",
            "schema": {
              "type": "string"
            },
            "allowEmptyValue": true,
            "description": "The presence of this header will indicate the player has granted consent to data collection. Players who do not consent should not have this header set on requests. The value of the header does not matter. This header is only required if the request originates in China.\n"
          },
          {
            "in": "header",
            "name": "PIPL_EXPORT",
            "schema": {
              "type": "string"
            },
            "allowEmptyValue": true,
            "description": "The presence of this header will indicate the player has granted consent to their data being sent out of China for processing.   Players who do not consent should not have this header set on requests. The value of the header does not matter. This header is only required if the request originates in China.\n"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/EventRequest"
                  },
                  {
                    "$ref": "#/components/schemas/EventListRequest"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Event submitted successfully.",
            "headers": {
              "PIPL_STATUS": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "no_consent",
                    "no_export"
                  ]
                },
                "description": "If a request requires PIPL headers to be set and they are not, this header will be set to indicate which form of consent was not provided. \n"
              }
            }
          },
          "400": {
            "description": "Request body invalid. See error message for more details."
          },
          "404": {
            "description": "Environment or project not found."
          }
        }
      }
    },
    "/api/analytics/collect/v1/uuid": {
      "get": {
        "summary": "Generate a random unique userID",
        "operationId": "generateUuid",
        "tags": [
          "Analytics"
        ],
        "description": "Generates a random unique userID. Subsequent requests will return a different value.\n\nIf you don’t have your own userID in your game, generating a Universally  Unique Identifier (UUID) is the recommended way to create one. You’ll need to store the returned value locally  on the client and reuse it for all future Collect calls from that specific client.\n",
        "responses": {
          "200": {
            "description": "userID generated successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UuidResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "EventRequest": {
        "type": "object",
        "description": "An event representing something happening in your game. This schema describes the default top-level fields but most events will be accepted.",
        "properties": {
          "eventName": {
            "type": "string",
            "description": "The name of the event.",
            "example": "gameStarted"
          },
          "userID": {
            "type": "string",
            "description": "A unique string that identifies the player and is consistent across their subsequent play sessions.\n",
            "example": "ABCD1-4321a879b185fcb9c6ca27abc5387e914"
          },
          "unityInstallationID": {
            "type": "string",
            "description": "The installation ID is provided by the Unity package and used internally by Unity services.  It can be safely omitted. The primary use case is identifying where multiple distinct users share a device.\n",
            "example": "Optional-Installation-ID"
          },
          "unityPlayerID": {
            "type": "string",
            "description": "The authenticated playerID, provided by the Unity authentication service. This can be useful to link analytics data to player accounts if you're using other Unity services (such as Cloud Save).  If you're not using the Unity authentication service, this field should be omitted.\n",
            "example": "Optional-Authenticated-Player-ID"
          },
          "sessionID": {
            "type": "string",
            "description": "A unique string value that’s persisted for the duration of each player gameplay session and regenerated  with each new gameplay session. The sessionID should be sent with every event the player triggers in their session.\nThere might be occasions when you want to send events containing valuable player information outside a player  session and don’t have access to a sessionID. These are called GHOST events and you should omit the sessionID  parameter and value on these events to ensure that they're not included in any player session calculations.\n",
            "example": "4879bf37-8566-46ce-9f3b-bd18d6ac614e"
          },
          "eventUUID": {
            "type": "string",
            "description": "Adding eventUUID to an event will prevent the event being inserted twice within a 24 hour period. This may happen when e.g. a network time-out occurs, even if the event has already been processed by Unity Analytics. Should be unique per event.\n",
            "example": "374cc674-9785-4772-8cca-d7cdf517a590"
          },
          "eventTimestamp": {
            "type": "string",
            "description": "If eventTimestamp is missing, the server will infer the timestamp based on the time the event was received. The date format should be as follows: `yyyy-MM-dd HH:mm:ss.SSS ±[hh]:[mm]` where `±[hh]:[mm]` can be included  to indicate offset from UTC.\n",
            "example": "2022-12-30 16:55:00.321 -08:00"
          },
          "eventVersion": {
            "type": "integer",
            "description": "The version of the standard event only.\n",
            "example": 1
          },
          "eventParams": {
            "type": "object",
            "description": "A JSON object containing information about the event that conforms to the event schema (Event Parameters).",
            "example": {
              "platform": "WEB",
              "param1": "stringParam",
              "param2": true,
              "param3": 123
            }
          }
        },
        "required": [
          "userID",
          "eventUUID"
        ]
      },
      "EventListRequest": {
        "type": "object",
        "description": "An object containing a list of events.",
        "properties": {
          "eventList": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventRequest"
            }
          }
        }
      },
      "UuidResponse": {
        "type": "object",
        "description": "Object containing a random unique userID.",
        "properties": {
          "userID": {
            "type": "string",
            "description": "User ID",
            "example": "0a71d2c8-fb93-4b8d-8d4d-8cbbd2425dc9"
          }
        }
      }
    }
  }
}
```