Skip to content

Production task ​

Production tasks assigned to workers

INFO

Every response arrives in the shared envelope — code, message, messages, status_code, time — with the payload in data. The tables below describe what is inside data.

POST /production-task/create ​

Create a new production task with tech-map items and warehouse assignments. Returns the hydrated task including items, route-sheet steps, materials, and warehouse quantities.

Request body

FieldTypeRequiredDescription
responsible_idstringYesEmployee ObjectId responsible for the task (required)
currency_idstringYesCurrency ObjectId for cost tracking (required)
organization_idstringYesOrganization ObjectId the task belongs to (required)
produced_warehouse_idstringYesWarehouse ObjectId where finished goods land (required)
itemsobject[]YesTech-map line items — at least one required
items[].tech_map_idstringYesProductionTechMap ObjectId (recipe/BOM reference)
items[].amountnumberYesPlanned production quantity (positive number)
used_warehouse_itemsobject[]YesPer-step warehouse assignments — at least one required
used_warehouse_items[].used_warehouse_idstringYesWarehouse ObjectId materials are consumed from for this step
used_warehouse_items[].step_idstringYesProductionStep ObjectId this warehouse assignment applies to
codestringNoOptional human-readable task code
notestringNoOptional free-text note
datestring (date)NoOptional task date (ISO 8601 YYYY-MM-DD)
attachmentsobject[]NoOptional pre-uploaded attachment object refs
json
{
  "responsible_id": "string",
  "currency_id": "string",
  "organization_id": "string",
  "produced_warehouse_id": "string",
  "items": [
    {
      "tech_map_id": "string",
      "amount": 0
    }
  ],
  "used_warehouse_items": [
    {
      "used_warehouse_id": "string",
      "step_id": "string"
    }
  ],
  "code": "string",
  "note": "string",
  "date": "string",
  "attachments": [
    {}
  ]
}

Response

FieldTypeDescription
_idstringProduction task ObjectId
numberstringAuto-generated sequential task number
codestringHuman-readable task code
notestringFree-text note
datestring (date-time)Task date
statestringCurrent task state. One of: new, in_progress, done, canceled
organizationobject
organization._idstring
organization.namestring
produced_warehouseobject
produced_warehouse._idstring
produced_warehouse.namestring
responsibleobject
responsible._idstring
responsible.full_namestring
responsible.numberstring
used_warehouse_itemsobject[]
used_warehouse_items[].step_idstring
used_warehouse_items[].stepobject
used_warehouse_items[].step._idstring
used_warehouse_items[].step.namestring
used_warehouse_items[].used_warehouse_idstring
used_warehouse_items[].used_warehouseobject
used_warehouse_items[].used_warehouse._idstring
used_warehouse_items[].used_warehouse.namestring
itemsobject[]Hydrated tech-map items with route-sheet steps, materials, and warehouse quantities
attachmentsobject[]
created_atstring (date-time)
updated_atstring (date-time)
json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "_id": "string",
    "number": "string",
    "code": "string",
    "note": "string",
    "date": "2025-05-01T12:00:00Z",
    "state": "new",
    "organization": {
      "_id": "string",
      "name": "string"
    },
    "produced_warehouse": {
      "_id": "string",
      "name": "string"
    },
    "responsible": {
      "_id": "string",
      "full_name": "string",
      "number": "string"
    },
    "used_warehouse_items": [
      {
        "step_id": "string",
        "step": {
          "_id": null,
          "name": null
        },
        "used_warehouse_id": "string",
        "used_warehouse": {
          "_id": null,
          "name": null
        }
      }
    ],
    "items": [
      {}
    ],
    "attachments": [
      {}
    ],
    "created_at": "2025-05-01T12:00:00Z",
    "updated_at": "2025-05-01T12:00:00Z"
  },
  "time": "2025-05-01T12:00:00Z"
}

GET /production-task/get-by-id/{id} ​

Fetch a single production task by ObjectId. Returns the same hydrated shape as create/update.

Path parameters

ParameterTypeRequiredDescription
idstringYesProduction-task ObjectId

Request body

No request body.

Response

Same response shape as POST /production-task/create.

POST /production-task/get-paging ​

Paginated list of production tasks, filterable by organization and state.

Request body

FieldTypeRequiredDescription
pagenumberYesDefault: 1
limitnumberYesDefault: 20
organization_idstringNoFilter by organization ObjectId
statestringNoFilter by task state. One of: new, in_progress, done, canceled
searchstringNoFree-text search across number and code fields
sort_bystringNoField to sort by (e.g. created_at)
ascnumberNoSort direction: 1 ascending, -1 descending. One of: 1, -1
json
{
  "page": 1,
  "limit": 20,
  "organization_id": "string",
  "state": "new",
  "search": "string",
  "sort_by": "string",
  "asc": 1
}

Response

FieldTypeDescription
totalnumber
listobject[]
list[]._idstringProduction task ObjectId
list[].numberstringAuto-generated sequential task number
list[].codestringHuman-readable task code
list[].notestringFree-text note
list[].datestring (date-time)Task date
list[].statestringCurrent task state. One of: new, in_progress, done, canceled
list[].organizationobject
list[].organization._idstring
list[].organization.namestring
list[].produced_warehouseobject
list[].produced_warehouse._idstring
list[].produced_warehouse.namestring
list[].responsibleobject
list[].responsible._idstring
list[].responsible.full_namestring
list[].responsible.numberstring
list[].created_atstring (date-time)
list[].updated_atstring (date-time)
json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "list": [
      {
        "_id": "string",
        "number": "string",
        "code": "string",
        "note": "string",
        "date": "2025-05-01T12:00:00Z",
        "state": "new",
        "organization": {
          "_id": null,
          "name": null
        },
        "produced_warehouse": {
          "_id": null,
          "name": null
        },
        "responsible": {
          "_id": null,
          "full_name": null,
          "number": null
        },
        "created_at": "2025-05-01T12:00:00Z",
        "updated_at": "2025-05-01T12:00:00Z"
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}

PUT /production-task/update/{id} ​

Update an existing production task. Only allowed while the task is in state new. Replaces items and warehouse assignments; re-runs tech-map hydration. Returns the updated hydrated task.

Path parameters

ParameterTypeRequiredDescription
idstringYesProduction-task ObjectId to update

Request body

FieldTypeRequiredDescription
responsible_idstringYesEmployee ObjectId responsible for the task (required)
currency_idstringYesCurrency ObjectId for cost tracking (required)
organization_idstringYesOrganization ObjectId the task belongs to (required)
produced_warehouse_idstringYesWarehouse ObjectId where finished goods land (required)
itemsobject[]YesTech-map line items — at least one required
items[].tech_map_idstringYesProductionTechMap ObjectId (recipe/BOM reference)
items[].amountnumberYesPlanned production quantity (positive number)
used_warehouse_itemsobject[]YesPer-step warehouse assignments — at least one required
used_warehouse_items[].used_warehouse_idstringYesWarehouse ObjectId materials are consumed from for this step
used_warehouse_items[].step_idstringYesProductionStep ObjectId this warehouse assignment applies to
codestringNoOptional human-readable task code
notestringNoOptional free-text note
datestring (date)NoOptional task date (ISO 8601 YYYY-MM-DD)
attachmentsobject[]NoOptional pre-uploaded attachment object refs
json
{
  "responsible_id": "string",
  "currency_id": "string",
  "organization_id": "string",
  "produced_warehouse_id": "string",
  "items": [
    {
      "tech_map_id": "string",
      "amount": 0
    }
  ],
  "used_warehouse_items": [
    {
      "used_warehouse_id": "string",
      "step_id": "string"
    }
  ],
  "code": "string",
  "note": "string",
  "date": "string",
  "attachments": [
    {}
  ]
}

Response

Same response shape as POST /production-task/create.

PUT /production-task/set-status/{id} ​

Transition a production task to a new state. Valid transitions: new→[in_progress, canceled, done]; in_progress→[canceled, done]; done→[canceled]; canceled→[]. Transitioning to canceled cascades cancellation of all linked production operations. NOTE: the reason field is accepted by the contract but is NOT persisted (the model has no reason field).

Path parameters

ParameterTypeRequiredDescription
idstringYesProduction-task ObjectId

Request body

FieldTypeRequiredDescription
statusstringYesTarget state for the production task (required). Valid transitions: new→[in_progress, canceled, done]; in_progress→[canceled, done]; done→[canceled]; canceled→[].. One of: new, in_progress, done, canceled
reasonstringNoOptional reason for the state transition. Accepted by the API contract but NOT persisted — the ProductionTask model has no reason field.
json
{
  "status": "new",
  "reason": "string"
}

Response

Same response shape as POST /production-task/create.

PUT /production-task/produce/{id} ​

Record production output against one step of the task's technological map. This is the write that actually moves material: the step's inputs are consumed from the used warehouse, amount of its output is produced into the produced warehouse, and the task advances. Reverse it with cancel-produced.

Path parameters

ParameterTypeRequiredDescription
idstringYesProduction-task ObjectId

Request body

FieldTypeRequiredDescription
tech_map_idstringYesTechnological-map ObjectId the step belongs to
step_idstringYesProduction-step ObjectId being produced
responsible_idstringYesEmployee ObjectId credited with the output
amountnumberYesQuantity produced in this call
used_datestring (date-time)YesWhen the inputs were consumed (ISO 8601)
produced_datestring (date-time)YesWhen the output was produced (ISO 8601)
codestringNoOptional external code for the resulting operation
statestringNoOptional initial state for the resulting production operation
notestringNoOptional free-text note
create_reminderbooleanNoCreate a follow-up reminder for the responsible employee
additional_costsobject[]NoExtra costs to fold into the produced item's cost price
additional_costs[].cost_idstringNoExtra-cost ObjectId
additional_costs[].amountnumberNoCost amount
json
{
  "tech_map_id": "string",
  "step_id": "string",
  "responsible_id": "string",
  "amount": 0,
  "used_date": "2025-05-01T12:00:00Z",
  "produced_date": "2025-05-01T12:00:00Z",
  "code": "string",
  "state": "string",
  "note": "string",
  "create_reminder": false,
  "additional_costs": [
    {
      "cost_id": "string",
      "amount": 0
    }
  ]
}

Response

Same response shape as POST /production-task/create.

PUT /production-task/cancel-produced/{id} ​

Reverse a previously recorded production for one step of the task. Cancels the operation the matching produce call created and returns the consumed material to stock. tech_map_id + step_id identify which produced step to undo.

Path parameters

ParameterTypeRequiredDescription
idstringYesProduction-task ObjectId

Request body

FieldTypeRequiredDescription
tech_map_idstringYesTechnological-map ObjectId the produced step belongs to
step_idstringYesProduction-step ObjectId whose production is being reversed
json
{
  "tech_map_id": "string",
  "step_id": "string"
}

Response

Same response shape as POST /production-task/create.

POST /production-task/state-report/by-product ​

Paginated production-task state report grouped by product. Answers how much of each product is planned, in progress, done or canceled across tasks — rather than listing the tasks themselves. Accepts the same filters as get-paging.

Request body

FieldTypeRequiredDescription
pagenumberYesDefault: 1
limitnumberYesDefault: 20
organization_idstringNoFilter by organization ObjectId
statestringNoFilter by task state. One of: new, in_progress, done, canceled
searchstringNoFree-text search across number and code fields
sort_bystringNoField to sort by (e.g. created_at)
ascnumberNoSort direction: 1 ascending, -1 descending. One of: 1, -1
json
{
  "page": 1,
  "limit": 20,
  "organization_id": "string",
  "state": "new",
  "search": "string",
  "sort_by": "string",
  "asc": 1
}

Response

FieldTypeDescription
totalnumber
listobject[]
list[].product_idstringProduct ObjectId
list[].productobjectHydrated product
list[].product._idstring
list[].product.namestring
list[].newnumberQuantity on tasks still in the new state
list[].in_progressnumberQuantity on tasks in progress
list[].donenumberQuantity on completed tasks
list[].cancelednumberQuantity on canceled tasks
list[].totalnumberTotal planned quantity across all states
json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "list": [
      {
        "product_id": "string",
        "product": {
          "_id": null,
          "name": null
        },
        "new": 0,
        "in_progress": 0,
        "done": 0,
        "canceled": 0,
        "total": 0
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}

This page is generated from the OpenAPI spec.

Bito 2.0 Integration API