Skip to content

nodes_samples_batch_create

POST
/api/nodes/{node_pk}/samples/batch
curl --request POST \
--url https://example.com/api/nodes/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/samples/batch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Workspace: 2489E9AD-2EE2-8E00-8EC9-32D5F69181C0' \
--data '{ "samples": [ "example" ] }'

Create several samples in the node, in a single request.

Each sample is created or refused on its own: a refused sample does not stop the others, and nothing is undone. results follows the order of the request and tells, for each sample, whether it was created and, when it was not, the error that prevented it.

The alias of a sample is unique in its node. A sample is refused with alias_taken when another sample of the node uses its alias, and with alias_repeated when an earlier sample of the batch has it; the earlier one is created. A sample whose title or alias is not valid is refused with the code of the field validation. Sending the refused samples again, once corrected, creates them.

The answer is a 201 when at least one sample was created, a 200 otherwise.

node_pk
required
string format: uuid
X-Workspace
required
string format: uuid

Workspace ID

Serializer for the creation of a batch of samples.

Only the list itself is checked here. Each sample is checked on its own, so that an invalid one is refused in the report instead of failing the batch.

object
samples
required

The samples to create, each as {title, alias}.

Array

Example generated

{
"samples": [
"example"
]
}
Media typeapplication/json

Serializer for the answer to the creation of a batch of samples.

object
created
required
integer
failed
required
integer
results
required
Array<object>

Serializer for what became of one sample of a batch.

object
title
required

The title as it was sent.

alias
required

The alias as it was sent.

created
required
boolean
sample
required

Null when not created.

object
id
required
string format: uuid
alias
required
string
<= 50 characters /^[-a-zA-Z0-9_]+$/
title
required
string
<= 1000 characters
node
required
string format: uuid
source
required

Determine source of object as either ‘local’, ‘inherited’, or ‘descendant’.

The function checks if the given object is:

  • local: if it is not associated with the current node’s ancestors or descendants.
  • inherited: if it is associated with one of the ancestors of the current node.
  • descendant: if it is associated with one of the descendants of the current node.

Parameters

obj : Sample Object being checked for its source.

Returns

source : str Source of object: - “inherited”: if object is from ancestor node. - “descendant”: if object is from descendant node. - “local”: if object is not associated with current node’s ancestors or descendants.

string
data
required

Return information about a given object, including the count of bound samples and a related URL.

Parameters

obj : Sample Object containing information about a sample.

Returns

dict Dictionary containing: - “count”: The count of bound samples for the given object (obj). - “related”: The URL for accessing bound data related to the object.

object
key
additional properties
datalink
required

Return information about bound datalinks related to a given object.

The method retrieves information about bound datalinks associated with the object, including the count of distinct datalink values and a URL for accessing the bound datalinks.

Parameters

obj : Sample Object containing information about a sample.

Returns

dict Dictionary containing: - “count”: The number of distinct values in the “datalink” field of the bound_data related to the given obj. - “related”: The URL for accessing the bound datalinks related to the given obj.

object
key
additional properties
created_time
required
string format: date-time
created_by
required

Return interactor information of the object’s creator.

Parameters

obj : Sample Object containing the creator information.

Returns

dict Interactor information of the creator.

object
key
additional properties
last_edited_time
required
string format: date-time
last_edited_by
required

Return information about the last interactor who edited the object.

Parameters

obj : Sample Object containing the last editor information.

Returns

dict Interactor information of the last editor.

object
key
additional properties
error
required

Why the sample was not created. Null when it was.

object
parameter
required

The field at fault.

string
code
required

alias_taken when another sample of the node uses the alias, alias_repeated when an earlier sample of the batch has it, or the code of the field validation (required, invalid, blank, max_length).

string
message
required
string

Example generated

{
"created": 1,
"failed": 1,
"results": [
{
"title": "example",
"alias": "example",
"created": true,
"sample": {
"alias": "example",
"title": "example",
"node": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"
},
"error": {
"parameter": "example",
"code": "example",
"message": "example"
}
}
]
}
Media typeapplication/json

Serializer for the answer to the creation of a batch of samples.

object
created
required
integer
failed
required
integer
results
required
Array<object>

Serializer for what became of one sample of a batch.

object
title
required

The title as it was sent.

alias
required

The alias as it was sent.

created
required
boolean
sample
required

Null when not created.

object
id
required
string format: uuid
alias
required
string
<= 50 characters /^[-a-zA-Z0-9_]+$/
title
required
string
<= 1000 characters
node
required
string format: uuid
source
required

Determine source of object as either ‘local’, ‘inherited’, or ‘descendant’.

The function checks if the given object is:

  • local: if it is not associated with the current node’s ancestors or descendants.
  • inherited: if it is associated with one of the ancestors of the current node.
  • descendant: if it is associated with one of the descendants of the current node.

Parameters

obj : Sample Object being checked for its source.

Returns

source : str Source of object: - “inherited”: if object is from ancestor node. - “descendant”: if object is from descendant node. - “local”: if object is not associated with current node’s ancestors or descendants.

string
data
required

Return information about a given object, including the count of bound samples and a related URL.

Parameters

obj : Sample Object containing information about a sample.

Returns

dict Dictionary containing: - “count”: The count of bound samples for the given object (obj). - “related”: The URL for accessing bound data related to the object.

object
key
additional properties
datalink
required

Return information about bound datalinks related to a given object.

The method retrieves information about bound datalinks associated with the object, including the count of distinct datalink values and a URL for accessing the bound datalinks.

Parameters

obj : Sample Object containing information about a sample.

Returns

dict Dictionary containing: - “count”: The number of distinct values in the “datalink” field of the bound_data related to the given obj. - “related”: The URL for accessing the bound datalinks related to the given obj.

object
key
additional properties
created_time
required
string format: date-time
created_by
required

Return interactor information of the object’s creator.

Parameters

obj : Sample Object containing the creator information.

Returns

dict Interactor information of the creator.

object
key
additional properties
last_edited_time
required
string format: date-time
last_edited_by
required

Return information about the last interactor who edited the object.

Parameters

obj : Sample Object containing the last editor information.

Returns

dict Interactor information of the last editor.

object
key
additional properties
error
required

Why the sample was not created. Null when it was.

object
parameter
required

The field at fault.

string
code
required

alias_taken when another sample of the node uses the alias, alias_repeated when an earlier sample of the batch has it, or the code of the field validation (required, invalid, blank, max_length).

string
message
required
string

Example generated

{
"created": 1,
"failed": 1,
"results": [
{
"title": "example",
"alias": "example",
"created": true,
"sample": {
"alias": "example",
"title": "example",
"node": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"
},
"error": {
"parameter": "example",
"code": "example",
"message": "example"
}
}
]
}
Media typeapplication/json
object
code
required
string
>= 1 characters
message
required
string
>= 1 characters
details
required
Array<object>
object
parameter
string
nullable
code
string
nullable
message
string

Example

{
"code": "body_validation_error",
"message": "The request body does not match the schema for the expected parameters. Check the `details` property for more details.",
"details": [
{
"parameter": "samples",
"code": "invalid",
"message": "A batch holds at most <max> samples, <n> were given."
}
]
}
Media typeapplication/json
object
code
required
string
>= 1 characters
message
required
string
>= 1 characters
details
required
Array<object>
object
parameter
string
nullable
code
string
nullable
message
string

Example

{
"code": "forbidden",
"message": "You do not have permission to perform this operation. Check the `details` property for more details.",
"details": [
{
"parameter": "node",
"code": "permission_denied",
"message": "Your role does not allow creation for this node."
}
]
}
Media typeapplication/json
object
code
required
string
>= 1 characters
message
required
string
>= 1 characters
details
required
Array<object>
object
parameter
string
nullable
code
string
nullable
message
string

Example

{
"code": "object_not_found",
"message": "Object not found. Check the `details` property for more details.",
"details": [
{
"parameter": "<id>",
"code": "does_not_exist",
"message": "\"<id>\" does not exist."
}
]
}
Media typeapplication/json
object
code
required
string
>= 1 characters
message
required
string
>= 1 characters
details
required
Array<object>
object
parameter
string
nullable
code
string
nullable
message
string

Example

{
"code": "node_operation_in_progress",
"message": "The requested operation cannot be performed because the node is currently in progress.",
"details": [
{
"parameter": "node",
"code": "in_progress",
"message": "Node '<node id>' is currently in progress and cannot perform operation 'create_sample'."
}
]
}