Pending invitation API endpoint

An invitation by email to someone without an account yet, for a role on a group, project or personal attribute; it takes effect when they sign up.

Table of contents

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

Endpoints

  • Private portal: https://www.brainstem.org/api/private/users/pendinginvitation/ (needs a token; one record: append <id>/)
  • Public portal: not available
  • Response keys: pending_invitation (detail, create, update), pending_invitations (list)
  • Permissions: see the permissions page
  • Uniqueness: token unique across BrainSTEM

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]
emailstring [required]; max 254 characters. Email address of the invitee (normalized to lowercase)
resource_typecomputed [read-only]
invited_tocomputed [read-only]
can_changeboolean [read-only]
manageboolean [read-only]
ownboolean [read-only]
expires_atdatetime [read-only]
is_expiredcomputed [read-only]
is_acceptedboolean [read-only]

List

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

Use example (Python API tool)

resp = client.load('pendinginvitation', load_all=True)
records = resp['pending_invitations']

Use example (MATLAB API tool)

resp = client.load('pendinginvitation', 'load_all', true);
records = resp.pending_invitations;

Response example

{
    "pending_invitations": [
        {
            "id": "<id>",
            "email": "",
            "resource_type": null,
            "invited_to": null,
            "can_change": true,
            "manage": true,
            "own": true,
            "expires_at": "2024-03-22T10:30:00Z",
            "is_expired": null,
            "is_accepted": true
        }
    ],
    "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/users/pendinginvitation/
  • 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('pendinginvitation', data={"email": "<email>"})
record = resp.json()['pending_invitation']

Use example (MATLAB API tool)

created = client.save(struct('email', '<email>'), 'pendinginvitation');
record = created.pending_invitation;

Detail

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

Use example (Python API tool)

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

Use example (MATLAB API tool)

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

Response example

{
    "pending_invitation": {
        "id": "<id>",
        "email": "",
        "resource_type": null,
        "invited_to": null,
        "can_change": true,
        "manage": true,
        "own": true,
        "expires_at": "2024-03-22T10:30:00Z",
        "is_expired": null,
        "is_accepted": true
    }
}

Change

  • Allowed portals: private
  • Request method: PATCH
  • URL: https://www.brainstem.org/api/private/users/pendinginvitation/<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('pendinginvitation', id='<id>', data={"email": "new value"})

Use example (MATLAB API tool)

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

Delete

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

Use example (Python API tool)

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

Use example (MATLAB API tool)

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

Custom actions

ActionRequest
resendPOST /api/private/users/pendinginvitation/<id>/resend/