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

# Create product price

> Adds a new price/discount row to the product.

`PriceType`, `Price`, `CurrencyId`, `StartDate` and `EndDate` are required.

| `PriceType` | Meaning  |
| ----------- | -------- |
| `1`         | Purchase |
| `2`         | Sales    |

* `Price` must be greater than 0 (`2302`).
* `Discount` is a percentage or a fixed amount depending on `IsDiscountPercentage` (default `true`); it cannot be negative (`2303`), and as a percentage it cannot exceed 100 (`2304`).
* `EndDate` must be after `StartDate` (`2306`).
* `UnitId` is required and must be one of the product's own units: its main unit (`UnitId`) or, if the product has a second/third unit, one of those. Any other unit in the company, or a unit that does not belong to the product, is rejected (`2309`).
* `IncludesVat` says whether `Price` includes VAT.

## Scope

A price row has at most **one** scope; if none are sent, it is a general price open to everyone.

| Scope                          | How to send it                                                                                   |
| ------------------------------ | ------------------------------------------------------------------------------------------------ |
| General                        | `CustomerId`, `CustomerGroupId`, `CustomerGroupDetailId` all empty                               |
| A single customer              | Only `CustomerId`                                                                                |
| An entire customer group       | Only `CustomerGroupId` (an ID from [customer groups](/en/v1/customers/definitions/groups))       |
| One detail of a customer group | `CustomerGroupId` **and** `CustomerGroupDetailId` together; the detail must belong to that group |

* `CustomerId` cannot be combined with either group field (`2314`).
* `CustomerGroupDetailId` cannot be sent without `CustomerGroupId` (`2313`); selecting a detail alone is not meaningful, the group must be specified first.


## OpenAPI

````yaml api-reference/openapi.json POST /api/v1/products/{productId}/prices
openapi: 3.1.1
info:
  title: Noyax API
  description: Server-to-server API for integrations to access Noyax data.
  version: '1.0'
servers:
  - url: https://api.noyax.com
security:
  - Bearer: []
tags:
  - name: Sections
  - name: Warehouses
  - name: Product Critical Stock
  - name: Product groups
  - name: Product Parameter Definitions
  - name: Product Parameters
  - name: Product Prices
  - name: Products
  - name: Cities
  - name: Countries
  - name: Currencies
  - name: Districts
  - name: Shipment Definitions
  - name: Units
  - name: VAT rates
  - name: Customer Addresses
  - name: Customer Bank Accounts
  - name: Customer Definitions
  - name: Customer Group Members
  - name: Customer Links
  - name: Customer Parameters
  - name: Customer Representatives
  - name: Customers
  - name: Customer Statement
  - name: Customer Telephones
paths:
  /api/v1/products/{productId}/prices:
    post:
      tags:
        - Product Prices
      summary: Create price
      description: >-
        Adds a new price/discount row to the product. PriceType, Price,
        CurrencyId, StartDate and EndDate are required.
      parameters:
        - name: productId
          in: path
          description: Product ID.
          required: true
          schema:
            type: string
            format: uuid
        - name: X-UserID
          in: header
          description: >-
            ID of the Noyax user the request is made on behalf of. Written to
            the audit fields of created, updated and deleted records.
          required: true
          schema:
            minimum: 1
            type: integer
            format: int32
        - name: X-CompanyID
          in: header
          description: >-
            ID of the company. The user must be assigned to this company. All
            reads and writes are limited to this company.
          required: true
          schema:
            minimum: 1
            type: integer
            format: int32
        - name: X-PeriodID
          in: header
          description: >-
            ID of the accounting period. Optional for customer endpoints; if
            sent, it is written to created records.
          schema:
            minimum: 1
            type: integer
            format: int32
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductPriceRequestDto'
          text/json:
            schema:
              $ref: '#/components/schemas/ProductPriceRequestDto'
          application/*+json:
            schema:
              $ref: '#/components/schemas/ProductPriceRequestDto'
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataResultOfProductPriceDto'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResult'
              example:
                Success: false
                ResultCode: '2314'
                Message: >-
                  CustomerId cannot be combined with CustomerGroupId or
                  CustomerGroupDetailId.
                Errors:
                  - Code: '2314'
                    Message: >-
                      CustomerId cannot be combined with CustomerGroupId or
                      CustomerGroupDetailId.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResult'
              example:
                Success: false
                ResultCode: '0102'
                Message: Token has expired. Obtain a new token using the refresh token.
                Errors:
                  - Code: '0102'
                    Message: >-
                      Token has expired. Obtain a new token using the refresh
                      token.
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResult'
              example:
                Success: false
                ResultCode: '0110'
                Message: You do not have permission for this operation.
                Errors:
                  - Code: '0110'
                    Message: You do not have permission for this operation.
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResult'
              example:
                Success: false
                ResultCode: '0120'
                Message: Daily request limit (10000) exceeded.
                Errors:
                  - Code: '0120'
                    Message: Daily request limit (10000) exceeded.
components:
  schemas:
    ProductPriceRequestDto:
      type: object
      properties:
        PriceType:
          type: integer
          description: 'Required. 1: Purchase, 2: Sales.'
          format: int32
          example: 2
        Price:
          type: number
          description: Required. Must be greater than 0.
          format: double
          example: 450
        CurrencyId:
          type:
            - 'null'
            - string
          description: Required. ID of a currency from GET /api/v1/definitions/currencies.
          format: uuid
        IncludesVat:
          type: boolean
          description: Whether Price includes VAT.
          example: false
        Discount:
          type: number
          description: >-
            Discount amount or percentage, depending on IsDiscountPercentage.
            Cannot be negative.
          format: double
          example: 10
        IsDiscountPercentage:
          type: boolean
          description: >-
            Whether Discount is a percentage (0-100) rather than a fixed amount.
            Defaults to true.
          example: true
        UnitId:
          type:
            - 'null'
            - string
          description: >-
            Required. Must be one of the product's own units: its main unit
            (UnitId on the product) or, for products with a second/third unit,
            one of those.
          format: uuid
        StartDate:
          type:
            - 'null'
            - string
          description: Required. Start of the validity period.
          format: date-time
        EndDate:
          type:
            - 'null'
            - string
          description: Required. End of the validity period. Must be after StartDate.
          format: date-time
        CustomerId:
          type:
            - 'null'
            - string
          description: >-
            Scope: applies only to this customer. Cannot be combined with
            CustomerGroupId or CustomerGroupDetailId. Leave every scope field
            empty for a general price.
          format: uuid
        CustomerGroupId:
          type:
            - 'null'
            - string
          description: >-
            Scope: applies to every customer in this group (from GET
            /api/v1/customers/groups), unless CustomerGroupDetailId narrows it
            to one detail. Cannot be combined with CustomerId.
          format: uuid
        CustomerGroupDetailId:
          type:
            - 'null'
            - string
          description: >-
            Scope: narrows CustomerGroupId to customers with this group detail.
            Requires CustomerGroupId to be set.
          format: uuid
        Description:
          type:
            - 'null'
            - string
          description: Description. At most 255 characters.
    DataResultOfProductPriceDto:
      required:
        - Success
        - ResultCode
        - Data
      type: object
      properties:
        Success:
          type: boolean
          description: Whether the operation succeeded.
          example: true
        ResultCode:
          type: string
          description: >-
            "0000" on success. On failure, the code of the first error; all
            errors are listed in Errors.
          example: '0000'
        Message:
          type:
            - 'null'
            - string
          description: >-
            Error message when Success is false. Messages of all errors are
            joined into a single text.
        Data:
          $ref: '#/components/schemas/ProductPriceDto'
    ErrorResult:
      type: object
      properties:
        Success:
          type: boolean
          description: Whether the operation succeeded.
          example: false
        ResultCode:
          type:
            - 'null'
            - string
          description: >-
            "0000" on success. On failure, the code of the first error; all
            errors are listed in Errors.
        Message:
          type:
            - 'null'
            - string
          description: >-
            Error message when Success is false. Messages of all errors are
            joined into a single text.
        Errors:
          type:
            - 'null'
            - array
          items:
            $ref: '#/components/schemas/ResultError'
          description: All errors with their codes. Only present when Success is false.
    ProductPriceDto:
      type: object
      properties:
        Id:
          type: string
          description: Price/discount row ID.
          format: uuid
        ProductId:
          type: string
          description: Product ID.
          format: uuid
        CurrencyCode:
          type:
            - 'null'
            - string
          description: Currency code.
          example: TRY
        UnitName:
          type:
            - 'null'
            - string
          description: Name of the unit, when UnitId is set.
        CustomerName:
          type:
            - 'null'
            - string
          description: Name of the customer, when CustomerId is set.
        CustomerGroupName:
          type:
            - 'null'
            - string
          description: Name of the customer group, when CustomerGroupId is set.
        CustomerGroupDetailName:
          type:
            - 'null'
            - string
          description: >-
            Name of the customer group detail, when CustomerGroupDetailId is
            set.
        PriceType:
          type: integer
          description: 'Required. 1: Purchase, 2: Sales.'
          format: int32
          example: 2
        Price:
          type: number
          description: Required. Must be greater than 0.
          format: double
          example: 450
        CurrencyId:
          type:
            - 'null'
            - string
          description: Required. ID of a currency from GET /api/v1/definitions/currencies.
          format: uuid
        IncludesVat:
          type: boolean
          description: Whether Price includes VAT.
          example: false
        Discount:
          type: number
          description: >-
            Discount amount or percentage, depending on IsDiscountPercentage.
            Cannot be negative.
          format: double
          example: 10
        IsDiscountPercentage:
          type: boolean
          description: >-
            Whether Discount is a percentage (0-100) rather than a fixed amount.
            Defaults to true.
          example: true
        UnitId:
          type:
            - 'null'
            - string
          description: >-
            Required. Must be one of the product's own units: its main unit
            (UnitId on the product) or, for products with a second/third unit,
            one of those.
          format: uuid
        StartDate:
          type:
            - 'null'
            - string
          description: Required. Start of the validity period.
          format: date-time
        EndDate:
          type:
            - 'null'
            - string
          description: Required. End of the validity period. Must be after StartDate.
          format: date-time
        CustomerId:
          type:
            - 'null'
            - string
          description: >-
            Scope: applies only to this customer. Cannot be combined with
            CustomerGroupId or CustomerGroupDetailId. Leave every scope field
            empty for a general price.
          format: uuid
        CustomerGroupId:
          type:
            - 'null'
            - string
          description: >-
            Scope: applies to every customer in this group (from GET
            /api/v1/customers/groups), unless CustomerGroupDetailId narrows it
            to one detail. Cannot be combined with CustomerId.
          format: uuid
        CustomerGroupDetailId:
          type:
            - 'null'
            - string
          description: >-
            Scope: narrows CustomerGroupId to customers with this group detail.
            Requires CustomerGroupId to be set.
          format: uuid
        Description:
          type:
            - 'null'
            - string
          description: Description. At most 255 characters.
    ResultError:
      required:
        - Code
        - Message
      type: object
      properties:
        Code:
          type: string
          description: Error code. See the result codes page for the full list.
        Message:
          type: string
          description: Error description.
  securitySchemes:
    Bearer:
      type: http
      description: Access token obtained from the Noyax auth service with your API key.
      scheme: bearer
      bearerFormat: JWT

````