# v2 API Reference

## API Authentication

All requests to the API **must have a valid Server-Key header provided.**

{% hint style="info" %}
**Not sure where to find your server key?**

Join your private server, open the settings, and search for "API key" under the ER:LC API header.
{% endhint %}

## What's new in API v2?

PRC API v2 is intended to provide a more consistent and simpler request model for developers. In addition, it provides highly requested data, such as player locations and vehicle colours!

API v1 will continue to operate, without major changes, until further notice.

## Endpoint Information

## Fetch server information

> Returns server status data. Additional fields can be included by setting query parameters to 'true'. All query parameters are optional.

```json
{"openapi":"3.0.1","info":{"title":"PRC Public API","version":"2.0.0"},"servers":[{"url":"https://api.policeroleplay.community","description":"PRC Public API v1"}],"security":[{"ServerKeyAuth":[]}],"components":{"securitySchemes":{"ServerKeyAuth":{"type":"apiKey","in":"header","name":"server-key","description":"REQUIRED ON ALL REQUESTS."}}},"paths":{"/v2/server":{"get":{"summary":"Fetch server information","description":"Returns server status data. Additional fields can be included by setting query parameters to 'true'. All query parameters are optional.","parameters":[{"name":"Players","in":"query","description":"Include player list in response","required":false,"schema":{"type":"boolean"}},{"name":"Staff","in":"query","description":"Include staff list (Admins, Mods, Helpers) in response","required":false,"schema":{"type":"boolean"}},{"name":"JoinLogs","in":"query","description":"Include join logs in response","required":false,"schema":{"type":"boolean"}},{"name":"Queue","in":"query","description":"Include queue data in response","required":false,"schema":{"type":"boolean"}},{"name":"KillLogs","in":"query","description":"Include kill logs in response","required":false,"schema":{"type":"boolean"}},{"name":"CommandLogs","in":"query","description":"Include command logs in response","required":false,"schema":{"type":"boolean"}},{"name":"ModCalls","in":"query","description":"Include moderator call logs in response","required":false,"schema":{"type":"boolean"}},{"name":"EmergencyCalls","in":"query","description":"Include emergency call logs in response","required":false,"schema":{"type":"boolean"}},{"name":"Vehicles","in":"query","description":"Include vehicle list in response","required":false,"schema":{"type":"boolean"}}],"responses":{"200":{"description":"Requested data. Optional fields only included when query=true.","content":{"application/json":{"schema":{"type":"object","required":["Name","OwnerId","CoOwnerIds","CurrentPlayers","MaxPlayers","JoinKey","AccVerifiedReq","TeamBalance"],"properties":{"Name":{"type":"string"},"OwnerId":{"type":"integer"},"CoOwnerIds":{"type":"array","items":{"type":"integer"}},"CurrentPlayers":{"type":"integer"},"MaxPlayers":{"type":"integer"},"JoinKey":{"type":"string"},"AccVerifiedReq":{"type":"string"},"TeamBalance":{"type":"boolean"},"Players":{"type":"array","description":"Only included when Players=true query parameter is provided","items":{"type":"object","properties":{"Team":{"type":"string"},"Player":{"type":"string"},"Callsign":{"type":["string","null"],"description":"Only available if the player is on a non-civilian team"},"Location":{"type":"object","properties":{"LocationX":{"type":"number"},"LocationZ":{"type":"number"},"PostalCode":{"type":"string"},"StreetName":{"type":"string"},"BuildingNumber":{"type":"string"}}},"Permission":{"type":"string"},"WantedStars":{"type":"integer"}}}},"Staff":{"type":"object","description":"Only included when Staff=true query parameter is provided","properties":{"Admins":{"type":"object","description":"Map of Roblox user IDs to usernames for server administrators","additionalProperties":false,"patternProperties":{"^[0-9]+$":{"type":"string","description":"Player's Roblox username"}}},"Mods":{"type":"object","description":"Map of Roblox user IDs to usernames for server moderators","additionalProperties":false,"patternProperties":{"^[0-9]+$":{"type":"string","description":"Player's Roblox username"}}},"Helpers":{"type":"object","description":"Map of Roblox user IDs to usernames for server helpers","additionalProperties":false,"patternProperties":{"^[0-9]+$":{"type":"string","description":"Player's Roblox username"}}}}},"JoinLogs":{"type":"array","description":"Only included when JoinLogs=true query parameter is provided","items":{"type":"object","properties":{"Join":{"type":"boolean"},"Timestamp":{"type":"integer"},"Player":{"type":"string"}}}},"Queue":{"type":"array","description":"Only included when Queue=true query parameter is provided","items":{"type":"integer"}},"KillLogs":{"type":"array","description":"Only included when KillLogs=true query parameter is provided","items":{"type":"object","properties":{"Killed":{"type":"string"},"Timestamp":{"type":"integer"},"Killer":{"type":"string"}}}},"CommandLogs":{"type":"array","description":"Only included when CommandLogs=true query parameter is provided","items":{"type":"object","properties":{"Player":{"type":"string"},"Timestamp":{"type":"integer"},"Command":{"type":"string"}}}},"ModCalls":{"type":"array","description":"Only included when ModCalls=true query parameter is provided","items":{"type":"object","properties":{"Caller":{"type":"string"},"Moderator":{"type":["string","null"]},"Timestamp":{"type":"integer"}}}},"EmergencyCalls":{"type":"array","description":"Only included when EmergencyCalls=true query parameter is provided","items":{"type":"object","properties":{"Team":{"type":"string"},"Caller":{"type":"integer"},"Players":{"type":"array","items":{"type":"integer"}},"Position":{"type":"array","items":{"type":"number"},"minItems":2,"maxItems":2},"StartedAt":{"type":"integer"},"CallNumber":{"type":"integer"},"Description":{"type":"string"},"PositionDescriptor":{"type":"string"}}}},"Vehicles":{"type":"array","description":"Only included when Vehicles=true query parameter is provided","items":{"type":"object","properties":{"Name":{"type":"string"},"Owner":{"type":"string"},"Plate":{"type":"string"},"Texture":{"type":["string","null"]},"ColorHex":{"type":"string"},"ColorName":{"type":"string"}}}}}}}}},"403":{"description":"Unauthorized"},"500":{"description":"Error communicating with Roblox","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"integer"}}}}}}}}}}}
```

## POST /v2/server/command

> Run a command as a player named "virtual server management"

```json
{"openapi":"3.0.1","info":{"title":"PRC Public API","version":"2.0.0"},"servers":[{"url":"https://api.policeroleplay.community","description":"PRC Public API v1"}],"security":[{"ServerKeyAuth":[]}],"components":{"securitySchemes":{"ServerKeyAuth":{"type":"apiKey","in":"header","name":"server-key","description":"REQUIRED ON ALL REQUESTS."}}},"paths":{"/v2/server/command":{"post":{"summary":"Run a command as a player named \"virtual server management\"","requestBody":{"description":"Command to be executed","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"command":{"type":"string","description":"The command to be executed"}}}}}},"responses":{"200":{"description":"Command executed successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","description":"A message explaining the status of your command"}}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","description":"An error message"}}}}}},"403":{"description":"Unauthorized"},"422":{"description":"The private server has no players in it","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","description":"An error message"},"commandId":{"type":"string","description":"A unique ID assigned to that command execution request, only used when you need to provide it to PRC for troubleshooting purposes"}}}}}},"500":{"description":"Problem communicating with Roblox","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","description":"A message explaining the status of your command"},"commandId":{"type":"string","description":"A unique ID assigned to that command execution request, only used when you need to provide it to PRC for troubleshooting purposes"}}}}}}}}}}}
```

**Resetting a global API key:**

If you were issued a global API key, you can reset it by sending a POST to **/v1/api-key/reset** with the "authorization" header set as your API key. This will send a new key which can only be viewed once. If you lose the key, the person who requested the API key must contact PRC.


---

# 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://policeroleplaycommunity.gitbook.io/d/for-developers/v2-api-reference.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.
