Create Trade
POST /api/v1/trades
Description
Creates a new trade in the system, recording details such as the products involved, quantities, prices, and specific requirements related to labeling and packaging. This endpoint is used for managing and documenting transactions between businesses and buyers.
Headers:
tenantId(required): The tenant ID under which the trade is to be registered. This should be included as a header.userId(required): The user ID of the individual responsible for creating the trade. This should also be included as a header.countryCode(required): The country code where the trade is being processed. This should be included as a header.
Request Body (application/json): Required. The body should include detailed information about the trade:
{
"productId": "string",
"description": "string",
"quantity": 0,
"indicativeUnitPrice": 0,
"totalAmount": 0,
"productUnitType": "Barrels",
"docLinks": [
{
"name": "string",
"link": "string"
}
],
"labellingRequirement": "string",
"packagingRequirement": "string",
"businessId": "string",
"buyerId": "string",
"userId": "string",
"tenantId": "string",
"countryCode": "string"
}
Responses:
- 201 Created: Indicates that the trade has been successfully created. The response typically includes details of the newly created trade entry.
Example Request:
curl -X POST "http://[base_url]/api/v1/trades" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer [access_token]" \
-H "tenantId: TEN123" \
-H "userId: USR456" \
-H "countryCode: US" \
-d '{
"productId": "12345",
"description": "High-quality crude oil",
"quantity": 1000,
"indicativeUnitPrice": 50,
"totalAmount": 50000,
"productUnitType": "Barrels",
"docLinks": [
{
"name": "Contract",
"link": "http://example.com/contract.pdf"
}
],
"labellingRequirement": "Hazardous Material",
"packagingRequirement": "Reinforced Steel Drums",
"businessId": "BIZ789",
"buyerId": "BUY456",
"userId": "USR456",
"tenantId": "TEN123",
"countryCode": "US"
}'
Example Response:
{
"message": "Trade created successfully.",
"tradeId": "trade123"
}
Error Responses:
- 400 Bad Request: Incorrect or incomplete data for the trade creation.
- 403 Forbidden: The user does not have permission to create a trade.
LANGUAGE
CURL REQUEST
curl --request POST \
--url /api/v1/trades \
--header 'accept: application/json' \
--header 'content-type: application/json'
RESPONSE
Click Try It! to start a request and see the response here!