Skip to main content

Supplier Group API

The Supplier Group API enables optical stores to organize suppliers into groups, manage group memberships, and maintain store-specific group details.
All Supplier Group API endpoints require authentication. Routes that operate in a store context also require a valid x-store-id header.

Overview

Supplier groups can be:
  • Created per store with unique names
  • Listed with pagination, filtering, and sorting
  • Retrieved individually or as a simplified list
  • Updated for name or metadata
  • Deleted individually or in bulk (if empty)
  • Used to bulk assign or remove suppliers

Endpoint Details

Base URL: https://joptic.jethings.com
Content-Type: application/json

Required Headers

Endpoints that require x-store-id enforce store-level access control. Ensure the requesting user has an active relation with the store.

Create Supplier Group

POST /supplier-groups Create a new supplier group scoped to the current store. Requires Authentication: Bearer token in Authorization header
Requires Header: x-store-id
Rate Limited: 10 requests per minute

Required Headers

Request Body

Request Body Example

Success Response

Status Code: 201 Created

Possible Errors

Example Requests

Supplier group names must be unique within a store. If a group with the same name already exists for the store, a 409 Conflict error is returned.

Get All Supplier Groups

GET /supplier-groups Retrieve a paginated list of supplier groups for the current store with optional filters. Requires Authentication: Bearer token in Authorization header
Requires Header: x-store-id
Rate Limited: 60 requests per minute

Required Headers

Query Parameters

Success Response

Status Code: 200 OK

Response Fields

SupplierGroup Object

Pagination Object

Possible Errors

Example Requests

Search by name:

Get Supplier Groups List

GET /supplier-groups/list Retrieve all supplier groups accessible to the authenticated user across stores they can access. This simplified list includes supplier count per group. Requires Authentication: Bearer token in Authorization header Rate Limited: 60 requests per minute

Success Response

Status Code: 200 OK

Possible Errors

Example Requests

This endpoint returns all supplier groups from stores the user has access to, sorted by name. It does not require the x-store-id header and is useful for dropdown lists or selection interfaces.

Get Supplier Group by ID

GET /supplier-groups/:id Retrieve a supplier group by ID. Requires Authentication: Bearer token in Authorization header Rate Limited: 60 requests per minute

Path Parameters

Success Response

Status Code: 200 OK

Possible Errors

Example Requests


Update Supplier Group

PUT /supplier-groups/:id Update a supplier group’s name. Requires Authentication: Bearer token in Authorization header Rate Limited: 20 requests per minute

Path Parameters

Request Body

Request Body Example

Success Response

Status Code: 200 OK Returns the updated SupplierGroup object (same shape as in “Get Supplier Group by ID”).

Possible Errors

Example Requests

If the new name conflicts with an existing supplier group name in the same store, a 409 Conflict error is returned. The name must be unique within the store scope.

Delete Supplier Group

DELETE /supplier-groups/:id Delete a supplier group. The group must not contain active suppliers. Requires Authentication: Bearer token in Authorization header Rate Limited: 5 requests per minute
If the group still contains suppliers, deletion will fail with a conflict error. Reassign or remove suppliers before deleting.

Path Parameters

Success Response

Status Code: 200 OK

Possible Errors

Example Requests


Bulk Delete Supplier Groups

DELETE /supplier-groups Delete multiple supplier groups by IDs. Each group must be empty (no active suppliers). Requires Authentication: Bearer token in Authorization header Rate Limited: 3 requests per minute

Request Body

Request Body Example

Success Response

Status Code: 200 OK

Possible Errors

Example Requests

This is a bulk delete operation. Only empty supplier groups (with no active suppliers) can be deleted. Groups with active suppliers will cause a 409 Conflict error. The operation processes each group individually and returns the count of successfully deleted groups. Rate limited to 3 requests per minute for safety.

Bulk Assign Suppliers to Group

POST /supplier-groups/:id/assign-suppliers Assign multiple suppliers to a supplier group. Existing assignments are skipped. Requires Authentication: Bearer token in Authorization header Rate Limited: 10 requests per minute

Path Parameters

Request Body

Request Body Example

Success Response

Status Code: 200 OK

Possible Errors

Example Requests

The operation processes each supplier individually. If a supplier is already assigned to the group, it is skipped. If a supplier doesn’t exist, it is skipped. The response indicates how many suppliers were successfully assigned out of the total provided.

Bulk Remove Suppliers from Group

POST /supplier-groups/:id/remove-suppliers Remove multiple suppliers from a supplier group. Relations are marked inactive rather than deleted. Requires Authentication: Bearer token in Authorization header Rate Limited: 10 requests per minute

Path Parameters

Request Body

Request Body Example

Success Response

Status Code: 200 OK

Possible Errors

Example Requests

The operation processes each supplier individually. If a supplier is not assigned to the group, it is skipped. The supplier-group relation is marked as inactive (soft delete) rather than being permanently deleted. The response indicates how many suppliers were successfully removed out of the total provided.

Business Logic

Supplier Group Management

Store ScopingSupplier groups are scoped to stores:
  1. Each supplier group belongs to a specific store
  2. Group names must be unique within a store (not globally)
  3. Users can only access groups from stores they have access to
  4. The x-store-id header determines the store context for operations
Unique Name ValidationGroup names are validated per store:
  1. When creating a group, the name must be unique within the store
  2. When updating a group, the new name must be unique within the store
  3. If a duplicate name is found, a 409 Conflict error is returned
  4. This allows the same group name to exist in different stores
Supplier Count TrackingSupplier counts are automatically calculated:
  1. supplierCount shows the number of active suppliers in the group
  2. Count is calculated from active supplier-group relations
  3. Count is updated in real-time when suppliers are assigned/removed
  4. Used to determine if a group can be deleted (must be 0)
Deletion RestrictionsGroups with suppliers cannot be deleted:
  1. Before deletion, the system checks if the group has active suppliers
  2. If supplierCount > 0, deletion fails with 409 Conflict
  3. You must remove all suppliers from the group before deletion
  4. Use the bulk remove endpoint to clear suppliers first
Bulk AssignmentBulk assignment is fault-tolerant:
  1. Each supplier is processed individually
  2. Already-assigned suppliers are skipped (no error)
  3. Non-existent suppliers are skipped (no error)
  4. Only successfully assigned suppliers are counted
  5. Response indicates success count vs total provided
Bulk RemovalBulk removal uses soft delete:
  1. Each supplier is processed individually
  2. Not-assigned suppliers are skipped (no error)
  3. Relations are marked inactive (not permanently deleted)
  4. This preserves historical data for audit purposes
  5. Response indicates success count vs total provided

Supplier Group States

Empty Group

Empty (supplierCount: 0)
Group has no active suppliers and can be deleted

Active Group

Active (supplierCount > 0)
Group contains suppliers and cannot be deleted

Store-Scoped

Store-Scoped
Group belongs to a specific store

Unique Name

Unique Name
Name must be unique within the store

Error Responses

All endpoints may return standard HTTP error codes:
  • 400 Bad Request - Invalid request parameters or body
  • 401 Unauthorized - Missing or invalid authentication token
  • 403 Forbidden - User does not have access to the store
  • 404 Not Found - Resource not found (supplier group, supplier, etc.)
  • 409 Conflict - Name duplicate or group has active suppliers
  • 429 Too Many Requests - Rate limit exceeded
  • 500 Internal Server Error - Server error

Error Response Format

Common Error Scenarios

409 Conflict - Duplicate Name
Occurs when trying to create or update a group with a name that already exists in the store. 409 Conflict - Group Has Suppliers
Occurs when trying to delete a group that still has active suppliers. 404 Not Found - Supplier Group
Occurs when the supplier group ID doesn’t exist. 400 Bad Request - Validation Error
Occurs when required fields are missing or data types are incorrect.

Usage Examples

Example 1: Create a supplier group

Example 2: Get all supplier groups with pagination

Example 3: Update supplier group name

Example 4: Assign suppliers to a group

Example 5: Remove suppliers from a group

Example 6: Delete empty supplier group


Best Practices

  • Use descriptive group names that indicate the category or type
  • Organize suppliers by product category, location, or business relationship
  • Keep group names consistent across stores
  • Use groups to filter and manage suppliers efficiently
  • Ensure group names are unique within each store
  • Use consistent naming conventions
  • Update group names when business needs change
  • Check for name conflicts before creating groups
  • Use bulk assignment for efficiency when adding multiple suppliers
  • Assign suppliers to groups during creation for better organization
  • Use bulk removal to clear groups before deletion
  • Monitor supplier counts to understand group usage
  • Use pagination when fetching large lists of groups
  • Default limit of 10 is suitable for most use cases
  • Maximum limit of 100 should be used sparingly
  • Always check hasNext and hasPrev for navigation
  • Check supplierCount before attempting deletion
  • Remove all suppliers from a group before deleting it
  • Use bulk delete for multiple empty groups
  • Verify group IDs before deletion
  • Deletion is permanent and cannot be undone
  • DELETE endpoints are rate limited for safety
  • Single delete: 5 requests per minute
  • Bulk delete: 3 requests per minute
  • Bulk operations: 10 requests per minute
  • Implement retry logic with exponential backoff for rate limit errors
  • Bulk operations are fault-tolerant and skip invalid entries
  • Check the response count to see how many operations succeeded
  • Handle partial success scenarios appropriately
  • Use bulk operations for efficiency when managing multiple items

Supplier groups work in conjunction with other inventory management endpoints:
  • Supplier API (/suppliers) - Manage suppliers that can be assigned to groups
  • Price List API (/price-lists) - Manage price lists for suppliers in groups
Supplier groups help organize suppliers by category, making it easier to manage vendor relationships and filter suppliers. Groups are store-scoped, allowing different stores to have their own organizational structure.

Summary


Supplier API

Manage suppliers and assignments

Price List API

Manage price lists for suppliers