Protocol API endpoint
A written method the lab reuses, such as a standard operating procedure.
Table of contents
Endpoints
- Private portal:
https://www.brainstem.org/api/private/personal_attributes/protocol/(needs a token; one record: append<id>/) - Public portal:
https://www.brainstem.org/api/public/personal_attributes/protocol/(read-only, public projects, no token) - Response keys:
protocol(detail, create, update),protocols(list) - Permissions: object permissions on the record itself (member / manager / owner roles)
- Deleting: also deletes the linked
protocolgroupmembershipinvitation,protocolmembershipinvitationrecords; refused (400) whileprocedure,procedureepisode,procedureepisodetemplate,proceduretemplate,subjectlogrecords point to it; clears the link onspecimenlog,specimenprocedure,specimenproceduretemplaterecords
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 255 characters |
description | string; nullable |
url | string; max 200 characters |
protocol_type | one of breeding, procedure, specimen_procedure, subject_log, specimen_log [required] |
subtypes | list of strings |
subtype_display | computed [read-only] |
licenses | list of license ids; nestable. Licenses that authorize this protocol |
attachment | string; max 100 characters |
is_public | boolean. Designates if the protocol is publicly available |
procedures | list of procedure ids [read-only]; nullable; nestable |
subjectlogs | list of subjectlog ids [read-only]; nullable; nestable |
users | computed [read-only] |
groups | computed [read-only] |
List
- Allowed portals: private, public
- Request method: GET
- URL:
https://www.brainstem.org/api/private/personal_attributes/protocol/ - Responses:
200OK;401Not authenticated;403Not allowed
Use example (Python API tool)
resp = client.load('protocol', load_all=True)
records = resp['protocols']
Use example (MATLAB API tool)
resp = client.load('protocol', 'load_all', true);
records = resp.protocols;
Response example
{
"protocols": [
{
"id": "<id>",
"name": "Protocol 1",
"description": "",
"url": "",
"protocol_type": "breeding",
"subtypes": [],
"subtype_display": null,
"licenses": [
"<license-id>"
],
"attachment": "",
"is_public": true,
"procedures": [
"<procedure-id>"
],
"subjectlogs": [
"<subjectlog-id>"
],
"users": null,
"groups": null
}
],
"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/personal_attributes/protocol/ - 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('protocol', data={"name": "Protocol 1", "protocol_type": "breeding"})
record = resp.json()['protocol']
Use example (MATLAB API tool)
created = client.save(struct('name', 'Protocol 1', 'protocol_type', 'breeding'), 'protocol');
record = created.protocol;
Detail
- Allowed portals: private, public
- Request method: GET
- URL:
https://www.brainstem.org/api/private/personal_attributes/protocol/<id>/ - Responses:
200OK;403Not allowed;404Not found
Use example (Python API tool)
resp = client.load('protocol', id='<id>')
record = resp.json()['protocol']
Use example (MATLAB API tool)
out = client.load('protocol', 'id', '<id>');
record = out.protocol;
Response example
{
"protocol": {
"id": "<id>",
"name": "Protocol 1",
"description": "",
"url": "",
"protocol_type": "breeding",
"subtypes": [],
"subtype_display": null,
"licenses": [
"<license-id>"
],
"attachment": "",
"is_public": true,
"procedures": [
"<procedure-id>"
],
"subjectlogs": [
"<subjectlog-id>"
],
"users": null,
"groups": null
}
}
Change
- Allowed portals: private
- Request method: PATCH
- URL:
https://www.brainstem.org/api/private/personal_attributes/protocol/<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('protocol', id='<id>', data={"name": "Protocol 1 (renamed)"})
Use example (MATLAB API tool)
client.save(struct('id', '<id>', 'name', 'Protocol 1 (renamed)'), 'protocol', 'method', 'patch');
Delete
- Allowed portals: private
- Request method: DELETE
- URL:
https://www.brainstem.org/api/private/personal_attributes/protocol/<id>/ - Responses:
204Deleted;400Still referenced by other records;403Not allowed;404Not found
Use example (Python API tool)
resp = client.delete('protocol', id='<id>')
Use example (MATLAB API tool)
client.delete('<id>', 'protocol');
Custom actions
| Action | Request |
|---|---|
leave | POST /api/private/personal_attributes/protocol/<id>/leave/ |
Data model
The fields are described for the web forms on the Protocol data model page.
Usage notes
attachmentis a file, not text: upload it as multipart form data (PDF, DOCX, XLSX, PPTX, ODT, CSV, Markdown or plain text, up to 15 MB). Responses return a signed download URL.subtypesare type codes of the selectedprotocol_type: procedure types forprocedure, specimen procedure types forspecimen_procedure, subject log types forsubject_logand specimen log types forspecimen_log. Codes are case-sensitive. An empty list makes the protocol apply to every type; when you changeprotocol_type, send matchingsubtypes(or[]) in the same request.