Create Community Link

Create a short-lived community user link code.

POST https://api.sonorancad.com/v2/general/links

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

Create a 4-character code for a communityUserId. The code is scoped to the authenticated community and expires after 10 minutes.

Request Body

{
  "communityUserId": "player_12345"
}

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:createCommunityLinkV2({
    communityUserId = 'player_12345',
  })

-- Inspect response.success, response.data, or response.reason as needed.
print(response.success)

Response

Successful requests return application/json.

Linking Account

Once a link code is created, direct the user to sonorancad.com/id?code=ENTERCODEHERE.

If the user is not logged in, they will be automatically redirected. The 4-digit code will be automatically entered into the ID page, processed, and the user's communityUserId will be linked to the community account.

Once linked, the communityUserId parameter can be used with any applicable v2 API endpoint.

To detect that link completion immediately, listen for the Community Link Verified push event or poll Check Community Link when needed.

Last updated

Was this helpful?