Skip to main content
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.
PTx Trimble (AGCO) exposes two API platforms. Leaf supports both as separate providers: Trimble and FarmEngage (this page). FarmEngage authenticates with AGCO ID, not Trimble Identity. Existing Trimble 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

  1. FarmEngage API access from PTx. Request credentials through PTx’s API request form. PTx issues an AGCO clientId and clientSecret.
  2. Your application’s redirect URL registered with PTx. If you use Magic Link or Leaf Link, register https://widget.withleaf.io.
  3. A grower’s refreshToken obtained through the FarmEngage (AGCO ID) OAuth 2.0 consent flow.
Legacy Trimble Agriculture credentials cannot be reused. The grower must re-authorize with AGCO ID, and you must attach a new farm-engage-credentials object. See Migrate from Trimble to FarmEngage.

Setup steps

If you use Magic Link or Leaf Link, register POST /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.
  1. Complete the FarmEngage OAuth 2.0 flow to obtain a refreshToken for the grower’s account. Leaf’s helper endpoints are documented in the Connect FarmEngage tutorial.
  2. POST the credentials to Leaf:
  1. Leaf validates the token against FarmEngage (GET /config/organizations) and begins syncing. Check credential status with GET /users/{leafUserId}/farm-engage-credentials.
  2. Confirm the grower authorized at least one FarmEngage organization. If they skipped that step, Leaf syncs nothing. Use GET /users/{leafUserId}/organizations/FarmEngage and send them the returned managementUri.

Credentials schema

Create request body: There is no subscriptionKey and no clientEnvironment. FarmEngage app keys and user credentials are production-only. Response:
POST create and GET responses both obfuscate 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 when fieldsAutoSync 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. The provider field on each object is FarmEngage:
  • Fields: "provider": "FarmEngage"
  • Machine files: "provider": "FarmEngage"
  • Field operations: "provider": "FarmEngage"
Legacy Trimble data continues to show "provider": "Trimble". You can filter by provider when querying:
Output format (GeoJSON/GeoParquet) and per-provider field-operation merge behavior match other providers. FarmEngage organization, grower, farm, and field IDs are new UUIDs that must not be joined to stored Trimble IDs. Grower records have no FarmEngage client display name. A parallel Trimble credential creates a second Leaf field, file, and operations graph.
If a Leaf user has both trimble-credentials and farm-engage-credentials attached, the same physical field might appear twice — once with "provider": "Trimble" and once with "provider": "FarmEngage". Remove the legacy credential after confirming the FarmEngage connection to avoid duplicates.

Organizations

After the grower authorizes, list the organizations Leaf can see:
Example response:
FarmEngage organization IDs are UUIDs. They do not match legacy Trimble organization IDs.
  • The list returns connectedOrganizations only. FarmEngage does not expose a separate not-connected list the way John Deere does.
  • managementUri is a single account-level URL. Send the grower there to grant or change which organizations your app can access.
  • If connectedOrganizations is 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:
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:
  • 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_url and /farmengage/get_token on the Trimble OAuth helper host, and AGCO-issued client credentials. api.farmengage.com rejects legacy Trimble tokens. Those helper endpoints are unauthenticated: send clientSecret only 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_url you send the helper must match the URL registered with PTx, including trailing slashes.

What to do next

Last modified on November 5, 2026