API integration
Make your automations available from the internet and learn how to secure access to it
This documentation article provides information on how to integrate your application with Visiomera’s API, including code snippets and examples in the most common programming languages. Additionally, it explains how to authenticate requests to the API.
Endpoints
Each automation with enabled API access has it’s own user defined endpoint that accepts POST requests. It looks something like:
https://api.visiomera.com/{your_endpoint}
Request format
You can send any parameters in the request body. These parameters will be used to initialize context variables of corresponding names. You can then embed these variables into ChatGPT prompts. For example, if you have a following prompt in your automation.
Draft a response to the following support ticket by user {{user_name}}:
{{ticket_body}}
Your request body will look something like:
{
"user_name": "Andrew Buck",
"ticket_body": "I forgot my login credentials, what should I do?"
}
You can read more about dynamic parameters in prompts here.
Response format
If the requests succeeds, the response body contains values of all return variables and usage details. The response can look like this:
{
"success": true,
"data": {
"response": "If you forgot your credentials, please restore it using your email address"
},
"usage": {
"total_usage": 1,
"prompt_length": 73
}
}
Authentication
To ensure that only you and your trusted partners can access the API, all requests are authorized using an API key. To generate one, go to the API keys page. Keep in mind, that you have to save the generated API key, it will not be shown to you again for security reasons. You can generate, enable and disable multiple API keys to get better control over who can access your automations.
Each request has to be send with the Authorization request header containing the Bearer keyword and your API key, for example:
Authorization: Bearer abcdef12345
Usage limits
API calls count into your usage limit. Each request consumes one credit regardless whether it succeeds or fails. Additional credits are used by prompts to ChatGPT depending on their number and context length, you can see details on our Billing overview page.
Example
The following code snippet shows you how to send a POST request to the API in different programming languages
const https = require('https'); const options = { hostname: 'api.visiomera.com', path: '/{your_endpoint}', method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${your_api_key}` } }; const data = { user_name: 'Andrew Buck',
ticket_body: 'I forgot my login credentials, what should I do?'
}; const req = https.request(options, res => { console.log(`statusCode: ${res.statusCode}`); res.on('data', d => { process.stdout.write(d); }); }); req.on('error', error => { console.error(error); }); req.write(JSON.stringify(data)); req.end();
import requests import json url = "https://api.visiomera.com/{your_endpoint}" headers = { "Content-Type": "application/json", "Authorization": f"Bearer {your_api_key}" } data = { "user_name": "Andrew Buck", "ticket_body": "I forgot my login credentials, what should I do?", }
response = requests.post(url, headers=headers, data=json.dumps(data))