Build

API key scopes

Give each service a key with only the scopes it needs.

Choose scopes from what the service calls

List the operations a service calls and grant only their scopes. Starting broad and narrowing later rarely happens: extra permissions quietly become dependencies.

  • Give processing (documents.process) and document management (documents.write) separate keys when different services own them.
  • Give reporting jobs read scopes only.
  • Never share a production key with developer machines or CI fixtures.

Keep a key inventory

FieldRecordNever record
NameService and environmentThe key itself
Responsible teamWho maintains the keyPersonal passwords
ScopesWhy each one is neededUnexplained broad access
Created and rotatedDates and change referenceThe key in a ticket
UsageLast used and a request summaryRequest bodies

Storing keys at run time

  • Load keys from environment variables or a secret manager.
  • Keep modules that read keys out of client bundles and static builds.
  • Mask key-like values in logs and error reports.
  • Let only the process that calls the API read the key.

Regular review

After deployments and on a regular schedule, look for unused keys, unexpected scope use, keys nobody is responsible for any more and keys in the wrong environment. Revoke a key once you have confirmed nothing still uses it.

Scope catalog

Each row lists exactly the v2 operations that require the scope (paths are relative to https://wellfriend.dev). Grant a key only the scopes for the operations its service calls; a call without every required scope returns 403 SCOPE_FORBIDDEN with details.requiredScopes.

ScopeAllows
analytics.readGET /api/v2/documents/{documentId}/analytics; GET /api/v2/secure-links/{linkId}/analytics; GET /api/v2/rooms/{roomId}/analytics; GET /api/v2/portals/{portalId}/analytics
connectors.readGET /api/v2/connector-accounts; GET /api/v2/connector-accounts/{accountId}/items; GET /api/v2/connector-operations
connectors.writePOST /api/v2/connector-accounts/{accountId}/test; POST /api/v2/connector-accounts/{accountId}/disconnect; POST /api/v2/connector-imports; POST /api/v2/connector-sends; POST /api/v2/connector-exports; POST /api/v2/generic-http-connections
documents.processPOST /api/v2/document-operations; POST /api/v2/document-chains; POST /api/v2/document-chains/{chainId}/cancel; POST /api/v2/document-chains/{chainId}/resume
documents.readGET /api/v2/documents; GET /api/v2/documents/{documentId}; GET /api/v2/document-operations/{operationId}; GET /api/v2/document-operations/{operationId}/outputs; GET /api/v2/document-chains/{chainId}; GET /api/v2/document-chains/{chainId}/events; POST /api/v2/connector-exports; GET /api/v2/documents/{documentId}/versions; GET /api/v2/documents/{documentId}/versions/{versionId}; GET /api/v2/documents/{documentId}/versions/{versionId}/content; GET /api/v2/documents/{documentId}/versions/{versionId}/pages/{page}/render
documents.writePOST /api/v2/documents; POST /api/v2/uploads; GET /api/v2/uploads/{uploadId}; DELETE /api/v2/uploads/{uploadId}; PUT /api/v2/uploads/{uploadId}/parts/{index}; POST /api/v2/uploads/{uploadId}/complete; POST /api/v2/connector-imports
embeds.readGET /api/v2/embed-sessions/{sessionId}
embeds.writePOST /api/v2/embed-sessions; POST /api/v2/embed-sessions/{sessionId}/refresh; POST /api/v2/embed-sessions/{sessionId}/revoke
esign.readGET /api/v2/esign/levels; GET /api/v2/esign/envelopes; GET /api/v2/esign/envelopes/{envelopeId}; GET /api/v2/esign/envelopes/{envelopeId}/certificate
esign.validatePOST /api/v2/esign/validate
esign.writePOST /api/v2/esign/envelopes; POST /api/v2/esign/envelopes/{envelopeId}/cancel
keys.readGET /api/v2/keys
keys.writePOST /api/v2/keys; POST /api/v2/keys/{keyId}/revoke; POST /api/v2/keys/{keyId}/rotate
links.readGET /api/v2/secure-links; GET /api/v2/secure-links/{linkId}; POST /api/v2/connector-sends; GET /api/v2/secure-links/{linkId}/recipients; GET /api/v2/secure-links/{linkId}/sessions
links.writePOST /api/v2/secure-links; PATCH /api/v2/secure-links/{linkId}; POST /api/v2/secure-links/{linkId}/revoke; POST /api/v2/secure-links/{linkId}/version; POST /api/v2/secure-links/{linkId}/recipients; POST /api/v2/secure-links/{linkId}/password; POST /api/v2/secure-links/{linkId}/sessions/{sessionId}/revoke
logs.readGET /api/v2/logs
mcp.invokePOST /mcp
resources.readGET /api/v2/templates; GET /api/v2/templates/{resourceId}; GET /api/v2/signature-requests; GET /api/v2/signature-requests/{resourceId}; GET /api/v2/annotations; GET /api/v2/annotations/{resourceId}; GET /api/v2/forms; GET /api/v2/forms/{resourceId}; GET /api/v2/deal-rooms; GET /api/v2/deal-rooms/{resourceId}; GET /api/v2/embeds; GET /api/v2/embeds/{resourceId}
resources.writePOST /api/v2/templates; PATCH /api/v2/templates/{resourceId}; POST /api/v2/templates/{resourceId}/actions; POST /api/v2/signature-requests; PATCH /api/v2/signature-requests/{resourceId}; POST /api/v2/signature-requests/{resourceId}/actions; POST /api/v2/annotations; PATCH /api/v2/annotations/{resourceId}; POST /api/v2/annotations/{resourceId}/actions; POST /api/v2/forms; PATCH /api/v2/forms/{resourceId}; POST /api/v2/forms/{resourceId}/actions; POST /api/v2/deal-rooms; PATCH /api/v2/deal-rooms/{resourceId}; POST /api/v2/deal-rooms/{resourceId}/actions; POST /api/v2/embeds; PATCH /api/v2/embeds/{resourceId}; POST /api/v2/embeds/{resourceId}/actions
rooms.accessPOST /api/v2/rooms/{roomId}/participants; PATCH /api/v2/rooms/{roomId}/participants/{participantId}; POST /api/v2/rooms/{roomId}/permissions; DELETE /api/v2/rooms/{roomId}/permissions/{permissionId}
rooms.readGET /api/v2/rooms; GET /api/v2/rooms/{roomId}; GET /api/v2/rooms/{roomId}/contents; GET /api/v2/portals; GET /api/v2/portals/{portalId}
rooms.writePOST /api/v2/rooms; POST /api/v2/rooms/{roomId}/actions; POST /api/v2/rooms/{roomId}/folders; PATCH /api/v2/rooms/{roomId}/folders/{folderId}; POST /api/v2/rooms/{roomId}/documents; PATCH /api/v2/rooms/{roomId}/documents/{roomDocumentId}; POST /api/v2/rooms/{roomId}/requests; POST /api/v2/rooms/{roomId}/questions; POST /api/v2/rooms/{roomId}/questions/{questionId}/answers; POST /api/v2/portals; PATCH /api/v2/portals/{portalId}; POST /api/v2/portals/{portalId}/actions; POST /api/v2/portals/{portalId}/rooms; POST /api/v2/portals/{portalId}/announcements; POST /api/v2/portals/{portalId}/resources
usage.readGET /api/v2/usage
webhooks.readPOST /api/v2/webhooks/verify; GET /api/v2/webhook-endpoints; GET /api/v2/webhook-endpoints/{endpointId}; GET /api/v2/webhook-deliveries; GET /api/v2/webhook-endpoints/{endpointId}/insights; GET /api/v2/webhook-deliveries/{deliveryId}
webhooks.writePOST /api/v2/webhook-endpoints; PATCH /api/v2/webhook-endpoints/{endpointId}; DELETE /api/v2/webhook-endpoints/{endpointId}; POST /api/v2/webhook-endpoints/{endpointId}/test; POST /api/v2/webhook-deliveries/{deliveryId}/replay; POST /api/v2/webhook-endpoints/{endpointId}/rotate-secret; POST /api/v2/webhook-endpoints/{endpointId}/replay
workflows.approvePOST /api/v2/workflow-approvals/{approvalId}/decision
workflows.executePOST /api/v2/workflows/{workflowId}/runs; POST /api/v2/workflow-runs/{runId}/cancel; POST /api/v2/workflow-runs/{runId}/replay
workflows.readGET /api/v2/workflows; GET /api/v2/workflows/{workflowId}; GET /api/v2/workflow-runs/{runId}
workflows.writePOST /api/v2/workflows/validate; POST /api/v2/workflows; PATCH /api/v2/workflows/{workflowId}; POST /api/v2/workflows/{workflowId}/publish