Flavours API
Ingredient

Create Ingredient

POST
/api/v2/ingredients

Create a new ingredient with its initial branch stock.

AuthorizationBearer <token>

You can retrieve your token by logging in.

In: header

Header Parameters

X-API-Version*string

API contract version to target. See the Changelog for what changed in each version.

Default"2.0.0"
Value in"2.3.0" | "2.2.0" | "2.1.0" | "2.0.0"

Request Body

application/json

market_id*string

The id of an existing record in the markets table.

branch_id*string

The id of an existing record in the branches table.

name_en*string

Must not be greater than 191 characters.

name_ar?|

Must not be greater than 191 characters.

source_unit*string

Must not be greater than 191 characters.

target_unit*string

Must not be greater than 191 characters.

source_rate*number
target_rate*number
minimum?|
maximum?|
stock?|

Must be at least 0.

cost?|

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:8000/api/v2/ingredients" \  -H "X-API-Version: 2.3.0" \  -H "Content-Type: application/json" \  -d '{    "market_id": "iure",    "branch_id": "numquam",    "name_en": "m",    "source_unit": "wojwpcafiodnnck",    "target_unit": "zcetirldimzmxd",    "source_rate": 32,    "target_rate": 120518.719  }'
{
  "meta": {
    "code": 200,
    "status": "success",
    "message": "Ingredient created successfully."
  },
  "data": {
    "id": "0393c0c6-a719-4409-9eb7-d1ae19d8f56e",
    "name_en": "Premium Olive Oil",
    "name_ar": "زيت زيتون فاخر",
    "deleted_at": null,
    "market_id": "07928d80-350c-46eb-8786-91a40ca509a0",
    "source_unit": "box",
    "target_unit": "l",
    "source_rate": "1.00",
    "target_rate": "12.00",
    "minimum": "5.00",
    "created_at": 1782824836760,
    "updated_at": 1782824836760,
    "maximum": "100.00"
  }
}
{
  "meta": {
    "code": 401,
    "status": "error",
    "message": "Unauthenticated."
  },
  "data": null
}
{
  "meta": {
    "code": 403,
    "status": "error",
    "message": "Unauthorized."
  },
  "data": null
}
{
  "meta": {
    "code": 404,
    "status": "error",
    "message": "Resource not found."
  },
  "data": null
}
{
  "meta": {
    "code": 422,
    "status": "error",
    "message": "The selected market id is invalid. (and 6 more errors)"
  },
  "data": [
    {
      "code": 0,
      "message": "The selected market is invalid.",
      "field": "market"
    },
    {
      "code": 0,
      "message": "The selected branch is invalid.",
      "field": "branch"
    },
    {
      "code": 0,
      "message": "The name en field is required.",
      "field": "name_en"
    },
    {
      "code": 0,
      "message": "The source unit field is required.",
      "field": "source_unit"
    },
    {
      "code": 0,
      "message": "The target unit field is required.",
      "field": "target_unit"
    },
    {
      "code": 0,
      "message": "The source rate must be greater than 0.",
      "field": "source_rate"
    },
    {
      "code": 0,
      "message": "The target rate must be greater than 0.",
      "field": "target_rate"
    }
  ]
}
{
  "meta": {
    "code": 500,
    "status": "error",
    "message": "Internal server error."
  },
  "data": null
}