Skip to main content
Leaf connects to CNHi using OAuth 2.0. CNHi covers Case IH, New Holland, and other CNH Industrial brands. Once connected, Leaf syncs growers, farms, fields, machine files, and field operations.

Prerequisites

  1. A CNHi developer account. Register here.
  2. Your application’s clientId, clientSecret, and subscriptionKey from CNHi.
  3. A grower’s refreshToken obtained through the CNHi OAuth 2.0 consent flow.

Setup steps

  1. Complete the CNHi OAuth 2.0 flow to obtain a refreshToken for the grower’s account.
  2. POST the credentials to Leaf:
curl -X POST \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Content-Type: application/json' \
    -d '{
      "clientId": "your-client-id",
      "clientSecret": "your-client-secret",
      "subscriptionKey": "your-subscription-key",
      "refreshToken": "grower-refresh-token",
      "clientEnvironment": "PRODUCTION"
    }' \
    'https://api.withleaf.io/services/usermanagement/api/users/{leafUserId}/cnhi-credentials'
  1. Leaf validates the token and begins syncing. Check credential status with GET /users/{leafUserId}/cnhi-credentials.

Credentials schema

Create request body:
FieldTypeRequiredDescription
clientIdstringYesYour application’s client ID from CNHi
clientSecretstringYesYour application’s client secret
subscriptionKeystringYesYour CNHi subscription key
refreshTokenstringYesThe grower’s OAuth refresh token
clientEnvironmentstringYesSTAGE or PRODUCTION
Response:
{
  "id": "uuid",
  "status": "str",
  "createdTime": "yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'",
  "clientId": "str",
  "clientSecret": "str",
  "refreshToken": "str",
  "clientEnvironment": "PRODUCTION",
  "subscriptionKey": "str"
}

Endpoints

Base URL: https://api.withleaf.io/services/usermanagement/api
ActionMethodPath
Get credentialsGET/users/{leafUserId}/cnhi-credentials
Create credentialsPOST/users/{leafUserId}/cnhi-credentials
Delete credentialsDELETE/users/{leafUserId}/cnhi-credentials
Get credential eventsGET/users/{leafUserId}/cnhi-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}/cnhi-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:
  • Status changes to invalid: The grower may have revoked access or the refresh token expired. Have the grower re-authorize.
  • STAGE vs. PRODUCTION mismatch: Make sure clientEnvironment matches the environment your CNHi app is registered in.
  • Missing subscription key: CNHi requires a subscriptionKey in addition to OAuth credentials. Verify you’re passing it in the request body.

What to do next

Last modified on March 19, 2026