Stock Endpoints
The Stock entity represents the quantity of products of the same type that are in a warehouse. Each stock includes a series of attributes that describe it.
Common Stock Characteristicsβ
-
Unique Identification: Each stock has a unique identifier
idthat distinguishes them from other stocks in the system. -
Stock Data: A Stock has associated information such as quantity, associated product data, associated warehouse data and other details.
-
Activities and Logging: Activities performed by a stock within the system, such as creation of resources, may be logged.
-
Product: Basic information about the product to which the stock is associated is stored, such as
idRemoteand the product reference. -
Warehouse: Basic information about the warehouse where each product is located is saved, such as
idRemote.
Endpointsβ
GET/Stock/getStockβ
Retrieve a paginated list of stocks.
Descriptionβ
This endpoint retrieves a paginated list of stocks from the system. It allows clients to fetch stocks data based on pagination parameters such as page number (page) and items per page (pageSize). The response includes detailed information about each stock, including its ID, quantity, product and warehouse information, and last updated timestamp.
Parametersβ
| Name | Description | Type | Default Value |
|---|---|---|---|
idProduct | Product ID | String optional | idProduct |
idWarehouse | Warehouse ID | String optional | idWarehouse |
page | Page number | Integer | 1 |
pageSize | Number of items per page | Integer | 10 |
Responsesβ
JSONβ
{
"data": [
{
"id": "string",
"product": {
"id": "string",
"idRemote": "string",
"reference": "string"
},
"warehouse": {
"id": "string",
"idRemote": "string"
},
"quantity": 0,
"createdAt": "string",
"updatedAt": "string"
}
],
"pagination": {
"totalItems": 0,
"itemsPerPage": 0,
"currentPage": 0,
"totalPages": 0,
"nextPageUrl": "string"
}
}
XMLβ
<?xml version="1.0" encoding="UTF-8"?>
<export>
<data>
<item>
<id>string</id>
<product>
<id>string</id>
<idRemote>string</idRemote>
<reference>string</reference>
</product>
<warehouse>
<id>string</id>
<idRemote>string</idRemote>
</warehouse>
<quantity>0</quantity>
<createdAt>string</createdAt>
<updatedAt>string</updatedAt>
</item>
</data>
<pagination>
<totalItems>0</totalItems>
<itemsPerPage>0</itemsPerPage>
<currentPage>0</currentPage>
<totalPages>0</totalPages>
<nextPageUrl>string</nextPageUrl>
</pagination>
</export>
πTry it outπ±
GET/Stock/updatedFromβ
Retrieve stocks from a modification date
Descriptionβ
This endpoint retrieves a paginated list of stocks from the system, starting from a specific modification date using the parameter date. It allows clients to fetch locations data based on pagination parameters such as page number (page) and items per page (pageSize). The response includes detailed information about each stock, including its ID, quantity, product and warehouse information, and last updated timestamp.
Parametersβ
| Name | Description | Type | Default Value |
|---|---|---|---|
date | Updated Date | String required | 1999-01-01 01:00:00 |
page | Page number | Integer | 1 |
pageSize | Number of items per page | Integer | 10 |
Responsesβ
JSONβ
{
"data": [
{
"id": "string",
"product": {
"id": "string",
"idRemote": "string",
"reference": "string"
},
"warehouse": {
"id": "string",
"idRemote": "string"
},
"quantity": 0,
"createdAt": "string",
"updatedAt": "string"
}
],
"pagination": {
"totalItems": 0,
"itemsPerPage": 0,
"currentPage": 0,
"totalPages": 0,
"nextPageUrl": "string"
}
}
XMLβ
<?xml version="1.0" encoding="UTF-8"?>
<export>
<data>
<item>
<id>string</id>
<product>
<id>string</id>
<idRemote>string</idRemote>
<reference>string</reference>
</product>
<warehouse>
<id>string</id>
<idRemote>string</idRemote>
</warehouse>
<quantity>0</quantity>
<createdAt>string</createdAt>
<updatedAt>string</updatedAt>
</item>
</data>
<pagination>
<totalItems>0</totalItems>
<itemsPerPage>0</itemsPerPage>
<currentPage>0</currentPage>
<totalPages>0</totalPages>
<nextPageUrl>string</nextPageUrl>
</pagination>
</export>
πTry it outπ±
GET/Stock/getStockMovementTypeβ
Retrieve a paginated list of stocks movement type.
Descriptionβ
This endpoint retrieves a paginated list of stocks movement type from the system. It allows clients to obtain the types of stock movements based on pagination parameters such as the page number (page) and the number of items per page (pageSize). The response includes the ID and name of each movement type.
Parametersβ
| Name | Description | Type | Default Value |
|---|---|---|---|
page | Page number | Integer | 1 |
pageSize | Number of items per page | Integer | 10 |
Responsesβ
JSONβ
{
"data": [
{
"id": "string",
"name": "string"
}
],
"pagination": {
"totalItems": 0,
"itemsPerPage": 0,
"currentPage": 0,
"totalPages": 0,
"nextPageUrl": "string"
}
}
XMLβ
<?xml version="1.0" encoding="UTF-8"?>
<export>
<data>
<item>
<id>string</id>
<name>string</name>
</item>
</data>
<pagination>
<totalItems>0</totalItems>
<itemsPerPage>0</itemsPerPage>
<currentPage>0</currentPage>
<totalPages>0</totalPages>
<nextPageUrl>string</nextPageUrl>
</pagination>
</export>
πTry it outπ±
POST/Stock/createβ
Stock Registration in the API: Using the POST Methodβ
Currently, our POST method in the API exclusively handles JSON format. To effectively register stocks, it is crucial to follow a process that ensures data integrity and proper system functionality.
Registration Process:β
-
Creation of Product: Creating a product is essential because it is where a stock with a zero quantity will be recorded for the first time. Then, the stock quantity corresponding to that product is recorded in this endpoint. πRegister Productπ±
-
Creation of Warehouse: A warehouse must exist in order to create a product and therefore to create a stock. The warehouse that is associated with the product is the one that is associated with the corresponding stock. πRegister Warehouseπ±
-
Movement Type: The movement type is already created and can be
IN,OUTorCORRECTION. In theINtype, the quantity entered in the JSON will be added to the quantity of the corresponding stock. For theOUTtype, it will be subtracted and for theCORRECTIONtype, it will be updated. As the stock is recorded when the product is created, there will always be one associated with this product in order to add, subtract or update the quantity.
Details of the POST Method:β
In this case, we will use the POST method to update stocks since they have been registered in the Product POST method. It is necessary to send structured data in JSON format that includes essential information such as the product ID, the warehouse ID and the quantity we want to register. The process ensures that each stock has a unique identity and is correctly configured to interact with the platform in a safe and efficient manner. The system will automatically create a local id.
All parameters in the request body are required.
The request must follow the following scheme:
[
{
"productId": "string",
"warehouseId": "string",
"quantity": 0,
"movementTypeId": "string"
}
]
It is possible to add multiple stocks through the same request by separating them with commas within the array in the body of the request.
Responsesβ
To avoid overloading the server, this endpoint sends a message to a consumer responsible for processing the request. To check the status of the submitted request, you need to access the URL provided in the response. A successfully sent message to the consumer should look like this:
{
"code": 201,
"message": "Stock message created successfully and dispatched to the queue.",
"statusUrl": "http://host/api/database/v1/message/status/66bf382938941"
}
The statusUrl field redirects us to a more detailed response about the request's status. A request successfully processed by the consumer will look like this:
{
"data": [
{
"status": "completed",
"errorMessage": null
}
],
"pagination": {
"totalItems": 1,
"itemsPerPage": 10,
"currentPage": 1,
"totalPages": 1,
"nextPageUrl": null
}
}
If any error occurs during message processing, the response will look something like this:
{
"code": 400,
"error": "Invalid stock data format, a required parameter is missing"
}
πTry it outπ±
Possible Response Errorsβ
| Error | Response Status | Response Body |
|---|---|---|
| This error occurs when a connection to the database cannot be established. It is an internal server problem. | 500 | {"code": 500,"error": "Database connection failed."} |
| This error occurs when you cannot insert or update items into the database. | 500 | {"code": 500,"error": "Invalid connection name, you cannot insert in default"} |
| This error occurs when a parameter is missing. | 400 | {"code": 400,"error": "Parameter $parameter is required"} |
| This error occurs when you are not authorized. | 401 | {"code": 401,"error": "Unauthorized."} |
| This error occurs when the Stock could not be found. | 404 | {"code": 404,"error": "No entity found for Stock with $id."} |
| This error occurs when you try to insert a Stock that already exists. | 409 | {"code": 409,"error": "Duplicate entry"} |
| This error occurs when you try to send too many requests in a short period of time. | 429 | {"code": 429,"error": "Too Many Requests"} |