Description

Use a HTTP POST request to create an agent.

Request

HTTP Method: POST

Parameter Description
type Type of agent to create:
Agents::EmailAgent
Agents::EventTransformationAgent
Agents::HTTPRequestAgent
Agents::IMAPAgent
Agents::TriggerAgent
Agents::WebhookAgent
name Name of the agent.
story_id ID of story to which the agent should be added.
keep_events_for Event retention period in seconds.
source_ids Array of agent IDs the agent should receive emitted events from.
source_ids Array of agent IDs the agent should emit events to.
options JSON Options block of the agent.

Sample request

curl -X POST \
  https://<tenant-name>.tines.io/api/v1/agents/<agent-id> \
  -H 'content-type: application/json' \
  -H 'x-user-email: <email-address>' \
  -H 'x-user-token: <api-token>'
  -d '{
	"type":"Agents::EventTransformationAgent",
	"name": "Extract email addresses and urls",
	"story_id":1,
	"keep_events_for":604800,
	"source_ids": [100, 102],
	"receiver_ids":[],
	"options":{
		"mode": "extract",
		"matchers": [
	    {
	      "path": "{{.text}}",
	      "regexp": "\\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}\\b",
	      "to": "email_addresses"
	    },
	    {
	      "path": "{{.text}}",
	      "regexp": "https?:\\/\\/[\\S]+",
	      "to": "urls"
	    }
	  ],
	  "message": "This is an optional message",
	  "expected_update_period_in_days": "2"
	}
}'  

Response

A successful request will return a JSON object describing the created agent.

Field description

Parameter Description
id Agent ID.
user_id User ID of the agent’s owner.
options JSON Options block of the agent.
name Name of the agent.
schedule Defined run scedule for the agent.
events_count Number of events agent has emitted.
last_check_at ISO 8601 Timestamp respresenting date and time of agent’s last sceduled run.
last_receive_at ISO 8601 Timestamp respresenting date and time of last event received.
last_checked_event_id Last event_id process by the agent.
created_at ISO 8601 Timestamp respresenting creation date and time of agent.
updated_at ISO 8601 Timestamp respresenting last updated date and time of agent.
last_web_request_at ISO 8601 Timestamp respresenting last web request process by the agent.
keep_events_for Defined event retention period in seconds.
last_event_at ISO 8601 Timestamp respresenting date and time the last event was received.
last_error_log_at ISO 8601 Timestamp respresenting date and time of last error thrown by the agent.
disabled Boolean flag indicating whether agent is disabled.
guid Unique identifier of the agent.
story_id ID of story to which the agent belongs.

Sample response

{
    "id": 242,
    "user_id": 1,
    "options": {
        "mode": "extract",
        "matchers": [
            {
                "path": "{{.text}}",
                "regexp": "\\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}\\b",
                "to": "email_addresses"
            },
            {
                "path": "{{.text}}",
                "regexp": "https?:\\/\\/[\\S]+",
                "to": "urls"
            }
        ],
        "message": "This is an optional message",
        "expected_update_period_in_days": "2"
    },
    "name": "Extract email addresses and urls",
    "schedule": null,
    "events_count": 0,
    "last_check_at": null,
    "last_receive_at": null,
    "last_checked_event_id": 92020,
    "created_at": "2018-06-05T14:16:22.008Z",
    "updated_at": "2018-06-05T14:16:22.008Z",
    "last_web_request_at": null,
    "keep_events_for": 604800,
    "last_event_at": null,
    "last_error_log_at": null,
    "disabled": false,
    "guid": "f990f6f3f3ba0ea366532902d4d6ca44",
    "story_id": 1
}