API Endpoint
API Endpoints in Lleverage allow you to trigger workflows programmatically from your own applications. When you create a workflow with an API Call trigger, you can publish it to generate an endpoint that can be called from external systems.
Key Features
Programmable access to your Lleverage workflows
Secure authentication with Lleverage API tokens
Support for file uploads and mixed data types
Code examples in multiple programming languages
Dynamic code generation based on workflow configuration
Custom integration into your existing applications
How to Create an API Endpoint
Start by creating a workflow with an API Call trigger
Configure the required fields in the trigger settings:
For file uploads, set the field type to File
Add any additional fields (text, number, etc.)
Configure authentication requirements
Build your workflow with the desired actions
Test your workflow using the Run Panel
Click the Publish button in the top right corner
The Publish Panel will display your API endpoint URL
💡 Read more about different trigger types in the Triggers documentation page.
How to View Code Examples
Publish your workflow with an API Call trigger
In the Publish Panel, locate the Get Code button
Click the button to view code examples
Select from available programming languages:
cURL
Node.js
Python
PHP (Laravel)
Go
💡 These code examples are dynamically generated based on your workflow's field configuration.
API Code Examples
cURL
curl -X POST "https://your-workflow.lleverage.run/your-endpoint" \
-H "Authorization: Bearer {YOUR_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"field1": "value1", "field2": "value2"}'
Node.js
const response = await fetch("https://your-workflow.lleverage.run/your-endpoint", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"field1": "value1",
"field2": "value2"
})
});
if (!response.ok) {
throw new Error("Failed to fetch data");
}
const data = await response.json();
console.log(data);
Python
import requests
headers = {
"Authorization": "Bearer YOUR_TOKEN"
}
response = requests.post(
"https://your-workflow.lleverage.run/your-endpoint",
headers=headers,
json={
"field1": "value1",
"field2": "value2"
}
)
print(response.json())
PHP (Laravel)
use Illuminate\Support\Facades\Http;
$response = Http::withToken('YOUR_TOKEN')
->post("https://your-workflow.lleverage.run/your-endpoint", [
"field1" => "value1",
"field2" => "value2"
]);
$data = $response->json();
print_r($data);
Go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
data := map[string]string{
"field1": "value1",
"field2": "value2"
}
payload, _ := json.Marshal(data)
req, _ := http.NewRequest("POST",
"https://your-workflow.lleverage.run/your-endpoint",
bytes.NewBuffer(payload))
req.Header.Add("Authorization", "Bearer YOUR_TOKEN")
req.Header.Add("Content-Type", "application/json")
client := &http.Client{}
response, _ := client.Do(req)
defer response.Body.Close()
body, _ := ioutil.ReadAll(response.Body)
fmt.Println(string(body))
}
How to Send Files via API
When your workflow includes file fields, you'll need to use multipart/form-data encoding:
cURL with File Upload
curl -X POST "https://your-workflow.lleverage.run/your-endpoint" \
-H "Authorization: Bearer {YOUR_TOKEN}" \
-F "file=@/path/to/your/file.ext" \
-F "field1=value1" \
-F "field2=value2"
Node.js with File Upload
const FormData = require('form-data');
const fs = require('fs');
const form = new FormData();
form.append('file', fs.createReadStream('/path/to/file.ext'));
form.append('field1', 'value1');
form.append('field2', 'value2');
const response = await fetch("https://your-workflow.lleverage.run/your-endpoint", {
method: "POST",
headers: {
...form.getHeaders(),
"Authorization": "Bearer YOUR_TOKEN"
},
body: form
});
Python with File Upload
import requests
files = {'file': open('/path/to/file.ext', 'rb')}
data = {'field1': 'value1', 'field2': 'value2'}
headers = {'Authorization': 'Bearer YOUR_TOKEN'}
response = requests.post(
"https://your-workflow.lleverage.run/your-endpoint",
files=files,
data=data,
headers=headers
)
print(response.json())
PHP (Laravel) with File Upload
use Illuminate\Support\Facades\Http;
$response = Http::withToken('YOUR_TOKEN')
->attach(
'file', // Field name
file_get_contents('/path/to/file.ext'), // File contents
'file.ext' // Filename
)->post("https://your-workflow.lleverage.run/your-endpoint", [
"field1" => "value1",
"field2" => "value2"
]);
$data = $response->json();
How to Structure API Requests
Use the endpoint URL provided in the Publish Panel
Include your Lleverage API token in the Authorization header (if required)
Structure your request body to include all fields defined in the trigger
For file uploads, use multipart/form-data encoding
Send the request using your preferred programming language or API client
⚠️ Always include all fields specified in the trigger configuration, even if you're not using them in your workflow. Missing required fields will cause the API call to fail.
How to Test API Endpoints
Use the provided code examples as a starting point
Modify the example with your actual API endpoint and token
Run the code from your development environment
Monitor the response to ensure successful workflow triggering
Check your workflow execution in the Lleverage platform
💡 Use tools like Postman or Insomnia to test your API endpoints before implementing them in your application.
Troubleshooting Common Issues
401 Unauthorized
Verify your API token is correct and active
Ensure the Authorization header is properly formatted:
Bearer YOUR_TOKEN
400 Bad Request
Check that all required fields are included
Verify field types match your workflow configuration
For file uploads, ensure proper multipart encoding
413 Payload Too Large
Check file size limits for your Lleverage plan
Consider compressing files before upload
Empty or Unexpected Response
Ensure your workflow has proper output configuration
Check workflow logs in Lleverage for processing errors
Best Practices
Store API tokens as environment variables
Implement retry logic for transient failures
Validate file types and sizes before sending
Log API responses for debugging
Monitor workflow execution logs regularly
Use HTTPS for all API communications
Handle errors gracefully in your application
⚠️ Be mindful of rate limits based on your Lleverage plan.
Last updated