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

# Assign User

> Assigns a user to a given project. The user must be an existing user in Voucherify.

> 🚧 Correct Use of Data
>
>To avoid errors, use the `"role"` key with either `"id"` or `"login"` keys.



## OpenAPI

````yaml /openapi/management.json post /management/v1/projects/{projectId}/users
openapi: 3.0.1
info:
  title: Voucherify API - Management
  version: v2018-08-01
  description: >-
    Voucherify promotion engine REST API. Please see
    https://docs.voucherify.io/docs for more details.
  contact:
    name: Voucherify Team
    url: https://www.voucherify.io/contact-support
    email: support@voucherify.io
  termsOfService: https://www.voucherify.io/legal/subscription-agreement
  license:
    name: MIT
    url: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/LICENSE
servers:
  - url: https://{cluster}.voucherify.io
    description: Base URL
    variables:
      cluster:
        default: api
        enum:
          - api
          - us1.api
          - as1.api
          - download
          - us1.download
          - as1.download
security: []
paths:
  /management/v1/projects/{projectId}/users:
    parameters:
      - schema:
          $ref: '#/components/schemas/ParameterProjectId'
        in: path
        name: projectId
        description: Provide the unique identifier of the project.
        required: true
    post:
      tags:
        - Management
      summary: Assign User
      description: >-
        Assigns a user to a given project. The user must be an existing user in
        Voucherify.


        > 🚧 Correct Use of Data

        >

        >To avoid errors, use the `"role"` key with either `"id"` or `"login"`
        keys.
      operationId: assign-user
      parameters: []
      requestBody:
        description: Defines the user details.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ManagementProjectsUsersAssignRequestBody'
        required: true
      responses:
        '200':
          description: Returns the details about the user assigned to the project.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagementProjectsUsersAssignResponseBody'
              examples:
                Example:
                  value:
                    id: user_FgEAjOV6RiObJdy36sYynXdqZNiA5gjM
                    login: name@youremaildomain.com
                    email: name@youremaildomain.com
                    first_name: Sammy
                    last_name: Jones
                    projects:
                      proj_9KeAhZB1: USER
                      proj_npnFzPr9: USER
                      proj_pEP3NO9s: USER
                      proj_zsPdrUIw: ADMIN
                    is_owner: false
        '400':
          description: >-
            Returns an error if the payload includes all three keys or the
            required data is missing.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/e_400_invalid_payload'
              examples:
                Invalid payload:
                  value:
                    code: 400
                    key: invalid_payload
                    message: Invalid payload
                    details: Payload must have required property 'name'
                    request_id: v-0e9389ccac8da56f55
        '401':
          description: Returns an error if an invalid token was provided.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Unauthorized:
                  value:
                    code: 401
                    message: Unauthorized
                    key: unauthorized
        '402':
          description: >-
            Returns an error if the current plan does not include the Management
            API feature.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorPaymentRequired'
              examples:
                Example:
                  value:
                    code: 402
                    message: Payment required
                    details: >-
                      Your current plan does not include a feature required to
                      perform this operation.
                    key: missing_required_feature
      security:
        - X-Management-Id: []
          X-Management-Token: []
components:
  schemas:
    ParameterProjectId:
      type: string
      example: proj_TrlkLiH4
    ManagementProjectsUsersAssignRequestBody:
      type: object
      title: Management Projects User Assign Request Body
      properties:
        id:
          type: string
          description: >-
            The unique identifier of the user who will be assigned to the
            project. It can be found in Team Settings > Team > Edit member.
            **Required** with the `role` string.


            Do **not** use with the `login` string.
        login:
          type: string
          description: >-
            The login data of the user who will be assigned to the project.
            **Required** with the `role` string.


            Do **not** use with the `id` string.
        role:
          type: string
          description: >-
            The role of the user to be added. It can be one of the following
            predefined roles:

            `ADMIN`, `USER`, `VIEWER`, `MERCHANT`,

            or an ID of a custom role.
      required:
        - role
    ManagementProjectsUsersAssignResponseBody:
      type: object
      title: Management Projects Users Create Response Body
      description: Details about the user assigned to the project.
      allOf:
        - $ref: '#/components/schemas/User'
    e_400_invalid_payload:
      title: Invalid Payload
      type: object
      description: 'Error: Bad Request &rarr; Invalid Payload'
      properties:
        code:
          type: integer
          default: 400
          description: Error's HTTP status code.
        key:
          type: string
          default: invalid_payload
          description: Short string describing the kind of error which occurred.
        message:
          type: string
          default: Invalid payload
          description: A human-readable message providing a short description of the error.
        details:
          type: string
          description: A human-readable message providing more details about the error.
        request_id:
          type: string
          example: v-0a884c6be8c3756f42
          description: >-
            This ID is useful when troubleshooting and/or finding the root cause
            of an error response by our support team.
    Error:
      title: Error Object
      type: object
      description: Error details
      properties:
        code:
          type: integer
          description: Error's HTTP status code.
        key:
          type: string
          description: Short string describing the kind of error which occurred.
        message:
          type: string
          description: A human-readable message providing a short description of the error.
        details:
          type: string
          description: A human-readable message providing more details about the error.
        request_id:
          type: string
          example: v-0a885062c80375740f
          description: >-
            This ID is useful when troubleshooting and/or finding the root cause
            of an error response by our support team.
        resource_id:
          type: string
          description: >-
            Unique resource ID that can be used in another endpoint to get more
            details.
          example: rf_0c5d710a87c8a31f86
        resource_type:
          type: string
          description: The resource type.
          example: voucher
        error:
          type: object
          description: Includes additional information about the error.
          properties:
            message:
              type: string
              description: The message configured by the user in a validation rule.
      required:
        - code
        - message
    ErrorPaymentRequired:
      title: Payment Required Error
      type: object
      description: 'Error: Payment required - the current plan does not include the feature.'
      properties:
        code:
          type: integer
          description: Error's HTTP status code.
        message:
          type: string
          description: A human-readable message providing a short description of the error.
        details:
          type: string
          description: A human-readable message providing more details about the error.
        key:
          type: string
          description: Short string describing the kind of error which occurred.
      required:
        - code
        - message
        - details
        - key
    User:
      type: object
      title: User
      description: Details about the user.
      properties:
        id:
          type: string
          description: >-
            The unique identifier of the user who has been assigned to the
            project.
        login:
          type: string
          description: The login data of the user who has been assigned to the project.
        email:
          type: string
          description: The email address of the user who has been assigned to the project.
        first_name:
          type: string
          description: The first name of the user who has been assigned to the project.
        last_name:
          type: string
          description: The last name of the user who has been assigned to the project.
        projects:
          type: object
          description: >-
            Lists key-value pairs, where the key is the project to which the
            user is assigned. The value is the role assigned in a given project.
            The predefined Voucherify roles are: `ADMIN`, `USER`, `VIEWER`,
            `MERCHANT`, `USER_RESTRICTED` (for the Areas and Stores, an
            Enterprise feature).
          additionalProperties:
            type: string
            description: Returns the role the user has in the project.
        is_owner:
          type: boolean
          description: >-
            Determines if the user is the owner for the organization in
            Voucherify.
      required:
        - id
        - login
        - email
        - first_name
        - last_name
        - projects
        - role
        - is_owner
  securitySchemes:
    X-Management-Id:
      type: apiKey
      name: X-Management-Id
      in: header
    X-Management-Token:
      type: apiKey
      name: X-Management-Token
      in: header

````