DELETE https://example.com/api/v1/products

Delete Product

Delete product by id

URL Parameters

ParameterTypeDescription
product_idintegerID of the product to update

Body Parameters

Same fields as Add Product apply; all fields are optional.

PHP
<?php

$baseUrl = 'https://example.com/api/v1/';
$apiKey  = ''; // You need to obtain a token from the admin for the API Key.
$result  = '';

function apiRequest($method, $url, $apiKey, $data = null)
{
	$ch = curl_init();

	$headers = [
		'X-API-Key: ' . trim($apiKey),
		'Accept: application/json',
	];

	if ($data !== null) {
		$headers[] = 'Content-Type: application/json';
	}

	curl_setopt_array($ch, [
		CURLOPT_URL => $url,
		CURLOPT_RETURNTRANSFER => true,
		CURLOPT_CUSTOMREQUEST => $method,
		CURLOPT_HTTPHEADER => $headers,
		CURLOPT_SSL_VERIFYPEER => false,
	]);

	if ($data !== null) {
		curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data, JSON_UNESCAPED_UNICODE));
	}

	$response = curl_exec($ch);
	$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
	$error = curl_error($ch);

	curl_close($ch);

	return [
		'http_code' => $httpCode,
		'curl_error' => $error,
		'response' => json_decode($response, true) ?: $response,
	];
	
}
function apiUploadImage($url, $apiKey, $filePath)
{
	$ch = curl_init();

	curl_setopt_array($ch, [
		CURLOPT_URL => $url,
		CURLOPT_RETURNTRANSFER => true,
		CURLOPT_POST => true,
		CURLOPT_HTTPHEADER => [
			'X-API-Key: ' . trim($apiKey),
			'Accept: application/json',
		],
		CURLOPT_POSTFIELDS => [
			'image' => new CURLFile($filePath, mime_content_type($filePath) ?: 'image/jpeg', basename($filePath)),
		],
		CURLOPT_SSL_VERIFYPEER => false,
	]);

	$response = curl_exec($ch);
	$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

	curl_close($ch);

	return [
		'http_code' => $httpCode,
		'response' => json_decode($response, true) ?: $response,
	];
}
$productID = 1;
$result = apiRequest('DELETE', $baseUrl . '/products/' . (int)$productID, $apiKey);
Sample Response (JSON)
(
    [http_code] => 200
    [curl_error] => 
    [response] => Array
        (
            [success] => 1
            [message] => Product Deleted
            [id] => 1
        )

)