Leaf connects to AgLeader using OAuth 2.0 with public/private key pairs. Once connected, Leaf syncs machine files and field operations for the Leaf user.Documentation Index
Fetch the complete documentation index at: https://docs.withleaf.io/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- An AgLeader developer account. Create an account.
- Your application’s
publicKeyandprivateKeyfrom AgLeader. - A grower’s
refreshTokenobtained through the AgLeader OAuth consent flow.
Setup steps
- Complete the AgLeader OAuth flow to obtain a
refreshTokenfor the grower’s account. - POST the credentials to Leaf:
- Leaf validates the token and begins syncing. Check credential status with
GET /users/{leafUserId}/ag-leader-credentials.
Credentials schema
Create request body:| Field | Type | Required | Description |
|---|---|---|---|
refreshToken | string | Yes | The grower’s refresh token |
publicKey | string | Yes | Your application’s public key from AgLeader |
privateKey | string | Yes | Your application’s private key from AgLeader |
Endpoints
Base URL:https://api.withleaf.io/services/usermanagement/api
| Action | Method | Path |
|---|---|---|
| Get credentials | GET | /users/{leafUserId}/ag-leader-credentials |
| Create credentials | POST | /users/{leafUserId}/ag-leader-credentials |
| Delete credentials | DELETE | /users/{leafUserId}/ag-leader-credentials |
| Get credential events | GET | /users/{leafUserId}/ag-leader-credentials/events |
Troubleshooting
Use the events endpoint to inspect credential health:- Status changes to invalid: The grower may have revoked access or tokens expired. Have the grower re-authorize through the AgLeader OAuth flow.
- Key mismatch: Verify that the
publicKeyandprivateKeyare from the same AgLeader application registration.
What to do next
- Connect AgLeader Tutorial — Step-by-step walkthrough.
- Provider Authentication Overview — How provider credentials work across all providers.
- API Reference: Providers — Full endpoint reference for provider credentials.

