POST /api/groups/:group_id/memberships/add_members

add or invite one or more members to a group (group admin privilege required)

Success Response Code: 201

Params

Param name Description
group_id
required

id / name of group


Value: Must be a String
group_memberships
optional

Value: Must be an Array of nested elements
group_memberships[user_id]
optional

user id to add to the group (required if email is not provided)


Value: Must be a Integer
group_memberships[email]
optional

email address of the user to add to the group (required if user_id is not provided; supersedes user_id)


Value: Must be a String
group_memberships[role]
optional

user's role in the group


Value: Must be one of: <code>admin</code>, <code>member</code>.
group_memberships[invite]
optional

create invite for email address if the user is not already a community member (requires email)


Value: Must be one of: <code>true</code>, <code>false</code>.

Response Fields

group_memberships array of group memberships Array<GroupMembership>
group_membership[id] group membership object id or null if not created Integer
group_membership[user_id] user id for the member Integer
group_membership[role] user's role ["Admin", "Member", "External Contributor"]
group_membership[role_key] key value of user's role ["admin", "member"]
group_membership[errors] errors for requested group membership or invite Array<String>
group_membership[invite] email address of group invite, if invite attempted String

Example Curl Commands

curl -X POST -v --basic -u "emily@socialcast.com:demo" https://demo.socialcast.com/api/groups/hrteam/memberships/add_members.json -H"Content-Type: application/json" -d'{"group_memberships":[{"user_id":21,"role":"member"},{"user_id":22,"role":"admin"}]}'
curl -X POST -v --basic -u "emily@socialcast.com:demo" https://demo.socialcast.com/api/groups/hrteam/memberships/add_members.json -H"Content-Type: application/json" -d'{"group_memberships":[{"email":"amanda@socialcast.com","role":"member"},{"user_id":22,"role":"admin"}]}'
curl -X POST -v --basic -u "emily@socialcast.com:demo" https://demo.socialcast.com/api/groups/hrteam/memberships/add_members.json -H"Content-Type: application/json" -d'{"group_memberships":[{"email":"newuser@socialcast.com","role":"member","invite":true},{"user_id":22,"role":"admin"}]}'

Examples

POST 
{
  "group_memberships": [
    {
      "role": "Member",
      "user_id": "31"
    }
  ]
}
201
{
  "group_memberships": [
    {
      "id": 38,
      "user_id": 31,
      "role": "Member",
      "role_key": "member"
    }
  ]
}
POST 
{
  "group_memberships": [
    {
      "role": "Member",
      "user_id": "31"
    },
    {
      "role": "Admin",
      "user_id": "33"
    }
  ]
}
201
{
  "group_memberships": [
    {
      "id": 39,
      "user_id": 31,
      "role": "Member",
      "role_key": "member"
    },
    {
      "id": 40,
      "user_id": 33,
      "role": "Admin",
      "role_key": "admin"
    }
  ]
}