> ## 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.

# Execute Script As Event By Unique Id

> Execute a CRMScript with event data as input.

Returns event data with output variable values.
NsApiSlow threshold: 5000 ms.
<para />## Online Restricted: ## The CRMScript agent is not available in Online by default. Access must be requested specifically when app is registered.



## OpenAPI

````yaml /openapi/agent/openapi-v3-CRMScriptAgent.json post /api/v1/Agents/CRMScript/ExecuteScriptAsEventByUniqueId
openapi: 3.0.0
info:
  version: v1-Agents
  title: SuperOffice Agent API v1
  description: SuperOffice Agent API - CRMScriptAgent
  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/CRMScript/ExecuteScriptAsEventByUniqueId:
    post:
      tags:
        - CRMScript_Agent
      summary: Execute Script As Event By Unique Id
      description: "Execute a CRMScript with event data as input.\n\nReturns event data with output variable values.\r\nNsApiSlow threshold: 5000 ms.\r\n<para />## Online Restricted: ## The CRMScript agent is not available in Online by default. Access must be requested specifically when app is registered."
      operationId: v1CRMScriptAgent_ExecuteScriptAsEventByUniqueId
      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.CRMScriptCarriers.ExecuteScriptAsEventByUniqueIdRequest
          text/json:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.CRMScriptCarriers.ExecuteScriptAsEventByUniqueIdRequest
          application/xml:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.CRMScriptCarriers.ExecuteScriptAsEventByUniqueIdRequest
          text/xml:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.CRMScriptCarriers.ExecuteScriptAsEventByUniqueIdRequest
          application/x-www-form-urlencoded:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.CRMScriptCarriers.ExecuteScriptAsEventByUniqueIdRequest
          application/json-patch+json:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.CRMScriptCarriers.ExecuteScriptAsEventByUniqueIdRequest
          application/merge-patch+json:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.CRMScriptCarriers.ExecuteScriptAsEventByUniqueIdRequest
        description: CRMScriptUniqueId, EventData
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuperOffice.CRM.Services.EventData'
            text/json:
              schema:
                $ref: '#/components/schemas/SuperOffice.CRM.Services.EventData'
            application/xml:
              schema:
                $ref: '#/components/schemas/SuperOffice.CRM.Services.EventData'
            text/xml:
              schema:
                $ref: '#/components/schemas/SuperOffice.CRM.Services.EventData'
            application/json-patch+json:
              schema:
                $ref: '#/components/schemas/SuperOffice.CRM.Services.EventData'
            application/merge-patch+json:
              schema:
                $ref: '#/components/schemas/SuperOffice.CRM.Services.EventData'
      security:
        - SuperOffice_Password: []
          SuperId_Authentication: []
components:
  schemas:
    SuperOffice.WebApi.v1.Carriers.CRMScriptCarriers.ExecuteScriptAsEventByUniqueIdRequest:
      description: >-
        ExecuteScriptAsEventByUniqueId: Execute a CRMScript with event data as
        input. Returns event data with output variable values.
      type: object
      properties:
        CRMScriptUniqueId:
          type: string
        EventData:
          $ref: '#/components/schemas/SuperOffice.CRM.Services.EventData'
    SuperOffice.CRM.Services.EventData:
      description: "EventData containing data related to event handlers\r\n<para />\r\nCarrier object for EventData.\r\nServices for the EventData Carrier is available from the <see cref=\"T:SuperOffice.CRM.Services.ICustomerServiceAgent\">CustomerService Agent</see>."
      type: object
      properties:
        Type:
          description: The type of event we are triggered by
          enum:
            - Unknown
            - NewTicket
            - NewTicketFromCustomerCenter
            - NewTicketFromEmail
            - NewTicketFromCustomerCenterBeforeSave
            - NewTicketFromSpmLink
            - NewNotifyTicketFromForm
            - NewTicketFromForm
            - TicketSave
            - TicketClosed
            - TicketPostponed
            - TicketDeleted
            - TicketActivated
            - TicketReopened
            - TicketReopenedFromCustomerCenter
            - TicketReopenedFromEmail
            - TicketChangedPriority
            - TicketChangedCategory
            - TicketChangedOwnedBy
            - TicketChangedPrimaryCustomer
            - TicketChangedTicketStatus
            - TicketChangedSlevel
            - TicketMessageAdded
            - TicketInternalMessageAdded
            - TicketExternalMessageAdded
            - TicketMessageSentimentCalculated
            - CompactModeInjection
            - CustomerCenterAuthentication
            - ScheduledTaskFailed
            - DbiTaskFailed
            - CustomerSetSubscriptions
            - ImportMailBeforeProcessing
            - ImportMailAfterProcessing
            - MainMenu
            - ChatNewSession
            - ChatSessionChangedStatus
            - ChatBeforeSaveNewMessage
            - ChatAfterSaveNewMessage
            - ServiceScreenNewTicketLoad
            - ServiceScreenNewQuickTicketLoad
            - ServiceScreenListTicketMessagesLoad
            - ServiceScreenAddMessageLoad
            - ServiceScreenEditTicketLoad
            - ServiceScreenViewCustomerLoad
            - ServiceScreenEditCustomerLoad
            - ServiceScreenViewCompanyLoad
            - ServiceScreenEditCompanyLoad
            - ServiceScreenForwardLoad
            - ServiceScreenEditExtraTableLoad
            - ServiceScreenNewTicketBeforeSubmit
            - ServiceScreenNewQuickTicketBeforeSubmit
            - ServiceScreenListTicketMessagesBeforeSubmit
            - ServiceScreenAddMessageBeforeSubmit
            - ServiceScreenEditTicketBeforeSubmit
            - ServiceScreenViewCustomerBeforeSubmit
            - ServiceScreenEditCustomerBeforeSubmit
            - ServiceScreenViewCompanyBeforeSubmit
            - ServiceScreenEditCompanyBeforeSubmit
            - ServiceScreenForwardBeforeSubmit
            - ServiceScreenEditExtraTableBeforeSubmit
            - ServiceScreenNewTicketAfterSubmit
            - ServiceScreenNewQuickTicketAfterSubmit
            - ServiceScreenListTicketMessagesAfterSubmit
            - ServiceScreenAddMessageAfterSubmit
            - ServiceScreenEditTicketAfterSubmit
            - ServiceScreenViewCustomerAfterSubmit
            - ServiceScreenEditCustomerAfterSubmit
            - ServiceScreenViewCompanyAfterSubmit
            - ServiceScreenEditCompanyAfterSubmit
            - ServiceScreenForwardAfterSubmit
            - ServiceScreenEditExtraTableAfterSubmit
            - SalesBeforeSaveAppointment
            - SalesBeforeSaveStakeholder
            - SalesBeforeSaveQuote
            - SalesBeforeSaveDocument
            - SalesBeforeSaveContact
            - SalesBeforeSavePerson
            - SalesBeforeSaveRelation
            - SalesBeforeSaveSale
            - SalesBeforeSaveProject
            - SalesBeforeSaveSelection
            - SalesBeforeSaveProjectMember
            - SalesBeforeSaveSelectionMember
            - SalesBeforeSaveQuoteLine
            - SalesBeforeSaveApproveQuote
            - SalesBeforeSaveRejectQuote
            - SalesBeforeSaveTicket
            - SalesLoadCustomObject
            - SalesBeforeSaveCustomObject
            - SalesAfterSaveAppointment
            - SalesAfterSaveStakeholder
            - SalesAfterSaveQuote
            - SalesAfterSaveDocument
            - SalesAfterSaveContact
            - SalesAfterSavePerson
            - SalesAfterSaveRelation
            - SalesAfterSaveSale
            - SalesAfterSaveProject
            - SalesAfterSaveSelection
            - SalesAfterSaveProjectMember
            - SalesAfterSaveSelectionMember
            - SalesAfterSaveQuoteLine
            - SalesAfterSaveApproveQuote
            - SalesAfterSaveRejectQuote
            - SalesAfterSaveTicket
            - SalesAfterSaveCustomObject
            - SalesSplitTicket
            - SalesLoadTicket
            - SalesLoadTicketMessage
          type: string
        InputValues:
          description: Environment values sent to the event handler
          type: object
          additionalProperties:
            type: string
        BlockExecution:
          description: Whether the context should stop what it is doing, e.g. saving a sale
          type: boolean
        NavigateTo:
          description: Where the context should naviate afterwards
          type: string
        Message:
          description: A message to be presented to the user
          type: string
        ShowDialog:
          description: JSON structure of dialog to show
          type: string
        OutputValues:
          description: Values sent back to the environment from the event handler
          type: object
          additionalProperties:
            type: string
        StateValues:
          description: Values kept between event handlers
          type: object
          additionalProperties:
            type: string
        Exception:
          description: String containing error message from handler system if it failed
          type: string
        ParserValues:
          description: Parser values sent to the event handler
          type: object
          additionalProperties:
            type: string
        CgiVariables:
          description: Cgi variables sent by some events
          type: object
          additionalProperties:
            type: string
        CgiContent:
          description: The Cgi content/body, sent by some events
          type: string
        Headers:
          description: >-
            Incoming headers if sent by the context which the script is executed
            from
          type: object
          additionalProperties:
            type: string
        TraceExecution:
          description: If true, then the execution will be traced
          type: boolean
        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.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

- [Execute Script As Event By Unique Id](/en/api/reference/restful/rest/crmscript/execute-script-as-event-by-unique-id.md)
- [SuperOffice.WebApi.Data.CRMScript ExecuteScriptAsEventByUniqueIdRequest](/en/api/reference/webapi/SuperOffice.WebApi.Data.CRMScript_ExecuteScriptAsEventByUniqueIdRequest.md)
- [SuperOffice.WebApi.Agents.CRMScriptAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.CRMScriptAgent.md)
- [SuperOffice.WebApi.Agents.ICRMScriptAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.ICRMScriptAgent.md)
- [Execute Script By Unique Id](/en/api/reference/restful/rest/crmscript/execute-script-by-unique-id.md)
