Insert Records
POST https://%7B%7Bvault_uri%7D%7D.vault.skyflowapis.com/v1/vaults/{vaultID}/{objectName}Content-Type: application/jsonInserts a record in the specified table.The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error.
Authentication
Section titled “Authentication”Authorizationheader (bearer token, required) — Access token, prefixed byBearer.
Servers
Section titled “Servers”https://%7B%7Bvault_uri%7D%7D.vault.skyflowapis.com(Production, default)https://%7B%7Bvault_uri%7D%7D.vault.skyflowapis-preview.com(Sandbox)
Request
Section titled “Request”Path parameters
Section titled “Path parameters”vaultID(string, required)objectName(string, required)
Body (application/json)
Section titled “Body (application/json)”This endpoint expects an object.
records(list of object, required) — Record values and tokens.fields(map from string to any, optional) — Fields and values for the record. For example,{'field_1':'value_1', 'field_2':'value_2'}.tokens(map from string to any, optional) — Fields and tokens for the record. For example,{'field_1':'token_1', 'field_2':'token_2'}.
tokenization(boolean, optional, default: false) — Iftrue, this operation returns tokens for fields with tokenization enabled.upsert(string, optional) — Name of a unique column in the table. Uses upsert operations to check if a record exists based on the unique column’s value. If a matching record exists, the record updates with the values you provide. If a matching record doesn’t exist, the upsert operation inserts a new record.When you upsert a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn’t included, it’s removed.homogeneous(boolean, optional, default: false) — Iftrue, this operation mandates that all the records have the same fields. This parameter does not work with upsert.byot(enum, optional, default: DISABLE) — Token insertion behavior.- Allowed values:
DISABLE,ENABLE,ENABLE_STRICT
- Allowed values:
Response
Section titled “Response”OK
records(list of object, optional) — Inserted records.skyflow_id(string, optional) — ID of the inserted record.tokens(object, optional) — Tokens for the record.
Errors
Section titled “Errors”400 Bad Request Error
Section titled “400 Bad Request Error”Returned when the request is invalid or cannot be served.
error(object, required)grpc_code(integer, required) — gRPC status codes. See https://grpc.io/docs/guides/status-codes.http_code(integer, required) — HTTP status codes. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status.http_status(string, required)message(string, required)details(list of map from string to any, optional)
401 Unauthorized Error
Section titled “401 Unauthorized Error”Returned when the request is unauthorized.
error(object, required)grpc_code(integer, required) — gRPC status codes. See https://grpc.io/docs/guides/status-codes.http_code(integer, required) — HTTP status codes. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status.http_status(string, required)message(string, required)details(list of map from string to any, optional)
422 Unprocessable Entity Error
Section titled “422 Unprocessable Entity Error”Returned when the request is well-formed but contains semantic errors that prevent it from being processed.
error(object, required)grpc_code(integer, required) — gRPC status codes. See https://grpc.io/docs/guides/status-codes.http_code(integer, required) — HTTP status codes. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status.http_status(string, required)message(string, required)details(list of map from string to any, optional)
500 Internal Server Error
Section titled “500 Internal Server Error”An unexpected error response.
error(object, required)grpc_code(integer, required) — gRPC status codes. See https://grpc.io/docs/guides/status-codes.http_code(integer, required) — HTTP status codes. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status.http_status(string, required)message(string, required)details(list of map from string to any, optional)
Examples
Section titled “Examples”Request
{ "records": [ { "fields": { "drivers_license_number": "13456789", "name": "John", "phone_number": "1236784563", "ssn": "123-45-6789" } }, { "fields": { "drivers_license_number": "98765432", "name": "James", "phone_number": "9876543215", "ssn": "345-45-9876" } } ], "tokenization": true, "upsert": "drivers_license_number", "homogeneous": false}Response
{ "records": [ { "skyflow_id": "9322ffcc-fb8b-4fbe-8551-55c80559007c", "tokens": { "drivers_license_number": "358a03eb-2592-4037-be31-046032471d44", "name": "16c5aa3e-fc49-4a87-8891-5a40c6c2f880", "phone_number": "015ef018-adf3-49a0-8590-dbe9746de044", "ssn": "341-11-6689" } }, { "skyflow_id": "51782ea4-91a5-4430-a06d-f4b76efd3d2f", "tokens": { "drivers_license_number": "f7d9a190-899c-40bf-b719-9e856afb6995", "name": "071a3ae2-62eb-4b63-bcca-17a4da96fc87", "phone_number": "a2fba7f3-d5e5-4e40-ab44-bce2c0ba1493", "ssn": "522-41-0947" } } ]}SDK Code
import requests
url = "https://{{vault_uri}}.vault.skyflowapis.com/v1/vaults/vaultID/objectName"
payload = { "records": [{ "fields": { "drivers_license_number": "13456789", "name": "John", "phone_number": "1236784563", "ssn": "123-45-6789" } }, { "fields": { "drivers_license_number": "98765432", "name": "James", "phone_number": "9876543215", "ssn": "345-45-9876" } }], "tokenization": True, "upsert": "drivers_license_number", "homogeneous": False}headers = { "Authorization": "Bearer <token>", "Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())const url = 'https://{{vault_uri}}.vault.skyflowapis.com/v1/vaults/vaultID/objectName';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"records":[{"fields":{"drivers_license_number":"13456789","name":"John","phone_number":"1236784563","ssn":"123-45-6789"}},{"fields":{"drivers_license_number":"98765432","name":"James","phone_number":"9876543215","ssn":"345-45-9876"}}],"tokenization":true,"upsert":"drivers_license_number","homogeneous":false}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://{{vault_uri}}.vault.skyflowapis.com/v1/vaults/vaultID/objectName"
payload := strings.NewReader("{\n \"records\": [\n {\n \"fields\": {\n \"drivers_license_number\": \"13456789\",\n \"name\": \"John\",\n \"phone_number\": \"1236784563\",\n \"ssn\": \"123-45-6789\"\n }\n },\n {\n \"fields\": {\n \"drivers_license_number\": \"98765432\",\n \"name\": \"James\",\n \"phone_number\": \"9876543215\",\n \"ssn\": \"345-45-9876\"\n }\n }\n ],\n \"tokenization\": true,\n \"upsert\": \"drivers_license_number\",\n \"homogeneous\": false\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(res) fmt.Println(string(body))
}require 'uri'require 'net/http'
url = URI("https://{{vault_uri}}.vault.skyflowapis.com/v1/vaults/vaultID/objectName")
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 \"records\": [\n {\n \"fields\": {\n \"drivers_license_number\": \"13456789\",\n \"name\": \"John\",\n \"phone_number\": \"1236784563\",\n \"ssn\": \"123-45-6789\"\n }\n },\n {\n \"fields\": {\n \"drivers_license_number\": \"98765432\",\n \"name\": \"James\",\n \"phone_number\": \"9876543215\",\n \"ssn\": \"345-45-9876\"\n }\n }\n ],\n \"tokenization\": true,\n \"upsert\": \"drivers_license_number\",\n \"homogeneous\": false\n}"
response = http.request(request)puts response.read_bodyimport com.mashape.unirest.http.HttpResponse;import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.post("https://{{vault_uri}}.vault.skyflowapis.com/v1/vaults/vaultID/objectName") .header("Authorization", "Bearer <token>") .header("Content-Type", "application/json") .body("{\n \"records\": [\n {\n \"fields\": {\n \"drivers_license_number\": \"13456789\",\n \"name\": \"John\",\n \"phone_number\": \"1236784563\",\n \"ssn\": \"123-45-6789\"\n }\n },\n {\n \"fields\": {\n \"drivers_license_number\": \"98765432\",\n \"name\": \"James\",\n \"phone_number\": \"9876543215\",\n \"ssn\": \"345-45-9876\"\n }\n }\n ],\n \"tokenization\": true,\n \"upsert\": \"drivers_license_number\",\n \"homogeneous\": false\n}") .asString();<?phprequire_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://{{vault_uri}}.vault.skyflowapis.com/v1/vaults/vaultID/objectName', [ 'body' => '{ "records": [ { "fields": { "drivers_license_number": "13456789", "name": "John", "phone_number": "1236784563", "ssn": "123-45-6789" } }, { "fields": { "drivers_license_number": "98765432", "name": "James", "phone_number": "9876543215", "ssn": "345-45-9876" } } ], "tokenization": true, "upsert": "drivers_license_number", "homogeneous": false}', 'headers' => [ 'Authorization' => 'Bearer <token>', 'Content-Type' => 'application/json', ],]);
echo $response->getBody();using RestSharp;
var client = new RestClient("https://{{vault_uri}}.vault.skyflowapis.com/v1/vaults/vaultID/objectName");var request = new RestRequest(Method.POST);request.AddHeader("Authorization", "Bearer <token>");request.AddHeader("Content-Type", "application/json");request.AddParameter("application/json", "{\n \"records\": [\n {\n \"fields\": {\n \"drivers_license_number\": \"13456789\",\n \"name\": \"John\",\n \"phone_number\": \"1236784563\",\n \"ssn\": \"123-45-6789\"\n }\n },\n {\n \"fields\": {\n \"drivers_license_number\": \"98765432\",\n \"name\": \"James\",\n \"phone_number\": \"9876543215\",\n \"ssn\": \"345-45-9876\"\n }\n }\n ],\n \"tokenization\": true,\n \"upsert\": \"drivers_license_number\",\n \"homogeneous\": false\n}", ParameterType.RequestBody);IRestResponse response = client.Execute(request);import Foundation
let headers = [ "Authorization": "Bearer <token>", "Content-Type": "application/json"]let parameters = [ "records": [["fields": [ "drivers_license_number": "13456789", "name": "John", "phone_number": "1236784563", "ssn": "123-45-6789" ]], ["fields": [ "drivers_license_number": "98765432", "name": "James", "phone_number": "9876543215", "ssn": "345-45-9876" ]]], "tokenization": true, "upsert": "drivers_license_number", "homogeneous": false] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://{{vault_uri}}.vault.skyflowapis.com/v1/vaults/vaultID/objectName")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0)request.httpMethod = "POST"request.allHTTPHeaderFields = headersrequest.httpBody = postData as Data
let session = URLSession.sharedlet dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) }})
dataTask.resume()