Authentication

Create Leenops API keys and understand REST scopes and MCP permissions.

Third-party REST and MCP integrations authenticate with a workspace API key:

Authorization: Bearer wks_your_api_key

The first-party /api/v1 routes also accept a verified Leenops session JWT. Use an API key for external integrations.

Create an API key

  1. Open Settings > AI > External Connections > API Keys.
  2. Select API Keys.
  3. Click Create API Key.
  4. Name the key and choose the smallest useful access preset or scope set.
  5. Optionally set an expiry date.
  6. Copy the key immediately. It is shown only once.

The canonical settings URL is:

https://workspace.leenops.com/settings/ai?tab=connections

Standard keys currently start with wks_.

REST example

curl "https://workspace.leenops.com/api/v1/crm/contacts?page=1&limit=10" \
  -H "Authorization: Bearer $LEENOPS_API_KEY" \
  -H "Accept: application/json"

REST scope catalog

Write scopes also satisfy their matching read scope.

ModuleRead scopeWrite scope
Support ticketstickets.readtickets.write
CRM shared resourcescrm.readcrm.write
CRM contactscontacts.readcontacts.write
CRM dealsdeals.readdeals.write
Projectsprojects.readprojects.write
Issues/tasksissues.readissues.write
Planningplanning.readplanning.write
Assetsassets.readassets.write
Bookingsbookings.readbookings.write
Field servicefsm.readfsm.write
Goalsgoals.readgoals.write
Marketingmarketing.readmarketing.write
Procurementprocurement.readprocurement.write
Stockstock.readstock.write
Subscriptionssubscriptions.readsubscriptions.write
Surveyssurveys.readsurveys.write
Timetime.readtime.write

Do not use older granular stock names such as stock.products.read or stock.movements.write; they are not valid key scopes.

REST requests require a matching read or write scope. A matching write scope also satisfies reads for that area. If a valid key receives 403, create or rotate to a key with the smallest scope listed by the endpoint guide.

MCP permissions

MCP tools use granular permissions such as read_contacts, create_contacts, update_contacts, and delete_contacts. The server derives those permissions from the key's scope preset unless the key stores an explicit permission map.

Inspect the exact effective permissions and tools for a key:

curl "https://workspace.leenops.com/api/mcp/session" \
  -H "Authorization: Bearer $LEENOPS_API_KEY"

See MCP tool discovery for the complete permission-aware tool list and schemas.

Authentication failures

StatusMeaning
401Missing, malformed, inactive, expired, or unknown key
403Valid key but the requested read, mutation, or tool needs another scope or permission
429Rate limit, monthly quota, or agent-trial tool quota reached

Workspace suspension, deletion, or lifecycle restrictions can also make an otherwise valid key unavailable.

Revoke and rotate

Revocation is immediate and irreversible. To rotate safely:

  1. Create a replacement key.
  2. Update the integration.
  3. Verify the new key with /api/mcp/session or a read-only REST request.
  4. Revoke the old key.

Use separate keys per client, set expiries for temporary tests, and never place keys in URLs, screenshots, commits, browser bundles, or shared logs.