Create an upsert
curl --request POST \
--url https://api.vectorify.ai/v1/upserts \
--header 'Api-Key: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"id": "123",
"data": {
"customer_name": "John Doe",
"status": "draft",
"amount": "100",
"currency": "USD",
"due_date": "2023-10-01"
},
"metadata": {
"customer_name": "John Doe",
"status": "draft"
},
"tenant": 987,
"url": "<string>"
}
]
}
'import requests
url = "https://api.vectorify.ai/v1/upserts"
payload = { "items": [
{
"id": "123",
"data": {
"customer_name": "John Doe",
"status": "draft",
"amount": "100",
"currency": "USD",
"due_date": "2023-10-01"
},
"metadata": {
"customer_name": "John Doe",
"status": "draft"
},
"tenant": 987,
"url": "<string>"
}
] }
headers = {
"Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
items: [
{
id: '123',
data: {
customer_name: 'John Doe',
status: 'draft',
amount: '100',
currency: 'USD',
due_date: '2023-10-01'
},
metadata: {customer_name: 'John Doe', status: 'draft'},
tenant: 987,
url: '<string>'
}
]
})
};
fetch('https://api.vectorify.ai/v1/upserts', 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.vectorify.ai/v1/upserts",
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([
'items' => [
[
'id' => '123',
'data' => [
'customer_name' => 'John Doe',
'status' => 'draft',
'amount' => '100',
'currency' => 'USD',
'due_date' => '2023-10-01'
],
'metadata' => [
'customer_name' => 'John Doe',
'status' => 'draft'
],
'tenant' => 987,
'url' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Api-Key: <api-key>",
"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.vectorify.ai/v1/upserts"
payload := strings.NewReader("{\n \"items\": [\n {\n \"id\": \"123\",\n \"data\": {\n \"customer_name\": \"John Doe\",\n \"status\": \"draft\",\n \"amount\": \"100\",\n \"currency\": \"USD\",\n \"due_date\": \"2023-10-01\"\n },\n \"metadata\": {\n \"customer_name\": \"John Doe\",\n \"status\": \"draft\"\n },\n \"tenant\": 987,\n \"url\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Api-Key", "<api-key>")
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.vectorify.ai/v1/upserts")
.header("Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"id\": \"123\",\n \"data\": {\n \"customer_name\": \"John Doe\",\n \"status\": \"draft\",\n \"amount\": \"100\",\n \"currency\": \"USD\",\n \"due_date\": \"2023-10-01\"\n },\n \"metadata\": {\n \"customer_name\": \"John Doe\",\n \"status\": \"draft\"\n },\n \"tenant\": 987,\n \"url\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vectorify.ai/v1/upserts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"id\": \"123\",\n \"data\": {\n \"customer_name\": \"John Doe\",\n \"status\": \"draft\",\n \"amount\": \"100\",\n \"currency\": \"USD\",\n \"due_date\": \"2023-10-01\"\n },\n \"metadata\": {\n \"customer_name\": \"John Doe\",\n \"status\": \"draft\"\n },\n \"tenant\": 987,\n \"url\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"result": "Queued",
"created_at": "<string>"
}
}{
"message": "<string>",
"errors": {}
}Upserts
Create an upsert
An upsert is an operation that allows you to create or update items in a single operation. You don’t have to worry about whether the item already exists or not.
The metadata field stores additional context about your items that won’t be used for search but enable filtering capabilities.
The tenant field is used to identify the organisation to which the items belong. It is required if you’ve selected multi from the project settings.
POST
/
upserts
Create an upsert
curl --request POST \
--url https://api.vectorify.ai/v1/upserts \
--header 'Api-Key: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"id": "123",
"data": {
"customer_name": "John Doe",
"status": "draft",
"amount": "100",
"currency": "USD",
"due_date": "2023-10-01"
},
"metadata": {
"customer_name": "John Doe",
"status": "draft"
},
"tenant": 987,
"url": "<string>"
}
]
}
'import requests
url = "https://api.vectorify.ai/v1/upserts"
payload = { "items": [
{
"id": "123",
"data": {
"customer_name": "John Doe",
"status": "draft",
"amount": "100",
"currency": "USD",
"due_date": "2023-10-01"
},
"metadata": {
"customer_name": "John Doe",
"status": "draft"
},
"tenant": 987,
"url": "<string>"
}
] }
headers = {
"Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
items: [
{
id: '123',
data: {
customer_name: 'John Doe',
status: 'draft',
amount: '100',
currency: 'USD',
due_date: '2023-10-01'
},
metadata: {customer_name: 'John Doe', status: 'draft'},
tenant: 987,
url: '<string>'
}
]
})
};
fetch('https://api.vectorify.ai/v1/upserts', 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.vectorify.ai/v1/upserts",
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([
'items' => [
[
'id' => '123',
'data' => [
'customer_name' => 'John Doe',
'status' => 'draft',
'amount' => '100',
'currency' => 'USD',
'due_date' => '2023-10-01'
],
'metadata' => [
'customer_name' => 'John Doe',
'status' => 'draft'
],
'tenant' => 987,
'url' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Api-Key: <api-key>",
"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.vectorify.ai/v1/upserts"
payload := strings.NewReader("{\n \"items\": [\n {\n \"id\": \"123\",\n \"data\": {\n \"customer_name\": \"John Doe\",\n \"status\": \"draft\",\n \"amount\": \"100\",\n \"currency\": \"USD\",\n \"due_date\": \"2023-10-01\"\n },\n \"metadata\": {\n \"customer_name\": \"John Doe\",\n \"status\": \"draft\"\n },\n \"tenant\": 987,\n \"url\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Api-Key", "<api-key>")
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.vectorify.ai/v1/upserts")
.header("Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"id\": \"123\",\n \"data\": {\n \"customer_name\": \"John Doe\",\n \"status\": \"draft\",\n \"amount\": \"100\",\n \"currency\": \"USD\",\n \"due_date\": \"2023-10-01\"\n },\n \"metadata\": {\n \"customer_name\": \"John Doe\",\n \"status\": \"draft\"\n },\n \"tenant\": 987,\n \"url\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vectorify.ai/v1/upserts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"id\": \"123\",\n \"data\": {\n \"customer_name\": \"John Doe\",\n \"status\": \"draft\",\n \"amount\": \"100\",\n \"currency\": \"USD\",\n \"due_date\": \"2023-10-01\"\n },\n \"metadata\": {\n \"customer_name\": \"John Doe\",\n \"status\": \"draft\"\n },\n \"tenant\": 987,\n \"url\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"result": "Queued",
"created_at": "<string>"
}
}{
"message": "<string>",
"errors": {}
}Was this page helpful?
⌘I