This page covers FarmEngage, PTx/AGCO’s API. For the legacy Trimble Agriculture integration, see Trimble. Existing Trimble connections continue to work until PTx disables that API. New integrations should use FarmEngage.
clientId, clientSecret, and refresh tokens do not work with FarmEngage.
Leaf connects to FarmEngage using OAuth 2.0. After Leaf validates the credentials and the grower authorizes at least one organization, Leaf syncs growers, farms, and fields when fieldsAutoSync is enabled. Leaf syncs machine files and field operations when operationsAutoSync is enabled.
Prerequisites
- FarmEngage API access from PTx. Request credentials through PTx’s API request form. PTx issues an AGCO
clientIdandclientSecret. - Your application’s redirect URL registered with PTx. If you use Magic Link or Leaf Link, register
https://widget.withleaf.io. - A grower’s
refreshTokenobtained through the FarmEngage (AGCO ID) OAuth 2.0 consent flow.
Setup steps
If you use Magic Link or Leaf Link, registerPOST /app-keys/FarmEngage/{appName}, add https://widget.withleaf.io at PTx, and add "FarmEngage" to allowedProviders. Those users do not need the helper or the farm-engage-credentials POST below.
- Complete the FarmEngage OAuth 2.0 flow to obtain a
refreshTokenfor the grower’s account. Leaf’s helper endpoints are documented in the Connect FarmEngage tutorial. - POST the credentials to Leaf:
- Leaf validates the token against FarmEngage (
GET /config/organizations) and begins syncing. Check credential status withGET /users/{leafUserId}/farm-engage-credentials. - Confirm the grower authorized at least one FarmEngage organization. If they skipped that step, Leaf syncs nothing. Use
GET /users/{leafUserId}/organizations/FarmEngageand send them the returnedmanagementUri.
Credentials schema
Create request body:
There is no
subscriptionKey and no clientEnvironment. FarmEngage app keys and user credentials are production-only.
Response:
clientId, clientSecret, accessToken, and refreshToken. Leaf obtains and refreshes the access token itself — you do not send accessToken on create.
Endpoints
Base URL:https://api.withleaf.io/services/usermanagement/api
Register Leaf Link / Magic Link app keys at
POST /app-keys/FarmEngage/{appName} with { "clientId", "clientSecret" }. That path has no {clientEnvironment} segment.
Data sync behavior
Leaf polls FarmEngage on the same schedule as other non-webhook providers (at least every 24 hours). Field hierarchy sync (growers, farms, fields) runs whenfieldsAutoSync is enabled. Machine files and field operations run when operationsAutoSync is enabled. Neither flag requires the other. There is no FarmEngage webhook subscription.
Field hierarchy. FarmEngage uses Organization → Client → Farm → Field. Leaf maps Client to Grower, Farm to Farm, and Field to Field. Boundaries come from each field’s extent geometry when FarmEngage reports a positive area. Leaf keys grower records by a salted hash of the AGCO ID token sub claim, not by the FarmEngage client ID. Leaf does not copy the client display name onto the grower.
Machine files. Leaf lists task files per authorized organization, downloads each file from its time-limited temporaryAccessUri, and runs the standard conversion pipeline. Leaf creates field operations the same way as for every other provider.
organizationDataSync / SELECTED-only org filtering is John Deere only. FarmEngage syncs every organization the grower’s token can see.
How FarmEngage data appears in Leaf’s APIs
FarmEngage data flows through the same Leaf endpoints as every other provider — fields, files, and operations. Theprovider field on each object is FarmEngage:
- Fields:
"provider": "FarmEngage" - Machine files:
"provider": "FarmEngage" - Field operations:
"provider": "FarmEngage"
"provider": "Trimble".
You can filter by provider when querying:
Organizations
After the grower authorizes, list the organizations Leaf can see:- The list returns
connectedOrganizationsonly. FarmEngage does not expose a separate not-connected list the way John Deere does. managementUriis a single account-level URL. Send the grower there to grant or change which organizations your app can access.- If
connectedOrganizationsis empty, the token is valid but no organization is authorized. Sync does not produce fields or files until the grower completes that step.
Troubleshooting
Use the events endpoint to inspect credential health:- Status changes to invalid: The grower might have revoked access, or a token refresh failed after FarmEngage issued a replacement refresh token. Leaf persists tokens from scheduled and on-demand credential refresh. Confirmation also refreshes against FarmEngage and does not store that replacement. If status becomes invalid immediately after attach, have the grower re-authorize through the AGCO ID OAuth flow.
- Empty organizations / no files: The grower authenticated but did not grant your application access to any FarmEngage organizations. Send them the
managementUri. - Using Trimble helper paths or Trimble client IDs: FarmEngage uses
/farmengage/get_urland/farmengage/get_tokenon the Trimble OAuth helper host, and AGCO-issued client credentials.api.farmengage.comrejects legacy Trimble tokens. Those helper endpoints are unauthenticated: sendclientSecretonly from a backend, never from browser or Leaf Link client code, and treat the helper’s token response as secrets. - Redirect URL mismatch: The
client_redirect_url/redirect_urlyou send the helper must match the URL registered with PTx, including trailing slashes.
What to do next
- Connect FarmEngage Tutorial — Step-by-step walkthrough.
- Migrate from Trimble to FarmEngage — For customers moving off the legacy Trimble provider.
- Provider Authentication Overview — How provider credentials work across all providers.
- API Reference: Providers — Full endpoint reference for provider credentials.

