# Rice REST API and OpenAPI

> The same CRM over HTTP, for your own agents and integrations.

## Base URL and spec

- Base URL: `https://api.ricecrm.ai/v1`
- OpenAPI 3.1: [api.ricecrm.ai/openapi.json](https://api.ricecrm.ai/openapi.json) (176 paths; it is a large file, so fetch it with a tool rather than pasting it into a prompt).
- Operations by area: Workspace admin (25), Lead routing (16), Salesforce (16), Workflows (16), Salesforce sync (13), Prospecting (12), Reports (11), Sync (10), Leads (9), Imports (8), Opportunities (8), Security (6), Activities (5), Close policy (5), Coaching (5), Custom fields (5), Merges (5), Pipelines (5), Feedback (4), Forecasting (4), History (4), Accounts (3), Contacts (3), Review (3), Tasks (3), Billing (2), Metrics (2), Support (2), Workspaces (2).

## Sign-in

- **OAuth 2.1:** authorization code with PKCE (S256). Authorization endpoint `https://auth.ricecrm.ai/oauth/authorize`, token endpoint `https://auth.ricecrm.ai/oauth/token`. Request the resource indicator of the API. Access tokens last 15 minutes and refresh tokens rotate. Scopes: `crm.read` and `crm.write`.
- **Workspace API keys** (`Authorization: Bearer rk.…`): carry `crm.read`, or `crm.read` and `crm.write`.

## Writes

- Every write needs an `Idempotency-Key` header (1 to 255 characters). Replays of the same key return the stored response.
- Updates (`PATCH`) also need an `If-Match` header with the version you read. A stale version returns a conflict.
- An optional `Rice-Source` header records where a change came from, for example `{"kind":"manual","ref":"..."}`.
- Agent writes follow each field's write rule: review fields are held for a person to approve, and locked fields are refused with `FIELD_LOCKED`.

The REST API mirrors the MCP tools. For the objects and fields, see the [data model](https://ricecrm.ai/docs/data-model).

---
Source: https://ricecrm.ai/docs/api. Index of all docs: https://ricecrm.ai/llms.txt
