# Server Events

## Calls

### gksphone:calls:newCall <a href="#gks-phonenewcall" id="gks-phonenewcall"></a>

Triggered when a new call is made.

```lua
AddEventHandler("gksphone:calls:newCall", function(call)
    print("New call:", json.encode(call, { indent = true }))
end)

-- Example print
New call: {
     "targetSource": 2,
     "isJobCall": true,
     "fromPayphone": false,
     "callerSource": 1,
     "targetNumber": "5555555",
     "isPrivateCall": false,
     "company": "police",
     "callId": 1002,
     "isBusy": false,
     "callerNumber": "6022005516",
     "callType": "calling"
}
```

### gksphone:calls:callAnswered

Triggered when a call is answered.

```lua
AddEventHandler("gksphone:calls:callAnswered", function(call)
    print("Call answered:", json.encode(call, { indent = true }))
end)

-- Example print
Call answered: {
     "callId": 1002,
     "callType": "calling",
     "isPrivateCall": false,
     "callerNumber": "6022005516",
     "targetNumber": "22222",
     "targetSource": 2,
     "callerSource": 1,
     "company": "police",
}
```

### gksphone:calls:callEnded

Triggered when a call is answered.

```lua
AddEventHandler("gksphone:calls:callEnded", function(call)
    print("Call ended:", json.encode(call, { indent = true }))
end)

-- Example print
Call ended: {
     "callId": 1002,
     "callType": "calling",
     "isPrivateCall": false,
     "callerNumber": "6022005516",
     "targetNumber": "22222",
     "targetSource": 2,
     "callerSource": 1,
     "company": "police",
}
```

## Messages <a href="#messagessms" id="messagessms"></a>

### gksphone:messages:messageSent

Triggered when a message is sent.

```lua
AddEventHandler("gksphone:messages:messageSent", function(call)
    print("New message:", json.encode(call, { indent = true }))
end)

-- Example print
New message: {
     "senderNumber": "6022005516",
     "senderPhoneId": "GKS2025AAAAA",
     "senderSource": 1 or nil,
     "receiverNumber": "22222",
     "receiverPhoneId": "",
     "receiverSource": 2 or nil
     "message": "Test Message",
     "messageId": 99,
     "timestamp": -- os.time
}

```

## Social media <a href="#social-media" id="social-media"></a>

### gksphone:adv:newPost

```lua
AddEventHandler("gksphone:adv:newPost", function(post)
    print("New post:", json.encode(post, { indent = true }))
end)

-- Example print
New post: {
     "id": 1,
     "phoneNumber": "22222",
     "message": "Test Message",
     "filter": "mechanic",
     "image": ["https://media.gkshop.org/183897083940438016/image/1747926801106.webp"] -- JSON
}
```

### gksphone:squawk:newPost

```lua
AddEventHandler("gksphone:squawk:newPost", function(post)
    print("New post:", json.encode(post, { indent = true }))
end)

-- Example print
New post: {
     "id": 1,
     "username": "gkshop",
     "content": "Test Message",
     "displayname": "GKSHOP",
     "image": ["https://media.gkshop.org/183897083940438016/image/1747926801106.webp"], -- json or string
     "isComment": false
}
```

### gksphone:snapgram:newPost

```lua
AddEventHandler("gksphone:snapgram:newPost", function(post)
    print("New post:", json.encode(post, { indent = true }))
end)

-- Example print
New post: {
     "id": 1,
     "username": "gkshop",
     "caption": "Test Message",
     "full_name": "GKSHOP",
     "media": ["https://media.gkshop.org/183897083940438016/image/1747926801106.webp"], -- json or string
     "location": ""
}
```

## Services

### gksphone:services:newReport

```lua
AddEventHandler("gksphone:services:newReport", function(report)
    print("New report:", json.encode(report, { indent = true }))
end)

-- Example print
New report: {
     "source": 1,
     "message": "Test Report",
     "reportPhoto": "https://media.gkshop.org/183897083940438016/image/1747926801106.webp",
     "job": "police",
     "isAnonymous": false,
     "phoneNumber": "123456789"
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gkshop.org/gksphone-v2/exports-and-events/server-events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
