[DEPRECATED] Create File
curl --request POST \
--url https://api-prod.extend.app/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"url": "<string>",
"rawText": "<string>",
"mediaType": "<string>"
}
'import requests
url = "https://api-prod.extend.app/files"
payload = {
"name": "<string>",
"url": "<string>",
"rawText": "<string>",
"mediaType": "<string>"
}
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({name: '<string>', url: '<string>', rawText: '<string>', mediaType: '<string>'})
};
fetch('https://api-prod.extend.app/files', 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-prod.extend.app/files",
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([
'name' => '<string>',
'url' => '<string>',
'rawText' => '<string>',
'mediaType' => '<string>'
]),
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-prod.extend.app/files"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"url\": \"<string>\",\n \"rawText\": \"<string>\",\n \"mediaType\": \"<string>\"\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-prod.extend.app/files")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"url\": \"<string>\",\n \"rawText\": \"<string>\",\n \"mediaType\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-prod.extend.app/files")
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 \"name\": \"<string>\",\n \"url\": \"<string>\",\n \"rawText\": \"<string>\",\n \"mediaType\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"file": {
"object": "file",
"id": "file_1234",
"name": "example_file",
"type": "PDF",
"contents": {
"rawText": "This is the raw text content of the file..."
},
"metadata": {"pageCount": 10},
"presignedUrl": "https://s3.example.com/file_1234.pdf",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}
}
File Endpoints
[DEPRECATED] Create File
Create a new file in Extend for use in an evaluation set.
[DEPRECATED] Create File
curl --request POST \
--url https://api-prod.extend.app/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"url": "<string>",
"rawText": "<string>",
"mediaType": "<string>"
}
'import requests
url = "https://api-prod.extend.app/files"
payload = {
"name": "<string>",
"url": "<string>",
"rawText": "<string>",
"mediaType": "<string>"
}
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({name: '<string>', url: '<string>', rawText: '<string>', mediaType: '<string>'})
};
fetch('https://api-prod.extend.app/files', 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-prod.extend.app/files",
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([
'name' => '<string>',
'url' => '<string>',
'rawText' => '<string>',
'mediaType' => '<string>'
]),
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-prod.extend.app/files"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"url\": \"<string>\",\n \"rawText\": \"<string>\",\n \"mediaType\": \"<string>\"\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-prod.extend.app/files")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"url\": \"<string>\",\n \"rawText\": \"<string>\",\n \"mediaType\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-prod.extend.app/files")
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 \"name\": \"<string>\",\n \"url\": \"<string>\",\n \"rawText\": \"<string>\",\n \"mediaType\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"file": {
"object": "file",
"id": "file_1234",
"name": "example_file",
"type": "PDF",
"contents": {
"rawText": "This is the raw text content of the file..."
},
"metadata": {"pageCount": 10},
"presignedUrl": "https://s3.example.com/file_1234.pdf",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}
}
Deprecation Notice: This endpoint is deprecated and will be removed in a future release. Use the
/upload endpoint instead.
Creating a new File is a prerequisite for using that file with the evaluation sets API.
This endpoint will pre-process the contents of the file, and store it in the Extend platform for use in evaluation sets. For files that require pre-processing (e.g. pdfs, images, etc.) this endpoint can take up to 30 seconds to complete.
Supported file types can be found here.
Body
string
The name of the file.
string
A pre signed URL for the file.
string
The raw text content of the file.
string
The media type of the file. (e.g.
application/pdf). Will be inferred if not provided.Response
boolean
A true or false value for whether the file was processed successfully or not.
File
A File object representing the newly created file. See the File
object for more details.
{
"success": true,
"file": {
"object": "file",
"id": "file_1234",
"name": "example_file",
"type": "PDF",
"contents": {
"rawText": "This is the raw text content of the file..."
},
"metadata": {"pageCount": 10},
"presignedUrl": "https://s3.example.com/file_1234.pdf",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}
}

