Protocol API endpoint

A written method the lab reuses, such as a standard operating procedure.

Table of contents

  1. Endpoints
  2. Fields
  3. List
  4. Add
  5. Detail
  6. Change
  7. Delete
  8. Custom actions
  9. Data model
  10. Usage notes

Endpoints

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]
namestring [required]; max 255 characters
descriptionstring; nullable
urlstring; max 200 characters
protocol_typeone of breeding, procedure, specimen_procedure, subject_log, specimen_log [required]
subtypeslist of strings
subtype_displaycomputed [read-only]
licenseslist of license ids; nestable. Licenses that authorize this protocol
attachmentstring; max 100 characters
is_publicboolean. Designates if the protocol is publicly available
procedureslist of procedure ids [read-only]; nullable; nestable
subjectlogslist of subjectlog ids [read-only]; nullable; nestable
userscomputed [read-only]
groupscomputed [read-only]

List

  • Allowed portals: private, public
  • Request method: GET
  • URL: https://www.brainstem.org/api/private/personal_attributes/protocol/
  • Responses: 200 OK; 401 Not authenticated; 403 Not 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: 201 Created; 400 Bad request (validation errors per field); 403 Not 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: 200 OK; 403 Not allowed; 404 Not 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: 200 OK; 400 Bad request; 403 Not allowed; 404 Not 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: 204 Deleted; 400 Still referenced by other records; 403 Not allowed; 404 Not found

Use example (Python API tool)

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

Use example (MATLAB API tool)

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

Custom actions

ActionRequest
leavePOST /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

  • attachment is 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.
  • subtypes are type codes of the selected protocol_type: procedure types for procedure, specimen procedure types for specimen_procedure, subject log types for subject_log and specimen log types for specimen_log. Codes are case-sensitive. An empty list makes the protocol apply to every type; when you change protocol_type, send matching subtypes (or []) in the same request.