Introduction to Refonte.AI API
Data Engine Core Resources
Data Engine Tasks Types
On your tasks, you can optionally supply a `callback_url`, a fully qualified URL, which we will POST when the task is finished, with the results. The JSON body (`application/json`) containing the data will be served. Alternatively, you have the option to specify a default callback URL in your profile, which will be utilized for tasks without one.
Additionally, you can include an email address as the `callback_url` in order to offer support for email automation pipelines and streamline testing. In this scenario, an email from `hello@refonte.ai` with the task's JSON payload as the body will be sent once each job is finished.
A 2xx status code should be included in your POST request response. Over the course of the following 24 hours, we will try up to 20 more times if we do not receive a 2xx status code.
The task will have a `true` value for the `callback_succeeded` argument if we receive a 2xx status code. In the event that we do not obtain a 2xx status code upon any subsequent attempt, the task's `callback_succeeded` parameter will be assigned a `false` value.
Example callback body
{
"task": {
"task_id": "576c41bf13e36b0600b02b34",
"completed_at": "2016-06-23T21:54:44.904Z",
"response": {
"category": "red"
},
"created_at": "2016-06-23T20:08:31.573Z",
"callback_url": "http://www.example.com/callback",
"type": "categorization",
"status": "completed",
"instruction": "Is this object red or blue?",
"params": {
"attachment_type": "text",
"attachment": "tomato",
"categories": [
"red",
"blue"
]
},
"metadata": {}
},
"response": {
"category": "red"
},
"task_id": "576c41bf13e36b0600b02b34"
}
If you're just testing and want to try a few requests, the easiest way to get started is to use a RequestBin and send requests using the provided URL as the `callback_url`. You can also use ngrok to expose a local server to the internet for fast prototyping.
We've also found Pipedream to be an easy-to-use platform to receive webhooks, view logs, take other actions.
If you'd like to authenticate our callbacks, we set a `refonte-ai--callback-auth` HTTP header on each of our callbacks. The value will be equal to your `Live Callback` `Auth Key` shown on your dashboard. If this header is not set, or it is set incorrectly, the callback is not from Refonte.AI.
Callbacks are sent for the following events:
Property | Type | Description |
---|---|---|
task_id | string | The `task_id` is the unique identifier for the task. It is identical to `task.task_id` |
status | string | The status of the task when it was completed. Normally `completed`, but can also be `error` in the case that a task failed to process. It is identical to `task.status` |
response | object | The response object of the completed request. It is identical to `task.response` |
task | object | The full `Task Object` for reference and convenience. |
When a job is finished or there is an issue, this endpoint resends the callback to the `callback_url`. This endpoint instructs Refonte.AI to resend the callback's original data (above) to your server in the event that it went down or if it somehow missed receiving a job.
Request
INSTALLATION
$ python -m pip install requests
---
import requests
url = "https://api.refonte.com/v1/task/taskId/send-callback"
headers = {"accept": "application/json"}
response = requests.post(url, headers=headers)
print(response.text)
Updated about 2 months ago