curl --request PUT \
--url https://api-dev.narrative.io/datasets/{dataset_id}/redaction \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"columns": [
{
"path": "email_address",
"category": "private_email",
"masking_strategy": {
"type": "keep_email_domain"
}
},
{
"path": "payment.card_number",
"category": "account_number",
"masking_strategy": {
"type": "keep_last_digits",
"count": 4
}
},
{
"path": "notes",
"category": null,
"masking_strategy": {
"type": "mask_everything"
}
}
]
}
'import requests
url = "https://api-dev.narrative.io/datasets/{dataset_id}/redaction"
payload = { "columns": [
{
"path": "email_address",
"category": "private_email",
"masking_strategy": { "type": "keep_email_domain" }
},
{
"path": "payment.card_number",
"category": "account_number",
"masking_strategy": {
"type": "keep_last_digits",
"count": 4
}
},
{
"path": "notes",
"category": None,
"masking_strategy": { "type": "mask_everything" }
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
columns: [
{
path: 'email_address',
category: 'private_email',
masking_strategy: {type: 'keep_email_domain'}
},
{
path: 'payment.card_number',
category: 'account_number',
masking_strategy: {type: 'keep_last_digits', count: 4}
},
{path: 'notes', category: null, masking_strategy: {type: 'mask_everything'}}
]
})
};
fetch('https://api-dev.narrative.io/datasets/{dataset_id}/redaction', 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-dev.narrative.io/datasets/{dataset_id}/redaction",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'columns' => [
[
'path' => 'email_address',
'category' => 'private_email',
'masking_strategy' => [
'type' => 'keep_email_domain'
]
],
[
'path' => 'payment.card_number',
'category' => 'account_number',
'masking_strategy' => [
'type' => 'keep_last_digits',
'count' => 4
]
],
[
'path' => 'notes',
'category' => null,
'masking_strategy' => [
'type' => 'mask_everything'
]
]
]
]),
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-dev.narrative.io/datasets/{dataset_id}/redaction"
payload := strings.NewReader("{\n \"columns\": [\n {\n \"path\": \"email_address\",\n \"category\": \"private_email\",\n \"masking_strategy\": {\n \"type\": \"keep_email_domain\"\n }\n },\n {\n \"path\": \"payment.card_number\",\n \"category\": \"account_number\",\n \"masking_strategy\": {\n \"type\": \"keep_last_digits\",\n \"count\": 4\n }\n },\n {\n \"path\": \"notes\",\n \"category\": null,\n \"masking_strategy\": {\n \"type\": \"mask_everything\"\n }\n }\n ]\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(string(body))
}HttpResponse<String> response = Unirest.put("https://api-dev.narrative.io/datasets/{dataset_id}/redaction")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"columns\": [\n {\n \"path\": \"email_address\",\n \"category\": \"private_email\",\n \"masking_strategy\": {\n \"type\": \"keep_email_domain\"\n }\n },\n {\n \"path\": \"payment.card_number\",\n \"category\": \"account_number\",\n \"masking_strategy\": {\n \"type\": \"keep_last_digits\",\n \"count\": 4\n }\n },\n {\n \"path\": \"notes\",\n \"category\": null,\n \"masking_strategy\": {\n \"type\": \"mask_everything\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/datasets/{dataset_id}/redaction")
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 \"columns\": [\n {\n \"path\": \"email_address\",\n \"category\": \"private_email\",\n \"masking_strategy\": {\n \"type\": \"keep_email_domain\"\n }\n },\n {\n \"path\": \"payment.card_number\",\n \"category\": \"account_number\",\n \"masking_strategy\": {\n \"type\": \"keep_last_digits\",\n \"count\": 4\n }\n },\n {\n \"path\": \"notes\",\n \"category\": null,\n \"masking_strategy\": {\n \"type\": \"mask_everything\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"error": "<string>",
"error_description": "<string>"
}{
"error": "<string>",
"error_description": "<string>"
}{
"error": "<string>",
"error_description": "<string>"
}Upload a dataset's sample redaction
Store the redaction for a dataset’s sample, replacing whatever was there before. Uploading also brings back a redaction that was previously deleted.
Two kinds of caller may upload: a customer with write access on datasets, or Narrative with admin access on datasets. A customer’s dataset is resolved inside their own company. Narrative’s is resolved by id alone, with no company scoping, which is what lets Narrative write a redaction for a customer’s dataset.
The stored redaction records who wrote it from your access token, so a written_by field in the
request body is ignored.
model_version names the privacy model that produced a redaction, and only Narrative may set it.
A customer sending it is refused with a 400 rather than dropped, so reading back a redaction
Narrative generated and sending it straight here needs model_version removed first. An upload
that leaves the field out clears a stored value, so a redaction you edit stops claiming a model
produced it.
curl --request PUT \
--url https://api-dev.narrative.io/datasets/{dataset_id}/redaction \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"columns": [
{
"path": "email_address",
"category": "private_email",
"masking_strategy": {
"type": "keep_email_domain"
}
},
{
"path": "payment.card_number",
"category": "account_number",
"masking_strategy": {
"type": "keep_last_digits",
"count": 4
}
},
{
"path": "notes",
"category": null,
"masking_strategy": {
"type": "mask_everything"
}
}
]
}
'import requests
url = "https://api-dev.narrative.io/datasets/{dataset_id}/redaction"
payload = { "columns": [
{
"path": "email_address",
"category": "private_email",
"masking_strategy": { "type": "keep_email_domain" }
},
{
"path": "payment.card_number",
"category": "account_number",
"masking_strategy": {
"type": "keep_last_digits",
"count": 4
}
},
{
"path": "notes",
"category": None,
"masking_strategy": { "type": "mask_everything" }
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
columns: [
{
path: 'email_address',
category: 'private_email',
masking_strategy: {type: 'keep_email_domain'}
},
{
path: 'payment.card_number',
category: 'account_number',
masking_strategy: {type: 'keep_last_digits', count: 4}
},
{path: 'notes', category: null, masking_strategy: {type: 'mask_everything'}}
]
})
};
fetch('https://api-dev.narrative.io/datasets/{dataset_id}/redaction', 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-dev.narrative.io/datasets/{dataset_id}/redaction",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'columns' => [
[
'path' => 'email_address',
'category' => 'private_email',
'masking_strategy' => [
'type' => 'keep_email_domain'
]
],
[
'path' => 'payment.card_number',
'category' => 'account_number',
'masking_strategy' => [
'type' => 'keep_last_digits',
'count' => 4
]
],
[
'path' => 'notes',
'category' => null,
'masking_strategy' => [
'type' => 'mask_everything'
]
]
]
]),
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-dev.narrative.io/datasets/{dataset_id}/redaction"
payload := strings.NewReader("{\n \"columns\": [\n {\n \"path\": \"email_address\",\n \"category\": \"private_email\",\n \"masking_strategy\": {\n \"type\": \"keep_email_domain\"\n }\n },\n {\n \"path\": \"payment.card_number\",\n \"category\": \"account_number\",\n \"masking_strategy\": {\n \"type\": \"keep_last_digits\",\n \"count\": 4\n }\n },\n {\n \"path\": \"notes\",\n \"category\": null,\n \"masking_strategy\": {\n \"type\": \"mask_everything\"\n }\n }\n ]\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(string(body))
}HttpResponse<String> response = Unirest.put("https://api-dev.narrative.io/datasets/{dataset_id}/redaction")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"columns\": [\n {\n \"path\": \"email_address\",\n \"category\": \"private_email\",\n \"masking_strategy\": {\n \"type\": \"keep_email_domain\"\n }\n },\n {\n \"path\": \"payment.card_number\",\n \"category\": \"account_number\",\n \"masking_strategy\": {\n \"type\": \"keep_last_digits\",\n \"count\": 4\n }\n },\n {\n \"path\": \"notes\",\n \"category\": null,\n \"masking_strategy\": {\n \"type\": \"mask_everything\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/datasets/{dataset_id}/redaction")
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 \"columns\": [\n {\n \"path\": \"email_address\",\n \"category\": \"private_email\",\n \"masking_strategy\": {\n \"type\": \"keep_email_domain\"\n }\n },\n {\n \"path\": \"payment.card_number\",\n \"category\": \"account_number\",\n \"masking_strategy\": {\n \"type\": \"keep_last_digits\",\n \"count\": 4\n }\n },\n {\n \"path\": \"notes\",\n \"category\": null,\n \"masking_strategy\": {\n \"type\": \"mask_everything\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"error": "<string>",
"error_description": "<string>"
}{
"error": "<string>",
"error_description": "<string>"
}{
"error": "<string>",
"error_description": "<string>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Unique identifier for a dataset.
Body
Body of PUT /datasets/{dataset_id}/redaction. The stored redaction's written_by comes from
your access token, and dataset_id, created_at and updated_at are ignored.
One entry per column that holds personal data. An array longer than maxItems is rejected with
a 400 and nothing is stored.
20480Show child attributes
Show child attributes
The privacy model that produced these columns. Only Narrative may set it: a caller with admin access on datasets may send it, and any other caller is refused with a 400. Leaving the field out clears a value already stored.
128Response
OK
Was this page helpful?

