Samples

Update a Sample

A Sample’s data is immutable — to change it, delete the Sample and create a new one. The only mutable property is its annotation (the ground-truth Label the Function learns from). Use these calls to set or clear that annotation.

There are two ways to call this operation:

Set annotation

PUT /v1/functions/{functionId}/samples/{sampleId}/annotation

Description

Sets (or replaces) the Sample’s annotation to the given Label. If the Sample already has an annotation, it is overwritten.

Path parameters

NameTypeRequiredDescription
functionId string yes

—

sampleId string yes

—

Request body

Content type: application/json.

FieldTypeRequiredDescription
labelId string nullable no

—

labelName string nullable no

—

Responses

StatusDescriptionBody
200 Success Annotation

Code samples

curl
curl -X PUT \
  -H 'Authorization: Bearer <accessToken>' \
  -H 'Content-Type: application/json' \
  -d '{
  "labelId": "<labelId>",
  "labelName": "spam"
}' \
  'https://www.nyckel.com/v1/functions/<functionId>/samples/<sampleId>/annotation'
Python
import requests

url = 'https://www.nyckel.com/v1/functions/<functionId>/samples/<sampleId>/annotation'
headers = {
    'Authorization': 'Bearer <accessToken>',
    'Content-Type': 'application/json',
}

body = """{
  "labelId": "<labelId>",
  "labelName": "spam"
}"""
response = requests.put(url, headers=headers, data=body)
print(response.json())
JavaScript
fetch('https://www.nyckel.com/v1/functions/<functionId>/samples/<sampleId>/annotation', {
  method: 'PUT',
  headers: {
    'Authorization': 'Bearer <accessToken>',
    'Content-Type': 'application/json',
  },
  body: `{
  "labelId": "<labelId>",
  "labelName": "spam"
}`,
})
  .then(response => response.json())
  .then(data => console.log(data));
PHP
<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://www.nyckel.com/v1/functions/<functionId>/samples/<sampleId>/annotation');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');

$headers = array(
    'Authorization: Bearer <accessToken>',
    'Content-Type: application/json',
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$body = <<<'NYCKEL_BODY'
{
  "labelId": "<labelId>",
  "labelName": "spam"
}
NYCKEL_BODY;
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

$response = curl_exec($ch);
curl_close($ch);
echo $response;

Clear annotation

DELETE /v1/functions/{functionId}/samples/{sampleId}/annotation

Description

Removes the Sample’s annotation. The Sample itself remains in the Function but no longer contributes to training until it is annotated again.

Path parameters

NameTypeRequiredDescription
functionId string yes

—

sampleId string yes

—

Responses

StatusDescriptionBody
200 Success —

Code samples

curl
curl -X DELETE \
  -H 'Authorization: Bearer <accessToken>' \
  'https://www.nyckel.com/v1/functions/<functionId>/samples/<sampleId>/annotation'
Python
import requests

url = 'https://www.nyckel.com/v1/functions/<functionId>/samples/<sampleId>/annotation'
headers = {
    'Authorization': 'Bearer <accessToken>',
}

response = requests.delete(url, headers=headers)
print(response.json())
JavaScript
fetch('https://www.nyckel.com/v1/functions/<functionId>/samples/<sampleId>/annotation', {
  method: 'DELETE',
  headers: {
    'Authorization': 'Bearer <accessToken>',
  },
})
  .then(response => response.json())
  .then(data => console.log(data));
PHP
<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://www.nyckel.com/v1/functions/<functionId>/samples/<sampleId>/annotation');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');

$headers = array(
    'Authorization: Bearer <accessToken>',
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
curl_close($ch);
echo $response;