Skip to content

API Member ​

Create (or register), read, update and delete members, and change a password. Part of the Webservice module since v10.0.0, before it was a separate package

WARNING

Since v10.0.0 the Member API is part of the module. The separate Webservice Member API and Webservice Member Tools API packages are no longer needed and no longer work: remove system/user/addons/reinos_webservice_member_api (or webservice_member_api) and webservice_member_tools_api after updating. The data, the permissions and the responses changed, see below (Breaking change). Forgot password and resend activation (the Member Tools API) are part of the Auth API.

Enable the API ​

The Member API is off by default. Enable it with Member API in the API settings, then enable the API for a member on the member page. The setting also enables forgot password, reset password and resend activation of the Auth API.

The Member API follows the rules of the member registration and the profile form of ExpressionEngine, but it is an implementation of the Webservice module. After updating ExpressionEngine, check that it still works as you expect.

Endpoints ​

MethodURLEndpoint
POST/webservice/membercreate_member
GET/webservice/memberread_member
PUT / PATCH/webservice/memberupdate_member
PUT/webservice/member/passwordupdate_member_password
DELETE/webservice/memberdelete_member

Enable the API for a member on the member page. The data is given in a data object, see default parameters.

Permissions ​

The ExpressionEngine permissions of the member apply:

EndpointYourselfAnother member
create_member-Create members. Without it, it is a registration (see below)
read_memberAlways, without dataAccess members
update_memberAlways, the email and username need your current_passwordEdit members
update_member_passwordWith your current_passwordEdit members
delete_memberNot possibleDelete members

A Super Admin can only be changed or deleted by a Super Admin, and the last Super Admin cannot be deleted. Nobody can change their own role.

create_member ​

NameDescription
usernameThe usernameRequired
emailThe email addressRequired
passwordThe password, it must match the password rules of ExpressionEngineRequired
password_confirmWhen given, it must match the passwordOptional
screen_nameThe screen name, default the usernameOptional
role_idThe primary role, only with the permission Create members. Default: the default role of the member settings. A locked role (e.g. Super Admin) only by a Super AdminOptional
bio, language, timezone, date_format, time_format, include_secondsThe profile settingsOptional
custom fieldsThe custom member fields by short name (or m_field_id_1)Optional
accept_termsRequired for a registration when Require terms of service is onOptional

Registration ​

Without the permission Create members (e.g. a visitor without credentials), create_member is a registration with the rules of the member registration of ExpressionEngine:

  • Allow members to register must be on, banned or blocked visitors cannot register;
  • the member gets the default role, role_id is ignored;
  • with Require member account activation the member is pending and gets the activation email (email) or has to be activated by an administrator (manual);
  • only the custom fields that are shown on the registration form are saved;
  • the administrators get the notification of a new member when that is on;
  • the hooks of ExpressionEngine are called: member_member_register_start, member_member_register_errors and member_member_register.

To let visitors register via the API, make the member/create_member endpoint public. It is not public by default: the API has no captcha, so the rate limiting is the only protection against spam registrations.

bash
curl -X POST 'https://your-domain.com/index.php/webservice/member' \
  -H 'Authorization: Bearer <shortkey>' \
  -H 'Content-Type: application/json' \
  -d '{"data":{"username":"john","email":"john@example.com","password":"a-strong-password","role_id":5}}'

read_member ​

Without data your own profile is returned. With a filter, other members are returned (permission Access members).

NameDescription
member_idOne or more member ids, an array or comma separatedOptional
role_idOne or more role idsOptional
username, email, screen_nameAn exact matchOptional
orderbymember_id (default), username, screen_name, email, join_date or last_visitOptional
sortasc (default) or descOptional
limit, offsetPaging, default 25, maximum 100Optional

Every member has member_id, username, screen_name, role_id, role_ids (all roles), join_date, last_visit, total_entries, total_comments, avatar_url, the profile settings and the custom fields. The email, pending_role_id and the custom fields that are not public are only returned for yourself or with Access members. The password, salt and codes are never returned.

update_member ​

NameDescription
member_idThe member, empty is yourselfOptional
screen_name, bio, language, timezone, date_format, time_format, include_secondsThe profile settingsOptional
emailThe new email address. For yourself the current_password is neededOptional
usernameThe new username. For yourself only when Allow members to change their username is on, with the current_passwordOptional
current_passwordYour current password, to change your own email or usernameOptional
role_idThe primary role of another memberOptional
custom fieldsBy short name. For yourself only the public fields, like the profile form of ExpressionEngineOptional

Only the given data is changed.

update_member_password ​

NameDescription
member_idThe member, empty is yourselfOptional
current_passwordYour current password, required for your own passwordOptional
passwordThe new passwordRequired
password_confirmWhen given, it must match the passwordOptional

The other sessions of the member are ended.

delete_member ​

NameDescription
member_idThe memberRequired
heir_idThe member that gets the entries and files, required when the member has entries (like in the CP)Optional

Errors ​

HTTP statusDescription
401Not logged in (e.g. reading your own profile without credentials)
403No permission, registration not allowed, your own role, yourself or a Super Admin
404The member does not exist
422The data is not valid, errors has a message per field, e.g. {"username": "This field must be unique."}

Hooks ​

webservice_create_member_start, webservice_create_member_end (member_id), webservice_read_member_end (the members, the return value replaces them), webservice_update_member_end (member_id), webservice_update_member_password_end (member_id) and webservice_delete_member_end (member_id). A registration also calls the hooks of ExpressionEngine, see above.

Changes in v10.0.0 ​

  • Part of the module, REST endpoints with the HTTP methods above. search_member is part of read_member.
  • The permissions of ExpressionEngine are checked.
  • group_id is replaced by role_id (roles since ExpressionEngine 6).
  • A registration follows the rules of ExpressionEngine (activation, default role, notifications).
  • Deleting a member with entries needs a heir_id.
  • Validation errors return a 422 with the errors per field.