Samples · operationId:PostSample

Create a Sample

POST /v1/functions/{functionId}/samples

Description

Create sample

Path parameters

NameTypeRequiredDescription
functionId string yes

Request body

Content type: application/json. Body schema: WritableSample.

Responses

StatusDescriptionBody
200 Success Sample

Code samples

curl
curl -X POST \
  -H 'Authorization: Bearer <accessToken>' \
  -H 'Content-Type: application/json' \
  -d '{
  "annotation": {
    "labelId": "<labelId>",
    "labelName": "spam"
  },
  "data": {
    "size": 0
  },
  "externalId": "external-123",
  "sampleSets": [
    {
      "sampleSetId": "<sampleSetId>",
      "weight": 0
    }
  ]
}' \
  'https://www.nyckel.com/v1/functions/<functionId>/samples'
Python
import requests

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

body = """{
  "annotation": {
    "labelId": "<labelId>",
    "labelName": "spam"
  },
  "data": {
    "size": 0
  },
  "externalId": "external-123",
  "sampleSets": [
    {
      "sampleSetId": "<sampleSetId>",
      "weight": 0
    }
  ]
}"""
response = requests.post(url, headers=headers, data=body)
print(response.json())
JavaScript
fetch('https://www.nyckel.com/v1/functions/<functionId>/samples', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <accessToken>',
    'Content-Type': 'application/json',
  },
  body: `{
  "annotation": {
    "labelId": "<labelId>",
    "labelName": "spam"
  },
  "data": {
    "size": 0
  },
  "externalId": "external-123",
  "sampleSets": [
    {
      "sampleSetId": "<sampleSetId>",
      "weight": 0
    }
  ]
}`,
})
  .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');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');

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

$body = <<<'NYCKEL_BODY'
{
  "annotation": {
    "labelId": "<labelId>",
    "labelName": "spam"
  },
  "data": {
    "size": 0
  },
  "externalId": "external-123",
  "sampleSets": [
    {
      "sampleSetId": "<sampleSetId>",
      "weight": 0
    }
  ]
}
NYCKEL_BODY;
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

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