Save To File
curl --request POST \
--url https://api-lr.agent.ai/v1/action/create_file \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"file_type": "pdf",
"body": "# Sample Document\n\nThis is a sample document content that will be saved to a file.",
"output_variable_name": "saved_file"
}
'import requests
url = "https://api-lr.agent.ai/v1/action/create_file"
payload = {
"file_type": "pdf",
"body": "# Sample Document
This is a sample document content that will be saved to a file.",
"output_variable_name": "saved_file"
}
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({
file_type: 'pdf',
body: JSON.stringify('# Sample Document\n\nThis is a sample document content that will be saved to a file.'),
output_variable_name: 'saved_file'
})
};
fetch('https://api-lr.agent.ai/v1/action/create_file', 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://api-lr.agent.ai/v1/action/create_file",
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([
'file_type' => 'pdf',
'body' => '# Sample Document
This is a sample document content that will be saved to a file.',
'output_variable_name' => 'saved_file'
]),
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://api-lr.agent.ai/v1/action/create_file"
payload := strings.NewReader("{\n \"file_type\": \"pdf\",\n \"body\": \"# Sample Document\\n\\nThis is a sample document content that will be saved to a file.\",\n \"output_variable_name\": \"saved_file\"\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://api-lr.agent.ai/v1/action/create_file")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"file_type\": \"pdf\",\n \"body\": \"# Sample Document\\n\\nThis is a sample document content that will be saved to a file.\",\n \"output_variable_name\": \"saved_file\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-lr.agent.ai/v1/action/create_file")
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 \"file_type\": \"pdf\",\n \"body\": \"# Sample Document\\n\\nThis is a sample document content that will be saved to a file.\",\n \"output_variable_name\": \"saved_file\"\n}"
response = http.request(request)
puts response.read_body{
"status": 200,
"response": {
"saved_file": "https://s3.example.com/asset-uploads/document.pdf"
}
}{
"status": 123,
"error": "<string>"
}Outputs
Save To File
Save text content as a downloadable file.
POST
/
action
/
create_file
Save To File
curl --request POST \
--url https://api-lr.agent.ai/v1/action/create_file \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"file_type": "pdf",
"body": "# Sample Document\n\nThis is a sample document content that will be saved to a file.",
"output_variable_name": "saved_file"
}
'import requests
url = "https://api-lr.agent.ai/v1/action/create_file"
payload = {
"file_type": "pdf",
"body": "# Sample Document
This is a sample document content that will be saved to a file.",
"output_variable_name": "saved_file"
}
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({
file_type: 'pdf',
body: JSON.stringify('# Sample Document\n\nThis is a sample document content that will be saved to a file.'),
output_variable_name: 'saved_file'
})
};
fetch('https://api-lr.agent.ai/v1/action/create_file', 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://api-lr.agent.ai/v1/action/create_file",
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([
'file_type' => 'pdf',
'body' => '# Sample Document
This is a sample document content that will be saved to a file.',
'output_variable_name' => 'saved_file'
]),
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://api-lr.agent.ai/v1/action/create_file"
payload := strings.NewReader("{\n \"file_type\": \"pdf\",\n \"body\": \"# Sample Document\\n\\nThis is a sample document content that will be saved to a file.\",\n \"output_variable_name\": \"saved_file\"\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://api-lr.agent.ai/v1/action/create_file")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"file_type\": \"pdf\",\n \"body\": \"# Sample Document\\n\\nThis is a sample document content that will be saved to a file.\",\n \"output_variable_name\": \"saved_file\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-lr.agent.ai/v1/action/create_file")
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 \"file_type\": \"pdf\",\n \"body\": \"# Sample Document\\n\\nThis is a sample document content that will be saved to a file.\",\n \"output_variable_name\": \"saved_file\"\n}"
response = http.request(request)
puts response.read_body{
"status": 200,
"response": {
"saved_file": "https://s3.example.com/asset-uploads/document.pdf"
}
}{
"status": 123,
"error": "<string>"
}Authorizations
Bearer token from your account (https://agent.ai/user/integrations#api)
Body
application/json
Enter the output file type (i.e. PDF).
Available options:
pdf, docx, html, md, odt, tex, azw3, epub, png Example:
"pdf"
Provide the content to be saved in the file, including text, bullet points, or other structured information.
Example:
"# Sample Document\n\nThis is a sample document content that will be saved to a file."
Provide a variable name to store the file URL to.
Pattern:
^[a-zA-Z0-9_]+$Example:
"saved_file"
⌘I

