CreateNewOrder

Function to create new order.

POST https://rest.crmango.com/api/CreateNewOrder

Authorization

1 Sent in the request headers
Bearer varchar

Auth token (required in Authorization header)

Body data

56 Sent in the request body
rad_code varchar

Document series code (e.g., OP, OV). Required

order_type varchar

Order type (received, issued). Required

name varchar

Order name or reference number

supplier_id integer

Supplier company ID
Reference: GetAllContacts

purchaser_fa_id integer

Purchaser contact ID (optional)
Reference: GetAllContacts

purchaser_os_id integer

Purchaser person ID (optional)
Reference: GetAllPersons

created_by integer

User ID who created the order
Reference: GetAllUsers

user_id integer

User ID tied to the order (usually same as created_by)
Reference: GetAllUsers

currency_id integer

Currency ID for prices
Reference: GetAllStates

active_service_id integer

ID of related service (optional, 0 = none)
Reference: GetAllLists

lang_id varchar

Language ISO code (en, sk, cs)

notify integer

Whether to notify stakeholders (0 = no, 1 = yes)

text_after_header varchar

Optional text printed after header

text_before_footer varchar

Optional text printed before footer

invoice_days int

Invoice due days

taxable_date date

Date of taxable

internal_number string

Internal number

own_cols[0].id_own_col integer

ID of custom field (own column)

own_cols[0].data mixed

Value assigned to the custom field (can be string, number, etc.)

products_tables[0].table_name varchar

Name/label of the product table (optional)

products_tables[0].products[0].name varchar

Product name

products_tables[0].products[0].mj_id integer

Unit of measurement ID
Reference: GetAllLists

products_tables[0].products[0].quantity decimal

Product quantity

products_tables[0].products[0].price decimal

Unit price (without VAT)

products_tables[0].products[0].vat decimal

VAT percentage (e.g., 20)

products_tables[0].products[0].price_type_id integer

Price type ID
Reference: GetAllLists

products_tables[0].products[0].cost_price decimal

Cost price (optional, for margin calculation)

products_tables[0].products[0].cost_type integer

Cost type
Reference: GetAllLists

products_tables[0].products[0].discount decimal

Discount

transport.transporter_id integer

Transporter company ID
Reference: GetAllContacts

transport.vehicle_id integer

Vehicle ID used for transport
Reference: GetAllLists

transport.trailer_id integer

Trailer ID used for transport
Reference: GetAllLists

transport.driver_id integer

Driver ID
Reference: GetAllPersons

transport.driver2_id integer

Second driver ID
Reference: GetAllPersons

transport.price integer|float

Transport price

transport.points[0].type varchar

Point type (start_point, load, unload, crossing_point, parking, gas_station, toll_station)

transport.points[0].lat varchar

Latitude of the point (GPS)

transport.points[0].long varchar

Longitude of the point (GPS)

transport.points[0].address varchar

Address of the point

transport.points[0].postal varchar

Postal code (optional)

transport.points[0].datetime datetime

Scheduled date and time (format: Y-m-dTH:i)

transport.points[0].note varchar

Short note for the point (optional)

transport.points[0].note_full varchar

Full note/details (optional)

transport.points[0].product_name varchar

Optional description of product(s)

transport.points[0].product_type varchar

Product type indicator
Reference: GetAllLists

transport.points[0].product_count varchar

Total number of items

transport.points[0].product_weight varchar

Total weight in kg (optional)

transport.points[0].product_volume varchar

Total volume in m³ (optional)

transport.points[0].product_mj varchar

Measurement unit
Reference: GetAllLists

transport.points[0].ldm varchar

LDM value

transport.points[0].contact_person varchar

Contact person at the location (optional)

transport.points[0].mobile_phone varchar

Contact phone number (optional)

transport.points[0].reference_number varchar

Internal or customer reference number (optional)

files array

Optional. Array of files (base64) to attach to the order. Multiple files allowed.

files[0].filename varchar

File name including extension (e.g., contract.pdf). Forbidden types: php, js, htm, html, css, htaccess, php3, php4, phtml, xml, bat

files[0].data varchar

File content encoded in base64 (without data:...;base64, prefix)

Response

9 HTTP 201

Function to create new order

code integer

HTTP status code (201 = Created)

message varchar

Confirmation message

created_id integer

ID of the newly created order

order_number varchar

Order code of the newly created order

files array

Result for each uploaded file (returned only if files were sent). The order is created even if some file fails

files[0].filename varchar

File name from request

files[0].status varchar

success or error

files[0].file_id integer

ID of the stored file (only on success)

files[0].message varchar

Error description (only on error)

Example request

curl --request POST \
  --url 'https://rest.crmango.com/api/CreateNewOrder' \
  --header 'Authorization: Bearer auth_token' \
  --header 'Content-Type: application/json' \
  --data '{
    {
      "rad_code": "OP",
      "order_type": "received",
      "name": "Order 1234",
      "supplier_id": 1,
      "purchaser_fa_id": 2,
      "purchaser_os_id": 3,
      "created_by": 2323,
      "user_id": 2323,
      "currency_id": 202,
      "active_service_id": 0,
      "lang_id": "en",
      "notify": 0,
      "text_after_header": "",
      "text_before_footer": "",
      "invoice_days": "14",
      "taxable_date": "26.10.2025",
      "internal_number": "",
      "own_cols": [
        {
          "id_own_col": 1,
          "data": ""
        },
        {
          "id_own_col": 2,
          "data": 1
        },
        {
          "id_own_col": 3,
          "data": ""
        }
      ],
      "products_tables": [
        {
          "table_name": "First table",
          "products": [
            {
              "name": "Macbook air",
              "mj_id": 1,
              "quantity": 1,
              "price": 1200,
              "vat": 20,
              "price_type_id": 0,
              "cost_price": 0,
              "cost_type": 0,
              "discount": 0
            },
            {
              "name": "HP Elite",
              "mj_id": 1,
              "quantity": 1,
              "price": 800,
              "vat": 20,
              "price_type_id": 0,
              "cost_price": 0,
              "cost_type": 0,
              "discount": 0
            }
          ]
        },
        {
          "table_name": "",
          "products": [
            {
              "name": "USB dongle",
              "mj_id": 1,
              "quantity": 23,
              "price": 10,
              "vat": 20,
              "price_type_id": 0,
              "cost_price": 0,
              "cost_type": 0,
              "discount": 0
            }
          ]
        }
      ],
      "transport": {
        "transporter_id": 23,
        "vehicle_id": 8,
        "trailer_id": 3,
        "driver_id": 1,
        "driver2_id": 1,
        "price": "235.24",
        "points": [
          {
            "type": "load",
            "lat": "45.748184204102",
            "long": "6.32590675354",
            "note": "",
            "address": "Chemin de Piezan, 74210 Val de Chaise, Francúzsko",
            "postal": "92200",
            "datetime": "2025-10-03T12:00",
            "note_full": "",
            "product_mj": "0",
            "ldm": "",
            "product_name": "",
            "product_type": "1",
            "product_count": "",
            "product_weight": "5000",
            "mobile_phone": "",
            "contact_person": "",
            "product_volume": "",
            "reference_number": ""
          },
          {
            "type": "unload",
            "note": "",
            "address": "Berlin",
            "postal": "",
            "datetime": "2025-10-03T12:00",
            "note_full": "",
            "product_mj": "0",
            "ldm": "",
            "product_name": "",
            "product_type": "1",
            "product_count": "",
            "product_weight": "5000",
            "mobile_phone": "",
            "contact_person": "",
            "product_volume": "",
            "reference_number": ""
          }
        ]
      },
      "files": [
        {
          "filename": "contract.pdf",
          "data": "JVBERi0xLjQKJcfsj6IKJSVFT0YK"
        },
        {
          "filename": "photo.jpg",
          "data": "/9j/4AAQSkZJRgABAQEASABIAAD/2wBD..."
        }
      ]
    }
  }'
{
    "code": 201,
    "message": "New order has been added",
    "created_id": 36589,
    "order_number": "OP-797-2025",
    "files": [
        {
            "filename": "contract.pdf",
            "status": "success",
            "file_id": 112
        },
        {
            "filename": "photo.jpg",
            "status": "error",
            "message": "Insufficient purchased disk space"
        }
    ]
}