Skip to main content

Supplier API

The Supplier API provides endpoints for managing suppliers and their relations to stores, groups, addresses, and contacts.
All Supplier API endpoints require authentication and a valid x-store-id header to identify the store context, unless stated otherwise.

Overview

Suppliers can be:
  • Linked to one or more stores
  • Assigned to one or more supplier groups
  • Created with optional address and contact information
  • Assigned or updated with a default price list
  • Filtered and sorted by various criteria
  • Retrieved in paginated lists
  • Deleted individually or in bulk

Endpoint Details

Base URL: /suppliers
Content-Type: application/json

Required Headers

Authorization: Bearer <token>
x-store-id: <store_id>
All routes require a valid x-store-id header. Users must have an active relation with the store to access its suppliers.

Get Suppliers

GET /suppliers Retrieve a paginated list of suppliers linked to the store that the authenticated user has access to. Requires Authentication: Bearer token in Authorization header

Required Headers

KeyValueRequiredDescription
x-store-idstringYesStore identifier (used by @StoreId() decorator)

Query Parameters

ParameterTypeRequiredDescriptionDefault
searchstringNoFilter by name or description (partial match)
namestringNoFilter by supplier name (partial match)
isActivebooleanNoFilter by active/inactive status
pagenumberNoPage number (1-based)1
limitnumberNoNumber of items per page (1–100)10
sortBystringNoSort field (name, isActive, updatedAt, createdAt)createdAt
sortOrderstringNoSort direction (asc or desc)desc

Success Response

Status Code: 200 OK
{
  "data": [
    {
      "id": "sup_12345",
      "storeIds": ["str_1", "str_2"],
      "supplierGroups": [
        { "id": "grp_1", "name": "Preferred" }
      ],
      "name": "Global Traders Ltd.",
      "description": "Household goods wholesaler",
      "note": "Ships on Mondays",
      "defaultPriceListId": "pl_abc123",
      "address": {
        "id": "addr_1",
        "street": "123 Main St",
        "city": "Casablanca",
        "state": "CA",
        "postalCode": "20000",
        "country": "MA"
      },
      "contact": {
        "id": "cont_1",
        "phone": "+212600111222",
        "fax": null,
        "email": "[email protected]",
        "website": "https://globaltraders.com"
      },
      "isActive": true,
      "createdAt": "2025-11-03T10:00:00.000Z",
      "updatedAt": "2025-11-03T10:30:00.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 10,
    "total": 12,
    "totalPages": 2,
    "hasNext": true,
    "hasPrev": false
  }
}

Response Fields

Supplier Object

FieldTypeDescription
idstringUnique supplier ID
storeIdsstring[]Store IDs this supplier is linked to
supplierGroupsobject[]Groups assigned to the supplier
supplierGroups[].idstringGroup ID
supplierGroups[].namestringGroup name
namestringSupplier display name
descriptionstring?Supplier description
notestring?Internal note
defaultPriceListIdstring?Default price list ID
addressAddress?Address information
contactContact?Contact information
isActivebooleanActive status
createdAtstringCreation timestamp (ISO 8601)
updatedAtstringLast update timestamp (ISO 8601)

Address

FieldTypeDescription
idstringAddress ID
streetstringStreet
citystringCity
statestringState/Province
postalCodestringPostal/ZIP code
countrystringCountry

Contact

FieldTypeDescription
idstringContact ID
phonestringPhone number
faxstringFax number
emailstringEmail address
websitestringWebsite URL

Pagination Object

FieldTypeDescription
pagenumberCurrent page number
limitnumberNumber of items per page
totalnumberTotal number of records
totalPagesnumberTotal pages available
hasNextbooleanWhether a next page exists
hasPrevbooleanWhether a previous page exists

Possible Errors

CodeMessage
400Bad Request - Invalid query params
403Forbidden - User does not have access to store
500Internal Server Error

Example Requests

Get all suppliers with default pagination:
curl -X GET "https://jethings-backend.fly.dev/suppliers" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "x-store-id: store_id_here"
Search suppliers by name/description:
curl -X GET "https://jethings-backend.fly.dev/suppliers?search=global&page=1&limit=10&sortBy=name&sortOrder=asc" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "x-store-id: store_id_here"
Filter by active status:
curl -X GET "https://jethings-backend.fly.dev/suppliers?isActive=true&page=1&limit=20" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "x-store-id: store_id_here"

Get Supplier by ID

GET /suppliers/:id Retrieve a single supplier by ID. The supplier must be linked to the current store. Requires Authentication: Bearer token in Authorization header

Required Headers

KeyValueRequiredDescription
x-store-idstringYesStore identifier (used by @StoreId() decorator)

Path Parameters

ParameterTypeRequiredDescription
idstringYesThe ID of the supplier

Success Response

Status Code: 200 OK
{
  "id": "sup_12345",
  "storeIds": ["str_1"],
  "supplierGroups": [{ "id": "grp_1", "name": "Preferred" }],
  "name": "Global Traders Ltd.",
  "description": "Household goods wholesaler",
  "note": "Ships on Mondays",
  "defaultPriceListId": "pl_abc123",
  "address": {
    "id": "addr_1",
    "street": "123 Main St",
    "city": "Casablanca",
    "state": "CA",
    "postalCode": "20000",
    "country": "MA"
  },
  "contact": {
    "id": "cont_1",
    "phone": "+212600111222",
    "fax": null,
    "email": "[email protected]",
    "website": "https://globaltraders.com"
  },
  "isActive": true,
  "createdAt": "2025-11-03T10:00:00.000Z",
  "updatedAt": "2025-11-03T10:30:00.000Z"
}

Possible Errors

CodeMessage
403Forbidden - User does not have access to store
404Not Found - Supplier not found or inaccessible
500Internal Server Error

Example Request

curl -X GET "https://jethings-backend.fly.dev/suppliers/sup_12345" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "x-store-id: store_id_here"

Create Supplier

POST /suppliers Create a new supplier and link it to the current store. You can optionally assign supplier groups, a default price list, address, and contact information. Requires Authentication: Bearer token in Authorization header

Required Headers

KeyValueRequiredDescription
x-store-idstringYesStore identifier (used by @StoreId() decorator)

Request Body

{
  "supplierGroupIds": ["grp_1", "grp_2"],
  "name": "Global Traders Ltd.",
  "description": "Household goods wholesaler",
  "note": "Ships on Mondays",
  "defaultPriceListId": "pl_abc123",
  "address": {
    "street": "123 Main St",
    "city": "Casablanca",
    "state": "CA",
    "postalCode": "20000",
    "country": "MA"
  },
  "contact": {
    "phone": "+212600111222",
    "fax": null,
    "email": "[email protected]",
    "website": "https://globaltraders.com"
  }
}

Request Body Fields

FieldTypeRequiredDescription
supplierGroupIdsstring[] UUIDNoSupplier groups to associate
namestringYesSupplier name
descriptionstringNoDescription
notestringNoInternal note
defaultPriceListIdstring (UUID)NoDefault price list to assign
addressAddressInputNoAddress to create
contactContactInputNoContact to create

AddressInput

FieldTypeRequiredDescription
streetstringNoStreet
citystringNoCity
statestringNoState/Province
postalCodestringNoPostal/ZIP code
countrystringNoCountry

ContactInput

FieldTypeRequiredDescription
phonestringNoPhone number
faxstringNoFax number
emailstringNoEmail address
websitestringNoWebsite URL

Success Response

Status Code: 200 OK
{
  "id": "sup_abc123",
  "storeIds": ["str_12345"],
  "supplierGroups": [
    { "id": "grp_1", "name": "Preferred" },
    { "id": "grp_2", "name": "Local" }
  ],
  "name": "Global Traders Ltd.",
  "description": "Household goods wholesaler",
  "note": "Ships on Mondays",
  "defaultPriceListId": "pl_abc123",
  "address": {
    "id": "addr_1",
    "street": "123 Main St",
    "city": "Casablanca",
    "state": "CA",
    "postalCode": "20000",
    "country": "MA"
  },
  "contact": {
    "id": "cont_1",
    "phone": "+212600111222",
    "fax": null,
    "email": "[email protected]",
    "website": "https://globaltraders.com"
  },
  "isActive": true,
  "createdAt": "2025-11-03T10:00:00.000Z",
  "updatedAt": "2025-11-03T10:00:00.000Z"
}

Possible Errors

CodeMessage
400Bad Request - Invalid request data
403Forbidden - User does not have access to this store
404Not Found - Price list or supplier group not found
500Internal Server Error - Failed to create supplier

Example Request

curl -X POST "https://jethings-backend.fly.dev/suppliers" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "x-store-id: store_id_here" \
  -d '{
    "supplierGroupIds": ["grp_1"],
    "name": "Global Traders Ltd.",
    "description": "Household goods wholesaler",
    "note": "Ships on Mondays",
    "defaultPriceListId": "pl_abc123",
    "address": {
      "street": "123 Main St",
      "city": "Casablanca",
      "state": "CA",
      "postalCode": "20000",
      "country": "MA"
    },
    "contact": {
      "phone": "+212600111222",
      "email": "[email protected]",
      "website": "https://globaltraders.com"
    }
  }'

Update Supplier

PUT /suppliers/:id Update an existing supplier. You may update core fields, default price list, address, and contact. If address/contact do not exist, they will be created. Requires Authentication: Bearer token in Authorization header

Required Headers

KeyValueRequiredDescription
x-store-idstringYesStore identifier (used by @StoreId() decorator)

Path Parameters

ParameterTypeRequiredDescription
idstringYesThe ID of the supplier

Request Body

{
  "name": "Global Traders Ltd. (Updated)",
  "description": "Updated description",
  "note": "Priority handling",
  "defaultPriceListId": "pl_789xyz",
  "isActive": true,
  "address": {
    "street": "456 New Ave",
    "city": "Rabat",
    "state": "RA",
    "postalCode": "10000",
    "country": "MA"
  },
  "contact": {
    "phone": "+212600999888",
    "fax": null,
    "email": "[email protected]",
    "website": "https://globaltraders.com/contact"
  }
}

Request Body Fields

FieldTypeRequiredDescription
namestringNoSupplier name
descriptionstringNoDescription
notestringNoInternal note
defaultPriceListIdstring (UUID)NoDefault price list to assign
isActivebooleanNoActive status
addressAddressInputNoAddress to create/update
contactContactInputNoContact to create/update

Success Response

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

Possible Errors

CodeMessage
403Forbidden - User does not have access to this store
404Not Found - Supplier or price list not found
500Internal Server Error - Failed to update supplier

Example Request

curl -X PUT "https://jethings-backend.fly.dev/suppliers/sup_abc123" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "x-store-id: store_id_here" \
  -d '{
    "name": "Global Traders Ltd. (Updated)",
    "defaultPriceListId": "pl_789xyz",
    "isActive": true
  }'

Delete Supplier

DELETE /suppliers/:id Delete a supplier by ID.
This operation deletes the supplier record. Use with caution.

Path Parameters

ParameterTypeRequiredDescription
idstringYesThe ID of the supplier

Success Response

Status Code: 200 OK
{ "message": "Supplier deleted successfully" }

Possible Errors

CodeMessage
404Not Found - Supplier not found
500Internal Server Error

Example Request

curl -X DELETE "https://jethings-backend.fly.dev/suppliers/sup_abc123" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Bulk Delete Suppliers

DELETE /suppliers Delete multiple suppliers by IDs in a single request. Requires Authentication: Bearer token in Authorization header

Required Headers

KeyValueRequiredDescription
x-store-idstringYesStore identifier (used by @StoreId() decorator)

Request Body

{
  "ids": ["sup_123", "sup_456", "sup_789"]
}

Request Body Fields

FieldTypeRequiredDescription
idsstring[] UUIDYesSupplier IDs to delete

Success Response

Status Code: 200 OK
{
  "message": "Successfully deleted 3 supplier(s)",
  "deletedCount": 3
}

Possible Errors

CodeMessage
400No supplier IDs provided
404No valid suppliers found to delete
500Internal Server Error

Example Request

curl -X DELETE "https://jethings-backend.fly.dev/suppliers" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "x-store-id: store_id_here" \
  -d '{ "ids": ["sup_123", "sup_456"] }'

Data Models

SupplierResponseDto

FieldTypeDescription
idstringUnique supplier ID
storeIdsstring[]Store IDs linked to the supplier
supplierGroupsobject[]Supplier groups (id, name)
namestringSupplier name
descriptionstring?Description
notestring?Internal note
defaultPriceListIdstring?Default price list ID
addressAddress?Address info
contactContact?Contact info
isActivebooleanActive status
createdAtDateCreation timestamp
updatedAtDateLast update timestamp

PaginationDto

FieldTypeDescription
pagenumberCurrent page number
limitnumberNumber of items per page
totalnumberTotal number of records
totalPagesnumberTotal pages available
hasNextbooleanWhether a next page exists
hasPrevbooleanWhether a previous page exists

PaginatedSuppliersResponseDto

{
  data: SupplierResponseDto[];
  pagination: PaginationDto;
}

Summary

EndpointMethodDescription
/suppliersGETRetrieve paginated list of suppliers
/suppliers/:idGETRetrieve a single supplier by ID
/suppliersPOSTCreate a new supplier and link to store
/suppliers/:idPUTUpdate an existing supplier
/suppliers/:idDELETEDelete a supplier by ID
/suppliersDELETEBulk delete suppliers

Security & Validation

  • All routes require a valid x-store-id header (except single delete which still requires auth)
  • User must have an active relation with the store to access its suppliers
  • Pagination limits should be respected (max 100 per page)
  • SortBy must be one of: name, isActive, updatedAt, createdAt
  • SortOrder must be either asc or desc
  • ids in bulk delete must be valid UUIDs
  • Price list and supplier group IDs must exist when provided

Error Responses

Common Error Codes

CodeDescription
400Bad Request - Invalid input or validation
403Forbidden - User does not have access
404Not Found - Resource missing
500Internal Server Error - Database or server error

Error Response Format

{
  "message": "Error description",
  "statusCode": 400
}