What you will build
An automation that updates your documentation when a pull request is merged. The workflow watches a GitHub repository for merged PRs and then calls the agent API to update your documentation in a different repository. This workflow connects two separate repositories:- Code repository: Where you store application code. You’ll set up the GitHub webhook on this repository. Examples include a backend API, frontend app, SDK, or CLI tool.
 - Documentation repository: Where you store your documentation and connect to your Mintlify project. The agent creates pull requests with documentation updates in this repository.
 
Workflow overview
- Someone merges a pull request in the code repository.
 - n8n receives the webhook from GitHub.
 - n8n sends the pull request context to the agent API.
 - The agent creates a pull request in the documentation repository.
 
Prerequisites
- n8n workspace
 - Mintlify admin API key
 - Mintlify Pro or Custom plan
 - Admin access to the GitHub repositories for your code and documentation
 - GitHub personal access token
 
Get your admin API key
- Navigate to the API keys page in your dashboard.
 - Select Create Admin API Key.
 - Copy the key and save it securely.
 
Get your GitHub personal access token
- In GitHub, navigate to Settings.
 - Click Developer settings.
 - Click Personal access tokens.
 - Click Tokens (classic).
 - Click Generate new token (classic).
 - Select these scopes:
repo(full control of private repositories)admin:repo_hook(if you want n8n to create webhooks)
 - Generate and save the token securely.
 
Build the workflow
Create the webhook trigger
- In n8n, create a new workflow.
 - Add a webhook node.
 - Configure the webhook:
- HTTP Method: 
POST - Path: 
auto-update-documentation(or any unique path) - Authentication: None
 - Respond: Immediately
 
 - HTTP Method: 
 - Save the workflow.
 - Copy the production webhook URL. It looks like: 
https://your-n8n-instance.app.n8n.cloud/webhook/auto-update-documentation 

Set up the GitHub webhook
- Navigate to your code repository on GitHub.
 - Click Settings.
 - Click Webhooks.
 - Click Add webhook.
 - Configure the webhook:
- Payload URL: Paste your n8n webhook URL
 - Content type: 
application/json - Which events would you like to trigger this webhook?
- Select Let me select individual events.
 - Select only Pull requests.
 
 - Select Active
 
 - Click Add webhook.
 
Filter for merged pull requests
Add a code node after the webhook to filter for merged pull requests and extract the relevant information.- Add a code node.
 - Name it “Filter merged PRs.”
 - Set mode to Run Once for All Items.
 - Add this JavaScript:
 
Filter merged PRs

Call the agent API
Add an HTTP request node to create a documentation job.- Add an HTTP request node.
 - Name it “Create agent job.”
 - 
Configure the request:
- Method: 
POST - URL: 
https://api.mintlify.com/v1/agent/YOUR_PROJECT_ID/job(replaceYOUR_PROJECT_IDwith your project ID from the API keys page of your dashboard) - Authentication: Generic Credential Type → Header Auth
- Create a new credential:
- Name: 
Authorization - Value: 
Bearer mint_YOUR_API_KEY(replace with your API key) 
 - Name: 
 
 - Create a new credential:
 - Send Body: On
 - Body Content Type: JSON
 - Specify Body: Using JSON
 - Add this JSON:
 
 - Method: 
 

Activate the workflow
- Save your workflow.
 - Set it to active.
 

Test the automation
- 
Create a test branch in your code repository:
 - 
Make a small change and commit it:
 - Open a pull request on GitHub.
 - Merge the pull request.
 
Verify the automation
Check the following to confirm the workflow is working:- n8n executions: You should see a new execution with all nodes completed successfully.
 - Documentation repository: After a minute or two, check for a new branch and pull request with documentation updates.
 
Troubleshooting
Webhook not triggering
- Verify the workflow is active in n8n.
 - Check GitHub repository Settings → Webhooks → Recent Deliveries for the response code.
 - Confirm the webhook URL matches your n8n webhook URL exactly.
 
401 error from agent API
- Verify your API key starts with 
mint_. - Check the Authorization header is formatted as 
Bearer mint_yourkey. - Confirm the API key is for the correct Mintlify organization.
 
401 error from GitHub
- Verify your token has the 
reposcope. - Check that the token hasn’t expired.
 - Confirm you included the 
User-Agentheader in the GitHub request.