---
title: "Create Domain User"
url: "https://developer.yukisoftware.com/apis/yuki-platform-api-prod-1/versions/1237fe18-1f8f-477a-8f52-b3546dd409bf/operations/createDomainUser"
---

> Full API specification: https://developer.yukisoftware.com/apis/yuki-platform-api-prod-1/versions/1237fe18-1f8f-477a-8f52-b3546dd409bf.md

# Create Domain User

`POST` `/domains/{domain-id}/users`

Operation ID: `createDomainUser`

This endpoint allows creating a new user for a specific domain. The user can be added with basic information including name, email, language preference, roles, and an optional message. Users attempting to perform this operation need to ensure they possess the necessary permissions. You should have yukiapi:domain:users:write scope to access this endpoint. Returns domains:user_already_exists (409) if a user with the given email already has access to the domain. <!-- authorization:start --> **Authorization** Called with a **Portal User** token - an employee of an accounting portal. The caller must hold at least one of these roles in the portal: `AccountantManagement`, `Accountant`. <!-- authorization:end -->

## Path parameters

- `domain-id` (string, required) - The domain name

## Header parameters

- `Authorization` (string, required) - Bearer token for authentication
- `Content-Type` (string, required) - Content type of the request body

## Request body (required)

Content types: `application/json`

## Responses

- `201` - Domain user successfully created
- `400` - Bad Request
- `401` - Unauthorized
- `403` - Forbidden
- `404` - Not Found
- `409` - Conflict
- `500` - Internal Server Error

## OpenAPI definition

```yaml
openapi: 3.0.0
info:
  title: Yuki Platform API Prod
  version: 1.0.52
servers:
  - url: https://apirest.yukiworks.com/api/v1
paths:
  /domains/{domain-id}/users:
    post:
      x-environments:
        - development
        - pilot
        - production
      x-portal-visibility:
        - internal
        - trusted
        - prod
      x-required-roles:
        - any-of:
            - AccountantManagement
            - Accountant
          scope: portal
      summary: Create Domain User
      description: >-
        This endpoint allows creating a new user for a specific domain. The user
        can be added with basic information including name, email, language
        preference, roles, and an optional message. Users attempting to perform
        this operation need to ensure they possess the necessary permissions.
        You should have yukiapi:domain:users:write scope to access this
        endpoint. Returns domains:user_already_exists (409) if a user with the
        given email already has access to the domain.


        <!-- authorization:start -->


        **Authorization**


        Called with a **Portal User** token - an employee of an accounting
        portal.


        The caller must hold at least one of these roles in the portal:
        `AccountantManagement`, `Accountant`.


        <!-- authorization:end -->
      operationId: createDomainUser
      tags:
        - Domain User
      parameters:
        - $ref: "#/components/parameters/AuthorizationHeader"
        - $ref: "#/components/parameters/ContentTypeHeader"
        - $ref: "#/components/parameters/DomainIdPath"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateDomainUser"
      security:
        - vismaConnectPortalUser:
            - yukiapi:domain:users:write
      responses:
        "201":
          $ref: "#/components/responses/CreateDomainUserResponse"
        "400":
          $ref: "#/components/responses/BadRequestResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedResponse"
        "403":
          $ref: "#/components/responses/ForbiddenResponse"
        "404":
          $ref: "#/components/responses/NotFoundResponse"
        "409":
          $ref: "#/components/responses/ConflictResponse"
        "500":
          $ref: "#/components/responses/InternalServerErrorResponse"
security:
  - vismaConnectPortalUser:
      - yukiapi:domain:users:write
components:
  parameters:
    AuthorizationHeader:
      name: Authorization
      in: header
      required: true
      description: Bearer token for authentication
      schema:
        type: string
    ContentTypeHeader:
      name: Content-Type
      in: header
      required: true
      description: Content type of the request body
      schema:
        type: string
        default: application/json
    DomainIdPath:
      name: domain-id
      in: path
      required: true
      description: The domain name
      example: 3afb7b54-6144-4561-9a29-1148006f2375
      schema:
        type: string
  schemas:
    CreateDomainUser:
      type: object
      properties:
        firstName:
          type: string
          description: First name of the user
        lastName:
          type: string
          description: Last name of the user
        email:
          type: string
          format: email
          description: User email
          example: john.doe@yuki.nl
        language:
          $ref: "#/components/schemas/Language"
        roles:
          $ref: "#/components/schemas/DomainRoles"
        message:
          type: string
          description: Additional message from the user
        companiesIds:
          type: array
          items:
            type: string
            format: uuid
          description: >
            List of company identifiers to grant access to. 

            If not provided or empty, the user will be granted access to all
            companies in the domain.
          example:
            - 123e4567-e89b-12d3-a456-426614174000
            - 987fcdeb-51a2-3bc4-d567-890123456789
      required:
        - firstName
        - lastName
        - email
        - language
        - roles
    Language:
      type: string
      enum:
        - nl-BE
        - en-US
        - fr-BE
        - nl-NL
      description: |
        The locale for the domain. \
        BE: nl-BE, en-US, fr-BE. \
        NL: en-US, nl-NL
      example: en-US
    DomainRoles:
      type: array
      description: User roles for the domain
      items:
        type: string
        enum:
          - Accountant
          - Backoffice
          - BackofficeController
          - FinAdmin
          - HRM
          - Management
          - Procurement
          - Purchase
          - Sales
          - SecurityManager
          - ReadOnlyUser
    BadRequestError:
      allOf:
        - $ref: "#/components/schemas/ProblemDetails"
      example:
        type: https://example.com/errors/bad-request
        title: Bad Request
        status: 400
        detail: The request is invalid or malformed.
        instance: /example/bad-request
    UnauthorizedError:
      allOf:
        - $ref: "#/components/schemas/ProblemDetails"
      example:
        type: https://example.com/errors/unauthorized
        title: Unauthorized
        status: 401
        detail: Authentication is required.
        instance: /example/unauthorized
    ForbiddenError:
      allOf:
        - $ref: "#/components/schemas/ProblemDetails"
      example:
        type: https://example.com/errors/forbidden
        title: Forbidden
        status: 403
        detail: You do not have permission to access this resource.
        instance: /example/forbidden
    NotFoundError:
      allOf:
        - $ref: "#/components/schemas/ProblemDetails"
      example:
        type: https://example.com/errors/not-found
        title: Not Found
        status: 404
        detail: The requested resource could not be found.
        instance: /example/not-found
    ConflictError:
      allOf:
        - $ref: "#/components/schemas/ProblemDetails"
      example:
        type: https://example.com/errors/conflict
        title: Conflict
        status: 409
        detail: The request could not be completed due to a conflict with the current
          state of the resource.
        instance: /example/conflict
    InternalServerError:
      allOf:
        - $ref: "#/components/schemas/ProblemDetails"
      example:
        type: https://example.com/errors/internal-server-error
        title: Internal Server Error
        status: 500
        detail: An unexpected error occurred.
        instance: /example/internal-server-error
    ProblemDetails:
      type: object
      properties:
        type:
          type: string
          example: https://dev.yuki.nl/errors/problem
        title:
          type: string
          example: Problem
        status:
          type: integer
          example: 500
        detail:
          type: string
          example: An unexpected error occurred.
        instance:
          type: string
          example: /example/endpoint
  responses:
    CreateDomainUserResponse:
      description: Domain user successfully created
      content:
        application/json:
          schema:
            type: object
            properties:
              id:
                type: string
                description: The unique identifier of the created domain user
                example: 3afb7b54-6144-4561-9a29-1148006f2375
    BadRequestResponse:
      description: Bad Request
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/BadRequestError"
    UnauthorizedResponse:
      description: Unauthorized
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/UnauthorizedError"
    ForbiddenResponse:
      description: Forbidden
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ForbiddenError"
    NotFoundResponse:
      description: Not Found
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/NotFoundError"
    ConflictResponse:
      description: Conflict
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ConflictError"
    InternalServerErrorResponse:
      description: Internal Server Error
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/InternalServerError"
  securitySchemes:
    vismaConnectPortalUser:
      type: oauth2
      description: >
        Visma Connect token belonging to a **Portal User** - an employee of an
        accounting portal. The token carries a `portal-id` claim, and the portal
        it identifies must match the portal in the route. Unless an endpoint
        says otherwise, the caller's roles are resolved against the portal.
      flows:
        authorizationCode:
          authorizationUrl: https://connect.identity.stagaws.visma.com/connect/authorize
          tokenUrl: https://connect.identity.stagaws.visma.com/connect/token
          scopes:
            yukiapi:domain:companies:read: Allows reading information of a Company
            yukiapi:domain:companies:update: Allows the update of a Company
            yukiapi:portal:portals:read: Allows reading portal information
            yukiapi:domain:domains:read: Allows reading domains information
            yukiapi:domain:domains:write: Allows modifications of domain information, may
              include create/update
            yukiapi:domain:domains:create: Allows the creation of new domains
            yukiapi:domain:domains:update: Allows updating existing domain information
            yukiapi:domain:domains:delete: Allows the deletion of domain data
            yukiapi:domain:users:read: Allows reading of domain user data
            yukiapi:domain:users:write: Allows the update of domain user data, may include create/update
            yukiapi:domain:users:update: Allows updating a Domain User
            yukiapi:domain:users:delete: Allows the deletion of Domain Users
            yukiapi:portal:portals:write: Allows updating existing portal information
            yukiapi:portal:users:read: Allows reading Portal user data
            yukiapi:portal:users:write: Allows the update of Portal user, may include create/update
            yukiapi:portal:users:update: Allows updating an existing Portal User
            yukiapi:portal:users:delete: Allows the deletion of a Portal User
```
