---
title: n8n Integration
description: Connect PostGrad to your n8n workflows using HTTP Request nodes.
---

import { Callout } from 'fumadocs-ui/components/callout';

<Callout type="info">
This integration works today using the REST API. No SDK required.
</Callout>

## Overview

n8n can connect to PostGrad using the built-in HTTP Request node. This lets you build workflows that search knowledge, react to new entries, and pipe business insights into other tools.

## Step 1: Store Your API Key

Before building workflows, store your PostGrad API key as an n8n credential:

1. Go to **Settings** > **Credentials** > **Add Credential**
2. Choose **Header Auth**
3. Set:
   - **Name:** `PostGrad API`
   - **Header Name:** `Authorization`
   - **Header Value:** `Bearer pg_live_YOUR_API_KEY`

## Step 2: Search Knowledge

Add an **HTTP Request** node to your workflow:

- **Method:** `GET`
- **URL:** `https://postgrad.io/api/v1/knowledge/search`
- **Authentication:** Header Auth (select your PostGrad credential)
- **Query Parameters:**
  - `q`: `{{ $json.searchQuery }}` (or a static string)
  - `limit`: `10`

The response body contains:

```json
{
  "data": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "title": "AI agent architecture uses RAG with vector embeddings",
      "category": "ai_architecture",
      "content": "The AI agent architecture uses retrieval-augmented generation...",
      "tags": ["rag", "vector-embeddings"],
      "confidence": 0.85,
      "reinforcement_count": 3
    }
  ],
  "pagination": { "total": 42, "limit": 10, "offset": 0, "has_more": true }
}
```

## Step 3: List Categories

Add an **HTTP Request** node:

- **Method:** `GET`
- **URL:** `https://postgrad.io/api/v1/knowledge/categories`
- **Authentication:** Header Auth (PostGrad credential)

No query parameters needed. Returns all categories with entry counts.

## Step 4: Get Usage Stats

Monitor your API consumption within workflows:

- **Method:** `GET`
- **URL:** `https://postgrad.io/api/v1/usage`
- **Authentication:** Header Auth (PostGrad credential)

## Example: Daily Knowledge Digest

Build a workflow that sends a daily Slack summary of new knowledge:

1. **Schedule Trigger** -- Run daily at 9:00 AM
2. **HTTP Request** -- `GET /api/v1/knowledge?limit=5&sort=created_at:desc` with PostGrad auth
3. **Code Node** -- Format entries into a Slack message:

```javascript
const entries = $input.all().map(item => item.json);
const lines = entries.map(e =>
  `*${e.title}* (${e.category}, confidence: ${e.confidence})\n${e.content.substring(0, 200)}...`
);

return [{
  json: {
    text: `*PostGrad Daily Digest*\n\n${lines.join('\n\n')}`
  }
}];
```

4. **Slack Node** -- Send message to your team channel

## Example: Knowledge-Enriched Lead Scoring

Combine PostGrad insights with CRM data:

1. **Webhook Trigger** -- Receive new lead from CRM
2. **HTTP Request** -- Search PostGrad for insights about the lead's industry:
   - `GET /api/v1/knowledge/search?q={{ $json.industry }}&categories=deal_evaluation,sales_process`
3. **Code Node** -- Score the lead based on available knowledge
4. **HTTP Request** -- Update lead score in CRM

## Tips

- Use the `limit` parameter to control response size and stay within your monthly quota
- Chain multiple HTTP Request nodes to search different categories
- Use n8n's **IF** node to branch logic based on confidence scores
- Set up error handling with the **Error Trigger** node for API failures
