# Create a membership

POST https://api.close.com/api/v1/membership/
Content-Type: application/json

Ensures an active membership for the given email will be provisioned.

- If the user already exists, they will be added to the requestor's organization.
- If it doesn't exist, a new user will be provisioned.

`role_id` can be one of `'admin'`, `'superuser'`, `'user'` or `'restricteduser'` for the corresponding predefined role, or an ID of a [Role](/resources/roles/).

This request requires "Manage Organization" permissions.

API access to this endpoint is supported via OAuth only.

Reference: https://developer.close.com/api/resources/memberships/create

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Close API
  version: 1.0.0
paths:
  /membership/:
    post:
      operationId: create
      summary: Create a membership
      description: >-
        Ensures an active membership for the given email will be provisioned.


        - If the user already exists, they will be added to the requestor's
        organization.

        - If it doesn't exist, a new user will be provisioned.


        `role_id` can be one of `'admin'`, `'superuser'`, `'user'` or
        `'restricteduser'` for the corresponding predefined role, or an ID of a
        [Role](/resources/roles/).


        This request requires "Manage Organization" permissions.


        API access to this endpoint is supported via OAuth only.
      tags:
        - subpackage_memberships
      parameters:
        - name: Authorization
          in: header
          description: Basic authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/memberships_create_Response_200'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                description: Any type
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                description: Any type
        '404':
          description: Not found
          content:
            application/json:
              schema:
                description: Any type
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateMembership'
servers:
  - url: https://api.close.com/api/v1
components:
  schemas:
    CreateMembership:
      type: object
      properties:
        email:
          type: string
          format: email
        role_id:
          type: string
      required:
        - email
        - role_id
      title: CreateMembership
    memberships_create_Response_200:
      type: object
      properties: {}
      description: Empty response body
      title: memberships_create_Response_200
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: basic
    OAuth2:
      type: http
      scheme: bearer

```