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

# Write Telemetry Events

> Write batches of entity based events to as Telemetry events (bypass PlayStream). The namespace must be 'custom' or start with 'custom.'

Allowed entity token types: title, title_player_account, master_player_account, service, game_server

## Error codes

This operation may return the following PlayFab errors:

| Error | Code |
| --- | --- |
| EncryptionKeyBroken | 1291 |
| EventEntityNotAllowed | 1372 |
| EventNamespaceNotAllowed | 1371 |
| InvalidEventContents | 1548 |
| InvalidJSONContent | 1200 |
| PerEntityEventRateLimitExceeded | 1392 |
| ProductDisabledForTitle | 1609 |
| TelemetryKeyDeactivated | 14205 |
| TelemetryKeyInvalid | 14203 |




## OpenAPI

````yaml /services/playfab/api-references/rest/events/events.openapi.json post /Event/WriteTelemetryEvents
openapi: 3.0.0
info:
  version: '260922'
  title: PlayFab Events API
  description: >-
    Write custom PlayStream and Telemetry events for any PlayFab entity.
    Telemetry events can be used for analytic, reporting, or debugging.
    PlayStream events can do all of that and also trigger custom actions in near
    real-time.
  termsOfService: https://playfab.com/terms/
  contact:
    url: https://community.playfab.com/index.html
  license:
    name: Apache 2.0
    url: https://github.com/PlayFab/API_Specs/blob/master/LICENSE
servers:
  - url: https://{titleId}.playfabapi.com
    description: PlayFab title endpoint
    variables:
      titleId:
        default: your_title_id
        description: Your PlayFab title ID (hex).
security: []
tags:
  - name: PlayStream
    description: PlayStream Management APIs
  - name: PlayStream Events
    description: PlayStream Events APIs
paths:
  /Event/WriteTelemetryEvents:
    post:
      tags:
        - PlayStream Events
      summary: Write Telemetry Events
      description: >
        Write batches of entity based events to as Telemetry events (bypass
        PlayStream). The namespace must be 'custom' or start with 'custom.'


        Allowed entity token types: title, title_player_account,
        master_player_account, service, game_server


        ## Error codes


        This operation may return the following PlayFab errors:


        | Error | Code |

        | --- | --- |

        | EncryptionKeyBroken | 1291 |

        | EventEntityNotAllowed | 1372 |

        | EventNamespaceNotAllowed | 1371 |

        | InvalidEventContents | 1548 |

        | InvalidJSONContent | 1200 |

        | PerEntityEventRateLimitExceeded | 1392 |

        | ProductDisabledForTitle | 1609 |

        | TelemetryKeyDeactivated | 14205 |

        | TelemetryKeyInvalid | 14203 |
      operationId: WriteTelemetryEvents
      requestBody:
        $ref: '#/components/requestBodies/WriteEventsRequest'
      responses:
        '200':
          $ref: '#/components/responses/WriteEventsResponse'
        '400':
          $ref: '#/components/responses/ApiErrorWrapper'
      security:
        - EntityToken: []
components:
  requestBodies:
    WriteEventsRequest:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WriteEventsRequest'
  responses:
    WriteEventsResponse:
      description: ''
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: integer
                description: >-
                  The Http status code. If X-ReportErrorAsSuccess header is set
                  to true, this will report the actual http error code.
              status:
                type: string
                description: The Http status code as a string.
              data:
                $ref: '#/components/schemas/WriteEventsResponse'
            example:
              code: 200
              status: OK
              data:
                AssignedEventIds:
                  - 496b598a05404142a6b6349c8cb29459
    ApiErrorWrapper:
      description: This is the outer wrapper for all responses with errors
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorWrapper'
  schemas:
    WriteEventsRequest:
      type: object
      properties:
        CustomTags:
          description: >-
            The optional custom tags associated with the request (e.g. build
            number, external trace identifiers, etc.).
          type: object
        Events:
          description: >-
            The collection of events to write. Up to 200 events can be written
            per request.
          type: array
          items:
            $ref: '#/components/schemas/EventContents'
          x-isclass: true
      required:
        - Events
      example:
        Events:
          - Entity:
              Id: A8140AB9109712B
              Type: title
              TypeString: title
            EventNamespace: com.playfab.events.example
            Name: something_happened
            Payload:
              Foo: Bar
              Nums:
                - 1
                - 2
                - 3
    WriteEventsResponse:
      type: object
      properties:
        AssignedEventIds:
          description: >-
            The unique identifiers assigned by the server to the events, in the
            same order as the events in the request. Only returned if
            FlushToPlayStream option is true.
          type: array
          items:
            type: string
      example:
        AssignedEventIds:
          - 496b598a05404142a6b6349c8cb29459
    ApiErrorWrapper:
      description: The basic wrapper around every failed API response
      type: object
      properties:
        code:
          description: Numerical HTTP code
          type: integer
        status:
          description: String HTTP code
          type: string
        error:
          description: Playfab error code
          type: string
        errorCode:
          description: Numerical PlayFab error code
          type: integer
        errorMessage:
          description: Description for the PlayFab errorCode
          type: string
        errorDetails:
          description: Detailed description of individual issues with the request object
          type: object
      required:
        - code
        - errorCode
    EventContents:
      type: object
      properties:
        CustomTags:
          description: >-
            The optional custom tags associated with the event (e.g. build
            number, external trace identifiers, etc.). Before an event is
            written, this collection and the base request custom tags will be
            merged, but not overriden. This enables the caller to specify static
            tags and per event tags.
          type: object
        Entity:
          allOf:
            - $ref: '#/components/schemas/EntityKey'
          description: >-
            Entity associated with the event. If null, the event will apply to
            the calling entity.
        EventNamespace:
          description: >-
            The namespace in which the event is defined. Allowed namespaces can
            vary by API.
          type: string
        Name:
          description: The name of this event.
          type: string
        OriginalId:
          description: >-
            The original unique identifier associated with this event before it
            was posted to PlayFab. The value might differ from the EventId
            value, which is assigned when the event is received by the server.
          type: string
        OriginalTimestamp:
          description: >-
            The time (in UTC) associated with this event when it occurred. If
            specified, this value is stored in the OriginalTimestamp property of
            the PlayStream event.
          type: string
        Payload:
          description: >-
            Arbitrary data associated with the event. Only one of Payload or
            PayloadJSON is allowed.
          type: object
        PayloadJSON:
          description: >-
            Arbitrary data associated with the event, represented as a JSON
            serialized string. Only one of Payload or PayloadJSON is allowed.
          type: string
      required:
        - EventNamespace
        - Name
    EntityKey:
      description: >-
        Combined entity type and ID structure which uniquely identifies a single
        entity.
      type: object
      properties:
        Id:
          description: Unique ID of the entity.
          type: string
        Type:
          description: >-
            Entity type. See
            https://learn.microsoft.com/gaming/playfab/features/data/entities/available-built-in-entity-types
          type: string
      required:
        - Id
  securitySchemes:
    EntityToken:
      type: apiKey
      in: header
      name: X-EntityToken
      description: >-
        This API requires an Entity Session Token, available from the Entity
        GetEntityToken method.

````

## Related topics

- [Write Telemetry Events](/services/playfab/api-references/rest/events/play-stream-events/write-telemetry-events.md)
- [Telemetry](/services/playfab/data-analytics/ingest-data/telemetry-overview.md)
- [PFEventsWriteTelemetryEventsAsync](/services/playfab/api-references/c/pfevents/functions/pfeventswritetelemetryeventsasync.md)
- [Telemetry Keys](/services/playfab/data-analytics/ingest-data/telemetry-keys-overview.md)
- [PFEventsWriteTelemetryEventsGetResult](/services/playfab/api-references/c/pfevents/functions/pfeventswritetelemetryeventsgetresult.md)
