Skip to content

Commit 90d6848

Browse files
authored
Update collections docs for latest cli (#730)
* update collections docs for latest cli * tidy up older cli docs * updates
1 parent c340ce6 commit 90d6848

File tree

1 file changed

+63
-18
lines changed

1 file changed

+63
-18
lines changed

adaptors/collections.md

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ It is designed for high performance over a large volume of data.
1010

1111
Collections are secure, private datastores which are only accessible to
1212
Workflows within a particular OpenFn Project. They can be created, managed and
13-
destroyed from the OpenFn Admin page.
13+
destroyed from the OpenFn Settings page.
1414

1515
The Collections Adaptor provides an interface to workflows to use the
1616
Collections API.
@@ -278,28 +278,69 @@ fn(state => {
278278
279279
## CLI usage
280280
281-
Workflows which use Collections can be run through the CLI. You will need to:
281+
Since version 1.21.0 (Jan 2026), `@openfn/cli` fully supports the use of
282+
collections in workflows.
282283
283-
- Get a Personal Access Token (PAT)
284-
- Update the `workflow.json` with your PAT and the OpenFn endpoint
285-
- Set the step to use the Collections adaptor
284+
Prior to 1.21.0, special setup was needed. So this guide is split into two
285+
sections: we recommend using the latest CLI and following first guide below.
286+
It's shorter, cleaner and easier.
287+
288+
But if you're unable to update your CLI, you can still configure collections
289+
manually with the [Older CLI guide](#older-cli).
290+
291+
Remember that a Collection must be created from the Settings page before it can
292+
be used!
293+
294+
:::tip
295+
296+
You can also call the Collections API directly from the CLI, without using a
297+
Workflow. See the [CLI Collections Guide](/documentation/collections-cli)
298+
299+
:::
300+
301+
### Latest CLI 1.20+
302+
303+
The CLI includes full native support for collections within a workflow.
304+
305+
If you've pulled a project from the app (Lightning), all you'll need to do is
306+
provide an API Token when you run the workflow. You can either do this by
307+
passing the `--api-key` argument, or by setting the `OPENFN_API_KEY` env var.
308+
309+
```bash
310+
openfn my-workflow.json --api-key $MY_OPENFN_PAT
311+
```
312+
313+
By default, the CLI will use our cloud platform at app.openfn.org to find any
314+
collections referenced in the workflow. To use a different deployment server,
315+
you can pass `--endpoint` or set the `OPENFN_ENDPOINT` env var. Note that this
316+
should point to the server root - so `http://app.openfn.org`, not
317+
`http://app.openfn.org/collections`.
286318

287319
:::tip
288320

289-
You can also call the Collections API directly from the CLI. See the
290-
[CLI Collections Guide](/documentation/collections-cli)
321+
Since v1.19.0 The CLI fully supports `.env` files. If you run multiple projects
322+
locally, you may want to create a `.env` file in your project root and configure
323+
your endpoint and API token in there:
324+
325+
```
326+
OPENFN_API_KEY="eyJhbGc..."
327+
OPENFN_ENDPOINT="https://app.openfn.org"
328+
```
329+
330+
The `.env` file will be automatically loaded by the CLI. Check debug output for
331+
details.
291332

292333
:::
293334

294-
Collections are designed for close integration with the platform app, but can be
295-
used from the CLI too.
335+
### Older CLI
296336

297-
You can get a Personal Access Token from any v2 deployment.
337+
The rest of this guide only applies when using older CLI versions, prior to
338+
1.21.0.
298339

299-
Remember that a Collection must be created from the Admin page before it can be
300-
used!
340+
Remember that a Collection must be created from the Settings page before it can
341+
be used!
301342

302-
### For a single job
343+
#### For a single job
303344

304345
You can pass multiple adaptors from the CLI:
305346

@@ -318,7 +359,7 @@ You'll need to set configuration on the state.json:
318359
}
319360
```
320361
321-
### For a workflow
362+
#### For a workflow
322363
323364
If you're using `workflow.json`, set the token and endpoint on
324365
`workflow.credentials`:
@@ -327,7 +368,7 @@ If you're using `workflow.json`, set the token and endpoint on
327368
{
328369
"workflow": {
329370
"steps": [ ... ],
330-
"credentials": {
371+
"configuration": {
331372
"collections_endpoint": "http://localhost:4000/collections",
332373
"collections_token": "...paste your Personal Access Token..."
333374
}
@@ -350,8 +391,12 @@ And make sure that any steps which use collections have multiple adaptors set:
350391
}
351392
```
352393

353-
### I've noticed a problem with this Adaptor, or something is out of date, what can I do?
394+
## Contributing
354395

355-
Thanks for asking! We are a fully Open Source Digital Public Good, and we welcome contributions from our community. Check out our [Adaptors Wiki](https://github.com/OpenFn/adaptors/blob/main/wiki/index.md) for more information on how you can update Adaptors!
396+
We are a fully Open Source Digital Public Good, and we welcome contributions
397+
from our community. Check out our
398+
[Adaptors Wiki](https://github.com/OpenFn/adaptors/blob/main/wiki/index.md) for
399+
more information on how you can update Adaptors!
356400

357-
Or, you can always reach out to the Community through our [Community Forum here](https://community.openfn.org/).
401+
Or, you can always reach out to the Community through our
402+
[Community Forum here](https://community.openfn.org/).

0 commit comments

Comments
 (0)