API Integrations
iTajir APIs

Integration Overview

This documentation provides a centralized reference for integrating with iTajir using secure, token-based APIs. It covers request/response conventions, authentication requirements, and the available integration endpoints used to sync data and validate availability across connected systems.

For token issuance, onboarding or integration setup, contact iTajir integration team. Check contact details in Support section below.
Format: JSON Auth: Token Base URL: {{url}} Version: v1
01 Authenticate

Send token headers with every call.

02 Sync Catalog

Create and update items, UOMs, prices, taxes, and images.

03 Validate Stock

Expose supplier stock checks for real-time availability.

04 Place Orders

ACK purchase orders with request and invoice references.

Authentication

All endpoints require a token header.

Required
Header Authorization: token {{token}}
Header Content-Type: application/json

Request/Response Conventions

Consistent JSON envelopes. Warnings are non-blocking and may appear on success responses.

JSON
Success Envelope (Example)
201
{
  "success": true,
  "message": "OK",
  "data": {}
}
Error Envelope (Example)
4xx/5xx
{
  "success": false,
  "error": {
    "code": "SOME_ERROR_CODE",
    "message": "Human readable message.",
    "details": {}
  }
}
Important: iTajir responses are consistent JSON envelopes with HTTP codes set via http_status_code.

Endpoints

Search in the sidebar to filter endpoints by name, method, or path.

6

Add Item

Sync an item to iTajir. Includes base item info, sellable UOMs (conversion factor, optional barcode, price), and an optional image payload. Image attach failures return as non-blocking warnings.

POST Production

Endpoint

POST {{url}}/api/method/myerpnext.myshop.apis.marketplace_api.sync_item

Headers

Required
Header Authorization: token {{token}}
Header Content-Type: application/json

Params

Body JSON
  • item (Object) — Required
  • item_image (Object) — Optional
  • item.uoms (Array) — Required (must include stock_uom)
  • item.tax_type (String) — Optional (must be one of the values returned by Get Tax Types API)
Image: Send raw Base64 only (without data:image/...;base64, prefix). If missing/malformed, iTajir will sync the item and return a warning.

Rules

Validation
  • item_group must match an existing group returned by Get Item Groups.
  • uoms must include the stock_uom entry (recommended: conversion_factor = 1).
  • uom values must exist in iTajir (use Get UOMs).
  • price_list_rate is required for each UOM; if missing/invalid, the request fails.
  • price_list_rate must include VAT.
  • barcode is optional. If provided, each barcode must be unique in payload and database.
  • tax_type is optional. If provided, each tax_type must be one of the values returned by Get Tax Types API. If NOT provided, default tax type is used (15%).
  • Image upload errors do not block item creation; they appear in warnings.
  • If item_code already exists (or is not unique), the request fails and the item is not created.

Examples

Request
Request JSON Example
JSON
{
  "item": {
    "item_code": "ITJ-TOY-27419",
    "item_name": "مكعبات بناء مغناطيسية",
    "item_group": "تعلمية و تنمية فكرية",
    "stock_uom": "حبة",
    "uoms": [
      {
        "conversion_factor": 1,
        "uom": "حبة",
        "barcode": "6291000123456",
        "price_list_rate": 29.95
      },
      {
        "conversion_factor": 12,
        "uom": "درزن",
        "barcode": "6291000123463",
        "price_list_rate": 329.00
      }
    ]
  },
  "tax_type": "5",
  "item_image": {
    "content": "iVBORw0KGgoAAAANSUhEUgAA...<base64 truncated>...5ErkJggg=="
  }
}

Schema Notes

Quick
Field Req Description
item.item_code Yes Unique item identifier (primary key).
item.item_name Yes Display name.
item.item_group Yes Must exist in Item Groups.
item.stock_uom Yes Base UOM for inventory tracking.
item.uoms[] Yes Must include the stock_uom entry.
item.tax_type No If provided, must be one of the values returned by Get Tax Types API.
item_image.content No Raw Base64 (no prefix). Warnings on failure.
Recommendation: The UOM matching stock_uom should use conversion_factor = 1.

Responses

Examples
Success (Example)
201
{
  "success": true,
  "message": "Item synced.",
  "data": {
    "item": "ITEM-000912"
  },
  "warnings": [
    {
      "code": "IMAGE_NOT_ATTACHED",
      "message": "No image content provided.",
      "details": null
    }
  ]
}
Error (Example)
409
{
  "success": false,
  "error": {
    "code": "BARCODE_NOT_UNIQUE",
    "message": "The following barcode(s) already exist in the system: 6291000123456, 6291000999001.",
    "details": {
      "conflicts": [
        "6291000123456",
        "6291000999001"
      ]
    }
  }
}

Update Item

Update an item previously synced by the supplier. This endpoint is authoritative for UOM conversions, barcodes, prices, taxes, and optionally the image. Supplier can only update their own items.

POST Production

Endpoint

POST {{url}}/api/method/myerpnext.myshop.apis.marketplace_api.update_item

Headers

Required
Header Authorization: token {{token}}
Header Content-Type: application/json

Params

Body JSON
  • item (Object) — Required
  • item.item_code (String) — Required
  • item.uoms (Array) — Optional (if provided, becomes authoritative)
  • tax_type (String) — Optional (top-level; controls item taxes)
  • item_image (Object) — Optional (authoritative only if provided)
Tip: If you only want to change the image, send item with item_code and include item_image. To clear the image, send empty content.

Rules

Authoritative
  • Ownership: Suppliers can update their own items only.
  • Authoritative: item.uoms becomes source of truth for UOM conversions, barcodes, and prices.
  • New UOM: When adding a new UOM, conversion_factor is required; if missing/invalid, the update fails.
  • Item Price: price_list_rate must include VAT.
  • Delete missing: UOMs/prices not included are removed from sellable conversions/prices.
  • Barcodes: List is replaced to match the request exactly; omit barcodes to clear all.
  • Tax Type:
    • If tax_type is provided → replaces existing taxes.
    • If tax_type is empty, or null → clears all taxes.
    • If tax_type is omitted from paylaod → existing taxes remain unchanged.
  • Image: If item_image is included:
    • If content provided → replace.
    • If content empty/missing → clear.
Note: On validation failure (e.g., duplicate barcode or invalid tax type), nothing is saved.

Examples

Request
Request JSON Example (Update + Replace UOMs + Tax)
JSON
{
  "item": {
    "item_code": "TOY-27419999",
    "item_name": "مكعبات بناء مغناطيسية – إصدار مطور",
    "item_group": "تعلمية و تنمية فكرية",
    "uoms": [
      {
        "uom": "حبة",
        "price_list_rate": 31.50,
        "barcode": "629100012349999"
      },
      {
        "uom": "كرتون",
        "conversion_factor": 12,
        "price_list_rate": 350.00,
        "barcode": "629100012340000"
      }
    ]
  },
  "tax_type": "15",
  "item_image": {
    "content": "iVBORw0KGgoAAAANSUhEUgAA...<base64 truncated>..."
  }
}
Response (Success Example)
200
{
  "success": true,
  "message": "Item updated.",
  "data": {
    "item": "TOY-27419999"
  }
}

Get Items

Retrieve the supplier’s synced items, including UOM conversion factors, barcodes, and prices. Supports pagination and optional search filtering.

GET Production

Endpoint

GET {{url}}/api/method/myerpnext.myshop.apis.marketplace_api.get_items

Headers

Required
Header Authorization: token {{token}}

Params

Query
Param Type Required Description
search String No Partial match on item_code or item_name.
start Int No Pagination offset (default: 0).
page_length Int No Page size (default: 50).
Pagination: Use start and page_length to load more.

Rules

Notes
  • Returns only items linked to the supplier via Item Supplier.
  • Prices are returned from the marketplace server price list configured in iTajir.
  • Barcodes and prices are returned as arrays.
  • UOM conversion factors are returned in uoms[].

Examples

Request/Response
Sample Request
Example
GET {{url}}/api/method/myerpnext.myshop.apis.marketplace_api.get_items?search=مكعبات&start=0&page_length=20
Sample Response (Example)
JSON
{
  "success": true,
  "message": "OK",
  "data": {
    "items": [
      {
        "name": "TOY-27419999",
        "item_code": "TOY-27419999",
        "item_name": "مكعبات بناء مغناطيسية",
        "item_group": "تعلمية و تنمية فكرية",
        "image": "/files/181574817x747_image.jpg",
        "disabled": 0,
        "tax_type": "15",
        "modified": "2026-01-29 12:15:59.070401",
        "uoms": [
          { "uom": "حبة", "conversion_factor": 1 },
          { "uom": "درزن", "conversion_factor": 12 }
        ],
        "barcodes": [
          { "barcode": "629100012347666", "uom": "حبة" },
          { "barcode": "629100012347366", "uom": "درزن" }
        ],
        "prices": [
          {
            "uom": "حبة",
            "price_list_rate": 29.95,
            "currency": "SAR",
            "modified": "2026-01-29 12:15:58.887829"
          },
          {
            "uom": "درزن",
            "price_list_rate": 329.0,
            "currency": "SAR",
            "modified": "2026-01-29 12:15:58.905117"
          }
        ]
      }
    ],
    "start": 0,
    "page_length": 20
  }
}

Get Item Groups

Fetch valid item groups to use when pushing items.

GET Dependency

Endpoint

GET {{url}}/api/method/myerpnext.myshop.apis.marketplace_api.get_item_groups

Headers

Required
Header Authorization: token {{token}}

Responses

Example
Sample Response
JSON
{
  "success": true,
  "message": "OK",
  "data": {
    "item_groups": [
      "تعلمية و تنمية فكرية",
      "منزل ومطبخ",
      "رياضية"
    ]
  }
}

Get UOMs

Fetch all enabled UOMs that can be used in item sync requests.

GET Dependency

Endpoint

GET {{url}}/api/method/myerpnext.myshop.apis.marketplace_api.get_uoms

Headers

Required
Header Authorization: token {{token}}

Responses

Example
Sample Response
JSON
{
  "success": true,
  "message": "OK",
  "data": {
    "uoms": [
      "حبة",
      "درزن",
      "كرتون",
      "علبة"
    ]
  }
}
Tip: Pull this list periodically, cache it, and validate UOMs in your integration layer.

Get Tax Types

Fetch all tax values that can be used as tax types. Returns a flat list of Tax Types.

GET Dependency

Endpoint

GET {{url}}/api/method/myerpnext.myshop.apis.marketplace_api.get_tax_types

Headers

Required
Header Authorization: token {{token}}
Header Content-Type: application/json

Params

None
  • No query parameters.
  • No request body.
Tip: Cache this list and refresh periodically (e.g., daily) to validate tax type selections.

Rules

Operational
  • Only tax templates with disabled = 0 are returned.
  • Returned values are the title field from Item Tax Template.
  • Order is not guaranteed; treat the list as an unordered set.

Responses

Example
Success Response
JSON
{
  "success": true,
  "message": "OK",
  "data": {
    "tax_types": [
      "0",
      "5",
      "15"
    ]
  }
}

Supplier Stock API (Required)

Supplier must provide a stock-check API and keep it available 24/7. iTajir calls this API to check inventory availability for a set of items. If the operation exceeds 2 seconds, iTajir stops processing and treats remaining items as 0.

POST Supplier Provided

Endpoint

POST Supplier-provided URL (registered in iTajir)

Headers

Required
Header Authorization: token {{token}}

Rules

Operational
  • Availability: Must be available 24/7.
  • Timeout behavior: Maximum runtime is 2 seconds. If exceeded, remaining items treated as 0.
  • Request body: Provide item codes in item_codes.
  • Response: Return current quantities per item. Unknown/out-of-stock items must return 0.
Note: Endpoint URL is provided by the supplier and registered in iTajir integration settings.

Examples

Request/Response
Request Body
JSON
{
  "item_codes": [
    "ITJ-TOY-27419",
    "ITJ-KITCH-10402",
    "ITJ-CARE-88210"
  ]
}
Stock Response
JSON
{
  "success": true,
  "message": "OK",
  "data": [
    { "item_code": "ITJ-TOY-27419", "qty": 120 },
    { "item_code": "ITJ-KITCH-10402", "qty": 0 },
    { "item_code": "ITJ-CARE-88210", "qty": 18 }
  ]
}

Responses

Notes
  • success should be true on successful execution.
  • data is an array of objects: item_code, qty.
  • If item unknown/out of stock, return 0.

Supplier Order Placement API (Required)

Supplier must provide an order-placement API and keep it available 24/7. iTajir calls this API to place a Purchase Order with the supplier. Supplier must validate the payload, verify stock, deduct/reserve the requested quantities, then create and submit/confirm a supplier Sales Invoice. Supplier must respond with an ACK containing request_id and sales_invoice.

POST Supplier Provided

Endpoint

POST Supplier-provided URL (registered in iTajir)

Headers

Required
Header Authorization: token {{token}}
Header Content-Type: application/json

Rules

Operational
  • Availability: Must be available 24/7.
  • Request body: Must accept marketplace_procurement, purchase_order, and items (non-empty array).
  • Item validation: Each item requires item_code, uom, qty > 0.
  • Stock validation: Validate total required qty per item_code across all lines.
  • Insufficient stock: Return success=false with a clear message. Do not ACK.
  • On success: Deduct/reserve stock, create & submit/confirm a supplier Sales Invoice, then ACK.
  • ACK required fields: Response data must include request_id and sales_invoice.
  • Envelope: Always use unified envelope: { "success": bool, "message": str, "data": ... }.
Note: Endpoint URL is provided by the supplier and registered in iTajir integration settings.

Schema

Request/Response

Request Schema Notes

Quick
Field Req Description
marketplace_procurement Yes iTajir Marketplace Procurement reference (MPR). Non-empty string.
purchase_order Yes iTajir Purchase Order reference. Non-empty string.
items[] Yes Non-empty array of item objects.
cart_quotation No Cart quotation reference (if present).
supplier No Supplier name/id (if present).
discount_percentage Yes Discount provided by supplier, as per the agreed terms
items[].item_code Yes Unique item identifier. Non-empty string.
items[].uom Yes Unit of Measure for the requested quantity. Non-empty string.
items[].qty Yes Requested quantity. Must be a number > 0.
items[].rate No Unit price (informational for supplier). Number.
items[].conversion_factor No UOM conversion factor (if provided). Default should be 1.
Validation: Supplier must reject non-object payloads, require marketplace_procurement and purchase_order, and require items as a non-empty array. Each item must include item_code, uom, and qty > 0.

Response Schema Notes

Quick
Field Req Description
success Yes true when order accepted and invoice created; otherwise false.
message Yes Human-readable status message (shown/logged by iTajir).
data Yes ACK data object when success=true; can be {} on failures.
data.request_id Yes Supplier-generated unique request reference (used for traceability).
data.sales_invoice Yes Supplier Sales Invoice identifier (recommended as string invoice number).
data.invoice_data No Optional informational invoice summary (may be logged/stored by iTajir).
data.invoice_data.posting_date No Invoice posting date (ISO date string).
data.invoice_data.total No Total before supplier discount (number).
data.invoice_data.discount No Discount amount (number). iTajir typically applies 10% supplier discount.
data.invoice_data.grand_total No Total after discount (number).
ACK strictness: If success=true, iTajir requires both data.request_id and data.sales_invoice. Missing either will be treated as an integration failure.

Examples

Request/Response
Request Body
JSON
{
  "marketplace_procurement": "MPR-000123",
  "cart_quotation": "QTN-000555",
  "purchase_order": "PO-000999",
  "supplier": "شركة الأهلي الدولية",
  "discount_percentage": 10.00,
  "items": [
    {
      "item_code": "TOY-27419",
      "uom": "حبة",
      "qty": 2,
      "rate": 25.0,
      "conversion_factor": 1
    },
    {
      "item_code": "ITJ-10402",
      "uom": "حبة",
      "qty": 1,
      "rate": 50.0,
      "conversion_factor": 1
    }
  ]
}
Success ACK
JSON
{
  "success": true,
  "message": "Acked",
  "data": {
    "request_id": "REQ-AB12CD34EF",
    "sales_invoice": "SINV-000123",
    "invoice_data": {
      "posting_date": "2025-02-22",
      "total": 100.0,
      "discount": 10.0,
      "grand_total": 90.0
    }
  }
}
Insufficient Stock
JSON
{
  "success": false,
  "message": "Insufficient stock for ITJ-TOY-27419. Required 5, available 2.",
  "data": {}
}
Invalid Payload
JSON
{
  "success": false,
  "message": "Invalid payload. marketplace_procurement and purchase_order are required.",
  "data": {}
}

Responses

Notes
  • ACK is required: On success, response data must include request_id and sales_invoice.
  • sales_invoice should be a string invoice identifier.
  • invoice_data is optional and informational (may be logged/stored).
  • Failure handling: Return success=false with a clear message.

Errors

Common error patterns and recommended handling.

Guidance
Error Response (Example)
409
{
  "success": false,
  "error": {
    "code": "BARCODE_NOT_UNIQUE",
    "message": "The following barcode(s) already exist in the system: 6291000123456, 6291000999001.",
    "details": {
      "conflicts": ["6291000123456", "6291000999001"]
    }
  }
}
Success With Warnings (Example)
201
{
  "success": true,
  "message": "Item synced.",
  "data": { "item": "ITEM-000912" },
  "warnings": [
    {
      "code": "IMAGE_NOT_ATTACHED",
      "message": "No image content provided.",
      "details": null
    }
  ]
}

How to Handle Errors

Playbook
Scenario Indicator Recommended Action
Duplicate item_code DUPLICATE_ITEM / ITEM_CODE_NOT_UNIQUE Verify item_code. Treat as upsert on your side or stop and alert an operator.
Duplicate barcode BARCODE_NOT_UNIQUE / DUPLICATE_BARCODES_IN_PAYLOAD Fix conflicting barcodes. If barcode is not available, omit it (barcode is optional).
Missing conversion factor on update MISSING_CONVERSION_FACTOR When adding a new UOM on update, include a valid conversion_factor (> 0).
Server error SERVER_ERROR Retry later using backoff. If persistent, share request details (excluding token) with support.
Image not attached warnings[] present Item is synced. Validate Base64 and optionally retry image upload later.
Tip: Log request/response (excluding tokens) plus correlation IDs to speed up debugging.

Best Practices

Guidelines for stable, maintainable integrations.

Operational

Idempotency & Duplicates

Reliability
  • Use item_code as your stable unique identifier.
  • Treat retrying the same payload as safe on your side (idempotent strategy).
  • Handle duplicate errors as a business decision: stop, alert, or reconcile.

Retries

Resilience
  • Retry transient failures (timeouts/network) with exponential backoff.
  • Avoid aggressive retries to prevent throttling and load spikes.
  • Store correlation IDs to track sync attempts end-to-end.
Tip: Persist the last successful sync timestamp per item for controlled replays.

Support

Token issuance, onboarding and integration setup.

iTajir

For token issuance, onboarding or integration setup, contact iTajir integration team.