> For the complete documentation index, see [llms.txt](https://docs.sonoransoftware.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sonoransoftware.com/bot/tutorials/sonoran-cad-integration.md).

# Sonoran CAD Integration

Sync Sonoran CAD permissions with Discord roles, including individual record templates.

Map Discord roles to Sonoran CAD permissions. Members receive the combined permissions from their mapped roles across all linked Discord servers.

{% hint style="warning" %}
CAD role mapping is unavailable in CMS mode. If CMS is configured, manage CAD permissions through [CMS ranks](https://docs.sonoransoftware.com/cms/integration-capabilities/sonoran-cad-sync) instead.
{% endhint %}

## Setup

### 1. Link Your CAD Community

[Invite Sonoran Bot and link your community](/bot/tutorials/getting-started.md). If the bot is already configured, run `/settings` and select **API Menu > Change CAD Setup** to enter your CAD community ID and API key.

### 2. Generate a Permission Code in CAD

In your CAD community, open **Administration > Permission Keys** and select **Bot permissions**.

<figure><img src="https://986342217-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgJnyZgUQPWpA5p9njAAR%2Fuploads%2Fgit-blob-0ce82e0e2fd4b778c8206b25714b98a05cf19794%2Fcad-bot-permission-keys.png?alt=media" alt="CAD Permission Keys panel with the Bot permissions button"><figcaption><p>Open the bot permission builder from Permission Keys.</p></figcaption></figure>

Select the permissions this Discord role should grant:

* **Access:** Pages and operational tools, such as the Police page.
* **Records:** View, create, edit, delete, and supervisor-field permissions for each record template.
* **Administration:** Administrative permissions, if needed for the role.

<figure><img src="https://986342217-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgJnyZgUQPWpA5p9njAAR%2Fuploads%2Fgit-blob-6fc0984d1c7dff3b57e68b37bdbef11f19526497%2Fcad-bot-permission-access.png?alt=media" alt="Bot permission builder with Police page access enabled"><figcaption><p>Choose page access for the role.</p></figcaption></figure>

For example, a patrol role could have **Police page** access and **View**, **Create**, and **Edit own** for Arrest Report records. Choose your community's templates and permissions; the screenshots use sample data.

<figure><img src="https://986342217-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgJnyZgUQPWpA5p9njAAR%2Fuploads%2Fgit-blob-78d20f0462e6e79c6a19ee68d2f327ac571f05f8%2Fcad-bot-permission-records.png?alt=media" alt="Arrest Report permissions with View, Create, and Edit own enabled and the generated permission code below"><figcaption><p>Select record actions, then copy the Permission code using the copy button.</p></figcaption></figure>

**Any** includes the member's own records. **Supervisor fields** is a separate permission for fields marked supervisor-only.

For limited edits, such as license points, select **Edit selected fields on others' records** and enable **Allow limited editing** on the desired fields in CAD. Leave **Edit any** off in every mapped role for that template; full editing takes precedence. Add **Edit own** separately if needed. Supervisor-only fields still require **Supervisor fields**.

The new selection requires an updated bot, CAD permission editor, and a backend catalog containing `edit.selected`. Existing codes keep their meaning. Codes containing the new permission are rejected without changing account permissions if the backend does not yet support it.

Copy the **Permission code** at the bottom. This one-line code replaces the old external bitmap generator. The bot applies it to its configured CAD community. It is configuration for the bot, not a permission key for members to redeem.

### 3. Map the Code to a Discord Role

1. Run `/rolemap` and select **Discord → Sonoran**.
2. Select **Create Mapping**.
3. Choose **CAD** under **Type**, then choose the Discord role.
4. Select **Set Permission**, paste the complete code, and submit.
5. Select **Create Mapping** to save.

The separate **Discord → Discord** option mirrors roles between linked Discord servers and does not grant CAD permissions.

Repeat for each role. To change a mapping, select **Edit Mapping**, choose the mapping, use **Edit Permission** to paste a new code, then select **Save Mapping**. Use **Delete Mapping** to remove it.

### 4. Sync Members

Members must link their Discord and Sonoran Software accounts using `/linkme`.

Sonoran Bot updates CAD permissions when members' Discord roles change, they leave a linked server, or they are banned from it. Members can run `/sync` to sync immediately. Administrators can run `/sync community: yes` to sync the community.

{% hint style="warning" %}
Sync replaces each member's CAD permissions with the combined permissions from their mapped roles. Manual grants and redeemed permission-key grants are overwritten unless a mapped role also grants them. A member with no mapped roles has no synced permissions. The community owner is excluded from synchronization.
{% endhint %}

## Existing Mappings and Template Changes

* **Existing numeric mappings keep working.** Replace them with a generated code when you want permissions for individual templates.
* **New templates need to be selected.** A generated code grants only the templates you selected. Generate and save an updated code to add another template. Existing numeric mappings retain their legacy category behavior.
* **Deleted templates:** If a mapped template is deleted, regenerate the affected code and update its mapping.
* **Large permission selections:** Codes are limited to 1,000 characters. If the builder reports that your selection is too large, split the permissions across additional Discord roles and map each separately.

Only grant the access each role needs, especially administrative and delete permissions.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.sonoransoftware.com/bot/tutorials/sonoran-cad-integration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
