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

# n8n Integration

> Build n8n workflows that call Sellfern public V1 APIs with scoped API keys.

Use n8n to automate Sellfern workflows from scheduled jobs, webhooks, and HTTP Request nodes. This page keeps the setup V1-safe: use scoped API keys, confirm endpoints in the API Reference, and avoid assumptions from older workflow examples.

## Prerequisites

* An n8n instance, either self-hosted or n8n Cloud
* A Sellfern API key with the minimum scope required for the workflow
* Any destination credentials your workflow needs, such as a team messaging webhook

## Create a Sellfern credential

In n8n, create a Header Auth credential for Sellfern.

* **Header name:** `x-api-key`
* **Header value:** your Sellfern API key stored in n8n credentials

Use this credential only from server-side n8n workflows. Do not paste API keys into prompts, logs, exported public workflow files, or browser code.

## Add an HTTP Request node

Configure an HTTP Request node to call an endpoint from the V1 API Reference.

* **Method:** choose the method shown in `/api-reference`
* **URL:** combine `https://api.sellfern.com` with the documented public path
* **Authentication:** Header Auth credential using `x-api-key`
* **Query/body:** match the request parameters and schema shown in the API Reference

If a live template or older example mentions an endpoint that is not present in `/api-reference`, do not use it for a public integration. Ask the user to confirm endpoint availability in the API Reference first.

## Writes and retries

For public write endpoints, add an `Idempotency-Key` header. Reuse the same value when retrying the same logical mutation after a timeout or uncertain server error.

Generate a new idempotency key for a different mutation.

## Handling common errors

| Response                   | What to do                                                                                                        |
| -------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| `401 unauthorized`         | Confirm the workflow is sending the Sellfern API key with the `x-api-key` header.                                 |
| `403 missing_scope`        | Ask the user for an API key with the minimum additional scope required by the node.                               |
| `404 not_found`            | Do not infer cross-organization access. Confirm the resource belongs to the organization attached to the API key. |
| `422 idempotency_conflict` | Generate a new idempotency key only if this is a different logical mutation.                                      |
| `429 rate_limited`         | Back off and retry later according to the workflow's retry policy.                                                |

## Recommended workflow pattern

1. Start with the Sellfern documentation index at `https://docs.sellfern.com/llms.txt`.
2. Read the relevant developer guide for authentication, scopes, errors, and idempotency.
3. Confirm the endpoint in `/api-reference`.
4. Build the n8n HTTP Request node with the scoped `x-api-key` credential.
5. Test the workflow manually before activating the schedule or trigger.
