Skip to main content

Create Operating Unit

Creates a new operating unit within a branch. Operating units represent operational contexts such as main branch inventory, buffer storage, return processing areas, or temporary event locations.

Request Body

branch_id
integer
required
ID of the branch this operating unit belongs to
name
string
required
Operating unit name (max 255 characters)
type
string
required
Operating unit type. Valid values:
  • BRANCH_MAIN - Main branch operating unit
  • BRANCH_BUFFER - Branch buffer storage
  • BRANCH_RETURN - Branch return processing
  • EVENT_TEMP - Temporary event unit
start_date
string
Start date in YYYY-MM-DD format
end_date
string
End date in YYYY-MM-DD format (must be after or equal to start_date). Used primarily for EVENT_TEMP types.
is_active
boolean
default:"true"
Whether the operating unit is active
meta
object
Additional metadata as a JSON object

Response

message
string
Success message
data
object
Created operating unit object
id
integer
Operating unit ID
branch_id
integer
Associated branch ID
name
string
Operating unit name
type
string
Operating unit type
start_date
string
Start date (YYYY-MM-DD format)
end_date
string
End date (YYYY-MM-DD format)
is_active
boolean
Active status
meta
object
Additional metadata
branch
object
Associated branch details
id
integer
Branch ID
name
string
Branch name
created_at
string
Creation timestamp (ISO 8601 UTC)
updated_at
string
Last update timestamp (ISO 8601 UTC)

Example Request

curl -X POST "https://api.sushigo.local/api/v1/operating-units" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "branch_id": 1,
    "name": "Main Kitchen",
    "type": "BRANCH_MAIN",
    "start_date": "2026-03-01",
    "is_active": true
  }'

Example Response

{
  "message": "Operating unit created successfully",
  "data": {
    "id": 5,
    "branch_id": 1,
    "name": "Main Kitchen",
    "type": "BRANCH_MAIN",
    "start_date": "2026-03-01",
    "end_date": null,
    "is_active": true,
    "meta": null,
    "branch": {
      "id": 1,
      "name": "Downtown Branch"
    },
    "created_at": "2026-03-06T14:22:30+00:00",
    "updated_at": "2026-03-06T14:22:30+00:00"
  }
}

Error Responses

422
object
Validation error
{
  "message": "The given data was invalid.",
  "errors": {
    "branch_id": ["The branch id field is required."],
    "name": ["The name field is required."],
    "type": ["The selected type is invalid."]
  }
}

Update Operating Unit

Updates an existing operating unit. All fields are optional; only provided fields will be updated.

Path Parameters

id
integer
required
Operating unit ID

Request Body

branch_id
integer
ID of the branch this operating unit belongs to
name
string
Operating unit name (max 255 characters)
type
string
Operating unit type (BRANCH_MAIN, BRANCH_BUFFER, BRANCH_RETURN, EVENT_TEMP)
start_date
string
Start date in YYYY-MM-DD format
end_date
string
End date in YYYY-MM-DD format (must be after or equal to start_date)
is_active
boolean
Whether the operating unit is active
meta
object
Additional metadata as a JSON object

Response

message
string
Success message
data
object
Updated operating unit object (same structure as create response)

Example Request

curl -X PUT "https://api.sushigo.local/api/v1/operating-units/5" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "name": "Updated Kitchen Name",
    "is_active": false
  }'

Example Response

{
  "message": "Operating unit updated successfully",
  "data": {
    "id": 5,
    "branch_id": 1,
    "name": "Updated Kitchen Name",
    "type": "BRANCH_MAIN",
    "start_date": "2026-03-01",
    "end_date": null,
    "is_active": false,
    "meta": null,
    "branch": {
      "id": 1,
      "name": "Downtown Branch"
    },
    "created_at": "2026-03-06T14:22:30+00:00",
    "updated_at": "2026-03-06T14:35:10+00:00"
  }
}

Error Responses

404
object
Operating unit not found
{
  "message": "Not found"
}
422
object
Validation error
{
  "message": "The given data was invalid.",
  "errors": {
    "end_date": ["The end date must be a date after or equal to start date."]
  }
}

Delete Operating Unit

Soft deletes an operating unit. The unit will be marked as deleted but retained in the database for audit purposes.

Path Parameters

id
integer
required
Operating unit ID

Response

message
string
Success message

Example Request

curl -X DELETE "https://api.sushigo.local/api/v1/operating-units/5" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"

Example Response

{
  "message": "Operating unit deleted successfully"
}

Error Responses

404
object
Operating unit not found
{
  "message": "Not found"
}

Build docs developers (and LLMs) love