Specimen API endpoint

One item of a specimen set, such as a single slice, section or well.

Table of contents

  1. Endpoints
  2. Fields
  3. List
  4. Add
  5. Detail
  6. Change
  7. Delete
  8. Data model

Endpoints

  • Private portal: https://www.brainstem.org/api/private/stem/specimen/ (needs a token; one record: append <id>/)
  • Public portal: https://www.brainstem.org/api/public/stem/specimen/ (read-only, public projects, no token)
  • Response keys: specimen (detail, create, update), specimens (list)
  • Permissions: inherited through specimen_set → projects (from project)
  • Uniqueness: specimen_set, local_identifier unique together
  • Schema payload: type selects a Specimen type; send its fields in details. type_schema_version is set by the server; do not send it.

Fields

[required] fields must be sent on create; [read-only] fields are returned but cannot be set. A nestable relation can be traversed in filters (filter{field.other}) and sideloaded with include[]=field.*; other relations can only be compared with ids (filter{field}=<id>). See the query syntax.

FieldDescription
idUUID string [read-only]
specimen_setspecimenset id [required]; nestable
local_identifierstring [required]; max 100 characters. Stable identifier for this specimen within its specimen set.
typeone of the Specimen types [required]
preparation_conditionsJSON object [read-only]
statusone of planned, available, in_use, reserved, consumed, discarded, lost [required]. Current availability status of this specimen.
qualityone of excellent, good, fair, poor, not_assessed. Quality assessment for this specimen.
lateralityone of left, right, bilateral, not_applicable. Which side of the brain or body this specimen comes from.
storage_locationstring; max 100 characters; nullable. Current physical storage location, container, or slot.
storage_conditionsstring; max 100 characters; nullable. Current storage conditions, such as temperature and medium.
termination_datetimedatetime; nullable. When this specimen was consumed, discarded, lost, or otherwise terminated.
ordernumber; nullable. Ordering within the specimen set.
source_specimenspecimen id; nullable; nestable. Specimen this specimen was derived from, if applicable.
notesstring; nullable. Free-text notes about this specimen.
detailsJSON object
type_schema_versionstring [set by the server]
created_atdatetime [read-only]; nullable
updated_atdatetime [read-only]

List

  • Allowed portals: private, public
  • Request method: GET
  • URL: https://www.brainstem.org/api/private/stem/specimen/
  • Responses: 200 OK; 401 Not authenticated; 403 Not allowed

Use example (Python API tool)

resp = client.load('specimen', load_all=True)
records = resp['specimens']

Use example (MATLAB API tool)

resp = client.load('specimen', 'load_all', true);
records = resp.specimens;

Response example

{
    "specimens": [
        {
            "id": "<id>",
            "specimen_set": "<specimenset-id>",
            "local_identifier": "",
            "type": "Slice",
            "preparation_conditions": {},
            "status": "available",
            "quality": "excellent",
            "laterality": "left",
            "storage_location": "",
            "storage_conditions": "",
            "termination_datetime": "2024-03-22T10:30:00Z",
            "order": 1,
            "source_specimen": "<specimen-id>",
            "notes": "",
            "details": {
                "...": "see the schema of the selected type"
            },
            "type_schema_version": "set by the server",
            "created_at": "2024-03-22T10:30:00Z",
            "updated_at": "2024-03-22T10:30:00Z"
        }
    ],
    "meta": {
        "page": 1,
        "per_page": 100,
        "total_results": 1,
        "total_pages": 1
    }
}

Add

  • Allowed portals: private
  • Request method: POST
  • URL: https://www.brainstem.org/api/private/stem/specimen/
  • Data: JSON object with at least the required fields
  • Responses: 201 Created; 400 Bad request (validation errors per field); 403 Not allowed

Use example (Python API tool)

resp = client.save('specimen', data={"specimen_set": "<specimenset-id>", "local_identifier": "<local_identifier>", "type": "CultureItem", "status": "available", "details": {"...": "see the schema of the selected type"}})
record = resp.json()['specimen']

Use example (MATLAB API tool)

created = client.save(struct('specimen_set', '<specimenset-id>', 'local_identifier', '<local_identifier>', 'type', 'CultureItem', 'status', 'available', 'details', struct()), 'specimen');  % struct() stands for the fields of the selected type
record = created.specimen;

Detail

  • Allowed portals: private, public
  • Request method: GET
  • URL: https://www.brainstem.org/api/private/stem/specimen/<id>/
  • Responses: 200 OK; 403 Not allowed; 404 Not found

Use example (Python API tool)

resp = client.load('specimen', id='<id>')
record = resp.json()['specimen']

Use example (MATLAB API tool)

out = client.load('specimen', 'id', '<id>');
record = out.specimen;

Response example

{
    "specimen": {
        "id": "<id>",
        "specimen_set": "<specimenset-id>",
        "local_identifier": "",
        "type": "Slice",
        "preparation_conditions": {},
        "status": "available",
        "quality": "excellent",
        "laterality": "left",
        "storage_location": "",
        "storage_conditions": "",
        "termination_datetime": "2024-03-22T10:30:00Z",
        "order": 1,
        "source_specimen": "<specimen-id>",
        "notes": "",
        "details": {
            "...": "see the schema of the selected type"
        },
        "type_schema_version": "set by the server",
        "created_at": "2024-03-22T10:30:00Z",
        "updated_at": "2024-03-22T10:30:00Z"
    }
}

Change

  • Allowed portals: private
  • Request method: PATCH
  • URL: https://www.brainstem.org/api/private/stem/specimen/<id>/
  • Data: JSON object with the fields to change. Lists (projects, tags, …) and JSON payloads (details, coordinates) are replaced as a whole: read the record first and send the full list or object.
  • Responses: 200 OK; 400 Bad request; 403 Not allowed; 404 Not found

Use example (Python API tool)

resp = client.save('specimen', id='<id>', data={"local_identifier": "new value"})

Use example (MATLAB API tool)

client.save(struct('id', '<id>', 'local_identifier', 'new value'), 'specimen', 'method', 'patch');

Delete

  • Allowed portals: private
  • Request method: DELETE
  • URL: https://www.brainstem.org/api/private/stem/specimen/<id>/
  • Responses: 204 Deleted; 400 Still referenced by other records; 403 Not allowed; 404 Not found

Use example (Python API tool)

resp = client.delete('specimen', id='<id>')

Use example (MATLAB API tool)

client.delete('<id>', 'specimen');

Data model

The fields are described for the web forms on the Specimen data model page.