Subject API endpoint
An animal in a study, described by its species, strain, sex and the procedures and logs recorded for it.
Table of contents
Endpoints
- Private portal:
https://www.brainstem.org/api/private/stem/subject/(needs a token; one record: append<id>/) - Public portal:
https://www.brainstem.org/api/public/stem/subject/(read-only, public projects, no token) - Response keys:
subject(detail, create, update),subjects(list) - Permissions: inherited through
projects(fromproject) - Uniqueness:
nameunique across BrainSTEM - Deleting: also deletes the linked
experimentalinterface,procedure,subjectlogrecords; refused (400) whilebreeding,procedureepisoderecords point to it; clears the link onspecimensetrecords
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.
| Field | Description |
|---|---|
id | UUID string [read-only] |
name | string [required]; max 100 characters |
description | string; nullable |
projects | list of project ids [required]; nestable |
licenses | list of license ids; nestable. Licenses covering this subject for regulatory reporting and compliance |
species | species id [required]; nestable |
strain | strain id; nullable; nestable. The strain of the subject, when one is defined. |
sex | one of F, M, U [required] |
status | one of planned, active, inactive, transferred, deceased, unknown [required]. Current participation status of the subject in research activities |
genetic_line | string; max 100 characters. The genetic line of your subject, e.g., Wild type or local genetic line: PV-Cre x Ai32 line A |
genotype | string; max 200 characters. Confirmed genotype, e.g., ‘PV-Cre/wt; Ai32/wt’. BrainSTEM also has Genotyping as a Subject log type, to describe the genotyping procedure and detailed results. |
subject_identifier | string; max 100 characters |
supplier | supplier id; nullable |
breeding | breeding id; nullable; nestable |
birth_date | date; nullable |
death_date | date; nullable |
extra_fields | JSON object |
procedures | list of procedure ids [read-only]; nullable; nestable |
subjectlogs | list of subjectlog ids [read-only]; nullable; nestable |
tags | list of strings; filter with filter{tags.name}=<name> |
name_used_in_storage | string; max 200 characters; nullable |
List
- Allowed portals: private, public
- Request method: GET
- URL:
https://www.brainstem.org/api/private/stem/subject/ - Responses:
200OK;401Not authenticated;403Not allowed
Use example (Python API tool)
resp = client.load('subject', load_all=True)
records = resp['subjects']
Use example (MATLAB API tool)
resp = client.load('subject', 'load_all', true);
records = resp.subjects;
Response example
{
"subjects": [
{
"id": "<id>",
"name": "Subject 1",
"description": "",
"projects": [
"<project-id>"
],
"licenses": [
"<license-id>"
],
"species": "<species-id>",
"strain": "<strain-id>",
"sex": "F",
"status": "active",
"genetic_line": "",
"genotype": "",
"subject_identifier": "",
"supplier": "<supplier-id>",
"breeding": "<breeding-id>",
"birth_date": "2024-03-22",
"death_date": "2024-03-22",
"extra_fields": {},
"procedures": [
"<procedure-id>"
],
"subjectlogs": [
"<subjectlog-id>"
],
"tags": [],
"name_used_in_storage": ""
}
],
"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/subject/ - Data: JSON object with at least the required fields
- Responses:
201Created;400Bad request (validation errors per field);403Not allowed
Use example (Python API tool)
resp = client.save('subject', data={"name": "Subject 1", "projects": ["<project-id>"], "species": "<species-id>", "sex": "F", "status": "active"})
record = resp.json()['subject']
Use example (MATLAB API tool)
created = client.save(struct('name', 'Subject 1', 'projects', {{'<project-id>'}}, 'species', '<species-id>', 'sex', 'F', 'status', 'active'), 'subject');
record = created.subject;
Detail
- Allowed portals: private, public
- Request method: GET
- URL:
https://www.brainstem.org/api/private/stem/subject/<id>/ - Responses:
200OK;403Not allowed;404Not found
Use example (Python API tool)
resp = client.load('subject', id='<id>')
record = resp.json()['subject']
Use example (MATLAB API tool)
out = client.load('subject', 'id', '<id>');
record = out.subject;
Response example
{
"subject": {
"id": "<id>",
"name": "Subject 1",
"description": "",
"projects": [
"<project-id>"
],
"licenses": [
"<license-id>"
],
"species": "<species-id>",
"strain": "<strain-id>",
"sex": "F",
"status": "active",
"genetic_line": "",
"genotype": "",
"subject_identifier": "",
"supplier": "<supplier-id>",
"breeding": "<breeding-id>",
"birth_date": "2024-03-22",
"death_date": "2024-03-22",
"extra_fields": {},
"procedures": [
"<procedure-id>"
],
"subjectlogs": [
"<subjectlog-id>"
],
"tags": [],
"name_used_in_storage": ""
}
}
Change
- Allowed portals: private
- Request method: PATCH
- URL:
https://www.brainstem.org/api/private/stem/subject/<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:
200OK;400Bad request;403Not allowed;404Not found
Use example (Python API tool)
resp = client.save('subject', id='<id>', data={"name": "Subject 1 (renamed)"})
Use example (MATLAB API tool)
client.save(struct('id', '<id>', 'name', 'Subject 1 (renamed)'), 'subject', 'method', 'patch');
Delete
- Allowed portals: private
- Request method: DELETE
- URL:
https://www.brainstem.org/api/private/stem/subject/<id>/ - Responses:
204Deleted;400Still referenced by other records;403Not allowed;404Not found
Use example (Python API tool)
resp = client.delete('subject', id='<id>')
Use example (MATLAB API tool)
client.delete('<id>', 'subject');
JSON field schemas
Schemas for the additional fields of a subject. The REST API returns these JSON fields as stored and validates writes against the schemas below. Every version is published at https://www.brainstem.org/schemas/Subject/<Type>/<version>.json and never changes; see Public schemas.
Additional fields
- type code
Array· version 1.0.1 · schema
Any extra parameters you want to add to this subject. Saved as key-value pairs. Values can be strings or numbers.
| Property | Description |
|---|---|
key | text |
value | object |
Illustrative payload:
[
{
"key": "text",
"value": {}
}
]
Data model
The fields are described for the web forms on the Subject data model page.
Usage notes
extra_fieldsis a JSON object whose keys start with a letter and contain only letters, digits and underscores; values are strings or numbers.