Skip to content
Getting started

CLI quickstart

Get started with the Lightfield API using the CLI.

This guide walks you through making your first request to the Lightfield API using the Lightfield CLI.

Terminal window
brew install Lightfld/lightfield/lightfield

Requires Go 1.22+.

Terminal window
go install github.com/Lightfld/lightfield-cli/cmd/lightfield@latest

Verify the installation:

Terminal window
lightfield --version

An API key can be created in Lightfield settings (admin only).

When creating the key, select the scopes your integration needs.

For the test call just below, you’ll need accounts:read.

Set the key as an environment variable so the CLI can use it:

Terminal window
export LIGHTFIELD_API_KEY="sk_lf_..."

The CLI follows a lightfield [resource] [command] [flags] structure.

List one account to verify your key and scope:

Terminal window
lightfield account list --api-key "$LIGHTFIELD_API_KEY" --limit 1

A successful response looks like:

{
"data": [
{
"id": "id",
"createdAt": "createdAt",
"fields": {
"foo": {
"value": "string",
"valueType": "valueType"
}
},
"httpLink": "httpLink",
"relationships": {
"foo": {
"cardinality": "cardinality",
"objectType": "objectType",
"values": [
"string"
]
}
}
}
],
"object": "object",
"totalCount": 1
}

With --limit 1, you get at most one account back. To fetch more results, use --limit and --offset. See List methods for pagination.

You can also create records directly from the command line:

Terminal window
lightfield account create \
--api-key "$LIGHTFIELD_API_KEY" \
--fields '{"$name": "Acme Corp", "$website": ["https://acme.com"]}'

Use --debug to see the full HTTP request and response, and --format json for machine-readable output:

Terminal window
lightfield account list --api-key "$LIGHTFIELD_API_KEY" --limit 1 --debug --format json

If you get 401 Unauthorized, check that LIGHTFIELD_API_KEY is set correctly. If you get 403 Forbidden, your key may not have the required scope (e.g. accounts:read for listing accounts). For more on error responses and how to handle them, see Errors.

FlagDescription
--api-keyAPI key (overrides LIGHTFIELD_API_KEY)
--base-urlCustom API base URL
--formatOutput format: auto, json, jsonl, pretty, raw, yaml
--debugEnable debug logging with full HTTP details
--helpShow help for any command
  • Objects in Lightfield — Overview of object types (accounts, contacts, opportunities, and more) and how they relate.
  • CLI API Reference — Full API reference with CLI code examples.
  • Rate limits — Request limits and how to handle 429 responses.
  • Idempotency — Safe retries for create and update operations.