🤖 Execute invoice generation workflow
Introduction​
This API allows users to send information via a POST request, and n8n will automatically generate an invoice based on that information. The API processes the content and returns an analysis based on the provided model.
Execute an invoice generation​
Endpoint​
Use the following endpoint to submit the content for invoice generation:
POST https://n8n.japanyosan.com/execute/generate-invoice
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 information used to generate the invoice.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/generate-invoice' \
--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/generate-invoice', {
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/generate-invoice"
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/generate-invoice";
$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/generate-invoice' \
--header 'X-N8N-API-KEY: ey*********' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-4o-mini",
"content": "...",
"prompt": "..."
}'
fetch('https://n8n.japanyosan.com/execute/generate-invoice', {
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/generate-invoice"
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/generate-invoice";
$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 generation, which provides the generated invoice based on the provided information.execution_id(integer): A unique identifier for the specific execution of the invoice generation workflow.
{
"response": ".....",
"execution_id": 778
}