User API endpoint
A person with a BrainSTEM account, who receives roles directly or through groups.
Table of contents
Endpoints
- Private portal:
https://www.brainstem.org/api/private/users/user/(needs a token; one record: append<id>/) - Public portal:
https://www.brainstem.org/api/public/users/user/(read-only, public projects, no token) - Response keys:
user(detail, create, update),users(list) - Permissions: see the permissions page
- Uniqueness:
emailunique across BrainSTEM - Deleting: also deletes the linked
behavior,behavioralassay,behavioralassaygroupmembershipinvitation,behavioralassaymembershipinvitation,behavioralcategory,behavioralcategoryapproval,behavioralparadigm,behavioralparadigmapproval,breeding,cohort,collection,consumable,consumableapproval,consumablestock,dataacquisition,dataacquisitiontemplate,datastorage,datastoragegroupmembershipinvitation,datastoragemembershipinvitation,epoch,equipment,experimentalinterface,experimentalinterfacetemplate,groupmembershipinvitation,groupmembershiprequest,hardwaredevice,hardwaredeviceapproval,inventory,inventorygroupmembershipinvitation,inventorymembershipinvitation,journal,journalapproval,laboratory,license,licensegroupmembershipinvitation,licensemembershipinvitation,manipulation,manipulationtemplate,materialusage,materialusagetemplate,pendinginvitation,procedure,procedureepisode,procedureepisodetemplate,procedurelog,proceduretemplate,project,projectgroupmembershipinvitation,projectmembershipinvitation,protocol,protocolgroupmembershipinvitation,protocolmembershipinvitation,publication,publicationapproval,regulatoryauthority,regulatoryauthorityapproval,session,setup,setupgroupmembershipinvitation,setupmembershipinvitation,setuptype,setuptypeapproval,species,speciesapproval,specimen,specimenlog,specimenprocedure,specimenproceduretemplate,specimenset,strain,strainapproval,subject,subjectlog,supplier,supplierapprovalrecords; clears the link onanatomicalregion,procedurerecords
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 | number [read-only] |
email | string [read-only] |
first_name | string; max 150 characters |
last_name | string; max 150 characters |
groups_own_json | string [read-only] |
profile | string [read-only] |
List
- Allowed portals: private, public
- Request method: GET
- URL:
https://www.brainstem.org/api/private/users/user/ - Responses:
200OK;401Not authenticated;403Not allowed
Use example (Python API tool)
resp = client.load('user', load_all=True)
records = resp['users']
Use example (MATLAB API tool)
resp = client.load('user', 'load_all', true);
records = resp.users;
Response example
{
"users": [
{
"id": 1,
"email": "",
"first_name": "",
"last_name": "",
"groups_own_json": "",
"profile": ""
}
],
"meta": {
"page": 1,
"per_page": 100,
"total_results": 1,
"total_pages": 1
}
}
Detail
- Allowed portals: private, public
- Request method: GET
- URL:
https://www.brainstem.org/api/private/users/user/<id>/ - Responses:
200OK;403Not allowed;404Not found
Use example (Python API tool)
resp = client.load('user', id='<id>')
record = resp.json()['user']
Use example (MATLAB API tool)
out = client.load('user', 'id', '<id>');
record = out.user;
Response example
{
"user": {
"id": 1,
"email": "",
"first_name": "",
"last_name": "",
"groups_own_json": "",
"profile": ""
}
}
Change
- Allowed portals: private
- Request method: PATCH
- URL:
https://www.brainstem.org/api/private/users/user/<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('user', id='<id>', data={"first_name": "new value"})
Use example (MATLAB API tool)
client.save(struct('id', '<id>', 'first_name', 'new value'), 'user', 'method', 'patch');