---
title: "Create Domain"
url: "https://developer.yukisoftware.com/apis/yuki-platform-api-prod-1/versions/9cdc452d-fd77-4e06-8797-f61e76134ec9/operations/createDomain"
---

> Full API specification: https://developer.yukisoftware.com/apis/yuki-platform-api-prod-1/versions/9cdc452d-fd77-4e06-8797-f61e76134ec9.md

# Create Domain

`POST` `/portals/{portal-id}/domains`

Operation ID: `createDomain`

This endpoint allows the creation of a new domain. Ensure you have the necessary permissions before attempting to create a domain. You should have the **openid** scope together with one of **yukiapi:domain:domains:create** or **yukiapi:domain:domains:write** to access this endpoint. The portal must be registered as a Yuki Partner and be allowed to create new administrations; otherwise the request is rejected with 403. Returns domains:already_exists (409) if a domain with that name already exists or the name is reserved, domains:validation_failed (400) if the domain cannot be created from the data supplied, or domains:creation_failed (500) if the domain and its default administration could not be created. <!-- 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

- `portal-id` (string, required) - The portal id

## Header parameters

- `Authorization` (string, required) - Bearer token for authentication

## Request body (required)

Content types: `application/json`

## Responses

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

## OpenAPI definition

```yaml
openapi: 3.0.0
info:
  title: Yuki Platform API Prod
  version: 1.0.77
servers:
  - url: https://apirest.yukiworks.be/api/v1
paths:
  /portals/{portal-id}/domains:
    post:
      x-environments:
        - development
        - pilot
        - production
      x-portal-visibility:
        - internal
        - trusted
        - prod
      x-required-roles:
        - any-of:
            - AccountantManagement
            - Accountant
          scope: portal
      summary: Create Domain
      description: >-
        This endpoint allows the creation of a new domain. Ensure you have the
        necessary permissions before attempting to create a domain. You should
        have the **openid** scope together with one of
        **yukiapi:domain:domains:create** or **yukiapi:domain:domains:write** to
        access this endpoint. The portal must be registered as a Yuki Partner
        and be allowed to create new administrations; otherwise the request is
        rejected with 403. Returns domains:already_exists (409) if a domain with
        that name already exists or the name is reserved,
        domains:validation_failed (400) if the domain cannot be created from the
        data supplied, or domains:creation_failed (500) if the domain and its
        default administration could not be created.


        <!-- 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: createDomain
      tags:
        - Domain
      parameters:
        - $ref: "#/components/parameters/AuthorizationHeader"
        - $ref: "#/components/parameters/PortalIdPath"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateDomain"
      security:
        - vismaConnectPortalUser:
            - openid
            - yukiapi:domain:domains:create
        - vismaConnectPortalUser:
            - openid
            - yukiapi:domain:domains:write
      responses:
        "201":
          $ref: "#/components/responses/CreateDomainResponse"
        "400":
          $ref: "#/components/responses/BadRequestResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedResponse"
        "403":
          $ref: "#/components/responses/ForbiddenResponse"
        "409":
          $ref: "#/components/responses/ConflictResponse"
        "500":
          $ref: "#/components/responses/InternalServerErrorResponse"
security:
  - vismaConnectPortalUser:
      - openid
      - yukiapi:domain:domains:create
  - vismaConnectPortalUser:
      - openid
      - yukiapi:domain:domains:write
components:
  parameters:
    AuthorizationHeader:
      name: Authorization
      in: header
      required: true
      description: Bearer token for authentication
      schema:
        type: string
    PortalIdPath:
      name: portal-id
      in: path
      required: true
      description: The portal id
      example: 3afb7b54-6144-4561-9a29-1148006f2375
      schema:
        type: string
  schemas:
    CreateDomain:
      type: object
      properties:
        name:
          type: string
          description: The domain name. Only lowercase letters, numbers and dashes are
            allowed, and it must start with a letter or number.
          example: my-company-name
        status:
          $ref: "#/components/schemas/DomainStatusCreate"
        bundle:
          $ref: "#/components/schemas/DomainBundle"
        language:
          $ref: "#/components/schemas/Language"
        company:
          $ref: "#/components/schemas/CreateCompany"
        createCustomerUser:
          type: boolean
          description: "Whether to also create a user account for the customer. When true,
            the customer (customerName/customerEmail) is invited as the first
            user of the domain: an invitation email is sent and, once accepted,
            the customer can log in with management permissions. When false, no
            user account is created and no email is sent. In both cases the
            customer is registered as the main contact person of the company
            created together with the domain."
          example: true
        customerName:
          type: string
          description: "The full name of the customer. Always required, regardless of
            createCustomerUser: together with customerEmail it identifies the
            main contact person of the company created together with the
            domain."
          example: John Doe
        customerEmail:
          type: string
          format: email
          description: "The email address of the customer. Always required, regardless of
            createCustomerUser: it is stored on the main contact person of the
            company created together with the domain and, when
            createCustomerUser is true, it is also used to send the invitation
            email."
          example: john.doe@yuki.nl
        backoffice:
          $ref: "#/components/schemas/BackOffice"
      required:
        - name
        - status
        - bundle
        - language
        - company
        - createCustomerUser
        - customerName
        - customerEmail
      title: CreateDomain
      description: Schema for creating a new domain.
    DomainStatusCreate:
      type: string
      enum:
        - Startup
        - Active
      description: The status of the domain for creation purposes.
      example: Active
    DomainBundle:
      type: string
      enum:
        - Minimal
        - Small
        - Medium
        - Large
        - Unlimited
      description: The bundle type for the domain.
      example: Medium
    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
    CreateCompany:
      type: object
      properties:
        name:
          type: string
          description: The name of the company.
          example: Example Corp
        address:
          $ref: "#/components/schemas/ContactAddress"
        mailingAddress:
          $ref: "#/components/schemas/ContactAddress"
        details:
          $ref: "#/components/schemas/CreateDomainCompanyDetails"
        legalForm:
          $ref: "#/components/schemas/LegalForm"
        internalCustomerCode:
          type: string
          description: The internal code that a company is defined with by the user.
          example: CUST-001
        financials:
          $ref: "#/components/schemas/DomainCompanyFinancials"
        taxInformation:
          $ref: "#/components/schemas/CompanyTaxInformation"
      required:
        - name
        - details
      description: Company information object.
    BackOffice:
      type: object
      description: Back office configuration settings.
      required:
        - access
      properties:
        access:
          type: string
          enum:
            - AllEmployees
            - EmployeesBODomain
            - AllEmployeesSupport
            - EmployeesBODomainSupport
          description: >
            Access level for the back office. Determines who can access the back
            office. Possible values: - AllEmployees: All employees have access.
            - EmployeesBODomain: Only employees of the BO domain have access. -
            AllEmployeesSupport: All employees have access, including support. -
            EmployeesBODomainSupport: Only employees of the BO domain and
            support have access.
          example: AllEmployees
        responsible:
          type: string
          nullable: true
          description: >
            BO Responsible user ID.

            If value is filled it will be updated, if empty string it will be
            disassociated, and if null no value will be created.
          example: user123
        backup:
          type: string
          nullable: true
          description: >
            BO Backup user ID.

            If value is filled it will be updated, if empty string it will be
            disassociated, and if null no value will be created.
          example: user456
        controller:
          type: string
          nullable: true
          description: >
            BO Controller user ID.

            If value is filled it will be updated, if empty string it will be
            disassociated, and if null no value will be created.
          example: user789
        accountManager:
          type: string
          nullable: true
          description: >
            BO Account manager user ID.

            If value is filled it will be updated, if empty string it will be
            disassociated, and if null no value will be created.
          example: user012
    BadRequestError:
      description: A 400 comes in two shapes that differ by title. A request that
        fails model binding never reaches the operation and carries the title
        below, with errors keyed by the rejected field. A request the operation
        itself rejects carries the title Validation Error, with errors keyed by
        the rejected field for a field check, or by the errorCode for a business
        rule. Both shapes carry errorCode, traceId and errors.
      allOf:
        - $ref: "#/components/schemas/ProblemDetails"
      example:
        type: https://httpstatuses.com/400
        title: One or more validation errors occurred.
        status: 400
        detail: The request contains invalid or malformed fields. See the errors
          property for details.
        instance: /example/bad-request
        traceId: 4bf92f3577b34da6a3ce929d0e0e4736
        errorCode: validation:invalid_input
        errors:
          country:
            - The country field is required.
    UnauthorizedError:
      allOf:
        - $ref: "#/components/schemas/ProblemDetails"
      example:
        type: https://httpstatuses.com/401
        title: Unauthorized
        status: 401
        detail: Authentication is required.
        instance: /example/unauthorized
        traceId: 4bf92f3577b34da6a3ce929d0e0e4736
        errorCode: authentication:unauthorized
    ForbiddenError:
      allOf:
        - $ref: "#/components/schemas/ProblemDetails"
      example:
        type: https://httpstatuses.com/403
        title: Forbidden
        status: 403
        detail: You do not have permission to access this resource.
        instance: /example/forbidden
        traceId: 4bf92f3577b34da6a3ce929d0e0e4736
        errorCode: authentication:forbidden
        errors:
          authentication:forbidden:
            - You do not have permission to access this resource.
    ConflictError:
      allOf:
        - $ref: "#/components/schemas/ProblemDetails"
      example:
        type: https://httpstatuses.com/409
        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
        traceId: 4bf92f3577b34da6a3ce929d0e0e4736
        errorCode: domains:user_already_exists
        errors:
          domains:user_already_exists:
            - The request could not be completed due to a conflict with the
              current state of the resource.
    InternalServerError:
      allOf:
        - $ref: "#/components/schemas/ProblemDetails"
      example:
        type: https://httpstatuses.com/500
        title: Internal Server Error
        status: 500
        detail: An unexpected error occurred.
        instance: /example/internal-server-error
        traceId: 4bf92f3577b34da6a3ce929d0e0e4736
        errorCode: server:internal_error
        errors:
          server:internal_error:
            - An unexpected error occurred.
    ContactAddress:
      type: object
      properties:
        address:
          type: string
          description: Street name and number.
          example: Main Street 123
        address2:
          type: string
          description: Additional address information.
          example: Suite 456
        postalCode:
          type: string
          description: Postal code.
          example: 1234AB
        city:
          type: string
          description: City name.
          example: Amsterdam
      required:
        - address
        - postalCode
        - city
      description: Address information object.
    CreateDomainCompanyDetails:
      type: object
      properties:
        cocNumber:
          type: string
          description: The legal identifier of the company.
          example: BE0123456789
        country:
          type: string
          description: Country ISO code. Must match the country of the portal in which the
            domain is created.
          example: NL
      required:
        - country
      description: Company details information object.
    LegalForm:
      type: string
      enum:
        - Unknown
        - SolePartnership
        - PrivateLimited
        - PublicLimited
        - GeneralPartnership
        - LimitedPartnership
        - Partnership
        - Association
        - Foundation
        - Cooperative
      description: >
        Legal form of the company. \

        BE: Unknown, SolePartnership, PrivateLimited, PublicLimited,
        GeneralPartnership, LimitedPartnership, Partnership, Association,
        Foundation, Cooperative. \

        NL: values to be added later
      example: PrivateLimited
    DomainCompanyFinancials:
      type: object
      properties:
        pettyCash:
          $ref: "#/components/schemas/PettyCashOption"
        financialYearFollowsCalendarMonths:
          type: boolean
          description: Whether the financial year follows calendar months.
          example: true
        yukiStartKeepingFinancialRecordsYear:
          type: string
          description: The year when Yuki started keeping financial records.
          example: "2023"
        yukiStartKeepingFinancialRecordsDate:
          type: string
          format: date-time
          description: The date when Yuki started keeping financial records.
          example: 2023-01-01T00:00:00Z
      description: Financial object containing financial-related settings.
    CompanyTaxInformation:
      type: object
      properties:
        vatLiable:
          type: boolean
          description: Whether the company is VAT liable.
          example: true
        vatNumber:
          type: string
          description: VAT number. Must be a valid VAT number for the company's country
            (details.country), including its country prefix; the request is
            rejected with 400 domains:validation_failed otherwise. The value is
            normalised to the national notation before it is stored, so the
            number returned by Get Company can differ from the one supplied here
            (for example BE0531247818 is returned as BE0531.247.818).
          example: NL123456782B01
        showVatReturn:
          type: boolean
          description: Whether to show VAT return.
          example: true
        autoICPDeclaration:
          type: boolean
          description: Whether to automatically generate ICP declaration.
          example: false
      description: Company tax information object.
    ProblemDetails:
      type: object
      description: Error body returned as application/problem+json on every 4xx and
        5xx response. Beyond the standard problem members it carries the
        traceId, errorCode and errors extensions.
      properties:
        type:
          type: string
          description: URI reference identifying the problem type. Always
            https://httpstatuses.com/{status}, so it restates the status and
            carries no Yuki-specific meaning; branch on errorCode instead.
          example: https://httpstatuses.com/400
        title:
          type: string
          description: Short, human-readable summary of the problem type, in English.
          example: Validation Error
        status:
          type: integer
          description: HTTP status code, repeated from the response status line.
          example: 400
        detail:
          type: string
          description: Human-readable explanation of this specific occurrence. Free text
            meant for developers, not a stable contract - do not parse it.
          example: The company id is required.
        instance:
          type: string
          description: Optional. Path of the request as the API received it. The gateway
            fronts the API, so it is not always populated and it may differ from
            the URL the client called.
          example: /api/v1/companies/3afb7b54-6144-4561-9a29-1148006f2375
        traceId:
          type: string
          description: Correlation id for the request - the 32-character hexadecimal W3C
            trace id taken from the incoming traceparent header, or a locally
            generated id when none was propagated. Quote it in support requests.
          example: 4bf92f3577b34da6a3ce929d0e0e4736
        errorCode:
          type: string
          description: Stable machine-readable error identifier in {feature}:{error_type}
            form. This is the member to branch on, together with the status -
            not the feature prefix on its own. A request refused before it
            reaches the operation can answer 403 with validation:invalid_input,
            and an operation that fails on an unexpected internal state can
            answer 500 with that same code.
          example: companies:not_found
        errors:
          type: object
          description: Messages that explain the failure, grouped by key. Present on the
            errors raised while the request is being handled, not only on
            validation failures. It is absent from the errors that stop a
            request before it reaches the operation - the 401 for a missing or
            unaccepted token, the 403 for an absent scope or an unusable tenant
            claim, and the 500 for a session that could not be created - which
            carry only traceId and errorCode. Keys take one of two shapes - the
            name of the rejected field when the request failed model binding or
            field validation, otherwise the errorCode of the failure, repeating
            the errorCode member.
          additionalProperties:
            type: array
            items:
              type: string
          example:
            companies:validation_failed:
              - The company id is required.
    PettyCashOption:
      type: string
      nullable: true
      enum:
        - Unknown
        - Regularly
        - Petty
        - None
      description: |
        Cash usage option: Unknown, Regularly, Petty, None
      example: Regularly
  responses:
    CreateDomainResponse:
      description: Domain successfully created
      content:
        application/json:
          schema:
            type: object
            properties:
              id:
                type: string
                description: The unique identifier of the created domain
                example: 3afb7b54-6144-4561-9a29-1148006f2375
              companyId:
                type: string
                description: The unique identifier of the company created together with the
                  domain
                example: 8c2e0d11-4b7a-4f3e-9d02-5a6f31c9e842
    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"
    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's tenant must be a portal; the API resolves
        it to the caller's portal. The portal in the route must be that portal
        or one of the caller's master-accountant portals. 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:
            openid: Required on every request, together with the endpoint API scope
            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 creation of Domain Users
            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
```
