Leaf connects to Stara using an API key combined with OAuth tokens. Once connected, Leaf syncs fields, machine files, and field operations. Stara’s FMIS structure exposes fields only (no separate grower or farm hierarchy).
Prerequisites
- A Stara developer/partner account with API access.
- Your
apiKey from Stara.
- The grower’s
accessToken, accessTokenClient, and refreshToken from the Stara authentication flow.
Setup steps
POST the credentials to Leaf:
curl -X POST \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"apiKey": "your-api-key",
"accessToken": "grower-access-token",
"accessTokenClient": "grower-access-token-client",
"refreshToken": "grower-refresh-token"
}' \
'https://api.withleaf.io/services/usermanagement/api/users/{leafUserId}/stara-credentials'
Credentials schema
Create request body:
| Field | Type | Required | Description |
|---|
apiKey | string | Yes | Your Stara API key |
accessToken | string | Yes | The grower’s access token |
accessTokenClient | string | Yes | The grower’s client access token |
refreshToken | string | Yes | The grower’s refresh token |
Response:
{
"id": "uuid",
"status": "str",
"createdTime": "yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'",
"accessTokenClient": "str",
"refreshToken": "str",
"accessToken": "str",
"apiKey": "str"
}
Endpoints
Base URL: https://api.withleaf.io/services/usermanagement/api
| Action | Method | Path |
|---|
| Get credentials | GET | /users/{leafUserId}/stara-credentials |
| Create credentials | POST | /users/{leafUserId}/stara-credentials |
| Delete credentials | DELETE | /users/{leafUserId}/stara-credentials |
| Get credential events | GET | /users/{leafUserId}/stara-credentials/events |
Troubleshooting
Use the events endpoint to inspect credential health:
curl -X GET \
-H 'Authorization: Bearer YOUR_TOKEN' \
'https://api.withleaf.io/services/usermanagement/api/users/{leafUserId}/stara-credentials/events'
Event logs are retained for 30 days. Once the credential is deleted or disassociated from the Leaf user, the logs are no longer available.
Common issues:
- No grower/farm hierarchy: Stara only exposes fields. If you expect grower or farm-level data, it won’t be available from this provider.
- Status changes to invalid: Tokens may have expired. Re-authenticate the grower through Stara.
What to do next