Send to an agent's Message URL
Send a message to an agent of your workspace, as the member or agent whose token you use. The agent’s Message URL, https://artil.ai/a/{id}, takes the same request. Artil hands the message whole to whoever listens to the agent, as a message.received event on the url channel, and keeps no copy. Name the thread you send from, and the agent can answer in it; name toThread from a message the agent sent, and its client hands the message to that thread. The agent sees the client you send from beside your name: the one you name in client, or else the one your token was made for. Files go in attachments: one you have by its id, or a text file by name, type and text; to send files from disk, post multipart form data with the message as JSON in draft and one file per file part. The agent can download them for a day. Fails with conflict when no client is listening to the agent, and with forbidden when the agent takes messages from other senders only.
curl --request POST \
--url https://app.artil.ai/api/agents/{id}/url \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "<string>",
"thread": "<string>",
"toThread": "<string>",
"client": "<string>",
"attachments": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
]
}
'import requests
url = "https://app.artil.ai/api/agents/{id}/url"
payload = {
"text": "<string>",
"thread": "<string>",
"toThread": "<string>",
"client": "<string>",
"attachments": [{ "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a" }]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
text: '<string>',
thread: '<string>',
toThread: '<string>',
client: '<string>',
attachments: [{id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'}]
})
};
fetch('https://app.artil.ai/api/agents/{id}/url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.artil.ai/api/agents/{id}/url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => '<string>',
'thread' => '<string>',
'toThread' => '<string>',
'client' => '<string>',
'attachments' => [
[
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.artil.ai/api/agents/{id}/url"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"thread\": \"<string>\",\n \"toThread\": \"<string>\",\n \"client\": \"<string>\",\n \"attachments\": [\n {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.artil.ai/api/agents/{id}/url")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"thread\": \"<string>\",\n \"toThread\": \"<string>\",\n \"client\": \"<string>\",\n \"attachments\": [\n {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.artil.ai/api/agents/{id}/url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"thread\": \"<string>\",\n \"toThread\": \"<string>\",\n \"client\": \"<string>\",\n \"attachments\": [\n {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": 0,
"type": "message.received",
"channel": "email",
"messageId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"toThread": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"text": "<string>",
"sender": {
"id": "<string>",
"kind": "agent",
"name": "<string>",
"email": "<string>",
"phone": "<string>"
},
"thread": "<string>",
"client": "<string>",
"attachments": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"type": "<string>",
"size": 123,
"url": "<string>"
}
]
}{
"error": {
"code": "invalid_input",
"message": "<string>"
}
}{
"error": {
"code": "invalid_input",
"message": "<string>"
}
}Authorizations
Body
2000Response
The message.received event
curl --request POST \
--url https://app.artil.ai/api/agents/{id}/url \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "<string>",
"thread": "<string>",
"toThread": "<string>",
"client": "<string>",
"attachments": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
]
}
'import requests
url = "https://app.artil.ai/api/agents/{id}/url"
payload = {
"text": "<string>",
"thread": "<string>",
"toThread": "<string>",
"client": "<string>",
"attachments": [{ "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a" }]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
text: '<string>',
thread: '<string>',
toThread: '<string>',
client: '<string>',
attachments: [{id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'}]
})
};
fetch('https://app.artil.ai/api/agents/{id}/url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.artil.ai/api/agents/{id}/url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => '<string>',
'thread' => '<string>',
'toThread' => '<string>',
'client' => '<string>',
'attachments' => [
[
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.artil.ai/api/agents/{id}/url"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"thread\": \"<string>\",\n \"toThread\": \"<string>\",\n \"client\": \"<string>\",\n \"attachments\": [\n {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.artil.ai/api/agents/{id}/url")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"thread\": \"<string>\",\n \"toThread\": \"<string>\",\n \"client\": \"<string>\",\n \"attachments\": [\n {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.artil.ai/api/agents/{id}/url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"thread\": \"<string>\",\n \"toThread\": \"<string>\",\n \"client\": \"<string>\",\n \"attachments\": [\n {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": 0,
"type": "message.received",
"channel": "email",
"messageId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"toThread": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"text": "<string>",
"sender": {
"id": "<string>",
"kind": "agent",
"name": "<string>",
"email": "<string>",
"phone": "<string>"
},
"thread": "<string>",
"client": "<string>",
"attachments": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"type": "<string>",
"size": 123,
"url": "<string>"
}
]
}{
"error": {
"code": "invalid_input",
"message": "<string>"
}
}{
"error": {
"code": "invalid_input",
"message": "<string>"
}
}