- Organization API keys for server automation owned by one church. This is the fastest way to test the production API.
- OAuth 2.1 (Sign in with Grain) for applications that act on behalf of individual users, especially apps serving multiple organizations.
REST API and MCP access require an active Enterprise plan for the organization you are accessing.
Organization API keys
An Owner, Admin, or custom role with Manage API access can create a key in Settings → API. Give the key a descriptive name, choose the smallest required scope set, and select an expiry. The secret is displayed only once. Production organizations receive keys beginning withgrain_live_. Sandbox, demo, and test organizations receive grain_test_ keys.
X-Organization-Id is optional. If you include the header, it must match the key’s organization. API keys work only under /api/v1; they cannot sign in to the Grain app, call tRPC or MCP, or authenticate directly with the identity provider.
API key scopes
Write access includes the corresponding read access. Donor and household scopes can expose personal information. Contribution and pledge responses include donor IDs but never embed donor identity; use a donor read scope to retrieve the related donor separately.
Rotation and revocation
Rotating a key displays a new secret once. The previous secret remains valid for up to 24 hours, or until its original expiry if sooner, so you can update automation without downtime. You can revoke the previous secret immediately after deployment. Full revocation permanently disables both secrets; the named key stays visible for audit history.OAuth 2.1 flow
1
Redirect to authorize
Send the user to
https://pqnoojlycpbwbatbdgep.supabase.co/auth/v1/oauth/authorize with your client ID, redirect URI, scopes, and PKCE parameters (code_challenge and code_challenge_method=S256).2
User consents
The user signs in (if needed) and approves access at
https://app.grainledger.com/oauth/consent.3
Receive authorization code
Grain redirects back to your
redirect_uri with an authorization code and state parameter.4
Exchange for tokens
POST the code to
https://pqnoojlycpbwbatbdgep.supabase.co/auth/v1/oauth/token with your code_verifier to receive access and refresh tokens.5
Call the API
Include
Authorization: Bearer <access_token> and X-Organization-Id on every API request.OAuth endpoints
MCP (AI agents)
Grain exposes a read-only MCP server athttps://api.grainledger.com/mcp for ChatGPT and other MCP clients. MCP uses the same OAuth identity and organization permissions; org scoping is via organizationId in tool arguments instead of X-Organization-Id. See MCP.
MCP is read-only because it exposes only read tools. OAuth tokens still identify the signed-in user, and Grain checks organization permissions on each tool call.
Authorization request example
Token exchange
X-Organization-Id header with OAuth
Every OAuth API request must include the organization (church) whose data you are accessing:OAuth scopes
Standard OIDC scopes control user profile data in tokens:
API access is granted per user session. Permissions (for example view transactions, manage donors) are enforced based on the user’s role in the specified organization.