> ## 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.

# Lindsay

> Connect to Lindsay FieldNET to pull irrigation activity data through Leaf's provider credentials API.

Leaf connects to Lindsay FieldNET using OAuth 2.0 credentials. Once connected, Leaf syncs irrigation activity data for the Leaf user.

## Prerequisites

1. A Lindsay developer account with API access.
2. Your application's `clientId` and `clientSecret` from Lindsay.
3. A grower's `refreshToken` obtained through the Lindsay OAuth 2.0 consent flow.
4. The `clientEnvironment` for your integration: `STAGE` or `PRODUCTION`.

## Credentials schema

| Field               | Type   | Required | Description                             |
| ------------------- | ------ | -------- | --------------------------------------- |
| `clientId`          | string | Yes      | Your Lindsay application client ID.     |
| `clientSecret`      | string | Yes      | Your Lindsay application client secret. |
| `refreshToken`      | string | Yes      | The grower's OAuth refresh token.       |
| `clientEnvironment` | string | Yes      | `STAGE` or `PRODUCTION`.                |

## Endpoints

| Method | Path                                             | Description                                |
| ------ | ------------------------------------------------ | ------------------------------------------ |
| GET    | `/users/{leafUserId}/lindsay-credentials`        | Get stored credentials.                    |
| POST   | `/users/{leafUserId}/lindsay-credentials`        | Create credentials.                        |
| DELETE | `/users/{leafUserId}/lindsay-credentials`        | Delete credentials.                        |
| GET    | `/users/{leafUserId}/lindsay-credentials/events` | Get credential events for troubleshooting. |

Base URL: `https://api.withleaf.io/services/usermanagement/api`

### Create credentials

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Content-Type: application/json' \
    -d '{
      "clientId": "your-client-id",
      "clientSecret": "your-client-secret",
      "refreshToken": "grower-refresh-token",
      "clientEnvironment": "PRODUCTION"
    }' \
    'https://api.withleaf.io/services/usermanagement/api/users/{leafUserId}/lindsay-credentials'
  ```

  ```python Python theme={null}
  import requests

  TOKEN = "YOUR_TOKEN"
  endpoint = "https://api.withleaf.io/services/usermanagement/api/users/{leafUserId}/lindsay-credentials"
  headers = {"Authorization": f"Bearer {TOKEN}"}

  payload = {
      "clientId": "your-client-id",
      "clientSecret": "your-client-secret",
      "refreshToken": "grower-refresh-token",
      "clientEnvironment": "PRODUCTION",
  }

  response = requests.post(endpoint, headers=headers, json=payload)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const axios = require("axios");

  const TOKEN = "YOUR_TOKEN";
  const endpoint = "https://api.withleaf.io/services/usermanagement/api/users/{leafUserId}/lindsay-credentials";
  const headers = { Authorization: `Bearer ${TOKEN}` };

  const payload = {
    clientId: "your-client-id",
    clientSecret: "your-client-secret",
    refreshToken: "grower-refresh-token",
    clientEnvironment: "PRODUCTION",
  };

  axios.post(endpoint, payload, { headers })
    .then((res) => console.log(res.data))
    .catch(console.error);
  ```
</CodeGroup>

### Response

```json theme={null}
{
  "id": "uuid",
  "status": "str",
  "createdTime": "2026-01-15T12:00:00.000000Z",
  "tokenMetadata": { "scopes": ["str"] },
  "clientId": "your-client-id",
  "clientSecret": "your-client-secret",
  "clientEnvironment": "PRODUCTION",
  "accessToken": "str",
  "refreshToken": "grower-refresh-token"
}
```

## Troubleshooting

Use the events endpoint to check credential health. Events are retained for 30 days and are deleted when the credential is removed.

```
GET /users/{leafUserId}/lindsay-credentials/events
```

## What to do next

* [Irrigation Overview](/irrigation/overview) for details on Lindsay and Valley irrigation data.
* [API Reference: Providers](/api-reference/providers) for the full credential path matrix.
