MENU navbar-image

Introduction

This documentation will provide all the information you need to work with our API

This documentation aims to provide all the information you need to work with our API.

Authenticating requests

This API is not authenticated.

AdminPortal Management

Store a newly created administrator Creates a new administrator account, validates the input data, generates a random password, sends a confirmation email, and returns the created user details along with a success message.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/add-admin" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"full_name\": \"John Doe\",
    \"email\": \"admin@example.com\"
}"
const url = new URL(
    "farmsell.org/api/v2/admin/add-admin"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "full_name": "John Doe",
    "email": "admin@example.com"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (201):


{
    "status": "SUCCESS",
    "message": "Registration successful. Please check your email for verification.",
    "user": {
        "id": 1,
        "full_name": "John Doe",
        "email": "admin@example.com",
        "created_at": "2025-01-30T12:00:00Z",
        "updated_at": "2025-01-30T12:00:00Z"
    }
}
 

Example response (400):


{
    "status": "FAILED",
    "error": "This email address is already associated with another account. Please use a different email."
}
 

Example response (500):


{
    "status": "FAILED",
    "result": "Database error: <error_message>"
}
 

Request      

POST api/v2/admin/add-admin

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

full_name   string   

The full name of the administrator. Example: John Doe

email   string   

The email address of the administrator. Must be unique. Example: admin@example.com

Login an administrator Authenticates an administrator by verifying their email and password, and returns a generated token for access to other API routes.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/login" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"email\": \"admin@example.com\",
    \"password\": \"password123\"
}"
const url = new URL(
    "farmsell.org/api/v2/admin/login"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "email": "admin@example.com",
    "password": "password123"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "data": {
        "token": "generated_token_here",
        "user": {
            "id": 1,
            "full_name": "John Doe",
            "email": "admin@example.com",
            "created_at": "2025-01-30T12:00:00Z",
            "updated_at": "2025-01-30T12:00:00Z"
        }
    }
}
 

Example response (401):


{
    "status": "FAILED",
    "message": "Invalid credentials"
}
 

Example response (404):


{
    "status": "FAILED",
    "message": "User not found"
}
 

Example response (422):


{
    "errors": {
        "email": [
            "The email field is required."
        ],
        "password": [
            "The password field is required."
        ]
    }
}
 

Example response (500):


{
    "status": "FAILED",
    "message": "Database error: <error_message>"
}
 

Request      

POST api/v2/admin/login

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

email   string   

The email address of the administrator. Example: admin@example.com

password   string   

The password of the administrator. Example: password123

Verify OTP and login Verifies the OTP entered by the user and logs the user in if the OTP is valid and not expired. Upon successful verification, a token is generated for the user.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/verify_otp" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"email\": \"\\\"admin@example.com\\\"\",
    \"otp\": \"\\\"123456\\\"\"
}"
const url = new URL(
    "farmsell.org/api/v2/admin/verify_otp"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "email": "\"admin@example.com\"",
    "otp": "\"123456\""
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
 "status": "SUCCESS",
 "user": {
     "id": 1,
     "full_name": "John Doe",
     "email": "admin@example.com",
     // other user details
 },
 "token": "access_token_here",
 "message": "Login successful"
}
 

Example response (422):


{
    "status": "FAILED",
    "message": "Invalid or expired OTP"
}
 

Example response (422):


{
    "errors": {
        "email": [
            "The email field is required."
        ],
        "otp": [
            "The otp field is required."
        ]
    }
}
 

Example response (500):


{
    "status": "FAILED",
    "message": "An error occurred: <error_message>"
}
 

Request      

POST api/v2/admin/verify_otp

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

email   string   

The email address of the administrator. Example: "admin@example.com"

otp   string   

The one-time password (OTP) sent to the user's email. Example: "123456"

Resend OTP verification code Resends the OTP verification code to the user's email address. This is useful if the user didn't receive the OTP or it has expired.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/resend-verify-code" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"email\": \"\\\"admin@example.com\\\"\"
}"
const url = new URL(
    "farmsell.org/api/v2/admin/resend-verify-code"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "email": "\"admin@example.com\""
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "message": "OTP sent successfully"
}
 

Example response (422):


{
    "errors": {
        "email": [
            "The email field is required."
        ]
    }
}
 

Example response (500):


{
    "status": "FAILED",
    "message": "An error occurred: <error_message>"
}
 

Request      

POST api/v2/admin/resend-verify-code

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

email   string   

The email address of the administrator. Example: "admin@example.com"

Verify an administrator's email Verifies the administrator's email using a unique verification link with a user ID and hash. Marks the email as verified if the link is valid.

Example request:
curl --request GET \
    --get "farmsell.org/api/v2/admin/email/verify/1/abcdef12345" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "farmsell.org/api/v2/admin/email/verify/1/abcdef12345"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "message": "Email verified successfully"
}
 

Example response (400):


{
    "status": "FAILED",
    "message": "Invalid verification link"
}
 

Example response (500):


{
    "status": "FAILED",
    "message": "An error occurred: <error_message>"
}
 

Request      

GET api/v2/admin/email/verify/{id}/{hash}

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

URL Parameters

id   integer   

The ID of the administrator to verify. Example: 1

hash   string   

The hashed verification code sent to the administrator's email. Example: abcdef12345

Resend email verification link Resends the email verification link to an administrator who has not yet verified their email address. Returns a success message if the email has been sent, or an error message if the email is already verified.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/resend" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"id\": 1
}"
const url = new URL(
    "farmsell.org/api/v2/admin/resend"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "id": 1
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "message": "Verification link sent!"
}
 

Example response (400):


{
    "status": "FAILED",
    "message": "Email is already verified."
}
 

Example response (500):


{
    "status": "FAILED",
    "message": "An error occurred: <error_message>"
}
 

Request      

POST api/v2/admin/resend

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

id   integer   

The ID of the administrator who needs the verification link. Example: 1

Get the admin profile This endpoint returns the profile information of the authenticated admin. It fetches the current admin's data using the authentication token.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/admin-profile" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "farmsell.org/api/v2/admin/admin-profile"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "data": {
        "id": 1,
        "full_name": "John Doe",
        "email": "admin@example.com",
        "created_at": "2025-01-30T10:00:00.000000Z",
        "updated_at": "2025-01-30T10:00:00.000000Z"
    }
}
 

Example response (500):


{
    "status": "FAILED",
    "message": "An error occurred: <error_message>"
}
 

Request      

POST api/v2/admin/admin-profile

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Update the authenticated admin's profile. This endpoint allows an authenticated admin to update their profile details. You can update optional fields like full name, email, profile picture, location, and more.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/admin-update-profile" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"full_name\": \"John Doe\",
    \"email\": \"admin@example.com\",
    \"user_name\": \"johndoe\",
    \"picture\": \"http:\\/\\/example.com\\/picture.jpg\",
    \"avatar_google\": \"http:\\/\\/example.com\\/avatar.jpg\",
    \"about_user\": \"I am a software developer.\",
    \"location\": \"New York\",
    \"language\": \"English\",
    \"gender\": \"Male\",
    \"image_cover\": \"http:\\/\\/example.com\\/cover.jpg\",
    \"country\": \"USA\",
    \"date_of_birth\": \"1985-10-10\",
    \"physical_address\": \"123 Street, City\",
    \"country_code\": \"+1\",
    \"phone\": \"+1234567890\"
}"
const url = new URL(
    "farmsell.org/api/v2/admin/admin-update-profile"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "full_name": "John Doe",
    "email": "admin@example.com",
    "user_name": "johndoe",
    "picture": "http:\/\/example.com\/picture.jpg",
    "avatar_google": "http:\/\/example.com\/avatar.jpg",
    "about_user": "I am a software developer.",
    "location": "New York",
    "language": "English",
    "gender": "Male",
    "image_cover": "http:\/\/example.com\/cover.jpg",
    "country": "USA",
    "date_of_birth": "1985-10-10",
    "physical_address": "123 Street, City",
    "country_code": "+1",
    "phone": "+1234567890"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "message": "Profile updated successfully.",
    "data": {
        "id": 1,
        "full_name": "John Doe",
        "email": "admin@example.com",
        "user_name": "johndoe",
        "picture": "http://example.com/picture.jpg",
        "avatar_google": "http://example.com/avatar.jpg",
        "about_user": "I am a software developer.",
        "location": "New York",
        "language": "English",
        "gender": "Male",
        "image_cover": "http://example.com/cover.jpg",
        "country": "USA",
        "date_of_birth": "1985-10-10",
        "physical_address": "123 Street, City",
        "country_code": "+1",
        "phone": "+1234567890",
        "created_at": "2025-01-30T10:00:00.000000Z",
        "updated_at": "2025-01-30T10:30:00.000000Z"
    }
}
 

Example response (404):


{
    "message": "Administor not found."
}
 

Example response (500):


{
    "message": "An error occurred while updating the profile.",
    "error": "<error_message>"
}
 

Request      

POST api/v2/admin/admin-update-profile

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

full_name   string|null  optional  

The full name of the admin. Example: John Doe

email   string|null  optional  

The email address of the admin. Example: admin@example.com

user_name   string|null  optional  

The username of the admin. Example: johndoe

picture   string|null  optional  

The profile picture URL. Example: http://example.com/picture.jpg

avatar_google   string|null  optional  

The Google avatar URL. Example: http://example.com/avatar.jpg

about_user   string|null  optional  

The biography or about section of the admin. Example: I am a software developer.

location   string|null  optional  

The location of the admin. Example: New York

language   string|null  optional  

The preferred language of the admin. Example: English

gender   string|null  optional  

The gender of the admin. Example: Male

image_cover   string|null  optional  

The cover image URL. Example: http://example.com/cover.jpg

country   string|null  optional  

The country of the admin. Example: USA

date_of_birth   date|null  optional  

The birth date of the admin. Example: 1985-10-10

physical_address   string|null  optional  

The physical address of the admin. Example: 123 Street, City

country_code   string|null  optional  

The country calling code. Example: +1

phone   string|null  optional  

The phone number of the admin. Example: +1234567890

Logout the authenticated admin. This endpoint allows the authenticated admin to log out by revoking and deleting their access token. After logging out, the admin will no longer be able to make authenticated requests until they log in again.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/admin_logout" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "farmsell.org/api/v2/admin/admin_logout"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());

Example response (200):


{
    "result": true,
    "message": "Successfully logged out"
}
 

Example response (401):


{
    "message": "Unauthorized"
}
 

Request      

POST api/v2/admin/admin_logout

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Category Management

Create a Category Creates a new product category with an optional banner image.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/category/add-category" \
    --header "Content-Type: multipart/form-data" \
    --header "Accept: application/json" \
    --form "category_name=sint"\
    --form "description=Officiis rerum quo eligendi ut laudantium est cum alias."\
    --form "image=@/tmp/phpHiPMV4" 
const url = new URL(
    "farmsell.org/api/v2/admin/category/add-category"
);

const headers = {
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
};

const body = new FormData();
body.append('category_name', 'sint');
body.append('description', 'Officiis rerum quo eligendi ut laudantium est cum alias.');
body.append('image', document.querySelector('input[name="image"]').files[0]);

fetch(url, {
    method: "POST",
    headers,
    body,
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "data": "Category created successfully"
}
 

Example response (400):


{
    "error": {
        "category_name": [
            "The category name field is required."
        ]
    }
}
 

Example response (500):


{
    "status": "FAILED",
    "data": "Error message"
}
 

Request      

POST api/v2/admin/category/add-category

Headers

Content-Type      

Example: multipart/form-data

Accept      

Example: application/json

Body Parameters

category_name   string   

The name of the category. Example: sint

description   string  optional  

The description of the category. Example: Officiis rerum quo eligendi ut laudantium est cum alias.

image   file  optional  

The image file for the category banner. Example: /tmp/phpHiPMV4

Update a Category Updates the details of an existing category, including an optional category banner image.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/category/update-category" \
    --header "Content-Type: multipart/form-data" \
    --header "Accept: application/json" \
    --form "category_id=9"\
    --form "category_name=sapiente"\
    --form "description=Dolor sunt non laborum ut."\
    --form "image=@/tmp/phpN3WdiI" 
const url = new URL(
    "farmsell.org/api/v2/admin/category/update-category"
);

const headers = {
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
};

const body = new FormData();
body.append('category_id', '9');
body.append('category_name', 'sapiente');
body.append('description', 'Dolor sunt non laborum ut.');
body.append('image', document.querySelector('input[name="image"]').files[0]);

fetch(url, {
    method: "POST",
    headers,
    body,
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "data": "Category updated successfully"
}
 

Example response (400):


{
    "error": {
        "category_id": [
            "The category_id field is required."
        ]
    }
}
 

Example response (404):


{
    "status": "FAILED",
    "data": "Category not found"
}
 

Example response (500):


{
    "status": "FAILED",
    "data": "Error message"
}
 

Request      

POST api/v2/admin/category/update-category

Headers

Content-Type      

Example: multipart/form-data

Accept      

Example: application/json

Body Parameters

category_id   integer   

The ID of the category to update. Example: 9

category_name   string  optional  

The new name of the category. Example: sapiente

description   string  optional  

The new description of the category. Example: Dolor sunt non laborum ut.

image   file  optional  

The image file for the category banner (optional). Example: /tmp/phpN3WdiI

List Categories Retrieves a list of categories with optional filters and pagination.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/category/all-category" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"search\": \"sunt\",
    \"category_id\": 19
}"
const url = new URL(
    "farmsell.org/api/v2/admin/category/all-category"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "search": "sunt",
    "category_id": 19
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
 "status": "SUCCESS",
 "data": {
     "current_page": 1,
     "data": [
         {
             "id": 1,
             "category_name": "Electronics",
             "banner": {
                 "picture_url": "electronics_banner.jpg"
             },
             "subcategory": [
                 {
                     "subcat_name": "Mobile Phones"
                 },
                 {
                     "subcat_name": "Laptops"
                 }
             ]
         },
         ...
     ],
     "last_page": 5
 }
}
 

Example response (400):


{
    "status": "FAILED",
    "data": "Invalid request"
}
 

Example response (500):


{
    "status": "FAILED",
    "data": "Error message"
}
 

Request      

POST api/v2/admin/category/all-category

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

search   string  optional  

Search term to filter categories by name (optional). Example: sunt

category_id   integer  optional  

Filter categories by a specific category ID (optional). Example: 19

Delete a Category Deletes a category from the system.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/category/delete-category" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"category_id\": 18
}"
const url = new URL(
    "farmsell.org/api/v2/admin/category/delete-category"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "category_id": 18
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "data": "Category deleted successfully"
}
 

Example response (400):


{
    "error": {
        "category_id": [
            "The category_id field is required."
        ]
    }
}
 

Example response (404):


{
    "status": "FAILED",
    "data": "Category not found"
}
 

Example response (500):


{
    "status": "FAILED",
    "data": "Error message"
}
 

Request      

POST api/v2/admin/category/delete-category

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

category_id   integer   

The ID of the category to delete. Example: 18

Endpoints

POST api/v2/admin/product/update-stock-level

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/product/update-stock-level" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "farmsell.org/api/v2/admin/product/update-stock-level"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());

Request      

POST api/v2/admin/product/update-stock-level

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

POST api/v2/admin/product/adjust-price

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/product/adjust-price" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "farmsell.org/api/v2/admin/product/adjust-price"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());

Request      

POST api/v2/admin/product/adjust-price

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

POST api/v2/admin/product/mark-product

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/product/mark-product" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "farmsell.org/api/v2/admin/product/mark-product"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());

Request      

POST api/v2/admin/product/mark-product

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Inventory Management

Get Product Analytics Retrieves various analytics related to product performance, including total products, low-stock items, top-performing products, and slow-moving products.

Example request:
curl --request GET \
    --get "farmsell.org/api/v2/admin/inventory/analytics" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "farmsell.org/api/v2/admin/inventory/analytics"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (200):


{
    "total_products": 150,
    "low_stock_items": 10,
    "top_performing_products": 5,
    "slow_moving_products": 8
}
 

Example response (500):


{
    "status": "FAILED",
    "message": "An error occurred while fetching analytics."
}
 

Request      

GET api/v2/admin/inventory/analytics

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Get All Stock Retrieves a paginated list of all stock products with optional filtering by status, category, subcategory, and product title.

Example request:
curl --request GET \
    --get "farmsell.org/api/v2/admin/inventory/all-stock?status=active&category_id=2&sub_category_id=5&product_title=Laptop" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "farmsell.org/api/v2/admin/inventory/all-stock"
);

const params = {
    "status": "active",
    "category_id": "2",
    "sub_category_id": "5",
    "product_title": "Laptop",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "payload": {
        "current_page": 1,
        "data": [
            {
                "id": 1,
                "product_title": "Laptop",
                "category": {
                    "id": 2,
                    "name": "Electronics"
                },
                "subCategory": {
                    "id": 5,
                    "name": "Computers"
                },
                "status": "active",
                "images": [
                    {
                        "id": 10,
                        "url": "https://example.com/image.jpg"
                    }
                ]
            }
        ],
        "per_page": 20,
        "total": 100
    }
}
 

Example response (500):


{
    "status": "FAILED",
    "message": "Failed to fetch products",
    "error": "Internal server error message"
}
 

Request      

GET api/v2/admin/inventory/all-stock

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Query Parameters

status   string  optional  

Optional The status of the products to filter. Example: active

category_id   integer  optional  

Optional The ID of the category to filter by. Example: 2

sub_category_id   integer  optional  

Optional The ID of the subcategory to filter by. Example: 5

product_title   string  optional  

Optional The product title to search for (partial match). Example: Laptop

Order Management

List All Orders Retrieves all orders with optional filters for status and date sorting.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/order/all-orders" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"status\": \"sed\",
    \"sort_date\": \"ratione\"
}"
const url = new URL(
    "farmsell.org/api/v2/admin/order/all-orders"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "status": "sed",
    "sort_date": "ratione"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "current_page": 1,
    "data": [
        {
            "id": 1,
            "customer": {
                "id": 123,
                "full_name": "John Doe",
                "phone": "123-456-7890",
                "email": "john.doe@example.com"
            },
            "items": [
                {
                    "id": 1,
                    "product": {
                        "id": 10,
                        "product_title": "Product Title"
                    },
                    "quantity": 2,
                    "price": 25
                }
            ],
            "status": "pending",
            "created_at": "2025-01-29T12:00:00Z"
        }
    ],
    "total": 100,
    "per_page": 20,
    "last_page": 5,
    "from": 1,
    "to": 20
}
 

Example response (500):


{
    "status": "FAILED",
    "message": "Failed to fetch products",
    "error": "Error message"
}
 

Request      

POST api/v2/admin/order/all-orders

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

status   string  optional  

optional The status of the order (e.g., 'pending', 'completed'). Example: sed

sort_date   string  optional  

optional The sorting order for the orders based on their creation date. Accepts 'asc' or 'desc'. Defaults to 'asc'. Example: ratione

Cancel an Order Cancels an existing order by updating its status to 'canceled'.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/order/cancel-order" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"orderId\": 6
}"
const url = new URL(
    "farmsell.org/api/v2/admin/order/cancel-order"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "orderId": 6
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "message": "Order has been cancelled"
}
 

Example response (404):


{
    "message": "Order not found"
}
 

Example response (500):


{
    "status": "FAILED",
    "message": "Order has been cancelled"
}
 

Request      

POST api/v2/admin/order/cancel-order

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

orderId   integer   

The ID of the order to be canceled. Example: 6

Mark an Order as Shipped Marks an existing order as shipped by updating its status to 'shipped'. Optionally, this could also update the shipment timestamp and notify the customer.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/order/shipped-order" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"orderId\": 3
}"
const url = new URL(
    "farmsell.org/api/v2/admin/order/shipped-order"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "orderId": 3
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "message": "Order has been shipped"
}
 

Example response (404):


{
    "message": "Order not found"
}
 

Example response (500):


{
    "status": "FAILED",
    "message": "Order has failed to be shipped"
}
 

Request      

POST api/v2/admin/order/shipped-order

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

orderId   integer   

The ID of the order to be marked as shipped. Example: 3

Bulk Update Orders to Shipped Status This endpoint allows you to bulk update the status of multiple orders to 'shipped'. It accepts an array of order IDs and processes them to set their status to 'shipped'.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/order/bulk_shipping" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"order_Ids\": [
        \"rerum\"
    ]
}"
const url = new URL(
    "farmsell.org/api/v2/admin/order/bulk_shipping"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "order_Ids": [
        "rerum"
    ]
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "message": "Bulk operation for 'shipped' completed",
    "results": {
        "shipped": [
            1,
            2,
            3
        ],
        "failed": [
            {
                "id": 4,
                "message": "Order not found"
            },
            {
                "id": 5,
                "message": "Status update failed"
            }
        ]
    }
}
 

Example response (500):


{
    "status": "FAILED",
    "message": "Something went wrong",
    "error": "Exception message here"
}
 

Request      

POST api/v2/admin/order/bulk_shipping

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

order_Ids   string[]   

The IDs of the orders to be updated to shipped status.

Mark an Order as Delivered Marks an existing order as delivered by updating its status to 'delivered'. Optionally, it records the delivery time and notifies the customer about the delivery.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/order/delivered-order" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"orderId\": 17
}"
const url = new URL(
    "farmsell.org/api/v2/admin/order/delivered-order"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "orderId": 17
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "message": "Order has been delivered"
}
 

Example response (404):


{
    "message": "Order not found"
}
 

Example response (500):


{
    "status": "FAILED",
    "message": "Order has failed to be delivered"
}
 

Request      

POST api/v2/admin/order/delivered-order

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

orderId   integer   

The ID of the order to be marked as delivered. Example: 17

Bulk Update Orders to Delivered Status This endpoint allows you to bulk update the status of multiple orders to 'delivered'. It accepts an array of order IDs and processes them to set their status to 'delivered'.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/order/bulk-delivered" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"order_Ids\": [
        \"distinctio\"
    ]
}"
const url = new URL(
    "farmsell.org/api/v2/admin/order/bulk-delivered"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "order_Ids": [
        "distinctio"
    ]
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "message": "Bulk operation for 'delivered' completed",
    "results": {
        "delivered": [
            1,
            2,
            3
        ],
        "failed": [
            {
                "id": 4,
                "message": "Order not found"
            },
            {
                "id": 5,
                "message": "Status update failed"
            }
        ]
    }
}
 

Example response (500):


{
    "status": "FAILED",
    "message": "Something went wrong",
    "error": "Exception message here"
}
 

Request      

POST api/v2/admin/order/bulk-delivered

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

order_Ids   string[]   

The IDs of the orders to be updated to delivered status.

Mark an Order as Completed Marks an existing order as completed by updating its status to 'completed'.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/order/completed-order" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"orderId\": 6
}"
const url = new URL(
    "farmsell.org/api/v2/admin/order/completed-order"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "orderId": 6
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "message": "Order has been completed"
}
 

Example response (404):


{
    "message": "Order not found"
}
 

Example response (500):


{
    "status": "FAILED",
    "message": "Order has failed been completed"
}
 

Request      

POST api/v2/admin/order/completed-order

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

orderId   integer   

The ID of the order to be marked as completed. Example: 6

Bulk Update Orders to Canceled Status This endpoint allows you to bulk update the status of multiple orders to 'canceled'. It accepts an array of order IDs and processes them to set their status to 'canceled'.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/order/bulk-canceled" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"order_Ids\": [
        \"reprehenderit\"
    ]
}"
const url = new URL(
    "farmsell.org/api/v2/admin/order/bulk-canceled"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "order_Ids": [
        "reprehenderit"
    ]
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "message": "Bulk operation for 'canceled' completed",
    "results": {
        "canceled": [
            1,
            2,
            3
        ],
        "failed": [
            {
                "id": 4,
                "message": "Order not found"
            },
            {
                "id": 5,
                "message": "Status update failed"
            }
        ]
    }
}
 

Example response (500):


{
    "status": "FAILED",
    "message": "Something went wrong",
    "error": "Exception message here"
}
 

Request      

POST api/v2/admin/order/bulk-canceled

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

order_Ids   string[]   

The IDs of the orders to be updated to canceled status.

Bulk Update Orders to Completed Status This endpoint allows you to bulk update the status of multiple orders to 'completed'. It accepts an array of order IDs and processes them to set their status to 'completed'.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/order/bulk-completed" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"order_Ids\": [
        \"provident\"
    ]
}"
const url = new URL(
    "farmsell.org/api/v2/admin/order/bulk-completed"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "order_Ids": [
        "provident"
    ]
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "message": "Bulk operation for 'completed' completed",
    "results": {
        "completed": [
            1,
            2,
            3
        ],
        "failed": [
            {
                "id": 4,
                "message": "Order not found"
            },
            {
                "id": 5,
                "message": "Status update failed"
            }
        ]
    }
}
 

Example response (500):


{
    "status": "FAILED",
    "message": "Something went wrong",
    "error": "Exception message here"
}
 

Request      

POST api/v2/admin/order/bulk-completed

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

order_Ids   string[]   

The IDs of the orders to be updated to completed status.

Get the Order Status Analysis Retrieves the count of orders by their status (pending, completed, canceled, delivered, and shipped). This is helpful for analyzing the distribution of orders across various statuses.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/order/order-status-analysis" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "farmsell.org/api/v2/admin/order/order-status-analysis"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "payload": {
        "pending": 10,
        "completed": 25,
        "canceled": 5,
        "delivered": 30,
        "shipped": 20
    }
}
 

Example response (500):


{
    "status": "ERROR",
    "message": "Internal Server Error"
}
 

Request      

POST api/v2/admin/order/order-status-analysis

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Export Orders Exports a list of orders with optional filters for status and sorting by date.

Example request:
curl --request GET \
    --get "farmsell.org/api/v2/admin/order/export-order?status=pending&sort_date=desc" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "farmsell.org/api/v2/admin/order/export-order"
);

const params = {
    "status": "pending",
    "sort_date": "desc",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (200):


{
    "file": "orders.csv"
}
 

Example response (404):


{
    "message": "No orders found to export."
}
 

Example response (500):


{
    "status": "FAILED",
    "message": "An error occurred while exporting orders."
}
 

Request      

GET api/v2/admin/order/export-order

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Query Parameters

status   string  optional  

Optional The status of the orders to filter. Example: pending

sort_date   string  optional  

Optional The sorting order for the creation date ('asc' or 'desc'). Default is 'asc'. Example: desc

Product Management

Get All Products

Example request:
curl --request GET \
    --get "farmsell.org/api/v2/admin/product/all-product" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "farmsell.org/api/v2/admin/product/all-product"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "message": "Products retrieved successfully",
    "data": [
        {
            "id": 1,
            "product_title": "Sample Product",
            "status": "Active"
        }
    ]
}
 

Request      

GET api/v2/admin/product/all-product

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Review Product

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/product/view-product" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"id\": 11
}"
const url = new URL(
    "farmsell.org/api/v2/admin/product/view-product"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "id": 11
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "message": "Product reviewed successfully",
    "data": {
        "id": 11,
        "product_title": "Sample Product",
        "status": "Reviewed"
    }
}
 

Example response (400):


{
    "status": "FAILED",
    "message": "Invalid Product ID"
}
 

Request      

POST api/v2/admin/product/view-product

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

id   integer   

The ID of the product to be reviewed. Example: 11

Approve a Product This endpoint approves a product by changing its status.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/product/approve-product" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"id\": 3
}"
const url = new URL(
    "farmsell.org/api/v2/admin/product/approve-product"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "id": 3
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "message": "Product approved successfully."
}
 

Request      

POST api/v2/admin/product/approve-product

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

id   integer   

The ID of the product to approve. Example: 3

Bulk Approve Products Approve multiple products in bulk.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/product/bulk-approve" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"product_Ids\": [
        1,
        2,
        3
    ]
}"
const url = new URL(
    "farmsell.org/api/v2/admin/product/bulk-approve"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "product_Ids": [
        1,
        2,
        3
    ]
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "message": "Bulk operation completed",
    "results": {
        "approved": [
            1,
            2
        ],
        "failed": [
            {
                "id": 3,
                "message": "Invalid status"
            }
        ]
    }
}
 

Request      

POST api/v2/admin/product/bulk-approve

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

product_Ids   string[]   

The list of product IDs to approve.

Reject a Product Rejects a product with a given reason.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/product/reject-product" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"id\": 18,
    \"reason\": \"et\"
}"
const url = new URL(
    "farmsell.org/api/v2/admin/product/reject-product"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "id": 18,
    "reason": "et"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "message": "Product rejected successfully."
}
 

Request      

POST api/v2/admin/product/reject-product

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

id   integer   

The ID of the product to reject. Example: 18

reason   string   

The reason for rejection. Example: et

Bulk reject Products Reject multiple products in bulk.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/product/bulk-reject" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"product_Ids\": [
        1,
        2,
        3
    ]
}"
const url = new URL(
    "farmsell.org/api/v2/admin/product/bulk-reject"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "product_Ids": [
        1,
        2,
        3
    ]
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "message": "Bulk operation completed",
    "results": {
        "rejected": [
            1,
            2
        ],
        "failed": [
            {
                "id": 3,
                "message": "Invalid status"
            }
        ]
    }
}
 

Request      

POST api/v2/admin/product/bulk-reject

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

product_Ids   string[]   

The list of product IDs to approve.

Update a Product Updates product details.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/product/update-product" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"id\": 14,
    \"product_title\": \"repellat\",
    \"price\": 687913.761,
    \"quantity_available\": 8
}"
const url = new URL(
    "farmsell.org/api/v2/admin/product/update-product"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "id": 14,
    "product_title": "repellat",
    "price": 687913.761,
    "quantity_available": 8
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "success",
    "edit_product": {
        "id": 1,
        "product_title": "New Title",
        "price": 50,
        "quantity_available": 100
    }
}
 

Request      

POST api/v2/admin/product/update-product

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

id   integer   

The ID of the product. Example: 14

product_title   string  optional  

The title of the product. Example: repellat

price   number  optional  

The price of the product. Example: 687913.761

quantity_available   integer  optional  

The available quantity. Example: 8

Get Product Analytics Retrieves the count of products in different statuses.

Example request:
curl --request GET \
    --get "farmsell.org/api/v2/admin/product/product-analytics" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "farmsell.org/api/v2/admin/product/product-analytics"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "payload": {
        "pending_count": 5,
        "approved_count": 10,
        "rejected_count": 2
    }
}
 

Request      

GET api/v2/admin/product/product-analytics

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

GET api/v2/admin/product/export-products

Example request:
curl --request GET \
    --get "farmsell.org/api/v2/admin/product/export-products" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "farmsell.org/api/v2/admin/product/export-products"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (401):

Show headers
cache-control: no-cache, private
content-type: application/json
x-ratelimit-limit: 120
x-ratelimit-remaining: 119
 

{
    "error": "Unauthorized"
}
 

Request      

GET api/v2/admin/product/export-products

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

SubCategory Management

Add SubCategories Adds one or more subcategories to a category.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/category/add-subcategory" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"category_id\": 7,
    \"sub_categories\": [
        \"omnis\"
    ]
}"
const url = new URL(
    "farmsell.org/api/v2/admin/category/add-subcategory"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "category_id": 7,
    "sub_categories": [
        "omnis"
    ]
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "result": true,
    "success": "subcategory created successfully"
}
 

Example response (422):


{
    "status": "ERROR",
    "errors": {
        "category_id": [
            "The category id must be a valid integer."
        ],
        "sub_categories.*.name": [
            "The subcategory name is required."
        ]
    }
}
 

Example response (500):


{
    "status": "FAILED",
    "data": "Error message"
}
 

Request      

POST api/v2/admin/category/add-subcategory

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

category_id   integer   

The ID of the category to associate the subcategories with. Example: 7

sub_categories   string[]   

An array of subcategory names.

*   object  optional  
name   string   

The name of each subcategory. Example: id

Update SubCategories Updates existing subcategories or creates new ones within a category.

Example request:
curl --request POST \
    "farmsell.org/api/v2/admin/category/update-subcategory" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"category_id\": 17,
    \"sub_categories\": [
        \"totam\"
    ]
}"
const url = new URL(
    "farmsell.org/api/v2/admin/category/update-subcategory"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "category_id": 17,
    "sub_categories": [
        "totam"
    ]
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "status": "SUCCESS",
    "message": "Subcategories updated successfully."
}
 

Example response (422):


{
    "status": "ERROR",
    "errors": {
        "category_id": [
            "The category id must be a valid integer."
        ],
        "sub_categories.*.sub_id": [
            "The subcategory id is required."
        ],
        "sub_categories.*.name": [
            "The subcategory name is required."
        ]
    }
}
 

Example response (500):


{
    "status": "FAILED",
    "error": "Error message"
}
 

Request      

POST api/v2/admin/category/update-subcategory

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

category_id   integer   

The ID of the category to update subcategories within. Example: 17

sub_categories   string[]   

An array of subcategories to be updated.

*   object  optional  
sub_id   integer   

The ID of the subcategory to update. Example: 5

name   string   

The name of the subcategory. Example: fuga