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

# Publish And Sync Ui Events

> Publish zero or more events and return any new events since the given event id, exactly like PublishAndRetrieveUiEvents — and additionally answer, for each ticket version the client supplies, whether that ticket has changed since (and by whom).

Requested tickets the user cannot see are omitted from the answer
NsApiSlow threshold: 5000 ms.
<para />## Experimental: ## This method is experimental, subject to change, and not intended for partners.



## OpenAPI

````yaml /openapi/agent/openapi-v3-ViewStateAgent.json post /api/v1/Agents/ViewState/PublishAndSyncUiEvents
openapi: 3.0.0
info:
  version: v1-Agents
  title: SuperOffice Agent API v1
  description: SuperOffice Agent API - ViewStateAgent
  contact:
    name: SuperOffice DevNet
    url: https://docs.superoffice.com/en/api/index.html
    email: sdk@superoffice.com
servers:
  - url: http://localhost:56350
  - url: https://localhost:56350
security: []
tags: []
externalDocs:
  description: >-
    The SuperOffice DevNet Community has more documentation, examples, and
    discussion forums.
  url: https://community.superoffice.com/en/developer/
paths:
  /api/v1/Agents/ViewState/PublishAndSyncUiEvents:
    post:
      tags:
        - ViewState_Agent
      summary: Publish And Sync Ui Events
      description: "Publish zero or more events and return any new events since the given event id, exactly like PublishAndRetrieveUiEvents — and additionally answer, for each ticket version the client supplies, whether that ticket has changed since (and by whom).\n\nRequested tickets the user cannot see are omitted from the answer\r\nNsApiSlow threshold: 5000 ms.\r\n<para />## Experimental: ## This method is experimental, subject to change, and not intended for partners."
      operationId: v1ViewStateAgent_PublishAndSyncUiEvents
      parameters:
        - name: $select
          in: query
          description: >-
            Optional comma separated list of properties to include in the
            result. Other fields are then nulled out to reduce payload size:
            "Name,department,category". Default = show all fields.
          required: false
          schema:
            type: string
        - name: Accept-Language
          in: header
          description: >-
            Convert string references and multi-language values into a specified
            language (iso2) code.
          required: false
          schema:
            type: string
        - name: SO-Language
          in: header
          description: >-
            Convert string references and multi-language values into a specified
            language (iso2) code. Overrides Accept-Language value.
          required: false
          schema:
            type: string
        - name: SO-Culture
          in: header
          description: >-
            Number, date formatting in a specified culture (iso2 language) code.
            Partially overrides SO-Language/Accept-Language value. Ignored if no
            Language set.
          required: false
          schema:
            type: string
        - name: SO-TimeZone
          in: header
          description: >-
            Specify the timezone code that you would like date/time responses
            converted to.
          required: false
          schema:
            type: string
        - name: SO-AppToken
          in: header
          description: >-
            The application token that identifies the partner app. Used when
            calling Online WebAPI from a server.
          required: false
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.ViewStateCarriers.PublishAndSyncUiEventsRequest
          text/json:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.ViewStateCarriers.PublishAndSyncUiEventsRequest
          application/xml:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.ViewStateCarriers.PublishAndSyncUiEventsRequest
          text/xml:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.ViewStateCarriers.PublishAndSyncUiEventsRequest
          application/x-www-form-urlencoded:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.ViewStateCarriers.PublishAndSyncUiEventsRequest
          application/json-patch+json:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.ViewStateCarriers.PublishAndSyncUiEventsRequest
          application/merge-patch+json:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.ViewStateCarriers.PublishAndSyncUiEventsRequest
        description: LatestKnownEventId, PublishEvents, Metrics, TicketVersions
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuperOffice.CRM.Services.LiveUiSyncResult'
            text/json:
              schema:
                $ref: '#/components/schemas/SuperOffice.CRM.Services.LiveUiSyncResult'
            application/xml:
              schema:
                $ref: '#/components/schemas/SuperOffice.CRM.Services.LiveUiSyncResult'
            text/xml:
              schema:
                $ref: '#/components/schemas/SuperOffice.CRM.Services.LiveUiSyncResult'
            application/json-patch+json:
              schema:
                $ref: '#/components/schemas/SuperOffice.CRM.Services.LiveUiSyncResult'
            application/merge-patch+json:
              schema:
                $ref: '#/components/schemas/SuperOffice.CRM.Services.LiveUiSyncResult'
      security:
        - SuperOffice_Password: []
          SuperId_Authentication: []
components:
  schemas:
    SuperOffice.WebApi.v1.Carriers.ViewStateCarriers.PublishAndSyncUiEventsRequest:
      description: >-
        PublishAndSyncUiEvents: Publish zero or more events and return any new
        events since the given event id, exactly like PublishAndRetrieveUiEvents
        — and additionally answer, for each ticket version the client supplies,
        whether that ticket has changed since (and by whom). Requested tickets
        the user cannot see are omitted from the answer
      type: object
      properties:
        LatestKnownEventId:
          format: int32
          type: integer
        PublishEvents:
          type: array
          items:
            $ref: '#/components/schemas/SuperOffice.CRM.Services.UiEvent'
        Metrics:
          type: array
          items:
            $ref: '#/components/schemas/SuperOffice.CRM.Services.MetricPair'
        TicketVersions:
          type: array
          items:
            $ref: '#/components/schemas/SuperOffice.CRM.Services.TicketVersionInfo'
    SuperOffice.CRM.Services.LiveUiSyncResult:
      description: "The combined answer of one live UI sync call: new UI events, plus the sync state of the tickets the client asked about.\r\n<para />\r\nCarrier object for LiveUiSyncResult."
      type: object
      properties:
        Events:
          description: >-
            New events since the given event id — the same content the
            PublishAndRetrieveUiEvents operation returns.
          type: array
          items:
            $ref: '#/components/schemas/SuperOffice.CRM.Services.UiEvent'
        TicketStates:
          description: >-
            Sync state of each requested ticket the user is allowed to see.
            Requested tickets the user cannot see are omitted.
          type: array
          items:
            $ref: '#/components/schemas/SuperOffice.CRM.Services.TicketStateInfo'
    SuperOffice.CRM.Services.UiEvent:
      description: "An event that the user interface should know about. The origin may be something that happens in the user interface (in any session), or in the database (for instance, background process)\r\n<para />\r\nCarrier object for UiEvent.\r\nServices for the UiEvent Carrier is available from the <see cref=\"T:SuperOffice.CRM.Services.IViewStateAgent\">ViewState Agent</see>."
      type: object
      properties:
        EventId:
          format: int32
          description: Id of event, increasing in chronological order, assigned by server
          type: integer
        EventName:
          description: Name of event, for instance 'change' or 'edit'
          type: string
        EntityType:
          description: Name of entity, for instance 'ticket'
          type: string
        EntityKey:
          format: int32
          description: Primary key of entity the event concerns
          type: integer
        AssociateId:
          format: int32
          description: The ID of the associate causing the event
          type: integer
        AssociateName:
          description: The full person name of the associate causing the event
          type: string
        EventDateTime:
          format: date-time
          description: When did the event happen
          type: string
        TableRight:
          $ref: '#/components/schemas/SuperOffice.CRM.Security.TableRight'
        FieldProperties:
          description: >-
            Field property dictionary mapping field names to field access
            rights.
          type: object
          additionalProperties:
            $ref: '#/components/schemas/SuperOffice.CRM.Security.FieldProperty'
    SuperOffice.CRM.Services.MetricPair:
      description: "Metric, in the form of string->int\r\n<para />\r\nCarrier object for MetricPair."
      type: object
      properties:
        Name:
          description: The name of the metric
          type: string
        Value:
          format: int32
          description: The value of the metric
          type: integer
    SuperOffice.CRM.Services.TicketVersionInfo:
      description: "A ticket the client is showing, together with the last-changed value of the client's loaded copy. Sent to the server to ask whether that copy is out of date.\r\n<para />\r\nCarrier object for TicketVersionInfo."
      type: object
      properties:
        TicketId:
          format: int32
          description: The primary key (auto-incremented)
          type: integer
        LastChanged:
          format: date-time
          description: >-
            The last-changed value of the copy the client has loaded.
            DateTime.MinValue (or omitted) means the client has no loaded copy
            and only wants the ticket's current value back.
          type: string
    SuperOffice.CRM.Services.TicketStateInfo:
      description: "The sync state of one ticket: its current last-changed value on the server, whether the client's copy is out of date, and who last changed it.\r\n<para />\r\nCarrier object for TicketStateInfo."
      type: object
      properties:
        TicketId:
          format: int32
          description: The primary key (auto-incremented)
          type: integer
        LastChanged:
          format: date-time
          description: >-
            The ticket's current last-changed value on the server. Clients store
            this and send it back as the version in later calls.
          type: string
        IsStale:
          description: >-
            True when the ticket changed after the version the client sent.
            Always false when the client sent no version (DateTime.MinValue).
          type: boolean
        ChangedById:
          format: int32
          description: >-
            The associate who made the latest change, when the ticket is stale
            and the change can be attributed; 0 otherwise.
          type: integer
        ChangedByName:
          description: >-
            Full name of the associate who made the latest change; empty when
            unknown.
          type: string
    SuperOffice.CRM.Security.TableRight:
      description: "Wraps a table right together with an explanatory reason.\r\nCode can indicate why access is restricted."
      type: object
      properties:
        Mask:
          type: string
        Reason:
          type: string
    SuperOffice.CRM.Security.FieldProperty:
      description: >-
        Class holding properties like field length, field type about a field in
        the carrier.
      type: object
      properties:
        FieldRight:
          $ref: '#/components/schemas/SuperOffice.CRM.Security.FieldRight'
        FieldType:
          type: string
        FieldLength:
          format: int32
          description: ''
          type: integer
    SuperOffice.CRM.Security.FieldRight:
      description: "Wraps the field right together with an explanatory reason.\r\nAlso adds logical operators to the field rights so that they can be easily combined."
      type: object
      properties:
        Mask:
          type: string
        Reason:
          type: string

````

## Related topics

- [Publish And Retrieve Ui Events](/en/api/reference/restful/agent/viewstate_agent/publish-and-retrieve-ui-events.md)
- [SuperOffice.WebApi.Data.ViewState PublishAndRetrieveUiEventsRequest](/en/api/reference/webapi/SuperOffice.WebApi.Data.ViewState_PublishAndRetrieveUiEventsRequest.md)
- [SuperOffice.WebApi.Agents.IViewStateAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.IViewStateAgent.md)
- [SuperOffice.WebApi.Agents.ViewStateAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.ViewStateAgent.md)
- [Is Publish Event Active](/en/api/reference/restful/agent/userdefinedfieldinfo_agent/is-publish-event-active.md)
- [SuperOffice.WebApi.Data.UiEvent](/en/api/reference/webapi/SuperOffice.WebApi.Data.UiEvent.md)
