Newlines

Create and manage new product line requests submitted for technical specification review.

Overview

The Newlines API provides secure endpoints to create, retrieve, update, and soft delete new product line requests. Start by calling the Create Newline endpoint to submit a new product line, then use Get Newline to retrieve its full details.

LIVE https://developer.traceallglobal.com/api/v1
Key Features
  • Soft delete support
  • Partial field updates
  • Returns newline & spec IDs on create
  • Role-based permissions

API Endpoints

GET
/newlines/{id}
Retrieve a newline by ID
POST
/newlines
Create a new product line
PUT
/newlines/{id}
Update newline fields
DELETE
/newlines/{id}
Soft delete — sets isactive = 0

Retrieve a single newline record by its newlineid.

Parameters

X-API-Key (header, string, Required) — Your API key. JWT validation is handled automatically.

id (path, integer, Required) — The newlineid to retrieve.

Test this endpoint

Response Examples

{
  "success": true,
  "data": {
    "newlineid": 1,
    "companyid": 2,
    "productname": "Organic Honey",
    "productcode": "HON001",
    "description": "Pure organic honeydew",
    "producttype": 3,
    "category": 2,
    "alcoholic": 0,
    "cannedfish": 0,
    "cbd": 0,
    "chocolate": 0,
    "coffee": 0,
    "curedmeats": 0,
    "freshfish": 0,
    "freshfruit": 0,
    "freshmeat": 0,
    "honey": 1,
    "jam": 0,
    "oliveoil": 0,
    "smokedfish": 0,
    "supplements": 0,
    "cheese": 0,
    "fish": 0,
    "mcs": 0,
    "buyer": 4,
    "buyercomments": "Approved for listing",
    "lastupdated": "2026-03-01 09:00:00",
    "created": "2026-01-15 10:00:00",
    "isactive": 1
  }
}
{ "success": false, "error": "Missing API key" }
{ "success": false, "error": "Newline not found" }

Code Examples

curl -X GET "https://developer.traceallglobal.com/api/v1/newlines/1" \
  -H "X-API-Key: YOUR_API_KEY"
fetch('https://developer.traceallglobal.com/api/v1/newlines/1', {
  method: 'GET',
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
})
.then(r => r.json())
.then(data => console.log(data));
<?php
$curl = curl_init('https://developer.traceallglobal.com/api/v1/newlines/1');
curl_setopt_array($curl, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ['X-API-Key: YOUR_API_KEY'],
]);
$data = json_decode(curl_exec($curl), true);
curl_close($curl);
print_r($data);

Create a new product line record. Also creates an associated product spec (dt_ps) record. Returns both newlineid and psid. Requires Editor permission or higher.

Parameters

X-API-Key (header, string, Required)

Content-Type (header, string, Required) — Must be application/json.

Body (JSON) — Required fields: companyid, siteid, productname, productcode. All other fields are optional.

Sample JSON:
{
  "companyid": 2,
  "siteid": 2,
  "productname": "Organic Honey",
  "productcode": "HON001",
  "description": "Pure organic honeydew",
  "producttype": 3,
  "category": 2,
  "alcoholic": 0,
  "cannedfish": 0,
  "cbd": 0,
  "chocolate": 0,
  "coffee": 0,
  "curedmeats": 0,
  "freshfish": 0,
  "freshfruit": 0,
  "freshmeat": 0,
  "honey": 1,
  "jam": 0,
  "oliveoil": 0,
  "smokedfish": 0,
  "supplements": 0,
  "cheese": 0,
  "fish": 0,
  "mcs": null,
  "buyer": 4,
  "buyercomments": ""
}
Test this endpoint

Response Examples

{
  "success": true,
  "data": {
    "message": "Newline created successfully",
    "newlineid": 42,
    "psid": 107
  }
}
{ "success": false, "error": "Missing required field: productname" }
{ "success": false, "error": "Missing API key" }

Code Examples

curl -X POST "https://developer.traceallglobal.com/api/v1/newlines" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "companyid": 2,
    "siteid": 2,
    "productname": "Organic Honey",
    "productcode": "HON001"
  }'
fetch('https://developer.traceallglobal.com/api/v1/newlines', {
  method: 'POST',
  headers: {
    'X-API-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    companyid: 2,
    siteid: 2,
    productname: 'Organic Honey',
    productcode: 'HON001'
  })
})
.then(r => r.json())
.then(data => console.log(data));
<?php
$body = json_encode([
    'companyid'   => 2,
    'siteid'      => 2,
    'productname' => 'Organic Honey',
    'productcode' => 'HON001',
]);
$curl = curl_init('https://developer.traceallglobal.com/api/v1/newlines');
curl_setopt_array($curl, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS     => $body,
    CURLOPT_HTTPHEADER     => [
        'X-API-Key: YOUR_API_KEY',
        'Content-Type: application/json',
    ],
]);
$data = json_decode(curl_exec($curl), true);
curl_close($curl);
print_r($data);

Update one or more fields on an existing newline. Only provided fields are updated — all others retain their current value. Send the request as POST with the header X-HTTP-Method-Override: PUT.

Parameters

X-API-Key (header, string, Required)

Content-Type (header, string, Required) — application/json

X-HTTP-Method-Override (header, string, Required) — Must be PUT

id (path, integer, Required) — The newlineid to update.

Body (JSON) — Any combination of the following optional fields:

  • companyid (integer)
  • productname (string, max 75)
  • productcode (string, max 12)
  • description (string)
  • producttype (integer)
  • category (integer)
  • mcs (integer)
  • buyer (integer — user ID)
  • buyercomments (string)
  • isactive (integer — 0 or 1)
  • alcoholic / cannedfish / cbd
  • chocolate / coffee / curedmeats
  • freshfish / freshfruit / freshmeat
  • honey / jam / oliveoil
  • smokedfish / supplements
  • cheese / fish
  • (all integers, 0 or 1)
Test this endpoint

Response Examples

{
  "success": true,
  "data": {
    "message": "Newline updated successfully",
    "data": { ...updated newline row... },
    "accordionHeader": 1
  }
}
{ "success": false, "error": "Newline not found after update" }
{ "success": false, "error": "No valid fields provided for update" }

Code Examples

curl -X POST "https://developer.traceallglobal.com/api/v1/newlines/1" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-HTTP-Method-Override: PUT" \
  -d '{"productname": "Updated Name", "isactive": 1}'
fetch('https://developer.traceallglobal.com/api/v1/newlines/1', {
  method: 'POST',
  headers: {
    'X-API-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
    'X-HTTP-Method-Override': 'PUT'
  },
  body: JSON.stringify({ productname: 'Updated Name', isactive: 1 })
})
.then(r => r.json())
.then(data => console.log(data));
<?php
$body = json_encode(['productname' => 'Updated Name', 'isactive' => 1]);
$curl = curl_init('https://developer.traceallglobal.com/api/v1/newlines/1');
curl_setopt_array($curl, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS     => $body,
    CURLOPT_HTTPHEADER     => [
        'X-API-Key: YOUR_API_KEY',
        'Content-Type: application/json',
        'X-HTTP-Method-Override: PUT',
    ],
]);
$data = json_decode(curl_exec($curl), true);
curl_close($curl);
print_r($data);

The record is not physically removed. Returns 404 if the newline does not exist or is already inactive. Requires Admin permission.

Parameters

X-API-Key (header, string, Required)

id (path, integer, Required) — The newlineid to delete.

Test this endpoint

Response Examples

{
  "success": true,
  "data": {
    "message": "Newline deleted (set to inactive) successfully",
    "newlineid": 1
  }
}
{ "success": false, "error": "Newline not found or already inactive" }
{ "success": false, "error": "Missing API key" }

Code Examples

curl -X DELETE "https://developer.traceallglobal.com/api/v1/newlines/1" \
  -H "X-API-Key: YOUR_API_KEY"
fetch('https://developer.traceallglobal.com/api/v1/newlines/1', {
  method: 'DELETE',
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
})
.then(r => r.json())
.then(data => console.log(data));
<?php
$curl = curl_init('https://developer.traceallglobal.com/api/v1/newlines/1');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST  => 'DELETE',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => ['X-API-Key: YOUR_API_KEY'],
]);
$data = json_decode(curl_exec($curl), true);
curl_close($curl);
print_r($data);

Create multiple new product lines in a single request. Accepts either a JSON array of newline objects (application/json) or a CSV file upload (multipart/form-data, field name file). Each row is processed independently — failures are collected and returned with a retry_payload so failed rows can be resubmitted without reprocessing successes. Each created row also automatically creates an associated product spec (dt_ps) record. Requires Editor permission or higher.

Parameters

X-API-Key (header, string, Required)

Content-Type (header, string, Required) — Either application/json for a JSON array body, or multipart/form-data for a CSV file upload.

Body (Required) — One of:

  • JSON array: An array of newline objects. Each object uses the same fields as POST /newlines. Required fields per row: companyid, siteid, productname, productcode. A single object is also accepted.
  • CSV file: A .csv file in form field file. Headers must match the field names (case-insensitive).
Sample JSON array (2 newlines):
[
  {
    "companyid": 2,
    "siteid": 2,
    "productname": "Organic Honey",
    "productcode": "HON001",
    "description": "Pure organic honeydew",
    "producttype": 3,
    "category": 2,
    "honey": 1,
    "buyer": 4,
    "buyercomments": ""
  },
  {
    "companyid": 2,
    "siteid": 2,
    "productname": "Dark Chocolate Bar",
    "productcode": "CHOC001",
    "chocolate": 1
  }
]
Test this endpoint (JSON array)
Provide a JSON array of newline objects. Each must include companyid, siteid, productname, and productcode.

Response Examples

{
  "success": true,
  "total": 2,
  "created": 1,
  "failed": 1,
  "results": [
    {
      "row": 1,
      "productname": "Organic Honey",
      "status": "success",
      "newlineid": 42,
      "psid": 107
    },
    {
      "row": 2,
      "productname": "Dark Chocolate Bar",
      "status": "error",
      "message": "Missing required fields: productcode"
    }
  ],
  "retry_payload": [
    {
      "companyid": 2,
      "siteid": 2,
      "productname": "Dark Chocolate Bar",
      "chocolate": 1
    }
  ]
}
{ "success": false, "error": "Missing API key" }
{ "success": false, "error": "Request body must be a non-empty JSON array of newline objects" }
{ "success": false, "error": "Unsupported content type. Use application/json or multipart/form-data with a CSV file." }

Code Examples

# JSON array
curl -X POST "https://developer.traceallglobal.com/api/v1/newlines/createNewlineBulk" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '[{"companyid":2,"siteid":2,"productname":"Organic Honey","productcode":"HON001","honey":1}]'

# CSV file upload
curl -X POST "https://developer.traceallglobal.com/api/v1/newlines/createNewlineBulk" \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "file=@newlines.csv"
const newlines = [
  {
    companyid: 2, siteid: 2,
    productname: 'Organic Honey', productcode: 'HON001',
    honey: 1, buyer: 4
  },
  {
    companyid: 2, siteid: 2,
    productname: 'Dark Chocolate Bar', productcode: 'CHOC001',
    chocolate: 1
  }
];

fetch('https://developer.traceallglobal.com/api/v1/newlines/createNewlineBulk', {
  method: 'POST',
  headers: { 'X-API-Key': 'YOUR_API_KEY', 'Content-Type': 'application/json' },
  body: JSON.stringify(newlines)
})
.then(r => r.json())
.then(data => {
  console.log(`Created: ${data.created}, Failed: ${data.failed}`);
  if (data.retry_payload.length > 0) console.log('Retry:', data.retry_payload);
});
<?php
$data = [
    [
        'companyid'   => 2,
        'siteid'      => 2,
        'productname' => 'Organic Honey',
        'productcode' => 'HON001',
        'honey'       => 1,
        'buyer'       => 4,
    ],
];
$curl = curl_init('https://developer.traceallglobal.com/api/v1/newlines/createNewlineBulk');
curl_setopt_array($curl, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS     => json_encode($data),
    CURLOPT_HTTPHEADER     => [
        'X-API-Key: YOUR_API_KEY',
        'Content-Type: application/json',
    ],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
echo "Created: {$result['created']}, Failed: {$result['failed']}\n";
if (!empty($result['retry_payload'])) {
    echo 'Retry: ' . json_encode($result['retry_payload'], JSON_PRETTY_PRINT) . "\n";
}
?>