Functions/Invoke-CreateTicket.ps1

#Install-Module PSGraphQL
Import-Module PSGraphQL

function Invoke-CreateTicket {
    Param(
         [Parameter(Mandatory=$true, Position= 0)][Alias("CustomerSubDomain", "Domain", "CustomerDomain")][String]$SubDomain,
         [Parameter(Mandatory=$true, Position= 1)][Alias("api_key", "API-KEY", "key")][String]$ApiKey,
         [Parameter(Mandatory=$true, Position= 2)][Alias("sub", "s")][String]$Subject,
         [Parameter(Mandatory=$true, Position= 3)][Alias("uid", "id")][string]$userId,
         [Parameter(Mandatory=$true, Position= 3)][Alias("aid", "accId")][string]$accountId         
         )
    $uri = "https://api.superops.ai/msp"
    
    $Subject = '"'+$Subject+'"' # Format to GraphQL schema

    $Mutation = "
        mutation {
          createTicket(
            input:{
                subject: $Subject,
                requester:{
                    userId: $userId
                },
                client:{
                    accountId: $accountId
                },
                ticketType: INCIDENT,
                source:AGENT
            }
        ){
            ticketId
            displayId
        }
     }
    "


    Write-Host $Mutation

    $requestHeaders = @{'CustomerSubDomain'=$SubDomain; 'Authorization'= $apiKey}
    
    $jsonResult = Invoke-GraphQLQuery -Query $Mutation -Headers $requestHeaders -Uri $uri -Raw

    Write-Host $jsonResult
}

Invoke-CreateTicket -SubDomain 'issues' -Subject 'New Tickett' -userId "6190518073584738304" -accountId "6190518073094004736"  -ApiKey 'Bearer api-eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiI1OTI0MzU3MjkxOTY5MDkzNjMyIiwicmFuZG9taXplciI6Ilx1MDAwNnJ5I--_vc6x77-977-9MiJ9.LHEw8-EtD26w4tlyfwPTNBa3ZL3PuOR4o-nmCgt-UvsctmxEIIXg652ss08dugYFGUb6TTTpBjliZogG-_FgXGuOqQywS-iN4HLHsWFWaeBUoK_OmlgqFp3w7RujUnrGbgrt1fm_bAiVgFI7QFjzqXgfwV8bKe_qAbUHKFTJiq7v4arSfk-DRCSdUknbVDY7dYfUWtbsqk4hJzGvYYY410yVTfuC5-IF6y_4jbNqCeZQACFrB5dJyXc75_nXMmghjISCrH5XCmToXNOhfvexN6M10P3qdznm8ilbF72zRMLfAW71ajo4YtWFhBTSENqip8Ju9I08VRt5j-Qd9xYr4A'