APIs
It is possible to interact with your Marvin robot using APIs to start new automations or getting back execution status and logs.
There are two different kinds of APIs you can interact with robot APIs
and user APIs
.
Robot APIs
Robot APIs are those used to interact direct with your robot, sending executions to a specific robot on your account. To use one of those APIs endpoints, it is necessary to have the robotKey
and robotSecret
, to retrieve the authentication token, used for all your requests.
Authentication Token
This endpoint is responsible to validate your robotKey
and robotSecret
, sending back an authorization token, to be used on all other API calls.
Verb: PUT
Endpoint: https://api.marvin.run/v2/robots/token
Headers:
- Content-Type: application/json
Query Parameters:
- fromDate: initial date to use as filter (timestamp format)
- toDate: final date to use as filter (timestamp format)
- scriptName: script name to filter
- robotName: robot name to filter
- execStatus: status name to filter
Payload:
Response:
{
"token": "hjbwfNytoos_aAA-FqpiVwwOl-qGh5Ed5Jo5s72DoDw", // Authorization Token
"expires": 1636202881 // Token expire date and time
}
Executing Scripts
This endpoint adds a new automation execution to your Marvin robot.
Verb: PUT
Endpoint: https://api.marvin.run/v2/scripts/execution/robot
Headers:
- Content-Type: application/json
- Authorization:
(received from Authentication Token)
Payload:
{
"robotId": "<your robotSecret>",
"script": "<name of script to be executed>",
"vars": { // Key/Value for all Marvin variable you want to set at process start
"city": "New York",
"year": "2021"
}
}
Response:
User APIs
User APIs are those used to get the same informations you see on your Marvin Console. To use these API endpoints, please contact Marvin Support Team and ask for your access.
List Executions
This endpoint returns a list with all executions from the last 7 days that you have on your Marvin Console.
Verb: GET
Endpoint: https://api.marvin.run/v2/automation/list
Headers:
- Authorization:
(received from Marvin Support Team)
Payload: no payload needed
Response:
[
{
"id": "8aea0658-79aa-496b-8563-ecbb8fe69d78", // Execution ID
"scriptName": "test", // Name of the automation process executed
"execStatus": "SUCCESS", // Current status of execution
"executionTime": "45.3094", // Execution duration time in seconds
"robotName": "Your Robot", // Name of the robot that executed automation
"logTime": 1643338651 // Timestamp of last status
}
]
Get Execution Details
This endpoint retrieve all details from an specific execution id.
Verb: GET
Endpoint: https://api.marvin.run/v2/automation/execution/{execution-id}
Headers:
- Authorization:
(received from Marvin Support Team)
Payload: no payload needed
Response:
{
"id": "d5f0a96f-33b2-48b4-9a29-bc7bf78ea288", // Execution ID
"execStatus": "SUCCESS", // Current automation status
"scriptName": "test", // Script to execute
"vars": { // Variables sent to execution
"city": "New York",
"year": "2021"
},
"createdAt": 1639519686, // Timestamp of execution creation
"robotName": "My Marvin - 01", // Robot name
"robotId": "c6ab9adb-98b7-4a92-8720-a2f49cabf4aa", // Robot ID
"logTime": 1639519689, // Timestamp of last status change
"logs": [ // List with all logs setted during script execution
{
"type": "log",
"log": "Initializing script execution"
},
{
"type": "success",
"log": "Script executed in 1 secs"
}
],
"executionTime": "1.5867180000059307", // Execution duration time in seconds
"to": [ // List of all e-mails that receive the execution status
"[email protected]"
]
}