> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lightdrift.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up stock-image selection for newsletters and blogs in n8n

> Import a manual Lightdrift workflow, configure a private API credential, verify it offline, and review image candidates with their source and license metadata.

When each newsletter or blog brief needs an image, a useful first automation is a candidate list for an editor to review. This guide connects a manual n8n workflow to Lightdrift's image-search API. It requests up to five candidates for one brief and keeps their source and rights metadata together. The editor still decides whether an image fits and can be used.

[Download the importable workflow JSON](https://raw.githubusercontent.com/JacksonHolland/lightdrift-claude-plugin/main/examples/n8n-image-search/workflow.json). The [example directory and README](https://github.com/JacksonHolland/lightdrift-claude-plugin/tree/main/examples/n8n-image-search) contain the offline verifier and compatibility evidence.

**Verification boundary:** offline fixture checks passed. Live n8n UI import, credential binding, and authenticated execution have not been verified for this example. The workflow does not select an approved image, download media, or publish a newsletter or blog post.

## 1. Import the workflow with live requests off

You need an n8n instance with the built-in nodes and JavaScript Code nodes enabled. Check the [tested node versions and compatibility limits](https://github.com/JacksonHolland/lightdrift-claude-plugin/blob/main/examples/n8n-image-search/VALIDATION.md) against your instance.

Save the linked JSON as `workflow.json`. In the n8n workflow editor's top-right **…** menu, choose **Import from File**, select the file, and save. These are the example's documented import steps; labels and instance permissions may differ. Keep the workflow inactive. Its only trigger is manual.

Inspect these five connected nodes before execution:

| Node                          | What to check                                                                                                                                       |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Manual start**              | Begins one manual workflow execution.                                                                                                               |
| **Your search settings**      | `query` starts empty; `allowLiveRequest` starts as Boolean `false`.                                                                                 |
| **Validate one live request** | Rejects anything other than one input item, Boolean `true`, and a trimmed brief of 1–1,000 characters.                                              |
| **Search Lightdrift**         | POSTs JSON to `https://api.lightdrift.ai/v1/search`; uses Header Auth, Execute Once, a 60-second timeout, and no retries, pagination, or redirects. |
| **Review image candidates**   | Produces a review item and preserves the complete response.                                                                                         |

The default-off gate stops the normal full workflow before the search request. It is not a self-resetting flag or an account-wide spending limit. Running the HTTP node directly with previous input, editing nodes, or adding triggers changes these bounds.

## 2. Configure your private credential and brief

Create or manage your own key in [Lightdrift API keys](https://lightdrift.ai/dashboard/api-keys). In **Search Lightdrift**, use **Generic Credential Type** and **Header Auth**. Replace the labelled placeholder by selecting your credential or creating one:

* Header **Name**: `X-API-Key`.
* Header **Value**: your own Lightdrift API key, entered only in the private n8n credential.

Save the credential and select it on the node. Do not put the key in the query, Code node, HTTP body, shared workflow JSON, or execution screenshots. The exported example contains a placeholder credential reference, not a usable secret. n8n may report the missing credential before running any nodes until you bind it.

In **Your search settings**, enter a brief such as `Coastal lighthouse at sunrise with open space for a newsletter headline`. Keep Boolean `allowLiveRequest` **false**. The validation node constructs this request; no key belongs in it:

```json theme={null}
{
  "query": "Coastal lighthouse at sunrise with open space for a newsletter headline",
  "k": 5,
  "filters": { "commercial": true, "orientation": "landscape" },
  "experiment": "lig128_n8n_search_v1"
}
```

Other [API search defaults](/guides/search) still apply. Composition is a request, not a guarantee. The commercial filter uses source-declared permissions; it does not clear every intended use. Keep the example's `lig128_n8n_search_v1` experiment value. A request tag alone does not establish attribution capture or adoption.

## 3. Run the offline verifier first

With Git and Node.js available, download the example and run its checks:

```sh theme={null}
git clone https://github.com/JacksonHolland/lightdrift-claude-plugin.git
cd lightdrift-claude-plugin/examples/n8n-image-search
node verify.mjs
```

The clone downloads repository files. The verifier itself makes **no network calls or paid searches** and needs no API key or n8n server. It runs the workflow's validation and mapping code against synthetic fixtures, checking the gate, request bounds, credential placeholder, and preservation of rights and response fields. Expect `PASS` followed by an `OFFLINE ONLY` limitation.

Fixture `.invalid` URLs, unknown permissions, and fictional query IDs are test data. They are not real candidates or evidence of working authentication. Fixtures are not pinned into the importable workflow.

## 4. Optionally authorize one search using your own credit

Review your account balance and [current pricing](https://api.lightdrift.ai/v1/pricing) first. On September 26, 2026, the pricing endpoint returned **$0.005 per search ($5 per 1,000)**. Asking for five candidates does not mean five searches; account entitlements and billing rules still apply.

1. Confirm your brief and selected credential, then set Boolean `allowLiveRequest` to **true**.
2. Click **Execute workflow** once, starting the entire workflow at **Manual start**. Do not execute the HTTP node in isolation.
3. Inspect **Review image candidates**. Save `query_id` as the request receipt and check execution and usage in your own account.
4. Set `allowLiveRequest` back to **false** and save immediately, including after an error.

Leaving the flag true and executing again can consume more credit. A non-2xx response stops the workflow; no automatic retry is configured. After a timeout or interrupted connection, completion is uncertain: check account usage before choosing to repeat the request.

If credentials or access fail, use the [authentication troubleshooting guide](/guides/authentication-troubleshooting). This workflow uses REST `X-API-Key`, not an Images MCP OAuth session or the public Docs MCP connection. For balance or rate-limit failures, inspect your account and [plans and limits](/guides/plans-and-limits). Zero candidates can be a valid response and is not, by itself, an authentication failure.

## 5. Carry source and license review into the editorial step

The last node returns one item even when there are no results. It includes `query_id`, `result_count`, `candidates`, a review reminder, and the full original `response`. Each candidate carries its asset ID, title, score, source, dimensions, file and thumbnail URLs, source page, and complete `rights` object when available. Null fields remain unknown; scores are not calibrated probabilities.

Before an editor places a candidate in content:

* Open `source_page` (from `rights.provenance_url`) and check the source declaration and subject accuracy.
* Review `license`, `license_verbatim`, `commercial`, `derivatives`, `share_alike`, `attribution_required`, `attribution`, and `basis`. Unknown/null permission flags are not permission. Follow the [rights guidance](/guides/rights); source metadata is not clearance for every use involving people, logos, or artwork.
* Preserve the query ID, asset ID, source link, rights metadata, and required credit alongside the selected image in the editorial record. Carry required attribution through the eventual export or publication.

Search output is a candidate list, not an approved or licensed publication. This workflow ends at review. It has no schedule, automatic selection, downloads, or CMS writes. If you later add a download step, use it without the Lightdrift credential: documented asset URLs redirect to signed links valid for one hour. Never forward your API key to an image host or source site.

To stop, leave the gate false or remove the workflow. Remove a dedicated n8n credential only if no other workflow needs it; revoke an exposed API key in your account.

[Create an account to try one brief](https://lightdrift.ai/sign-up?utm_source=docs\&utm_medium=guide\&utm_campaign=lig151_n8n_guide_v1\&utm_content=n8n-stock-image-selection).

Guide copy version `lig151_n8n_guide_v1` (1.0.0), checked September 26, 2026 against the [public API contract](https://api.lightdrift.ai/openapi.json), [response documentation](/api-reference/introduction), and example version 1.0.0. Publication and offline verification do not demonstrate live import, useful selection, repeat use, or payment.
