For the complete documentation index, see llms.txt. This page is also available as Markdown.

Get Penal Codes

Retrieve the community penal code configuration.

GET https://api.sonorancad.com/v2/general/penal-codes

Rate limit: 4 requests per minute Authenticated v2 endpoints are rate limited per API key rather than per IP address.

Return the configured penal codes for the authenticated community.

Example Request

-- luarocks install sonoran.lua
-- For SonoranCADFiveM in-game usage, see the SonoranCADFiveM tab for the export-based client.
local Sonoran = require("sonoran")

local sonoran = Sonoran.createClient({
  product = Sonoran.productEnums.CAD,
  communityId = "YOUR_COMMUNITY_ID",
  apiKey = "YOUR_API_KEY",
  defaultServerId = 1
})

local response = sonoran.cad:getPenalCodesV2()

if response.success then
  print(("Found %d penal codes"):format(#response.data))
else
  print(response.reason)
end

Use this tab when calling the v2 API from the server side of an in-game FiveM resource.

  • Sonoran.lua and Sonoran.js: use the sonorancad export to get the configured CAD client.

  • Sonoran.Net: FiveM exports do not return a .NET client, so read the Sonoran CAD convars and create a client.

  • Sonoran.py: FiveM does not run Python resources; use the Sonoran.py tab for external integrations.

The API key is stored in sonoran_apiKey as a protected FiveM convar. After add_convar_permission is configured, only explicitly permitted resources can read it. Grant access with add_convar_permission your-resource-name read sonoran_apiKey. If the API key changes in config.json, fully restart the sonorancad resource before reading the updated value.

Sonoran.lua

local cad = exports["sonorancad"]:getCadClient()
local response = cad:getPenalCodesV2()

if response.success then
  print(("Found %d penal codes"):format(#response.data))
else
  print(response.reason)
end

Sonoran.js

(async () => {
  const cad = exports["sonorancad"].getCadClient();
  const response = await cad.getPenalCodesV2();

  if (response.success) {
    console.log(response.data);
  } else {
    console.error(response.reason);
  }
})();

Sonoran.Net

Import this YAML into Postman with Import -> Raw text to create a single-endpoint request collection for this route.

Response

Successful requests return application/json.

Last updated

Was this helpful?