nsindocs Search the docs⌘K
  1. Docs
  2. API reference
  3. Sharing

Change a member's role or notifications

patchhttps://api.nsin.ir/domains/{domain}/members/{userId}

Auth: Authorization: Bearer nsin_… or X-Api-Key: nsin_… — see API keys.

Partial update. Changing role requires members.manage; a member may change their own notification preferences without it.

The owner's role cannot be changed, and the owner always receives every notification category.

A role change freezes whatever the OLD role was switching on, so a demotion cannot silently mute alerts the member was already receiving. Categories they never touched still follow the new role.

Path parameters

  • domainstringrequiredpath

    The domain name (for example example.com) — not a numeric id.

  • userIdintegerrequiredpath

    The member's user id, from the member list.

Request body

Content type: application/json · required

  • rolestring

    A role that may be assigned to a member or invitation. owner is not grantable — it always follows domain ownership.

    One of: "admin" "editor" "viewer"
  • notifyobject

    Category → channel → tri-state. true/false records an explicit choice; null deletes the stored choice so the pair falls back to the member's role default — that is how you reset a switch rather than pinning it off. Unknown categories or channels are rejected, so a typo can never read as "no change made".

Responses

200The membership after the change.

Content type: application/json

  • idinteger

    Membership id.

  • domain_idinteger
  • user_idinteger
  • rolestring

    Your role on a domain. owner is implicit for the domain's creator and for global admins; the other three are grantable via sharing.

    One of: "owner" "admin" "editor" "viewer"
  • notifyNotifyMatrix

    Category → channel → enabled. The effective matrix: explicit choices merged over the member's role defaults, so a client never has to reimplement the fallback.

  • notify_defaultedobject
json
{
  "id": 0,
  "domain_id": 0,
  "user_id": 0,
  "role": "owner",
  "notify": {},
  "notify_defaulted": {}
}
400Invalid user id or body, nothing to update, an invalid role, or an attempt to change the owner's role or notifications.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "read-only API key"
}
401Missing, malformed, revoked or expired API key. (A valid key whose account has been deactivated gets 403 account is inactive instead.)

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "invalid API key"
}
403The key is read-only, your role on the domain lacks the required permission, or the domain's plan does not include the feature.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "read-only API key"
}
404Domain or member not found.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "read-only API key"
}
429The key exceeded its request budget (300 requests per minute by default).

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "rate limit exceeded"
}

Example request

bash
curl -X PATCH "https://api.nsin.ir/domains/example.com/members/0" \
  -H "Authorization: Bearer $NSIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "role": "admin",
  "notify": {}
}'
esc