> ## 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 shipment definition

> Adds a shipment definition.

* `Code` is required and must be unique within the company.
* `TransportMode` is required and must be one of the values below.
* `TransportInfo1` is required; its meaning depends on the transport mode (below).
* A shipment is made either by a carrier company or with your own vehicle; the rules are below.
* `TransportInfo1` is required; its meaning depends on the transport mode (below).
* A shipment is made either by a carrier company or with your own vehicle; the rules are below.
* Other fields are optional free text; the maximum length of each field is in its description. Longer values are rejected with `0003`.

What `TransportInfo1` and `TransportInfo2` mean depends on the transport mode; the Noyax screen changes the labels of these fields accordingly. The values are written to the e-despatch advice as transport information.

| `TransportMode` | Transport mode | `TransportInfo1` (required) | `TransportInfo2` |
| --------------- | -------------- | --------------------------- | ---------------- |
| `1`             | Road           | License plate               | —                |
| `2`             | Rail           | Train number                | Rail car number  |
| `3`             | Maritime       | Vessel name                 | IMO number       |
| `4`             | Air            | Aircraft number             | —                |

The second field exists only for rail and maritime; for road and air `TransportInfo2` is not stored even if sent.

## Carrier company or your own vehicle?

A shipment is made either by a carrier company or with the company's own vehicle. The API does not have a separate field for this; it decides by **whether the carrier company fields are filled**:

<Tabs>
  <Tab title="Own vehicle">
    Leave all carrier fields (`CarrierName`, `CarrierTaxNumber`, `CarrierCity`, `CarrierDistrict`, `CarrierCountry`) empty.

    * `Driver1FirstName`, `Driver1LastName` and `Driver1IdentityNumber` are **required** (`0537`).
    * `Driver2*` fields are optional.
    * Trailer plates are stored only for **road** transport (`TransportMode: 1`); for other transport modes they stay empty even if sent.
  </Tab>

  <Tab title="Carrier company">
    If any carrier field is filled, **all five are required** (`0536`).

    * Driver information is not needed; even if sent it is not stored and comes back empty.
    * Trailer plates are not stored.
  </Tab>
</Tabs>


## OpenAPI

````yaml api-reference/openapi.json POST /api/v1/definitions/shipment-definitions
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/definitions/shipment-definitions:
    post:
      tags:
        - Shipment Definitions
      summary: Create shipment definition
      description: >-
        Adds a shipment definition. Code must be unique within the company;
        TransportMode must be 1-4.
      parameters:
        - 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/ShipmentDefinitionRequestDto'
          text/json:
            schema:
              $ref: '#/components/schemas/ShipmentDefinitionRequestDto'
          application/*+json:
            schema:
              $ref: '#/components/schemas/ShipmentDefinitionRequestDto'
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataResultOfShipmentDefinitionDto'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResult'
              example:
                Success: false
                ResultCode: '0537'
                Message: >-
                  Driver1FirstName, Driver1LastName and Driver1IdentityNumber
                  are required when no carrier company is used.
                Errors:
                  - Code: '0537'
                    Message: >-
                      Driver1FirstName, Driver1LastName and
                      Driver1IdentityNumber are required when no carrier company
                      is used.
        '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:
    ShipmentDefinitionRequestDto:
      type: object
      properties:
        Code:
          type:
            - 'null'
            - string
          description: >-
            Required. Shipment code, unique within the company. At most 50
            characters.
          example: '5469'
        Description:
          type:
            - 'null'
            - string
          description: Description. At most 255 characters.
          example: Istanbul road shipments
        TransportMode:
          type: integer
          description: >-
            Required. 1: Road, 2: Rail, 3: Maritime, 4: Air. Decides what
            TransportInfo1 and TransportInfo2 mean.
          format: int32
          example: 1
        TransportInfo1:
          type:
            - 'null'
            - string
          description: >-
            Required. Vehicle identifier, by TransportMode: 1 license plate, 2
            train number, 3 vessel name, 4 aircraft number. At most 50
            characters.
          example: 34ABC123
        TransportInfo2:
          type:
            - 'null'
            - string
          description: >-
            Second transport information, used only when TransportMode is 2
            (rail car number) or 3 (IMO number). Not stored for 1 (road) and 4
            (air). At most 50 characters.
        CarrierName:
          type:
            - 'null'
            - string
          description: >-
            Carrier company name. Required together with the other Carrier*
            fields when the shipment is made by a carrier company; leave all of
            them empty for the company's own vehicle. At most 75 characters.
          example: Example Logistics Ltd.
        CarrierTaxNumber:
          type:
            - 'null'
            - string
          description: Carrier company tax number. At most 50 characters.
          example: '1234567890'
        CarrierCity:
          type:
            - 'null'
            - string
          description: Carrier company city. At most 50 characters.
          example: ISTANBUL
        CarrierDistrict:
          type:
            - 'null'
            - string
          description: Carrier company district. At most 50 characters.
          example: KADIKÖY
        CarrierCountry:
          type:
            - 'null'
            - string
          description: Carrier company country. At most 50 characters.
          example: TÜRKİYE
        Driver1FirstName:
          type:
            - 'null'
            - string
          description: >-
            First name of driver 1. Required when no carrier company is used.
            Not stored when a carrier company is used. At most 50 characters.
          example: Ahmet
        Driver1LastName:
          type:
            - 'null'
            - string
          description: >-
            Last name of driver 1. Required when no carrier company is used. At
            most 20 characters.
          example: Kaya
        Driver1IdentityNumber:
          type:
            - 'null'
            - string
          description: >-
            National ID number (TCKN) of driver 1. Required when no carrier
            company is used. At most 20 characters.
          example: '12345678901'
        Driver2FirstName:
          type:
            - 'null'
            - string
          description: First name of driver 2. At most 50 characters.
        Driver2LastName:
          type:
            - 'null'
            - string
          description: Last name of driver 2. At most 20 characters.
        Driver2IdentityNumber:
          type:
            - 'null'
            - string
          description: National ID number (TCKN) of driver 2. At most 20 characters.
        TrailerPlate1:
          type:
            - 'null'
            - string
          description: >-
            Trailer license plate 1. Stored only when TransportMode is 1 (road)
            and no carrier company is used. At most 20 characters.
          example: 34ABC123
        TrailerPlate2:
          type:
            - 'null'
            - string
          description: >-
            Trailer license plate 2. Stored only when TransportMode is 1 (road)
            and no carrier company is used. At most 20 characters.
    DataResultOfShipmentDefinitionDto:
      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/ShipmentDefinitionDto'
    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.
    ShipmentDefinitionDto:
      type: object
      properties:
        Id:
          type: string
          description: Shipment definition ID. Use it as ShipmentDefinitionId in customers.
          format: uuid
        Code:
          type:
            - 'null'
            - string
          description: >-
            Required. Shipment code, unique within the company. At most 50
            characters.
          example: '5469'
        Description:
          type:
            - 'null'
            - string
          description: Description. At most 255 characters.
          example: Istanbul road shipments
        TransportMode:
          type: integer
          description: >-
            Required. 1: Road, 2: Rail, 3: Maritime, 4: Air. Decides what
            TransportInfo1 and TransportInfo2 mean.
          format: int32
          example: 1
        TransportInfo1:
          type:
            - 'null'
            - string
          description: >-
            Required. Vehicle identifier, by TransportMode: 1 license plate, 2
            train number, 3 vessel name, 4 aircraft number. At most 50
            characters.
          example: 34ABC123
        TransportInfo2:
          type:
            - 'null'
            - string
          description: >-
            Second transport information, used only when TransportMode is 2
            (rail car number) or 3 (IMO number). Not stored for 1 (road) and 4
            (air). At most 50 characters.
        CarrierName:
          type:
            - 'null'
            - string
          description: >-
            Carrier company name. Required together with the other Carrier*
            fields when the shipment is made by a carrier company; leave all of
            them empty for the company's own vehicle. At most 75 characters.
          example: Example Logistics Ltd.
        CarrierTaxNumber:
          type:
            - 'null'
            - string
          description: Carrier company tax number. At most 50 characters.
          example: '1234567890'
        CarrierCity:
          type:
            - 'null'
            - string
          description: Carrier company city. At most 50 characters.
          example: ISTANBUL
        CarrierDistrict:
          type:
            - 'null'
            - string
          description: Carrier company district. At most 50 characters.
          example: KADIKÖY
        CarrierCountry:
          type:
            - 'null'
            - string
          description: Carrier company country. At most 50 characters.
          example: TÜRKİYE
        Driver1FirstName:
          type:
            - 'null'
            - string
          description: >-
            First name of driver 1. Required when no carrier company is used.
            Not stored when a carrier company is used. At most 50 characters.
          example: Ahmet
        Driver1LastName:
          type:
            - 'null'
            - string
          description: >-
            Last name of driver 1. Required when no carrier company is used. At
            most 20 characters.
          example: Kaya
        Driver1IdentityNumber:
          type:
            - 'null'
            - string
          description: >-
            National ID number (TCKN) of driver 1. Required when no carrier
            company is used. At most 20 characters.
          example: '12345678901'
        Driver2FirstName:
          type:
            - 'null'
            - string
          description: First name of driver 2. At most 50 characters.
        Driver2LastName:
          type:
            - 'null'
            - string
          description: Last name of driver 2. At most 20 characters.
        Driver2IdentityNumber:
          type:
            - 'null'
            - string
          description: National ID number (TCKN) of driver 2. At most 20 characters.
        TrailerPlate1:
          type:
            - 'null'
            - string
          description: >-
            Trailer license plate 1. Stored only when TransportMode is 1 (road)
            and no carrier company is used. At most 20 characters.
          example: 34ABC123
        TrailerPlate2:
          type:
            - 'null'
            - string
          description: >-
            Trailer license plate 2. Stored only when TransportMode is 1 (road)
            and no carrier company is used. At most 20 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

````