> ## Documentation Index
> Fetch the complete documentation index at: https://docs.base39.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Membership in the Selected Organization



## OpenAPI

````yaml /api-reference/openapi.json patch /v2/memberships/{userId}
openapi: 3.1.0
info:
  title: Base39 API
  description: Base39 API
  version: 1.0.0
  contact:
    name: Base39 Team
    url: https://base39.com.br
    email: suporte@base39.com.br
  termsOfService: https://base39.com.br/termos
  license:
    name: Proprietary
    url: https://base39.com.br/termos
servers:
  - url: https://api.base39.com.br
    description: Production
  - url: https://api.dev.base39.cloud
    description: Development
  - url: http://localhost:3000
    description: Local
security:
  - OAuth2: []
tags:
  - name: Search
  - name: Companies
  - name: Registration
  - name: Addresses
  - name: Relationships
  - name: Queries
  - name: Credit & Financial
  - name: Checks
  - name: Protests
  - name: Government Debt
  - name: Litigation & Bankruptcy
  - name: Compliance
  - name: Certificates
  - name: Restrictions
  - name: SCR
  - name: Reputation
  - name: Social Assistance
  - name: History
  - name: Graph
  - name: Files
  - name: Rules
  - name: Monitoring
  - name: Scorecards
  - name: Feature Store
  - name: Mentions
  - name: Views
  - name: Skills
  - name: Custom Tools
  - name: Connections
  - name: Connectors
  - name: OAuth Integrations
  - name: WhatsApp
  - name: Upstreams
  - name: Billing
  - name: Usage
  - name: Organizations
  - name: Members
  - name: Users
  - name: Authentication
  - name: API Keys
  - name: Notifications
  - name: Changelog
  - name: Webhooks
  - name: Vaults
  - name: Version
  - name: Context Schema
paths:
  /v2/memberships/{userId}:
    patch:
      tags:
        - Members
      summary: Update Membership in the Selected Organization
      operationId: memberships_update
      parameters:
        - name: userId
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateOrgMembershipInput'
      responses:
        '200':
          description: Selected organization membership updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrgMembershipOutput'
        '401':
          description: Unauthorized
        '403':
          description: Forbidden - Requires admin role
        '404':
          description: Membership not found
components:
  schemas:
    UpdateOrgMembershipInput:
      type: object
      properties:
        role:
          type: string
          description: User role in the organization
          enum:
            - admin
            - editor
            - viewer
            - operator
            - restricted
        status:
          type: string
          description: User membership status in the organization
          enum:
            - active
            - disabled
    OrgMembershipOutput:
      type: object
      properties:
        userId:
          type: string
        orgId:
          type: string
        role:
          type: string
          description: Role of the user in this organization (admin, editor, viewer)
        status:
          type: string
          enum:
            - active
            - waiting_approval
            - disabled
        createdAt:
          type: string
          format: date-time
        lastActivityAt:
          type: string
          format: date-time
          nullable: true
        user:
          $ref: '#/components/schemas/OrgMembershipUserOutput'
      required:
        - userId
        - orgId
        - role
        - status
        - createdAt
        - lastActivityAt
        - user
    OrgMembershipUserOutput:
      type: object
      properties:
        id:
          type: string
        email:
          type: object
          nullable: true
        firstName:
          type: string
          nullable: true
        lastName:
          type: string
          nullable: true
        name:
          type: string
          nullable: true
        picture:
          type: string
          nullable: true
        lastLoginAt:
          type: string
          format: date-time
          nullable: true
        super:
          type: boolean
      required:
        - id
        - email
        - super
  securitySchemes:
    OAuth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://id.local.base39.cloud/oauth2/authorize
          tokenUrl: https://id.local.base39.cloud/oauth2/token
          scopes:
            profile: Read user profile
            email: Read user email
            openid: OpenID authentication
      description: OAuth2 Authorization Code flow

````