# Update Record

```http
PUT https://%7B%7Bvault_uri%7D%7D.vault.skyflowapis.com/v1/vaults/{vaultID}/{objectName}/{ID}
Content-Type: application/json
```

Updates the specified record in a table.When you update 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.The time-to-live (TTL) for a transient field resets when the field value is updated.

## Authentication

- `Authorization` header (bearer token, required) — Access token, prefixed by `Bearer `.

## Servers

- `https://%7B%7Bvault_uri%7D%7D.vault.skyflowapis.com` (Production, default)
- `https://%7B%7Bvault_uri%7D%7D.vault.skyflowapis-preview.com` (Sandbox)

## Request

### Path parameters

- `vaultID` (string, required)
- `objectName` (string, required)
- `ID` (string, required)

### Body (application/json)

This endpoint expects an object.

- `record` (object, optional) — 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) — If `true`, this operation returns tokens for fields with tokenization enabled.
- `byot` (enum, optional, default: DISABLE) — Token insertion behavior.
  - Allowed values: `DISABLE`, `ENABLE`, `ENABLE_STRICT`

## Response

### 200

OK

- `skyflow_id` (string, optional) — ID of the updated record.
- `tokens` (map from string to any, optional) — Tokens for the record.

## Errors

### 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](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](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

Returned when the request is unauthorized.

- `error` (object, required)
  - `grpc_code` (integer, required) — gRPC status codes. See [https://grpc.io/docs/guides/status-codes](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](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)

### 404 Not Found Error

Returned when a resource doesn't exist.

- `error` (object, required)
  - `grpc_code` (integer, required) — gRPC status codes. See [https://grpc.io/docs/guides/status-codes](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](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

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](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](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

An unexpected error response.

- `error` (object, required)
  - `grpc_code` (integer, required) — gRPC status codes. See [https://grpc.io/docs/guides/status-codes](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](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

**Request**

```json
{
  "record": {
    "fields": {
      "drivers_license_number": "89867453",
      "name": "Steve Smith",
      "phone_number": "8794523160",
      "ssn": "143-89-2306"
    }
  },
  "tokenization": true
}
```

**Response**

```json
{
  "skyflow_id": "4423ccdf-75eb-4e2e-abfc-acb43b1440cd",
  "tokens": {
    "drivers_license_number": "2fd8e729-228a-43cf-8274-d0d0efe47f6c",
    "name": "f5c268b7-5dd4-4d37-a12d-05d148a8a440",
    "phone_number": "4639c565-85c8-4120-94a6-e0e91ffaeca4",
    "ssn": "736-96-1306"
  }
}
```

**SDK Code**

```python
import requests

url = "https://{{vault_uri}}.vault.skyflowapis.com/v1/vaults/vaultID/objectName/ID"

payload = {
    "record": { "fields": {
            "drivers_license_number": "89867453",
            "name": "Steve Smith",
            "phone_number": "8794523160",
            "ssn": "143-89-2306"
        } },
    "tokenization": True
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://{{vault_uri}}.vault.skyflowapis.com/v1/vaults/vaultID/objectName/ID';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"record":{"fields":{"drivers_license_number":"89867453","name":"Steve Smith","phone_number":"8794523160","ssn":"143-89-2306"}},"tokenization":true}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://{{vault_uri}}.vault.skyflowapis.com/v1/vaults/vaultID/objectName/ID"

	payload := strings.NewReader("{\n  \"record\": {\n    \"fields\": {\n      \"drivers_license_number\": \"89867453\",\n      \"name\": \"Steve Smith\",\n      \"phone_number\": \"8794523160\",\n      \"ssn\": \"143-89-2306\"\n    }\n  },\n  \"tokenization\": true\n}")

	req, _ := http.NewRequest("PUT", 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))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://{{vault_uri}}.vault.skyflowapis.com/v1/vaults/vaultID/objectName/ID")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"record\": {\n    \"fields\": {\n      \"drivers_license_number\": \"89867453\",\n      \"name\": \"Steve Smith\",\n      \"phone_number\": \"8794523160\",\n      \"ssn\": \"143-89-2306\"\n    }\n  },\n  \"tokenization\": true\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://{{vault_uri}}.vault.skyflowapis.com/v1/vaults/vaultID/objectName/ID")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"record\": {\n    \"fields\": {\n      \"drivers_license_number\": \"89867453\",\n      \"name\": \"Steve Smith\",\n      \"phone_number\": \"8794523160\",\n      \"ssn\": \"143-89-2306\"\n    }\n  },\n  \"tokenization\": true\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://{{vault_uri}}.vault.skyflowapis.com/v1/vaults/vaultID/objectName/ID', [
  'body' => '{
  "record": {
    "fields": {
      "drivers_license_number": "89867453",
      "name": "Steve Smith",
      "phone_number": "8794523160",
      "ssn": "143-89-2306"
    }
  },
  "tokenization": true
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://{{vault_uri}}.vault.skyflowapis.com/v1/vaults/vaultID/objectName/ID");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"record\": {\n    \"fields\": {\n      \"drivers_license_number\": \"89867453\",\n      \"name\": \"Steve Smith\",\n      \"phone_number\": \"8794523160\",\n      \"ssn\": \"143-89-2306\"\n    }\n  },\n  \"tokenization\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "record": ["fields": [
      "drivers_license_number": "89867453",
      "name": "Steve Smith",
      "phone_number": "8794523160",
      "ssn": "143-89-2306"
    ]],
  "tokenization": true
] 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/ID")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let 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()
```