🤖 Execute invoice analytics workflow
Introduction​
This API allows users to send an invoice via a POST request, and n8n will automatically evaluate and rate the invoice. The API processes the content and returns an analysis based on the provided model.
Execute an invoice analytics​
Endpoint​
Use the following endpoint to submit the invoice for analytic:
POST https://n8n.japanyosan.com/execute/invoice-analytics
Headers​
The API requires the following headers:
X-N8N-API-KEY- Your n8n API key for authenticationContent-Type: application/json
Request Parameters​
- The API expects the following parameters as a JSON payload:
model(string) - The AI model to use. Accepted values:- ollama
- gpt-4o
- gpt-4o-mini
- gpt-4-turbo
- gpt-3.5-turbo
- gemini-1.5-pro
- gemini-1.5-flash
- claude-3-5-sonnet-latest
- claude-3-5-haiku-latest
- claude-3-opus-latest
prompt(string) - The specific prompt to provide for the invoice evaluation.content(string) - The invoice text to be analyzed.llmKey(string) - Your API key for the selected model. Not required when using theollamamodel.
Example Request​
- Bash
- Javascript
- Python
- Php
curl --location 'https://n8n.japanyosan.com/execute/invoice-analytics' \
--header 'X-N8N-API-KEY: ey*********' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-4o-mini",
"content": "...",
"llmKey": "sk-proj-ERa23*******",
"prompt": "..."
}'
fetch('https://n8n.japanyosan.com/execute/invoice-analytics', {
method: 'POST',
headers: {
'X-N8N-API-KEY': 'ey*********',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gpt-4o-mini',
content: '...',
llmKey: 'sk-proj-ERa23*******',
prompt: '...'
})
})
.then(response => response.json())
.then(data => console.log(data));
import requests
import json
url = "https://n8n.japanyosan.com/execute/invoice-analytics"
headers = {
"X-N8N-API-KEY": "ey*********",
"Content-Type": "application/json"
}
data = {
"model": "gpt-4o-mini",
"content": "...",
"llmKey": "sk-proj-ERa23*******",
"prompt": "..."
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
<?php
$url = "https://n8n.japanyosan.com/execute/invoice-analytics";
$headers = [
"X-N8N-API-KEY: ey*********",
"Content-Type: application/json"
];
$data = [
"model" => "gpt-4o-mini",
"content" => "...",
"llmKey" => "sk-proj-ERa23*******",
"prompt" => "..."
];
$options = [
"http" => [
"header" => implode("
", $headers),
"method" => "POST",
"content" => json_encode($data)
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
echo $response;
?>
For Ollama model requests, you can omit the llmKey:
- Bash
- Javascript
- Python
- Php
curl --location 'https://n8n.japanyosan.com/execute/invoice-analytics' \
--header 'X-N8N-API-KEY: ey*********' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-4o-mini",
"content": "...",
"prompt": "..."
}'
fetch('https://n8n.japanyosan.com/execute/invoice-analytics', {
method: 'POST',
headers: {
'X-N8N-API-KEY': 'ey*********',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gpt-4o-mini',
content: '...',
prompt: '...'
})
})
.then(response => response.json())
.then(data => console.log(data));
import requests
import json
url = "https://n8n.japanyosan.com/execute/invoice-analytics"
headers = {
"X-N8N-API-KEY": "ey*********",
"Content-Type": "application/json"
}
data = {
"model": "gpt-4o-mini",
"content": "...",
"prompt": "..."
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
<?php
$url = "https://n8n.japanyosan.com/execute/invoice-analytics";
$headers = [
"X-N8N-API-KEY: ey*********",
"Content-Type: application/json"
];
$data = [
"model" => "gpt-4o-mini",
"content" => "...",
"prompt" => "..."
];
$options = [
"http" => [
"header" => implode("
", $headers),
"method" => "POST",
"content" => json_encode($data)
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
echo $response;
?>
Response​
The response body contains the following two keys:
response(string): The result of the invoice analysis, which provides the evaluation and rating of the submitted invoice.execution_id(integer): A unique identifier for the specific execution of the invoice analytics workflow.
{
"response": ".....",
"execution_id": 778
}